| 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 376 |
| 377 | 377 |
| 378 {##############################################################################} | 378 {##############################################################################} |
| 379 {# FIXME: We should return a rejected Promise if an error occurs in this | 379 {# FIXME: We should return a rejected Promise if an error occurs in this |
| 380 function when ALL methods in this overload return Promise. In order to do so, | 380 function when ALL methods in this overload return Promise. In order to do so, |
| 381 we must ensure either ALL or NO methods in this overload return Promise #} | 381 we must ensure either ALL or NO methods in this overload return Promise #} |
| 382 {% macro overload_resolution_method(overloads, world_suffix) %} | 382 {% macro overload_resolution_method(overloads, world_suffix) %} |
| 383 static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
nfo<v8::Value>& info) | 383 static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 384 { | 384 { |
| 385 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{overloads
.name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 385 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{overloads
.name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
| 386 {% if overloads.measure_all_as %} | |
| 387 UseCounter::count(callingExecutionContext(info.GetIsolate()), UseCounter::{{
overloads.measure_all_as}}); | |
| 388 {% endif %} | |
| 389 {% if overloads.deprecate_all_as %} | |
| 390 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), Use
Counter::{{overloads.deprecate_all_as}}); | |
| 391 {% endif %} | |
| 392 {# First resolve by length #} | 386 {# First resolve by length #} |
| 393 {# 2. Initialize argcount to be min(maxarg, n). #} | 387 {# 2. Initialize argcount to be min(maxarg, n). #} |
| 394 switch (std::min({{overloads.maxarg}}, info.Length())) { | 388 switch (std::min({{overloads.maxarg}}, info.Length())) { |
| 395 {# 3. Remove from S all entries whose type list is not of length argcount. #
} | 389 {# 3. Remove from S all entries whose type list is not of length argcount. #
} |
| 396 {% for length, tests_methods in overloads.length_tests_methods %} | 390 {% for length, tests_methods in overloads.length_tests_methods %} |
| 397 {# 10. If i = d, then: #} | 391 {# 10. If i = d, then: #} |
| 398 case {{length}}: | 392 case {{length}}: |
| 399 {# Then resolve by testing argument #} | 393 {# Then resolve by testing argument #} |
| 400 {% for test, method in tests_methods %} | 394 {% for test, method in tests_methods %} |
| 401 {% filter runtime_enabled(not overloads.runtime_enabled_function_all and | 395 {% filter runtime_enabled(not overloads.runtime_enabled_function_all and |
| 402 method.runtime_enabled_function) %} | 396 method.runtime_enabled_function) %} |
| 403 if ({{test}}) { | 397 if ({{test}}) { |
| 404 {% if method.measure_as and not overloads.measure_all_as %} | |
| 405 UseCounter::count(callingExecutionContext(info.GetIsolate()), UseCou
nter::{{method.measure_as}}); | |
| 406 {% endif %} | |
| 407 {% if method.deprecate_as and not overloads.deprecate_all_as %} | |
| 408 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate
()), UseCounter::{{method.deprecate_as}}); | |
| 409 {% endif %} | |
| 410 {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info)
; | 398 {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info)
; |
| 411 return; | 399 return; |
| 412 } | 400 } |
| 413 {% endfilter %} | 401 {% endfilter %} |
| 414 {% endfor %} | 402 {% endfor %} |
| 415 break; | 403 break; |
| 416 {% endfor %} | 404 {% endfor %} |
| 417 default: | 405 default: |
| 418 {# Invalid arity, throw error #} | 406 {# Invalid arity, throw error #} |
| 419 {# Report full list of valid arities if gaps and above minimum #} | 407 {# Report full list of valid arities if gaps and above minimum #} |
| (...skipping 16 matching lines...) Expand all Loading... |
| 436 {% endmacro %} | 424 {% endmacro %} |
| 437 | 425 |
| 438 | 426 |
| 439 {##############################################################################} | 427 {##############################################################################} |
| 440 {% macro method_callback(method, world_suffix) %} | 428 {% macro method_callback(method, world_suffix) %} |
| 441 {% filter conditional(method.conditional_string) %} | 429 {% filter conditional(method.conditional_string) %} |
| 442 static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCall
backInfo<v8::Value>& info) | 430 static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCall
backInfo<v8::Value>& info) |
| 443 { | 431 { |
| 444 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); | 432 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| 445 {% if not method.overloads %}{# Overloaded methods are measured in overload_
resolution_method() #} | 433 {% if not method.overloads %}{# Overloaded methods are measured in overload_
resolution_method() #} |
| 446 {% if method.measure_as %} | |
| 447 UseCounter::count(callingExecutionContext(info.GetIsolate()), UseCounter::{{
method.measure_as}}); | |
| 448 {% endif %} | |
| 449 {% if method.deprecate_as %} | |
| 450 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), Use
Counter::{{method.deprecate_as}}); | |
| 451 {% endif %} | |
| 452 {% endif %}{# not method.overloads #} | 434 {% endif %}{# not method.overloads #} |
| 453 {% if method.is_custom %} | 435 {% if method.is_custom %} |
| 454 {{v8_class}}::{{method.name}}MethodCustom(info); | 436 {{v8_class}}::{{method.name}}MethodCustom(info); |
| 455 {% else %} | 437 {% else %} |
| 456 {{cpp_class}}V8Internal::{{method.name}}Method{{world_suffix}}(info); | 438 {{cpp_class}}V8Internal::{{method.name}}Method{{world_suffix}}(info); |
| 457 {% endif %} | 439 {% endif %} |
| 458 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | 440 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| 459 } | 441 } |
| 460 {% endfilter %} | 442 {% endfilter %} |
| 461 {% endmacro %} | 443 {% endmacro %} |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 if method.is_per_world_bindings else '0' %} | 611 if method.is_per_world_bindings else '0' %} |
| 630 {% set property_attribute = | 612 {% set property_attribute = |
| 631 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut
es) | 613 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut
es) |
| 632 if method.property_attributes else 'v8::None' %} | 614 if method.property_attributes else 'v8::None' %} |
| 633 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} | 615 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} |
| 634 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig
uration = { | 616 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig
uration = { |
| 635 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}},
{{method.length}}, {{only_exposed_to_private_script}}, | 617 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}},
{{method.length}}, {{only_exposed_to_private_script}}, |
| 636 }; | 618 }; |
| 637 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu
re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); | 619 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu
re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); |
| 638 {%- endmacro %} | 620 {%- endmacro %} |
| OLD | NEW |