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}}"); |
11 {%- endset %} | 11 {%- endset %} |
12 | 12 |
13 {% set function_call = func_call_with_prep_of_args(method, world_suffix) %} | 13 {% set function_call = func_call_with_prep_of_args(method, world_suffix) %} |
14 | 14 |
15 {% if 'exceptionState' in function_call %} | 15 {% if 'exceptionState' in function_call or |
| 16 (method.returns_promise and not method.is_static) %} |
16 {{define_exception_state}} | 17 {{define_exception_state}} |
17 {% if method.returns_promise %} | 18 {% if method.returns_promise %} |
18 ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState); | 19 ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState); |
19 {% endif %} | 20 {% endif %} |
20 {% endif %} | 21 {% endif %} |
21 | 22 |
22 {% if not method.is_static %} | 23 {% if not method.is_static %} |
| 24 {% if method.returns_promise %} |
| 25 // V8DOMConfiguration::DoNotCheckHolder |
| 26 // Make sure that info.Holder() really points to an instance of the type. |
| 27 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) { |
| 28 {{throw_type_error(method, '"Illegal invocation"')}} |
| 29 return; |
| 30 } |
| 31 {% endif %} |
23 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 32 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
24 {% endif %} | 33 {% endif %} |
25 | 34 |
26 {# Security checks #} | 35 {# Security checks #} |
27 {% if method.is_check_security_for_receiver %} | 36 {% if method.is_check_security_for_receiver %} |
28 {{define_exception_state}} | 37 {{define_exception_state}} |
29 {% if interface_name == 'EventTarget' %} | 38 {% if interface_name == 'EventTarget' %} |
30 // Performance hack for EventTarget. Checking whether it's a Window or not | 39 // Performance hack for EventTarget. Checking whether it's a Window or not |
31 // prior to the call to BindingSecurity::shouldAllowAccessTo increases 30% | 40 // prior to the call to BindingSecurity::shouldAllowAccessTo increases 30% |
32 // of speed performance on Android Nexus 7 as of Dec 2015. ALWAYS_INLINE | 41 // of speed performance on Android Nexus 7 as of Dec 2015. ALWAYS_INLINE |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 {% from 'utilities.cpp.tmpl' import property_location %} | 635 {% from 'utilities.cpp.tmpl' import property_location %} |
627 {% set method_callback = | 636 {% set method_callback = |
628 '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %} | 637 '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %} |
629 {% set method_callback_for_main_world = | 638 {% set method_callback_for_main_world = |
630 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class_or_partial, met
hod.name) | 639 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class_or_partial, met
hod.name) |
631 if method.is_per_world_bindings else '0' %} | 640 if method.is_per_world_bindings else '0' %} |
632 {% set property_attribute = | 641 {% set property_attribute = |
633 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_att
ributes) | 642 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_att
ributes) |
634 if method.property_attributes else 'v8::None' %} | 643 if method.property_attributes else 'v8::None' %} |
635 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} | 644 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} |
636 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m
ethod.length}}, {{property_attribute}}, {{only_exposed_to_private_script}}, {{pr
operty_location(method)}}} | 645 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' |
| 646 if method.returns_promise else 'V8DOMConfiguration::CheckHolder' %} |
| 647 {"{{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}}} |
637 {%- endmacro %} | 648 {%- endmacro %} |
638 | 649 |
639 | 650 |
640 {######################################} | 651 {######################################} |
641 {% macro install_custom_signature(method, instance_template, prototype_template,
interface_template, signature) %} | 652 {% macro install_custom_signature(method, instance_template, prototype_template,
interface_template, signature) %} |
642 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; | 653 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; |
643 V8DOMConfiguration::installMethod(isolate, world, {{instance_template}}, {{proto
type_template}}, {{interface_template}}, {{signature}}, {{method.name}}MethodCon
figuration); | 654 V8DOMConfiguration::installMethod(isolate, world, {{instance_template}}, {{proto
type_template}}, {{interface_template}}, {{signature}}, {{method.name}}MethodCon
figuration); |
644 {%- endmacro %} | 655 {%- endmacro %} |
645 | 656 |
646 | 657 |
(...skipping 15 matching lines...) Expand all Loading... |
662 if method.overloads else | 673 if method.overloads else |
663 method.runtime_enabled_function) %} | 674 method.runtime_enabled_function) %} |
664 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; | 675 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; |
665 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto
typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); | 676 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto
typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); |
666 {% endfilter %}{# runtime_enabled() #} | 677 {% endfilter %}{# runtime_enabled() #} |
667 {% endfilter %}{# exposed() #} | 678 {% endfilter %}{# exposed() #} |
668 {% endfilter %}{# secure_context() #} | 679 {% endfilter %}{# secure_context() #} |
669 {% endfor %} | 680 {% endfor %} |
670 {% endif %} | 681 {% endif %} |
671 {%- endmacro %} | 682 {%- endmacro %} |
OLD | NEW |