| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 {%- endif %}{# argument.idl_type == 'EventListener' #} | 93 {%- endif %}{# argument.idl_type == 'EventListener' #} |
| 94 {%- else %} | 94 {%- else %} |
| 95 {{argument.cpp_type}} {{argument.name}} | 95 {{argument.cpp_type}} {{argument.name}} |
| 96 {%- endif %} | 96 {%- endif %} |
| 97 {% endmacro %} | 97 {% endmacro %} |
| 98 | 98 |
| 99 | 99 |
| 100 {######################################} | 100 {######################################} |
| 101 {% macro generate_argument(method, argument, world_suffix) %} | 101 {% macro generate_argument(method, argument, world_suffix) %} |
| 102 {% if argument.is_optional and not argument.has_default and | 102 {% if argument.is_optional and not argument.has_default and |
| 103 argument.idl_type != 'Dictionary' and | 103 not argument.is_dictionary and |
| 104 not argument.is_callback_interface %} | 104 not argument.is_callback_interface %} |
| 105 {# Optional arguments without a default value generate an early call with | 105 {# Optional arguments without a default value generate an early call with |
| 106 fewer arguments if they are omitted. | 106 fewer arguments if they are omitted. |
| 107 Optional Dictionary arguments default to empty dictionary. #} | 107 Optional Dictionary arguments default to empty dictionary. #} |
| 108 if (UNLIKELY(info.Length() <= {{argument.index}})) { | 108 if (UNLIKELY(info.Length() <= {{argument.index}})) { |
| 109 {% if world_suffix %} | 109 {% if world_suffix %} |
| 110 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum
ent.cpp_value) | indent}} | 110 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum
ent.cpp_value) | indent}} |
| 111 {% else %} | 111 {% else %} |
| 112 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value)
| indent}} | 112 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value)
| indent}} |
| 113 {% endif %} | 113 {% endif %} |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 167 } |
| 168 {% elif argument.is_variadic_wrapper_type %} | 168 {% elif argument.is_variadic_wrapper_type %} |
| 169 for (int i = {{argument.index}}; i < info.Length(); ++i) { | 169 for (int i = {{argument.index}}; i < info.Length(); ++i) { |
| 170 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) { | 170 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) { |
| 171 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % | 171 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % |
| 172 (argument.index + 1, argument.idl_type)) | in
dent(8)}} | 172 (argument.index + 1, argument.idl_type)) | in
dent(8)}} |
| 173 return; | 173 return; |
| 174 } | 174 } |
| 175 {{argument.name}}.append(V8{{argument.idl_type}}::toImpl(v8::Handle<v8::Obje
ct>::Cast(info[i]))); | 175 {{argument.name}}.append(V8{{argument.idl_type}}::toImpl(v8::Handle<v8::Obje
ct>::Cast(info[i]))); |
| 176 } | 176 } |
| 177 {% elif argument.is_dictionary %} |
| 178 {# Dictionaries must have type Undefined, Null or Object: |
| 179 http://heycam.github.io/webidl/#es-dictionary #} |
| 180 if (!isUndefinedOrNull(info[{{argument.index}}]) && !info[{{argument.index}}]->I
sObject()) { |
| 181 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % |
| 182 (argument.index + 1, argument.name)) | indent}} |
| 183 return; |
| 184 } |
| 185 {{argument.v8_value_to_local_cpp_value}}; |
| 177 {% else %}{# argument.is_nullable #} | 186 {% else %}{# argument.is_nullable #} |
| 178 {{argument.v8_value_to_local_cpp_value}}; | 187 {{argument.v8_value_to_local_cpp_value}}; |
| 179 {% endif %}{# argument.is_nullable #} | 188 {% endif %}{# argument.is_nullable #} |
| 180 {# Type checking, possibly throw a TypeError, per: | 189 {# Type checking, possibly throw a TypeError, per: |
| 181 http://www.w3.org/TR/WebIDL/#es-type-mapping #} | 190 http://www.w3.org/TR/WebIDL/#es-type-mapping #} |
| 182 {% if argument.has_type_checking_unrestricted %} | 191 {% if argument.has_type_checking_unrestricted %} |
| 183 {# Non-finite floating point values (NaN, +Infinity or −Infinity), per: | 192 {# Non-finite floating point values (NaN, +Infinity or −Infinity), per: |
| 184 http://heycam.github.io/webidl/#es-float | 193 http://heycam.github.io/webidl/#es-float |
| 185 http://heycam.github.io/webidl/#es-double #} | 194 http://heycam.github.io/webidl/#es-double #} |
| 186 if (!std::isfinite({{argument.name}})) { | 195 if (!std::isfinite({{argument.name}})) { |
| 187 {{throw_type_error(method, '"%s parameter %s is non-finite."' % | 196 {{throw_type_error(method, '"%s parameter %s is non-finite."' % |
| 188 (argument.idl_type, argument.index + 1)) | indent
}} | 197 (argument.idl_type, argument.index + 1)) | indent
}} |
| 189 return; | 198 return; |
| 190 } | 199 } |
| 191 {% elif argument.enum_validation_expression %} | 200 {% elif argument.enum_validation_expression %} |
| 192 {# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #} | 201 {# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #} |
| 193 String string = {{argument.name}}; | 202 String string = {{argument.name}}; |
| 194 if (!({{argument.enum_validation_expression}})) { | 203 if (!({{argument.enum_validation_expression}})) { |
| 195 {{throw_type_error(method, | 204 {{throw_type_error(method, |
| 196 '"parameter %s (\'" + string + "\') is not a valid enum value."' % | 205 '"parameter %s (\'" + string + "\') is not a valid enum value."' % |
| 197 (argument.index + 1)) | indent}} | 206 (argument.index + 1)) | indent}} |
| 198 return; | 207 return; |
| 199 } | 208 } |
| 200 {% elif argument.idl_type in ['Dictionary', 'Promise'] %} | 209 {% elif argument.idl_type == 'Promise' %} |
| 201 {# Dictionaries must have type Undefined, Null or Object: | 210 {# We require this for our implementation of promises, though not in spec: |
| 202 http://heycam.github.io/webidl/#es-dictionary | |
| 203 We also require this for our implementation of promises, though not in spec: | |
| 204 http://heycam.github.io/webidl/#es-promise #} | 211 http://heycam.github.io/webidl/#es-promise #} |
| 205 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { | 212 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { |
| 206 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % | 213 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % |
| 207 (argument.index + 1, argument.name)) | indent}} | 214 (argument.index + 1, argument.name)) | indent}} |
| 208 return; | 215 return; |
| 209 } | 216 } |
| 210 {% endif %} | 217 {% endif %} |
| 211 {% endmacro %} | 218 {% endmacro %} |
| 212 | 219 |
| 213 | 220 |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 if method.is_per_world_bindings else '0' %} | 637 if method.is_per_world_bindings else '0' %} |
| 631 {% set property_attribute = | 638 {% set property_attribute = |
| 632 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut
es) | 639 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut
es) |
| 633 if method.property_attributes else 'v8::None' %} | 640 if method.property_attributes else 'v8::None' %} |
| 634 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} | 641 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} |
| 635 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig
uration = { | 642 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig
uration = { |
| 636 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}},
{{method.length}}, {{only_exposed_to_private_script}}, | 643 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}},
{{method.length}}, {{only_exposed_to_private_script}}, |
| 637 }; | 644 }; |
| 638 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu
re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); | 645 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu
re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); |
| 639 {%- endmacro %} | 646 {%- endmacro %} |
| OLD | NEW |