| 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 {# 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 {# Overloaded methods have length checked during overload resolution #} | 10 {# Overloaded methods have length checked during overload resolution #} |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum
ent.cpp_value) | indent}} | 102 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum
ent.cpp_value) | indent}} |
| 103 {% else %} | 103 {% else %} |
| 104 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value)
| indent}} | 104 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value)
| indent}} |
| 105 {% endif %} | 105 {% endif %} |
| 106 {% if argument.has_event_listener_argument %} | 106 {% if argument.has_event_listener_argument %} |
| 107 {{hidden_dependency_action(method.name) | indent}} | 107 {{hidden_dependency_action(method.name) | indent}} |
| 108 {% endif %} | 108 {% endif %} |
| 109 return; | 109 return; |
| 110 } | 110 } |
| 111 {% endif %} | 111 {% endif %} |
| 112 {% if argument.has_type_checking_interface and not argument.is_variadic_wrapper_
type %} | |
| 113 {# Type checking for wrapper interface types (if interface not implemented, | |
| 114 throw a TypeError), per http://www.w3.org/TR/WebIDL/#es-interface | |
| 115 Note: for variadic arguments, the type checking is done for each matched | |
| 116 argument instead; see argument.is_variadic_wrapper_type code-path below. #} | |
| 117 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())) { | |
| 118 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % | |
| 119 (argument.index + 1, argument.idl_type)) | indent
}} | |
| 120 return; | |
| 121 } | |
| 122 {% endif %}{# argument.has_type_checking_interface #} | |
| 123 {% if argument.is_callback_interface %} | 112 {% if argument.is_callback_interface %} |
| 124 {# FIXME: remove EventListener special case #} | 113 {# FIXME: remove EventListener special case #} |
| 125 {% if argument.idl_type == 'EventListener' %} | 114 {% if argument.idl_type == 'EventListener' %} |
| 126 {% if method.name == 'removeEventListener' or method.name == 'removeListener' %} | 115 {% if method.name == 'removeEventListener' or method.name == 'removeListener' %} |
| 127 {{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(i
nfo.GetIsolate()), info[{{argument.index}}], false, ListenerFindOnly); | 116 {{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(i
nfo.GetIsolate()), info[{{argument.index}}], false, ListenerFindOnly); |
| 128 {% else %}{# method.name == 'addEventListener' #} | 117 {% else %}{# method.name == 'addEventListener' #} |
| 129 {{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(i
nfo.GetIsolate()), info[{{argument.index}}], false, ListenerFindOrCreate); | 118 {{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(i
nfo.GetIsolate()), info[{{argument.index}}], false, ListenerFindOrCreate); |
| 130 {% endif %}{# method.name #} | 119 {% endif %}{# method.name #} |
| 131 {% else %}{# argument.idl_type == 'EventListener' #} | 120 {% else %}{# argument.idl_type == 'EventListener' #} |
| 132 {# Callback functions must be functions: | 121 {# Callback functions must be functions: |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 http://www.w3.org/TR/WebIDL/#es-type-mapping #} | 169 http://www.w3.org/TR/WebIDL/#es-type-mapping #} |
| 181 {% if argument.has_type_checking_unrestricted %} | 170 {% if argument.has_type_checking_unrestricted %} |
| 182 {# Non-finite floating point values (NaN, +Infinity or −Infinity), per: | 171 {# Non-finite floating point values (NaN, +Infinity or −Infinity), per: |
| 183 http://heycam.github.io/webidl/#es-float | 172 http://heycam.github.io/webidl/#es-float |
| 184 http://heycam.github.io/webidl/#es-double #} | 173 http://heycam.github.io/webidl/#es-double #} |
| 185 if (!std::isfinite({{argument.name}})) { | 174 if (!std::isfinite({{argument.name}})) { |
| 186 {{throw_type_error(method, '"%s parameter %s is non-finite."' % | 175 {{throw_type_error(method, '"%s parameter %s is non-finite."' % |
| 187 (argument.idl_type, argument.index + 1)) | indent
}} | 176 (argument.idl_type, argument.index + 1)) | indent
}} |
| 188 return; | 177 return; |
| 189 } | 178 } |
| 179 {% elif argument.has_type_checking_interface and not argument.is_variadic_wrappe
r_type %} |
| 180 {# Type checking for wrapper interface types (if interface not implemented, |
| 181 throw a TypeError), per http://www.w3.org/TR/WebIDL/#es-interface |
| 182 Note: for variadic arguments, the type checking is done for each matched |
| 183 argument instead; see argument.is_variadic_wrapper_type code-path above. #} |
| 184 if (!{{argument.name}}{% if argument.is_nullable %} && !isUndefinedOrNull(info[{
{argument.index}}]){% endif %}) { |
| 185 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % |
| 186 (argument.index + 1, argument.idl_type)) | indent
}} |
| 187 return; |
| 188 } |
| 190 {% elif argument.enum_validation_expression %} | 189 {% elif argument.enum_validation_expression %} |
| 191 {# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #} | 190 {# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #} |
| 192 String string = {{argument.name}}; | 191 String string = {{argument.name}}; |
| 193 if (!({{argument.enum_validation_expression}})) { | 192 if (!({{argument.enum_validation_expression}})) { |
| 194 {{throw_type_error(method, | 193 {{throw_type_error(method, |
| 195 '"parameter %s (\'" + string + "\') is not a valid enum value."' % | 194 '"parameter %s (\'" + string + "\') is not a valid enum value."' % |
| 196 (argument.index + 1)) | indent}} | 195 (argument.index + 1)) | indent}} |
| 197 return; | 196 return; |
| 198 } | 197 } |
| 199 {% elif argument.idl_type == 'Promise' %} | 198 {% elif argument.idl_type == 'Promise' %} |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 if method.overloads else | 652 if method.overloads else |
| 654 method.runtime_enabled_function) %} | 653 method.runtime_enabled_function) %} |
| 655 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio
nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho
dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument
s}})->GetFunction()); | 654 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio
nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho
dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument
s}})->GetFunction()); |
| 656 {% endfilter %}{# runtime_enabled() #} | 655 {% endfilter %}{# runtime_enabled() #} |
| 657 {% endfilter %}{# exposed() #} | 656 {% endfilter %}{# exposed() #} |
| 658 {% endfilter %}{# per_context_enabled() #} | 657 {% endfilter %}{# per_context_enabled() #} |
| 659 {% endfor %} | 658 {% endfor %} |
| 660 {% endif %} | 659 {% endif %} |
| 661 } | 660 } |
| 662 {%- endmacro %} | 661 {%- endmacro %} |
| OLD | NEW |