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

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

Issue 1476863003: bindings: Ignores the last undefined arguments when counting the args. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed a review comment. Created 5 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 unified diff | Download patch
OLDNEW
1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %} 1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro generate_method(method, world_suffix) %} 5 {% macro generate_method(method, world_suffix) %}
6 {% filter conditional(method.conditional_string) %} 6 {% filter conditional(method.conditional_string) %}
7 {% if method.returns_promise and method.has_exception_state %} 7 {% if method.returns_promise and method.has_exception_state %}
8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat e) 8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat e)
9 {% else %} 9 {% else %}
10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) 10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 {% endfilter %} 67 {% endfilter %}
68 {% endmacro %} 68 {% endmacro %}
69 69
70 70
71 {######################################} 71 {######################################}
72 {% macro generate_arguments(method, world_suffix) %} 72 {% macro generate_arguments(method, world_suffix) %}
73 {% for argument in method.arguments %} 73 {% for argument in method.arguments %}
74 {{generate_argument_var_declaration(argument)}}; 74 {{generate_argument_var_declaration(argument)}};
75 {% endfor %} 75 {% endfor %}
76 { 76 {
77 {% if method.has_optional_argument_without_default_value %}
78 {# Count the effective number of arguments. (arg1, arg2, undefined) is
79 interpreted as two arguments are passed and (arg1, undefined, arg3) is
80 interpreted as three arguments are passed. #}
81 int numArgsPassed = info.Length();
82 while (numArgsPassed > 0) {
83 if (!info[numArgsPassed - 1]->IsUndefined())
84 break;
85 --numArgsPassed;
86 }
87 {% endif %}
77 {% for argument in method.arguments %} 88 {% for argument in method.arguments %}
78 {% if argument.set_default_value %} 89 {% if argument.set_default_value %}
79 if (!info[{{argument.index}}]->IsUndefined()) { 90 if (!info[{{argument.index}}]->IsUndefined()) {
80 {{generate_argument(method, argument, world_suffix) | indent(8)}} 91 {{generate_argument(method, argument, world_suffix) | indent(8)}}
81 } else { 92 } else {
82 {{argument.set_default_value}}; 93 {{argument.set_default_value}};
83 } 94 }
84 {% else %} 95 {% else %}
85 {{generate_argument(method, argument, world_suffix) | indent}} 96 {{generate_argument(method, argument, world_suffix) | indent}}
86 {% endif %} 97 {% endif %}
87 {% endfor %} 98 {% endfor %}
88 } 99 }
89 {% endmacro %} 100 {% endmacro %}
90 101
91 102
92 {######################################} 103 {######################################}
93 {% macro generate_argument_var_declaration(argument) %} 104 {% macro generate_argument_var_declaration(argument) %}
94 {# FIXME: remove EventListener special case #} 105 {# FIXME: remove EventListener special case #}
95 {% if argument.idl_type == 'EventListener' %} 106 {% if argument.idl_type == 'EventListener' %}
96 RefPtrWillBeRawPtr<{{argument.idl_type}}> {{argument.name}} 107 RefPtrWillBeRawPtr<{{argument.idl_type}}> {{argument.name}}
97 {%- else %} 108 {%- else %}
98 {{argument.cpp_type}} {{argument.name}} 109 {{argument.cpp_type}} {{argument.name}}
99 {%- endif %}{# argument.idl_type == 'EventListener' #} 110 {%- endif %}{# argument.idl_type == 'EventListener' #}
100 {% endmacro %} 111 {% endmacro %}
101 112
102 113
103 {######################################} 114 {######################################}
104 {% macro generate_argument(method, argument, world_suffix) %} 115 {% macro generate_argument(method, argument, world_suffix) %}
105 {% if argument.is_optional and not argument.has_default and 116 {% if argument.is_optional_without_default_value %}
106 not argument.is_dictionary and
107 not argument.is_callback_interface %}
108 {# Optional arguments without a default value generate an early call with 117 {# Optional arguments without a default value generate an early call with
109 fewer arguments if they are omitted. 118 fewer arguments if they are omitted.
110 Optional Dictionary arguments default to empty dictionary. #} 119 Optional Dictionary arguments default to empty dictionary. #}
111 if (UNLIKELY(info.Length() <= {{argument.index}})) { 120 if (UNLIKELY(numArgsPassed <= {{argument.index}})) {
112 {% if world_suffix %} 121 {% if world_suffix %}
113 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum ent.cpp_value) | indent}} 122 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum ent.cpp_value) | indent}}
114 {% else %} 123 {% else %}
115 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}} 124 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}}
116 {% endif %} 125 {% endif %}
117 {% if argument.has_event_listener_argument %} 126 {% if argument.has_event_listener_argument %}
118 {{hidden_dependency_action(method.name) | indent}} 127 {{hidden_dependency_action(method.name) | indent}}
119 {% endif %} 128 {% endif %}
120 return; 129 return;
121 } 130 }
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all 692 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all
684 if method.overloads else 693 if method.overloads else
685 method.runtime_enabled_function) %} 694 method.runtime_enabled_function) %}
686 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 695 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
687 V8DOMConfiguration::installMethod(isolate, v8::Local<v8::Object>(), prototypeObj ect, interfaceObject, defaultSignature, {{method.name}}MethodConfiguration); 696 V8DOMConfiguration::installMethod(isolate, v8::Local<v8::Object>(), prototypeObj ect, interfaceObject, defaultSignature, {{method.name}}MethodConfiguration);
688 {% endfilter %}{# runtime_enabled() #} 697 {% endfilter %}{# runtime_enabled() #}
689 {% endfilter %}{# exposed() #} 698 {% endfilter %}{# exposed() #}
690 {% endfor %} 699 {% endfor %}
691 {% endif %} 700 {% endif %}
692 {%- endmacro %} 701 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698