Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl

Issue 2717183002: Slim V8DOMConfiguration::MethodConfiguration by refactoring per-world bindings. (Closed)
Patch Set: haraken Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 {% set method_callback_for_main_world = 595 {% set method_callback_for_main_world =
596 '%s::%sMethodCallbackForMainWorld' % (v8_class_or_partial, method.name) 596 '%s::%sMethodCallbackForMainWorld' % (v8_class_or_partial, method.name)
597 if method.is_per_world_bindings else 'nullptr' %} 597 if method.is_per_world_bindings else 'nullptr' %}
598 {% set property_attribute = 598 {% set property_attribute =
599 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_att ributes) 599 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_att ributes)
600 if method.property_attributes else 'v8::None' %} 600 if method.property_attributes else 'v8::None' %}
601 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' 601 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder'
602 if method.returns_promise else 'V8DOMConfiguration::CheckHolder' %} 602 if method.returns_promise else 'V8DOMConfiguration::CheckHolder' %}
603 {% set access_check = 'V8DOMConfiguration::CheckAccess' 603 {% set access_check = 'V8DOMConfiguration::CheckAccess'
604 if method.is_check_security_for_receiver else 'V8DOMConfiguration::DoNotC heckAccess' %} 604 if method.is_check_security_for_receiver else 'V8DOMConfiguration::DoNotC heckAccess' %}
605 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}, {{property_attribute}}, {{property_location(method)}}, {{holder_ check}}, {{access_check}}} 605 {% if method.is_per_world_bindings %}
606 {% set method_callback_for_main_world =
607 '%s::%sMethodCallbackForMainWorld' % (v8_class_or_partial, method.name) % }
608 {"{{method.name}}", {{method_callback_for_main_world}}, {{method.length}}, {{pro perty_attribute}}, {{property_location(method)}}, {{holder_check}}, {{access_che ck}}, V8DOMConfiguration::MainWorld},
609 {"{{method.name}}", {{method_callback}}, {{method.length}}, {{property_attribute }}, {{property_location(method)}}, {{holder_check}}, {{access_check}}, V8DOMConf iguration::NonMainWorlds}
610 {%- else %}
611 {"{{method.name}}", {{method_callback}}, {{method.length}}, {{property_attribute }}, {{property_location(method)}}, {{holder_check}}, {{access_check}}, V8DOMConf iguration::AllWorlds}
612 {%- endif %}
606 {%- endmacro %} 613 {%- endmacro %}
607 614
608 615
609 {######################################} 616 {######################################}
610 {% 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) %}
611 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 618 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration [] = {
612 V8DOMConfiguration::installMethod(isolate, world, {{instance_template}}, {{proto type_template}}, {{interface_template}}, {{signature}}, {{method.name}}MethodCon figuration); 619 {{method_configuration(method) | indent(2)}}
620 };
621 for (const auto& methodConfig : {{method.name}}MethodConfiguration)
622 V8DOMConfiguration::installMethod(isolate, world, {{instance_template}}, {{pro totype_template}}, {{interface_template}}, {{signature}}, methodConfig);
613 {%- endmacro %} 623 {%- endmacro %}
614 624
615 625
616 {######################################} 626 {######################################}
617 {% macro install_conditionally_enabled_methods() %} 627 {% macro install_conditionally_enabled_methods() %}
618 {% if methods | conditionally_exposed(is_partial) %} 628 {% if methods | conditionally_exposed(is_partial) %}
619 {% for method in methods | conditionally_exposed(is_partial) %} 629 {% for method in methods | conditionally_exposed(is_partial) %}
620 {% filter secure_context(method.overloads.secure_context_test_all 630 {% filter secure_context(method.overloads.secure_context_test_all
621 if method.overloads else 631 if method.overloads else
622 method.secure_context_test) %} 632 method.secure_context_test) %}
623 {% filter exposed(method.overloads.exposed_test_all 633 {% filter exposed(method.overloads.exposed_test_all
624 if method.overloads else 634 if method.overloads else
625 method.exposed_test) %} 635 method.exposed_test) %}
626 {% filter runtime_enabled(method.overloads.runtime_enabled_all 636 {% filter runtime_enabled(method.overloads.runtime_enabled_all
627 if method.overloads else 637 if method.overloads else
628 method.runtime_enabled_feature_name) %} 638 method.runtime_enabled_feature_name) %}
629 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 639 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration [] = {
630 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); 640 {{method_configuration(method) | indent(2)}}
641 };
642 for (const auto& methodConfig : {{method.name}}MethodConfiguration)
643 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), pro totypeObject, interfaceObject, signature, methodConfig);
631 {% endfilter %}{# runtime_enabled() #} 644 {% endfilter %}{# runtime_enabled() #}
632 {% endfilter %}{# exposed() #} 645 {% endfilter %}{# exposed() #}
633 {% endfilter %}{# secure_context() #} 646 {% endfilter %}{# secure_context() #}
634 {% endfor %} 647 {% endfor %}
635 {% endif %} 648 {% endif %}
636 {%- endmacro %} 649 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698