OLD | NEW |
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'] %} | 9 {% if method.name in ['addEventListener', 'removeEventListener'] %} |
10 {{add_remove_event_listener_method(method.name) | indent}} | 10 {{add_remove_event_listener_method(method.name) | indent}} |
(...skipping 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 {% endif %} | 31 {% endif %} |
32 {% if method.is_check_security_for_node %} | 32 {% if method.is_check_security_for_node %} |
33 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), imp->{{meth
od.name}}(exceptionState), exceptionState)) { | 33 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), imp->{{meth
od.name}}(exceptionState), exceptionState)) { |
34 v8SetReturnValueNull(info); | 34 v8SetReturnValueNull(info); |
35 exceptionState.throwIfNeeded(); | 35 exceptionState.throwIfNeeded(); |
36 return; | 36 return; |
37 } | 37 } |
38 {% endif %} | 38 {% endif %} |
39 {% for argument in method.arguments %} | 39 {% for argument in method.arguments %} |
40 {{generate_argument(method, argument) | indent}} | 40 {{generate_argument(method, argument, world_suffix) | indent}} |
41 {% endfor %} | 41 {% endfor %} |
42 {% if world_suffix %} | 42 {% if world_suffix %} |
43 {{cpp_method_call(method, method.v8_set_return_value_for_main_world, method.
cpp_value) | indent}} | 43 {{cpp_method_call(method, method.v8_set_return_value_for_main_world, method.
cpp_value) | indent}} |
44 {% else %} | 44 {% else %} |
45 {{cpp_method_call(method, method.v8_set_return_value, method.cpp_value) | in
dent}} | 45 {{cpp_method_call(method, method.v8_set_return_value, method.cpp_value) | in
dent}} |
46 {% endif %} | 46 {% endif %} |
47 {% endif %}{# addEventListener, removeEventListener #} | 47 {% endif %}{# addEventListener, removeEventListener #} |
48 } | 48 } |
49 {% endfilter %} | 49 {% endfilter %} |
50 {% endmacro %} | 50 {% endmacro %} |
(...skipping 20 matching lines...) Expand all Loading... |
71 if (listener) { | 71 if (listener) { |
72 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, eventN
ame, info[0]); | 72 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, eventN
ame, info[0]); |
73 impl->{{method_name}}(eventName, {{listener}}, info[2]->BooleanValue()); | 73 impl->{{method_name}}(eventName, {{listener}}, info[2]->BooleanValue()); |
74 if (!impl->toNode()) | 74 if (!impl->toNode()) |
75 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::event
ListenerCacheIndex, info.GetIsolate()); | 75 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::event
ListenerCacheIndex, info.GetIsolate()); |
76 } | 76 } |
77 {% endmacro %} | 77 {% endmacro %} |
78 | 78 |
79 | 79 |
80 {######################################} | 80 {######################################} |
81 {% macro generate_argument(method, argument) %} | 81 {% macro generate_argument(method, argument, world_suffix) %} |
82 {% if argument.is_optional and not argument.has_default and | 82 {% if argument.is_optional and not argument.has_default and |
83 argument.idl_type != 'Dictionary' and | 83 argument.idl_type != 'Dictionary' and |
84 not argument.is_callback_interface %} | 84 not argument.is_callback_interface %} |
85 {# Optional arguments without a default value generate an early call with | 85 {# Optional arguments without a default value generate an early call with |
86 fewer arguments if they are omitted. | 86 fewer arguments if they are omitted. |
87 Optional Dictionary arguments default to empty dictionary. #} | 87 Optional Dictionary arguments default to empty dictionary. #} |
88 if (UNLIKELY(info.Length() <= {{argument.index}})) { | 88 if (UNLIKELY(info.Length() <= {{argument.index}})) { |
| 89 {% if world_suffix %} |
| 90 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum
ent.cpp_value) | indent}} |
| 91 {% else %} |
89 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value)
| indent}} | 92 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value)
| indent}} |
| 93 {% endif %} |
90 return; | 94 return; |
91 } | 95 } |
92 {% endif %} | 96 {% endif %} |
93 {% if method.is_strict_type_checking and argument.is_wrapper_type %} | 97 {% if method.is_strict_type_checking and argument.is_wrapper_type %} |
94 {# Type checking for wrapper interface types (if interface not implemented, | 98 {# Type checking for wrapper interface types (if interface not implemented, |
95 throw TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 99 throw TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
96 if (info.Length() > {{argument.index}} && !{% if argument.is_nullable %}isUndefi
nedOrNull(info[{{argument.index}}]){% else %}info[{{argument.index}}]->IsUndefin
ed(){% endif %} && !V8{{argument.idl_type}}::hasInstance(info[{{argument.index}}
], info.GetIsolate())) { | 100 if (info.Length() > {{argument.index}} && !{% if argument.is_nullable %}isUndefi
nedOrNull(info[{{argument.index}}]){% else %}info[{{argument.index}}]->IsUndefin
ed(){% endif %} && !V8{{argument.idl_type}}::hasInstance(info[{{argument.index}}
], info.GetIsolate())) { |
97 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % | 101 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % |
98 (argument.index + 1, argument.idl_type)) | indent
}} | 102 (argument.index + 1, argument.idl_type)) | indent
}} |
99 return; | 103 return; |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 v8::Handle<v8::Object> wrapper = info.Holder(); | 398 v8::Handle<v8::Object> wrapper = info.Holder(); |
395 {% if is_constructor_raises_exception %} | 399 {% if is_constructor_raises_exception %} |
396 if (exceptionState.throwIfNeeded()) | 400 if (exceptionState.throwIfNeeded()) |
397 return; | 401 return; |
398 {% endif %} | 402 {% endif %} |
399 | 403 |
400 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8
_class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu
ration::Dependent); | 404 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8
_class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu
ration::Dependent); |
401 v8SetReturnValue(info, wrapper); | 405 v8SetReturnValue(info, wrapper); |
402 } | 406 } |
403 {% endmacro %} | 407 {% endmacro %} |
OLD | NEW |