| OLD | NEW |
| 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t
o_local_cpp_value %} | 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t
o_local_cpp_value %} |
| 2 | 2 |
| 3 {##############################################################################} | 3 {##############################################################################} |
| 4 {% macro generate_method(method, world_suffix) %} | 4 {% macro generate_method(method, world_suffix) %} |
| 5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) { | 5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) { |
| 6 {% filter format_remove_duplicates([ | 6 {% filter format_remove_duplicates([ |
| 7 'ExceptionState exceptionState', | 7 'ExceptionState exceptionState', |
| 8 'ScriptState* scriptState = ']) %} | 8 'ScriptState* scriptState = ']) %} |
| 9 {% set define_exception_state -%} | 9 {% set define_exception_state -%} |
| 10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont
ext, "{{interface_name}}", "{{method.name}}"); | 10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont
ext, "{{interface_name}}", "{{method.name}}"); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 {# [CallWith=ScriptArguments] #} | 251 {# [CallWith=ScriptArguments] #} |
| 252 ScriptArguments* scriptArguments(ScriptArguments::create(scriptState, info, {{me
thod.number_of_arguments}})); | 252 ScriptArguments* scriptArguments(ScriptArguments::create(scriptState, info, {{me
thod.number_of_arguments}})); |
| 253 {% endif %} | 253 {% endif %} |
| 254 {% if method.is_call_with_document %} | 254 {% if method.is_call_with_document %} |
| 255 {# [ConstructorCallWith=Document] #} | 255 {# [ConstructorCallWith=Document] #} |
| 256 Document& document = *toDocument(currentExecutionContext(info.GetIsolate())); | 256 Document& document = *toDocument(currentExecutionContext(info.GetIsolate())); |
| 257 {% endif %} | 257 {% endif %} |
| 258 {# Call #} | 258 {# Call #} |
| 259 {% if method.idl_type == 'void' %} | 259 {% if method.idl_type == 'void' %} |
| 260 {{cpp_value}}; | 260 {{cpp_value}}; |
| 261 {% elif method.is_implemented_in_private_script %} | |
| 262 {{method.cpp_type}} result{{method.cpp_type_initializer}}; | |
| 263 if (!{{method.cpp_value}}) | |
| 264 return; | |
| 265 {% elif method.use_output_parameter_for_result %} | 261 {% elif method.use_output_parameter_for_result %} |
| 266 {{method.cpp_type}} result; | 262 {{method.cpp_type}} result; |
| 267 {{cpp_value}}; | 263 {{cpp_value}}; |
| 268 {% elif method.is_constructor %} | 264 {% elif method.is_constructor %} |
| 269 {{method.cpp_type}} impl = {{cpp_value}}; | 265 {{method.cpp_type}} impl = {{cpp_value}}; |
| 270 {% elif method.use_local_result %} | 266 {% elif method.use_local_result %} |
| 271 {{method.cpp_type}} result = {{cpp_value}}; | 267 {{method.cpp_type}} result = {{cpp_value}}; |
| 272 {% endif %} | 268 {% endif %} |
| 273 {# Post-call #} | 269 {# Post-call #} |
| 274 {% if method.is_raises_exception %} | 270 {% if method.is_raises_exception %} |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 342 } |
| 347 {% endmacro %} | 343 {% endmacro %} |
| 348 | 344 |
| 349 | 345 |
| 350 {##############################################################################} | 346 {##############################################################################} |
| 351 {% macro overload_resolution_method(overloads, world_suffix) %} | 347 {% macro overload_resolution_method(overloads, world_suffix) %} |
| 352 static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
nfo<v8::Value>& info) { | 348 static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
nfo<v8::Value>& info) { |
| 353 {% set fall_through_to_partial_overloads = not is_partial and overloads.has_pa
rtial_overloads %} | 349 {% set fall_through_to_partial_overloads = not is_partial and overloads.has_pa
rtial_overloads %} |
| 354 | 350 |
| 355 {% if overloads.measure_all_as %} | 351 {% if overloads.measure_all_as %} |
| 356 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionContext
(info.GetIsolate()), UseCounter::{{overloads.measure_all_as}}); | 352 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::{{ov
erloads.measure_all_as}}); |
| 357 {% endif %} | 353 {% endif %} |
| 358 {% if overloads.deprecate_all_as %} | 354 {% if overloads.deprecate_all_as %} |
| 359 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentExec
utionContext(info.GetIsolate()), UseCounter::{{overloads.deprecate_all_as}}); | 355 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()), UseC
ounter::{{overloads.deprecate_all_as}}); |
| 360 {% endif %} | 356 {% endif %} |
| 361 | 357 |
| 362 {# First resolve by length #} | 358 {# First resolve by length #} |
| 363 {% if not fall_through_to_partial_overloads %} | 359 {% if not fall_through_to_partial_overloads %} |
| 364 bool isArityError = false; | 360 bool isArityError = false; |
| 365 {% endif %} | 361 {% endif %} |
| 366 {# 2. Initialize argcount to be min(maxarg, n). #} | 362 {# 2. Initialize argcount to be min(maxarg, n). #} |
| 367 switch (std::min({{overloads.maxarg}}, info.Length())) { | 363 switch (std::min({{overloads.maxarg}}, info.Length())) { |
| 368 {# 3. Remove from S all entries whose type list is not of length argcount. #
} | 364 {# 3. Remove from S all entries whose type list is not of length argcount. #
} |
| 369 {% for length, tests_methods in overloads.length_tests_methods %} | 365 {% for length, tests_methods in overloads.length_tests_methods %} |
| 370 {# 10. If i = d, then: #} | 366 {# 10. If i = d, then: #} |
| 371 case {{length}}: | 367 case {{length}}: |
| 372 {# Then resolve by testing argument #} | 368 {# Then resolve by testing argument #} |
| 373 {% for test, method in tests_methods %} | 369 {% for test, method in tests_methods %} |
| 374 {% if method.visible %} | 370 {% if method.visible %} |
| 375 {% filter runtime_enabled(not overloads.runtime_enabled_function_all and | 371 {% filter runtime_enabled(not overloads.runtime_enabled_function_all and |
| 376 method.runtime_enabled_function) %} | 372 method.runtime_enabled_function) %} |
| 377 if ({{test}}) { | 373 if ({{test}}) { |
| 378 {% if method.measure_as and not overloads.measure_all_as %} | 374 {% if method.measure_as and not overloads.measure_all_as %} |
| 379 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionC
ontext(info.GetIsolate()), UseCounter::{{method.measure_as('Method')}}); | 375 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter
::{{method.measure_as('Method')}}); |
| 380 {% endif %} | 376 {% endif %} |
| 381 {% if method.deprecate_as and not overloads.deprecate_all_as %} | 377 {% if method.deprecate_as and not overloads.deprecate_all_as %} |
| 382 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), curre
ntExecutionContext(info.GetIsolate()), UseCounter::{{method.deprecate_as}}); | 378 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate())
, UseCounter::{{method.deprecate_as}}); |
| 383 {% endif %} | 379 {% endif %} |
| 384 {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info); | 380 {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info); |
| 385 return; | 381 return; |
| 386 } | 382 } |
| 387 {% endfilter %} | 383 {% endfilter %} |
| 388 {% endif %} | 384 {% endif %} |
| 389 {% endfor %} | 385 {% endfor %} |
| 390 break; | 386 break; |
| 391 {% endfor %}{# length, tests_methods #} | 387 {% endfor %}{# length, tests_methods #} |
| 392 {% if not fall_through_to_partial_overloads %} | 388 {% if not fall_through_to_partial_overloads %} |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 instance->postMessage(context, message.release(), transferables.messagePorts,
exceptionState); | 480 instance->postMessage(context, message.release(), transferables.messagePorts,
exceptionState); |
| 485 } | 481 } |
| 486 {% endmacro %} | 482 {% endmacro %} |
| 487 | 483 |
| 488 | 484 |
| 489 {##############################################################################} | 485 {##############################################################################} |
| 490 {% macro method_callback(method, world_suffix) %} | 486 {% macro method_callback(method, world_suffix) %} |
| 491 void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCallbackInf
o<v8::Value>& info) { | 487 void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCallbackInf
o<v8::Value>& info) { |
| 492 {% if not method.overloads %}{# Overloaded methods are measured in overload_re
solution_method() #} | 488 {% if not method.overloads %}{# Overloaded methods are measured in overload_re
solution_method() #} |
| 493 {% if method.measure_as %} | 489 {% if method.measure_as %} |
| 494 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionContext
(info.GetIsolate()), UseCounter::{{method.measure_as('Method')}}); | 490 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::{{me
thod.measure_as('Method')}}); |
| 495 {% endif %} | 491 {% endif %} |
| 496 {% if method.deprecate_as %} | 492 {% if method.deprecate_as %} |
| 497 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentExec
utionContext(info.GetIsolate()), UseCounter::{{method.deprecate_as}}); | 493 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()), UseC
ounter::{{method.deprecate_as}}); |
| 498 {% endif %} | 494 {% endif %} |
| 499 {% endif %}{# not method.overloads #} | 495 {% endif %}{# not method.overloads #} |
| 500 {% if world_suffix in method.activity_logging_world_list %} | 496 {% if world_suffix in method.activity_logging_world_list %} |
| 501 {% if method.is_static %} | 497 {% if method.is_static %} |
| 502 ScriptState* scriptState = ScriptState::forFunctionObject(info); | 498 ScriptState* scriptState = ScriptState::forFunctionObject(info); |
| 503 {% else %} | 499 {% else %} |
| 504 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 500 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 505 {% endif %} | 501 {% endif %} |
| 506 V8PerContextData* contextData = scriptState->perContextData(); | 502 V8PerContextData* contextData = scriptState->perContextData(); |
| 507 if (contextData && contextData->activityLogger()) { | 503 if (contextData && contextData->activityLogger()) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 } | 547 } |
| 552 } | 548 } |
| 553 | 549 |
| 554 void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Local<v8:
:Name>, const v8::PropertyCallbackInfo<v8::Value>& info) { | 550 void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Local<v8:
:Name>, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 555 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix}}
(info); | 551 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix}}
(info); |
| 556 } | 552 } |
| 557 {% endmacro %} | 553 {% endmacro %} |
| 558 | 554 |
| 559 | 555 |
| 560 {##############################################################################} | 556 {##############################################################################} |
| 561 {% macro method_implemented_in_private_script(method) %} | |
| 562 bool {{v8_class}}::PrivateScript::{{method.name}}Method({{method.argument_declar
ations_for_private_script | join(', ')}}) { | |
| 563 if (!frame) | |
| 564 return false; | |
| 565 v8::HandleScope handleScope(toIsolate(frame)); | |
| 566 ScriptForbiddenScope::AllowUserAgentScript script; | |
| 567 ScriptState* scriptState = ScriptState::forWorld(frame, DOMWrapperWorld::priva
teScriptIsolatedWorld()); | |
| 568 if (!scriptState) | |
| 569 return false; | |
| 570 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); | |
| 571 if (!scriptStateInUserScript) | |
| 572 return false; | |
| 573 | |
| 574 ScriptState::Scope scope(scriptState); | |
| 575 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Global(
), scriptState->isolate()); | |
| 576 {% for argument in method.arguments %} | |
| 577 v8::Local<v8::Value> {{argument.handle}} = {{argument.private_script_cpp_value
_to_v8_value}}; | |
| 578 {% endfor %} | |
| 579 {% if method.arguments %} | |
| 580 v8::Local<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} }; | |
| 581 {% else %} | |
| 582 {# Empty array initializers are illegal, and don\t compile in MSVC. #} | |
| 583 v8::Local<v8::Value> *argv = 0; | |
| 584 {% endif %} | |
| 585 ExceptionState exceptionState(scriptState->isolate(), ExceptionState::Executio
nContext, "{{cpp_class}}", "{{method.name}}"); | |
| 586 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMMethod(scriptState,
scriptStateInUserScript, "{{cpp_class}}", "{{method.name}}", holder, {{method.ar
guments | length}}, argv); | |
| 587 if (v8Value.IsEmpty()) | |
| 588 return false; | |
| 589 {% if method.idl_type != 'void' %} | |
| 590 {{v8_value_to_local_cpp_value(method.private_script_v8_value_to_local_cpp_valu
e) | indent(2)}} | |
| 591 *result = cppValue; | |
| 592 {% endif %} | |
| 593 CHECK(!exceptionState.hadException()); | |
| 594 return true; | |
| 595 } | |
| 596 {% endmacro %} | |
| 597 | |
| 598 | |
| 599 {##############################################################################} | |
| 600 {% macro generate_constructor(constructor) %} | 557 {% macro generate_constructor(constructor) %} |
| 601 {% set name = '%sConstructorCallback' % v8_class | 558 {% set name = '%sConstructorCallback' % v8_class |
| 602 if constructor.is_named_constructor else | 559 if constructor.is_named_constructor else |
| 603 'constructor%s' % (constructor.overload_index or '') %} | 560 'constructor%s' % (constructor.overload_index or '') %} |
| 604 static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info) { | 561 static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 605 {% set function_call = func_call_with_prep_of_args(constructor) %} | 562 {% set function_call = func_call_with_prep_of_args(constructor) %} |
| 606 | 563 |
| 607 {% if constructor.is_named_constructor %} | 564 {% if constructor.is_named_constructor %} |
| 608 if (!info.IsConstructCall()) { | 565 if (!info.IsConstructCall()) { |
| 609 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::const
ructorNotCallableAsFunction("{{constructor.name}}")); | 566 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::const
ructorNotCallableAsFunction("{{constructor.name}}")); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 {% macro method_configuration(method) %} | 600 {% macro method_configuration(method) %} |
| 644 {% from 'utilities.cpp.tmpl' import property_location %} | 601 {% from 'utilities.cpp.tmpl' import property_location %} |
| 645 {% set method_callback = | 602 {% set method_callback = |
| 646 '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %} | 603 '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %} |
| 647 {% set method_callback_for_main_world = | 604 {% set method_callback_for_main_world = |
| 648 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class_or_partial, met
hod.name) | 605 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class_or_partial, met
hod.name) |
| 649 if method.is_per_world_bindings else '0' %} | 606 if method.is_per_world_bindings else '0' %} |
| 650 {% set property_attribute = | 607 {% set property_attribute = |
| 651 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_att
ributes) | 608 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_att
ributes) |
| 652 if method.property_attributes else 'v8::None' %} | 609 if method.property_attributes else 'v8::None' %} |
| 653 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} | |
| 654 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' | 610 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' |
| 655 if method.returns_promise else 'V8DOMConfiguration::CheckHolder' %} | 611 if method.returns_promise else 'V8DOMConfiguration::CheckHolder' %} |
| 656 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m
ethod.length}}, {{property_attribute}}, {{only_exposed_to_private_script}}, {{pr
operty_location(method)}}, {{holder_check}}} | 612 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m
ethod.length}}, {{property_attribute}}, {{property_location(method)}}, {{holder_
check}}} |
| 657 {%- endmacro %} | 613 {%- endmacro %} |
| 658 | 614 |
| 659 | 615 |
| 660 {######################################} | 616 {######################################} |
| 661 {% macro install_custom_signature(method, instance_template, prototype_template,
interface_template, signature) %} | 617 {% macro install_custom_signature(method, instance_template, prototype_template,
interface_template, signature) %} |
| 662 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; | 618 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; |
| 663 V8DOMConfiguration::installMethod(isolate, world, {{instance_template}}, {{proto
type_template}}, {{interface_template}}, {{signature}}, {{method.name}}MethodCon
figuration); | 619 V8DOMConfiguration::installMethod(isolate, world, {{instance_template}}, {{proto
type_template}}, {{interface_template}}, {{signature}}, {{method.name}}MethodCon
figuration); |
| 664 {%- endmacro %} | 620 {%- endmacro %} |
| 665 | 621 |
| 666 | 622 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 682 if method.overloads else | 638 if method.overloads else |
| 683 method.runtime_enabled_function) %} | 639 method.runtime_enabled_function) %} |
| 684 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; | 640 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; |
| 685 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto
typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); | 641 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto
typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); |
| 686 {% endfilter %}{# runtime_enabled() #} | 642 {% endfilter %}{# runtime_enabled() #} |
| 687 {% endfilter %}{# exposed() #} | 643 {% endfilter %}{# exposed() #} |
| 688 {% endfilter %}{# secure_context() #} | 644 {% endfilter %}{# secure_context() #} |
| 689 {% endfor %} | 645 {% endfor %} |
| 690 {% endif %} | 646 {% endif %} |
| 691 {%- endmacro %} | 647 {%- endmacro %} |
| OLD | NEW |