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{% if method.overload_index %}, int ty
peCheckedArgumentIndex{% endif %}) |
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 #} |
11 {% if method.number_of_required_arguments and not method.overload_index %} | 11 {% if method.number_of_required_arguments and not method.overload_index %} |
12 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { | 12 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { |
13 {{throw_minimum_arity_type_error(method, method.number_of_required_argum
ents) | indent(8)}} | 13 {{throw_minimum_arity_type_error(method, method.number_of_required_argum
ents) | indent(8)}} |
14 return; | 14 return; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 {% elif argument.is_dictionary %} | 165 {% elif argument.is_dictionary %} |
166 {# Dictionaries must have type Undefined, Null or Object: | 166 {# Dictionaries must have type Undefined, Null or Object: |
167 http://heycam.github.io/webidl/#es-dictionary #} | 167 http://heycam.github.io/webidl/#es-dictionary #} |
168 if (!isUndefinedOrNull(info[{{argument.index}}]) && !info[{{argument.index}}]->I
sObject()) { | 168 if (!isUndefinedOrNull(info[{{argument.index}}]) && !info[{{argument.index}}]->I
sObject()) { |
169 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % | 169 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % |
170 (argument.index + 1, argument.name)) | indent}} | 170 (argument.index + 1, argument.name)) | indent}} |
171 return; | 171 return; |
172 } | 172 } |
173 {{argument.v8_value_to_local_cpp_value}}; | 173 {{argument.v8_value_to_local_cpp_value}}; |
174 {% else %}{# argument.is_nullable #} | 174 {% else %}{# argument.is_nullable #} |
| 175 {# Optionally do an "unsafe" type conversion if meaningful for this argument's |
| 176 type and if this method is overloaded and the argument's type was checked as |
| 177 part of overload resolution for this particular call. #} |
| 178 {% if argument.is_ever_distinguishing_argument and |
| 179 argument.v8_value_to_local_cpp_value_without_type_check %} |
| 180 if (typeCheckedArgumentIndex == {{argument.index}}) |
| 181 {{argument.v8_value_to_local_cpp_value_without_type_check}}; |
| 182 else |
| 183 {{argument.v8_value_to_local_cpp_value}}; |
| 184 {% else %} |
175 {{argument.v8_value_to_local_cpp_value}}; | 185 {{argument.v8_value_to_local_cpp_value}}; |
| 186 {% endif %} |
176 {% endif %}{# argument.is_nullable #} | 187 {% endif %}{# argument.is_nullable #} |
177 {# Type checking, possibly throw a TypeError, per: | 188 {# Type checking, possibly throw a TypeError, per: |
178 http://www.w3.org/TR/WebIDL/#es-type-mapping #} | 189 http://www.w3.org/TR/WebIDL/#es-type-mapping #} |
179 {% if argument.has_type_checking_unrestricted %} | 190 {% if argument.has_type_checking_unrestricted %} |
180 {# Non-finite floating point values (NaN, +Infinity or −Infinity), per: | 191 {# Non-finite floating point values (NaN, +Infinity or −Infinity), per: |
181 http://heycam.github.io/webidl/#es-float | 192 http://heycam.github.io/webidl/#es-float |
182 http://heycam.github.io/webidl/#es-double #} | 193 http://heycam.github.io/webidl/#es-double #} |
183 if (!std::isfinite({{argument.name}})) { | 194 if (!std::isfinite({{argument.name}})) { |
184 {{throw_type_error(method, '"%s parameter %s is non-finite."' % | 195 {{throw_type_error(method, '"%s parameter %s is non-finite."' % |
185 (argument.idl_type, argument.index + 1)) | indent
}} | 196 (argument.idl_type, argument.index + 1)) | indent
}} |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), Use
Counter::{{overloads.deprecate_all_as}}); | 381 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), Use
Counter::{{overloads.deprecate_all_as}}); |
371 {% endif %} | 382 {% endif %} |
372 {# First resolve by length #} | 383 {# First resolve by length #} |
373 {# 2. Initialize argcount to be min(maxarg, n). #} | 384 {# 2. Initialize argcount to be min(maxarg, n). #} |
374 switch (std::min({{overloads.maxarg}}, info.Length())) { | 385 switch (std::min({{overloads.maxarg}}, info.Length())) { |
375 {# 3. Remove from S all entries whose type list is not of length argcount. #
} | 386 {# 3. Remove from S all entries whose type list is not of length argcount. #
} |
376 {% for length, tests_methods in overloads.length_tests_methods %} | 387 {% for length, tests_methods in overloads.length_tests_methods %} |
377 {# 10. If i = d, then: #} | 388 {# 10. If i = d, then: #} |
378 case {{length}}: | 389 case {{length}}: |
379 {# Then resolve by testing argument #} | 390 {# Then resolve by testing argument #} |
380 {% for test, method in tests_methods %} | 391 {% for test, method, typed_checked_argument_index in tests_methods %} |
381 {% filter runtime_enabled(not overloads.runtime_enabled_function_all and | 392 {% filter runtime_enabled(not overloads.runtime_enabled_function_all and |
382 method.runtime_enabled_function) %} | 393 method.runtime_enabled_function) %} |
383 if ({{test}}) { | 394 if ({{test}}) { |
384 {% if method.measure_as and not overloads.measure_all_as %} | 395 {% if method.measure_as and not overloads.measure_all_as %} |
385 UseCounter::count(callingExecutionContext(info.GetIsolate()), UseCou
nter::{{method.measure_as}}); | 396 UseCounter::count(callingExecutionContext(info.GetIsolate()), UseCou
nter::{{method.measure_as}}); |
386 {% endif %} | 397 {% endif %} |
387 {% if method.deprecate_as and not overloads.deprecate_all_as %} | 398 {% if method.deprecate_as and not overloads.deprecate_all_as %} |
388 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate
()), UseCounter::{{method.deprecate_as}}); | 399 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate
()), UseCounter::{{method.deprecate_as}}); |
389 {% endif %} | 400 {% endif %} |
390 {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info)
; | 401 {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info,
{{typed_checked_argument_index}}); |
391 return; | 402 return; |
392 } | 403 } |
393 {% endfilter %} | 404 {% endfilter %} |
394 {% endfor %} | 405 {% endfor %} |
395 break; | 406 break; |
396 {% endfor %} | 407 {% endfor %} |
397 default: | 408 default: |
398 {# Invalid arity, throw error #} | 409 {# Invalid arity, throw error #} |
399 {# Report full list of valid arities if gaps and above minimum #} | 410 {# Report full list of valid arities if gaps and above minimum #} |
400 {% if overloads.valid_arities %} | 411 {% if overloads.valid_arities %} |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 return true; | 551 return true; |
541 } | 552 } |
542 {% endmacro %} | 553 {% endmacro %} |
543 | 554 |
544 | 555 |
545 {##############################################################################} | 556 {##############################################################################} |
546 {% macro generate_constructor(constructor) %} | 557 {% macro generate_constructor(constructor) %} |
547 {% set name = '%sConstructorCallback' % v8_class | 558 {% set name = '%sConstructorCallback' % v8_class |
548 if constructor.is_named_constructor else | 559 if constructor.is_named_constructor else |
549 'constructor%s' % (constructor.overload_index or '') %} | 560 'constructor%s' % (constructor.overload_index or '') %} |
550 static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info) | 561 static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info{% if constr
uctor.overload_index %}, int typeCheckedArgumentIndex{% endif %}) |
551 { | 562 { |
552 {% if constructor.is_named_constructor %} | 563 {% if constructor.is_named_constructor %} |
553 if (!info.IsConstructCall()) { | 564 if (!info.IsConstructCall()) { |
554 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallab
leAsFunction("{{constructor.name}}"), info.GetIsolate()); | 565 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallab
leAsFunction("{{constructor.name}}"), info.GetIsolate()); |
555 return; | 566 return; |
556 } | 567 } |
557 | 568 |
558 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExis
tingObject) { | 569 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExis
tingObject) { |
559 v8SetReturnValue(info, info.Holder()); | 570 v8SetReturnValue(info, info.Holder()); |
560 return; | 571 return; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 if method.is_per_world_bindings else '0' %} | 627 if method.is_per_world_bindings else '0' %} |
617 {% set property_attribute = | 628 {% set property_attribute = |
618 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut
es) | 629 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut
es) |
619 if method.property_attributes else 'v8::None' %} | 630 if method.property_attributes else 'v8::None' %} |
620 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} | 631 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} |
621 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig
uration = { | 632 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig
uration = { |
622 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}},
{{method.length}}, {{only_exposed_to_private_script}}, | 633 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}},
{{method.length}}, {{only_exposed_to_private_script}}, |
623 }; | 634 }; |
624 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu
re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); | 635 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu
re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); |
625 {%- endmacro %} | 636 {%- endmacro %} |
OLD | NEW |