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

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

Issue 166593002: IDL compiler: sync Python to r166999 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: reupload Created 6 years, 10 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 {% if method.name in ['addEventListener', 'removeEventListener',
10 'dispatchEvent'] %}
11 {{add_event_listener_remove_event_listener_dispatch_event() | indent}}
12 {% endif %}
9 {% if method.name in ['addEventListener', 'removeEventListener'] %} 13 {% if method.name in ['addEventListener', 'removeEventListener'] %}
10 {{add_remove_event_listener_method(method.name) | indent}} 14 {{add_event_listener_remove_event_listener_method(method.name) | indent}}
11 {% else %} 15 {% else %}
12 {% if method.number_of_required_arguments %} 16 {% if method.number_of_required_arguments %}
13 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { 17 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) {
14 {{throw_type_error(method, 18 {{throw_type_error(method,
15 'ExceptionMessages::notEnoughArguments(%s, info.Length())' % 19 'ExceptionMessages::notEnoughArguments(%s, info.Length())' %
16 method.number_of_required_arguments) | indent(8)}} 20 method.number_of_required_arguments) | indent(8)}}
17 return; 21 return;
18 } 22 }
19 {% endif %} 23 {% endif %}
20 {% if not method.is_static %} 24 {% if not method.is_static %}
(...skipping 23 matching lines...) Expand all
44 {% else %} 48 {% else %}
45 {{cpp_method_call(method, method.v8_set_return_value, method.cpp_value) | in dent}} 49 {{cpp_method_call(method, method.v8_set_return_value, method.cpp_value) | in dent}}
46 {% endif %} 50 {% endif %}
47 {% endif %}{# addEventListener, removeEventListener #} 51 {% endif %}{# addEventListener, removeEventListener #}
48 } 52 }
49 {% endfilter %} 53 {% endfilter %}
50 {% endmacro %} 54 {% endmacro %}
51 55
52 56
53 {######################################} 57 {######################################}
54 {% macro add_remove_event_listener_method(method_name) %} 58 {% macro add_event_listener_remove_event_listener_dispatch_event() %}
55 {# Set template values for addEventListener vs. removeEventListener #} 59 {# FIXME: Clean up: use the normal |imp| above,
56 {% set listener_lookup_type, listener, hidden_dependency_action = 60 use the existing shouldAllowAccessToFrame check if possible. #}
57 ('ListenerFindOrCreate', 'listener', 'addHiddenValueToArray')
58 if method_name == 'addEventListener' else
59 ('ListenerFindOnly', 'listener.get()', 'removeHiddenValueFromArray')
60 %}
61 EventTarget* impl = {{v8_class}}::toNative(info.Holder()); 61 EventTarget* impl = {{v8_class}}::toNative(info.Holder());
62 if (DOMWindow* window = impl->toDOMWindow()) { 62 if (DOMWindow* window = impl->toDOMWindow()) {
63 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window->fr ame(), exceptionState)) { 63 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window->fr ame(), exceptionState)) {
64 exceptionState.throwIfNeeded(); 64 exceptionState.throwIfNeeded();
65 return; 65 return;
66 } 66 }
67 if (!window->document()) 67 if (!window->document())
68 return; 68 return;
69 } 69 }
70 {% endmacro %}
71
72
73 {######################################}
74 {% macro add_event_listener_remove_event_listener_method(method_name) %}
75 {# Set template values for addEventListener vs. removeEventListener #}
76 {% set listener_lookup_type, listener, hidden_dependency_action =
77 ('ListenerFindOrCreate', 'listener', 'addHiddenValueToArray')
78 if method_name == 'addEventListener' else
79 ('ListenerFindOnly', 'listener.get()', 'removeHiddenValueFromArray')
80 %}
70 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[1], false, {{listener_lookup_type}}); 81 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[1], false, {{listener_lookup_type}});
71 if (listener) { 82 if (listener) {
72 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, eventN ame, info[0]); 83 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, eventN ame, info[0]);
73 impl->{{method_name}}(eventName, {{listener}}, info[2]->BooleanValue()); 84 impl->{{method_name}}(eventName, {{listener}}, info[2]->BooleanValue());
74 if (!impl->toNode()) 85 if (!impl->toNode())
75 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::event ListenerCacheIndex, info.GetIsolate()); 86 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::event ListenerCacheIndex, info.GetIsolate());
76 } 87 }
77 {% endmacro %} 88 {% endmacro %}
78 89
79 90
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 v8::Handle<v8::Object> wrapper = info.Holder(); 435 v8::Handle<v8::Object> wrapper = info.Holder();
425 {% if is_constructor_raises_exception %} 436 {% if is_constructor_raises_exception %}
426 if (exceptionState.throwIfNeeded()) 437 if (exceptionState.throwIfNeeded())
427 return; 438 return;
428 {% endif %} 439 {% endif %}
429 440
430 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu ration::Dependent); 441 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu ration::Dependent);
431 v8SetReturnValue(info, wrapper); 442 v8SetReturnValue(info, wrapper);
432 } 443 }
433 {% endmacro %} 444 {% endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/unstable/v8_methods.py ('k') | Source/bindings/tests/idls/TestObjectPython.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698