| 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 {% if method.number_of_required_arguments %} | 10 {% if method.number_of_required_arguments %} |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value)
| indent}} | 87 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value)
| indent}} |
| 88 {% endif %} | 88 {% endif %} |
| 89 {% if argument.has_event_listener_argument %} | 89 {% if argument.has_event_listener_argument %} |
| 90 {{hidden_dependency_action(method.name) | indent}} | 90 {{hidden_dependency_action(method.name) | indent}} |
| 91 {% endif %} | 91 {% endif %} |
| 92 return; | 92 return; |
| 93 } | 93 } |
| 94 {% endif %} | 94 {% endif %} |
| 95 {% if argument.has_type_checking_interface %} | 95 {% if argument.has_type_checking_interface %} |
| 96 {# Type checking for wrapper interface types (if interface not implemented, | 96 {# Type checking for wrapper interface types (if interface not implemented, |
| 97 throw TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 97 throw a TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
| 98 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())) { | 98 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())) { |
| 99 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % | 99 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % |
| 100 (argument.index + 1, argument.idl_type)) | indent
}} | 100 (argument.index + 1, argument.idl_type)) | indent
}} |
| 101 return; | 101 return; |
| 102 } | 102 } |
| 103 {% endif %} | 103 {% endif %} |
| 104 {% if argument.is_callback_interface %} | 104 {% if argument.is_callback_interface %} |
| 105 {# FIXME: remove EventListener special case #} | 105 {# FIXME: remove EventListener special case #} |
| 106 {% if argument.idl_type == 'EventListener' %} | 106 {% if argument.idl_type == 'EventListener' %} |
| 107 {% if method.name == 'removeEventListener' %} | 107 {% if method.name == 'removeEventListener' %} |
| 108 RefPtr<{{argument.idl_type}}> {{argument.name}} = V8EventListenerList::getEventL
istener(info[1], false, ListenerFindOnly); | 108 RefPtr<{{argument.idl_type}}> {{argument.name}} = V8EventListenerList::getEventL
istener(info[1], false, ListenerFindOnly); |
| 109 {% else %}{# method.name == 'addEventListener' #} | 109 {% else %}{# method.name == 'addEventListener' #} |
| 110 RefPtr<{{argument.idl_type}}> {{argument.name}} = V8EventListenerList::getEventL
istener(info[1], false, ListenerFindOrCreate); | 110 RefPtr<{{argument.idl_type}}> {{argument.name}} = V8EventListenerList::getEventL
istener(info[1], false, ListenerFindOrCreate); |
| 111 {% endif %}{# method.name #} | 111 {% endif %}{# method.name #} |
| 112 {% else %} | 112 {% else %} |
| 113 {# Callback functions must be functions: |
| 114 http://www.w3.org/TR/WebIDL/#es-callback-function #} |
| 113 {% if argument.is_optional %} | 115 {% if argument.is_optional %} |
| 114 OwnPtr<{{argument.idl_type}}> {{argument.name}}; | 116 OwnPtr<{{argument.idl_type}}> {{argument.name}}; |
| 115 if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.ind
ex}}])) { | 117 if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.ind
ex}}])) { |
| 116 if (!info[{{argument.index}}]->IsFunction()) { | 118 if (!info[{{argument.index}}]->IsFunction()) { |
| 117 {{throw_type_error(method, | 119 {{throw_type_error(method, |
| 118 '"The callback provided as parameter %s is not a function."' % | 120 '"The callback provided as parameter %s is not a function."' % |
| 119 (argument.index + 1)) | indent(8)}} | 121 (argument.index + 1)) | indent(8)}} |
| 120 return; | 122 return; |
| 121 } | 123 } |
| 122 {{argument.name}} = V8{{argument.idl_type}}::create(v8::Handle<v8::Function>
::Cast(info[{{argument.index}}]), currentExecutionContext(info.GetIsolate())); | 124 {{argument.name}} = V8{{argument.idl_type}}::create(v8::Handle<v8::Function>
::Cast(info[{{argument.index}}]), currentExecutionContext(info.GetIsolate())); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 149 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) { | 151 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) { |
| 150 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % | 152 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % |
| 151 (argument.index + 1, argument.idl_type)) | in
dent(8)}} | 153 (argument.index + 1, argument.idl_type)) | in
dent(8)}} |
| 152 return; | 154 return; |
| 153 } | 155 } |
| 154 {{argument.name}}.append(V8{{argument.idl_type}}::toNative(v8::Handle<v8::Ob
ject>::Cast(info[i]))); | 156 {{argument.name}}.append(V8{{argument.idl_type}}::toNative(v8::Handle<v8::Ob
ject>::Cast(info[i]))); |
| 155 } | 157 } |
| 156 {% else %} | 158 {% else %} |
| 157 {{argument.v8_value_to_local_cpp_value}}; | 159 {{argument.v8_value_to_local_cpp_value}}; |
| 158 {% endif %} | 160 {% endif %} |
| 159 {% if argument.enum_validation_expression %} | 161 {# Type checking, possibly throw a TypeError, per: |
| 160 {# Methods throw on invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums
#} | 162 http://www.w3.org/TR/WebIDL/#es-type-mapping #} |
| 163 {% if argument.has_type_checking_unrestricted %} |
| 164 {# Non-finite floating point values (NaN, +Infinity or −Infinity), per: |
| 165 http://heycam.github.io/webidl/#es-float |
| 166 http://heycam.github.io/webidl/#es-double #} |
| 167 if (!std::isfinite({{argument.name}})) { |
| 168 {{throw_type_error(method, '"%s parameter %s is non-finite."' % |
| 169 (argument.idl_type, argument.index + 1)) | indent
}} |
| 170 return; |
| 171 } |
| 172 {% elif argument.enum_validation_expression %} |
| 173 {# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #} |
| 161 String string = {{argument.name}}; | 174 String string = {{argument.name}}; |
| 162 if (!({{argument.enum_validation_expression}})) { | 175 if (!({{argument.enum_validation_expression}})) { |
| 163 {{throw_type_error(method, | 176 {{throw_type_error(method, |
| 164 '"parameter %s (\'" + string + "\') is not a valid enum value."' % | 177 '"parameter %s (\'" + string + "\') is not a valid enum value."' % |
| 165 (argument.index + 1)) | indent}} | 178 (argument.index + 1)) | indent}} |
| 166 return; | 179 return; |
| 167 } | 180 } |
| 168 {% endif %} | 181 {% elif argument.idl_type in ['Dictionary', 'Promise'] %} |
| 169 {% if argument.idl_type in ['Dictionary', 'Promise'] %} | 182 {# Dictionaries must have type Undefined, Null or Object: |
| 183 http://heycam.github.io/webidl/#es-dictionary |
| 184 We also require this for our implementation of promises, though not in spec: |
| 185 http://heycam.github.io/webidl/#es-promise #} |
| 170 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { | 186 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { |
| 171 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % | 187 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % |
| 172 (argument.index + 1, argument.name)) | indent}} | 188 (argument.index + 1, argument.name)) | indent}} |
| 173 return; | 189 return; |
| 174 } | 190 } |
| 175 {% endif %} | 191 {% endif %} |
| 176 {% endmacro %} | 192 {% endmacro %} |
| 177 | 193 |
| 178 | 194 |
| 179 {######################################} | 195 {######################################} |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 {% endfor %} | 464 {% endfor %} |
| 449 {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{cons
tructor.argument_list | join(', ')}}); | 465 {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{cons
tructor.argument_list | join(', ')}}); |
| 450 {% if is_constructor_raises_exception %} | 466 {% if is_constructor_raises_exception %} |
| 451 if (exceptionState.throwIfNeeded()) | 467 if (exceptionState.throwIfNeeded()) |
| 452 return; | 468 return; |
| 453 {% endif %} | 469 {% endif %} |
| 454 | 470 |
| 455 {{generate_constructor_wrapper(constructor) | indent}} | 471 {{generate_constructor_wrapper(constructor) | indent}} |
| 456 } | 472 } |
| 457 {% endmacro %} | 473 {% endmacro %} |
| OLD | NEW |