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

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

Issue 289843006: Avoid extra arity and type check on distinguishing argument (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: additional test Created 6 years, 7 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
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 {% if method.number_of_required_arguments %} 10 {% if method.number_of_required_arguments %}
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum ent.cpp_value) | indent}} 85 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum ent.cpp_value) | indent}}
86 {% else %} 86 {% else %}
87 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}} 87 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}}
88 {% endif %} 88 {% endif %}
89 {% if argument.has_event_listener_argument %} 89 {% if argument.has_event_listener_argument %}
90 {{hidden_dependency_action(method.name) | indent}} 90 {{hidden_dependency_action(method.name) | indent}}
91 {% endif %} 91 {% endif %}
92 return; 92 return;
93 } 93 }
94 {% endif %} 94 {% endif %}
95 {% if argument.has_type_checking_interface %} 95 {% if argument.has_type_checking_interface and argument.index != method.distingu ishing_argument_index %}
96 {# Type checking for wrapper interface types (if interface not implemented, 96 {# Type checking for wrapper interface types (if interface not implemented,
97 throw a TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} 97 throw a TypeError), per http://www.w3.org/TR/WebIDL/#es-interface
98 If the argument is the distinguishing argument for an overloaded method,
99 the type is checked as part of overload resolution instead. #}
98 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())) { 100 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())) {
99 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % 101 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' %
100 (argument.index + 1, argument.idl_type)) | indent }} 102 (argument.index + 1, argument.idl_type)) | indent }}
101 return; 103 return;
102 } 104 }
103 {% endif %} 105 {% endif %}
104 {% if argument.is_callback_interface %} 106 {% if argument.is_callback_interface %}
105 {# FIXME: remove EventListener special case #} 107 {# FIXME: remove EventListener special case #}
106 {% if argument.idl_type == 'EventListener' %} 108 {% if argument.idl_type == 'EventListener' %}
107 {% if method.name == 'removeEventListener' %} 109 {% if method.name == 'removeEventListener' %}
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 {% endfor %} 506 {% endfor %}
505 {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{cons tructor.argument_list | join(', ')}}); 507 {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{cons tructor.argument_list | join(', ')}});
506 {% if is_constructor_raises_exception %} 508 {% if is_constructor_raises_exception %}
507 if (exceptionState.throwIfNeeded()) 509 if (exceptionState.throwIfNeeded())
508 return; 510 return;
509 {% endif %} 511 {% endif %}
510 512
511 {{generate_constructor_wrapper(constructor) | indent}} 513 {{generate_constructor_wrapper(constructor) | indent}}
512 } 514 }
513 {% endmacro %} 515 {% endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698