Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: Source/bindings/templates/attributes.cpp

Issue 808373002: IDL: Simplify [TypeChecking=Interface] code generation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/templates/attributes.cpp
diff --git a/Source/bindings/templates/attributes.cpp b/Source/bindings/templates/attributes.cpp
index 00232bf6f7b8b4ffd4052d92f743a8d1d748e4d6..95b914522cd70670198f3ddecd3de993ab10f5e2 100644
--- a/Source/bindings/templates/attributes.cpp
+++ b/Source/bindings/templates/attributes.cpp
@@ -217,16 +217,6 @@ v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info
{% if attribute.has_setter_exception_state %}
ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.name}}", "{{interface_name}}", holder, info.GetIsolate());
{% endif %}
- {# Type checking #}
- {% if attribute.has_type_checking_interface %}
- {# Type checking for interface types (if interface not implemented, throw
- TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
- if ({% if attribute.is_nullable %}!isUndefinedOrNull(v8Value) && {% endif %}!V8{{attribute.idl_type}}::hasInstance(v8Value, info.GetIsolate())) {
- exceptionState.throwTypeError("The provided value is not of type '{{attribute.idl_type}}'.");
- exceptionState.throwIfNeeded();
- return;
- }
- {% endif %}
{% if attribute.use_output_parameter_for_result %}
{{attribute.cpp_type}} cppValue;
{% endif %}
@@ -260,6 +250,14 @@ v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info
exceptionState.throwIfNeeded();
return;
}
+ {% elif attribute.has_type_checking_interface %}
+ {# Type checking for interface types (if interface not implemented, throw
+ TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
+ if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) {
+ exceptionState.throwTypeError("The provided value is not of type '{{attribute.idl_type}}'.");
+ exceptionState.throwIfNeeded();
+ return;
+ }
{% elif attribute.enum_validation_expression %}
{# Setter ignores invalid enum values:
http://www.w3.org/TR/WebIDL/#idl-enums #}

Powered by Google App Engine
This is Rietveld 408576698