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

Side by Side Diff: Source/bindings/templates/methods.cpp

Issue 359763002: IDL: Avoid double type-check for variadic interface type arguments (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: the fix Created 6 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | Source/bindings/tests/idls/TestObject.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {##############################################################################} 1 {##############################################################################}
2 {% macro generate_method(method, world_suffix) %} 2 {% macro generate_method(method, world_suffix) %}
3 {% filter conditional(method.conditional_string) %} 3 {% filter conditional(method.conditional_string) %}
4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
5 { 5 {
6 {# Local variables #} 6 {# Local variables #}
7 {% if method.has_exception_state %} 7 {% if method.has_exception_state %}
8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate());
9 {% endif %} 9 {% endif %}
10 {# Overloaded methods have length checked during overload resolution #} 10 {# Overloaded methods have length checked during overload resolution #}
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum ent.cpp_value) | indent}} 114 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum ent.cpp_value) | indent}}
115 {% else %} 115 {% else %}
116 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}} 116 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}}
117 {% endif %} 117 {% endif %}
118 {% if argument.has_event_listener_argument %} 118 {% if argument.has_event_listener_argument %}
119 {{hidden_dependency_action(method.name) | indent}} 119 {{hidden_dependency_action(method.name) | indent}}
120 {% endif %} 120 {% endif %}
121 return; 121 return;
122 } 122 }
123 {% endif %} 123 {% endif %}
124 {% if argument.has_type_checking_interface %} 124 {% if argument.has_type_checking_interface and not argument.is_variadic_wrapper_ type %}
125 {# Type checking for wrapper interface types (if interface not implemented, 125 {# Type checking for wrapper interface types (if interface not implemented,
126 throw a TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} 126 throw a TypeError), per http://www.w3.org/TR/WebIDL/#es-interface
127 Note: for variadic arguments, the type checking is done for each matched
128 argument instead; see argument.is_variadic_wrapper_type code-path below. #}
127 if (info.Length() > {{argument.index}} && {% if argument.is_nullable %}!isUndefi nedOrNull(info[{{argument.index}}]) && {% endif %}!V8{{argument.idl_type}}::hasI nstance(info[{{argument.index}}], info.GetIsolate())) { 129 if (info.Length() > {{argument.index}} && {% if argument.is_nullable %}!isUndefi nedOrNull(info[{{argument.index}}]) && {% endif %}!V8{{argument.idl_type}}::hasI nstance(info[{{argument.index}}], info.GetIsolate())) {
128 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % 130 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' %
129 (argument.index + 1, argument.idl_type)) | indent }} 131 (argument.index + 1, argument.idl_type)) | indent }}
130 return; 132 return;
131 } 133 }
132 {% endif %}{# argument.has_type_checking_interface #} 134 {% endif %}{# argument.has_type_checking_interface #}
133 {% if argument.is_callback_interface %} 135 {% if argument.is_callback_interface %}
134 {# FIXME: remove EventListener special case #} 136 {# FIXME: remove EventListener special case #}
135 {% if argument.idl_type == 'EventListener' %} 137 {% if argument.idl_type == 'EventListener' %}
136 {% if method.name == 'removeEventListener' %} 138 {% if method.name == 'removeEventListener' %}
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), isolate); 538 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), isolate);
537 {% else %} 539 {% else %}
538 {% set constructor_class = v8_class + ('Constructor' 540 {% set constructor_class = v8_class + ('Constructor'
539 if constructor.is_named_constructor else 541 if constructor.is_named_constructor else
540 '') %} 542 '') %}
541 v8::Handle<v8::Object> wrapper = info.Holder(); 543 v8::Handle<v8::Object> wrapper = info.Holder();
542 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{constr uctor_class}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}}); 544 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{constr uctor_class}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}});
543 {% endif %} 545 {% endif %}
544 v8SetReturnValue(info, wrapper); 546 v8SetReturnValue(info, wrapper);
545 {% endmacro %} 547 {% endmacro %}
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/tests/idls/TestObject.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698