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

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

Issue 204213002: Replace custom EventTarget toNative call with [ToNativeArg] extended attribute Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 {% if method.has_exception_state %} 6 {% if method.has_exception_state %}
7 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); 7 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate());
8 {% endif %} 8 {% endif %}
9 {# FIXME: remove these special cases: http://crbug.com/353484 #} 9 {# FIXME: remove these special cases: http://crbug.com/353484 #}
10 {% if method.number_of_required_arguments and not 10 {% if method.number_of_required_arguments and not
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 {% elif argument.is_variadic_wrapper_type %} 159 {% elif argument.is_variadic_wrapper_type %}
160 {{argument.vector_type}}<{{argument.cpp_type}} > {{argument.name}}; 160 {{argument.vector_type}}<{{argument.cpp_type}} > {{argument.name}};
161 for (int i = {{argument.index}}; i < info.Length(); ++i) { 161 for (int i = {{argument.index}}; i < info.Length(); ++i) {
162 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) { 162 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) {
163 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % 163 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' %
164 (argument.index + 1, argument.idl_type)) | in dent(8)}} 164 (argument.index + 1, argument.idl_type)) | in dent(8)}}
165 return; 165 return;
166 } 166 }
167 {{argument.name}}.append(V8{{argument.idl_type}}::toNative(v8::Handle<v8::Ob ject>::Cast(info[i]))); 167 {{argument.name}}.append(V8{{argument.idl_type}}::toNative(v8::Handle<v8::Ob ject>::Cast(info[i])));
168 } 168 }
169 {# FIXME: remove EventListener special case
170 (just for ListenerFindOrCreate/ListenerFindOnly argument) #}
171 {% elif argument.idl_type == 'EventListener' and
172 interface_name == 'EventTarget' and
173 method.name == 'addEventListener' %}
174 V8TRYCATCH_VOID(RefPtr<EventListener>, {{argument.name}}, V8EventListenerList::g etEventListener(info[{{argument.index}}], false, ListenerFindOrCreate));
175 {% elif argument.idl_type == 'EventListener' and
176 interface_name == 'EventTarget' and
177 method.name == 'removeEventListener' %}
178 V8TRYCATCH_VOID(RefPtr<EventListener>, {{argument.name}}, V8EventListenerList::g etEventListener(info[{{argument.index}}], false, ListenerFindOnly));
179 {% else %} 169 {% else %}
180 {{argument.v8_value_to_local_cpp_value}}; 170 {{argument.v8_value_to_local_cpp_value}};
181 {% endif %} 171 {% endif %}
182 {% if argument.enum_validation_expression %} 172 {% if argument.enum_validation_expression %}
183 {# Methods throw on invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #} 173 {# Methods throw on invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #}
184 String string = {{argument.name}}; 174 String string = {{argument.name}};
185 if (!({{argument.enum_validation_expression}})) { 175 if (!({{argument.enum_validation_expression}})) {
186 {{throw_type_error(method, 176 {{throw_type_error(method,
187 '"parameter %s (\'" + string + "\') is not a valid enum value."' % 177 '"parameter %s (\'" + string + "\') is not a valid enum value."' %
188 (argument.index + 1)) | indent}} 178 (argument.index + 1)) | indent}}
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 v8::Handle<v8::Object> wrapper = info.Holder(); 445 v8::Handle<v8::Object> wrapper = info.Holder();
456 {% if is_constructor_raises_exception %} 446 {% if is_constructor_raises_exception %}
457 if (exceptionState.throwIfNeeded()) 447 if (exceptionState.throwIfNeeded())
458 return; 448 return;
459 {% endif %} 449 {% endif %}
460 450
461 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu ration::Dependent); 451 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu ration::Dependent);
462 v8SetReturnValue(info, wrapper); 452 v8SetReturnValue(info, wrapper);
463 } 453 }
464 {% endmacro %} 454 {% endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698