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

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

Issue 1372373002: bindings: Reduces the custom registration of methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %} 1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro generate_method(method, world_suffix) %} 5 {% macro generate_method(method, world_suffix) %}
6 {% filter conditional(method.conditional_string) %} 6 {% filter conditional(method.conditional_string) %}
7 {% if method.returns_promise and method.has_exception_state %} 7 {% if method.returns_promise and method.has_exception_state %}
8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat e) 8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat e)
9 {% else %} 9 {% else %}
10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) 10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 v8::Local<v8::Object> wrapper = info.Holder(); 645 v8::Local<v8::Object> wrapper = info.Holder();
646 wrapper = impl->associateWithWrapper(info.GetIsolate(), &{{constructor_class}}:: wrapperTypeInfo, wrapper); 646 wrapper = impl->associateWithWrapper(info.GetIsolate(), &{{constructor_class}}:: wrapperTypeInfo, wrapper);
647 v8SetReturnValue(info, wrapper); 647 v8SetReturnValue(info, wrapper);
648 {% endmacro %} 648 {% endmacro %}
649 649
650 650
651 {##############################################################################} 651 {##############################################################################}
652 {% macro method_configuration(method) %} 652 {% macro method_configuration(method) %}
653 {% from 'conversions.cpp' import property_location %} 653 {% from 'conversions.cpp' import property_location %}
654 {% set method_callback = 654 {% set method_callback =
655 '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %} 655 '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %}
656 {% set method_callback_for_main_world = 656 {% set method_callback_for_main_world =
657 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class_or_partial, method. name) 657 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class_or_partial, met hod.name)
658 if method.is_per_world_bindings else '0' %} 658 if method.is_per_world_bindings else '0' %}
659 {% set property_attribute =
660 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_att ributes)
661 if method.property_attributes else 'v8::None' %}
659 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} 662 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %}
660 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}, {{only_exposed_to_private_script}}, {{property_location(method)} }} 663 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}, {{property_attribute}}, {{only_exposed_to_private_script}}, {{pr operty_location(method)}}}
661 {%- endmacro %} 664 {%- endmacro %}
662 665
663 666
664 {######################################} 667 {######################################}
665 {% macro install_custom_signature(method, instance_template, prototype_template, interface_template, signature) %} 668 {% macro install_custom_signature(method, instance_template, prototype_template, interface_template, signature) %}
666 {% set property_attribute =
667 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_att ributes)
668 if method.property_attributes else 'v8::None' %}
669 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 669 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
670 V8DOMConfiguration::installMethod(isolate, {{instance_template}}, {{prototype_te mplate}}, {{interface_template}}, {{signature}}, {{property_attribute}}, {{metho d.name}}MethodConfiguration); 670 V8DOMConfiguration::installMethod(isolate, {{instance_template}}, {{prototype_te mplate}}, {{interface_template}}, {{signature}}, {{method.name}}MethodConfigurat ion);
671 {%- endmacro %} 671 {%- endmacro %}
672 672
673 {######################################} 673 {######################################}
674 {% macro install_conditionally_enabled_methods() %} 674 {% macro install_conditionally_enabled_methods() %}
675 {% if conditionally_enabled_methods %} 675 {% if conditionally_enabled_methods %}
676 {# Define operations with limited exposure #} 676 {# Define operations with limited exposure #}
677 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domTempl ate(isolate)); 677 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domTempl ate(isolate));
678 ExecutionContext* context = toExecutionContext(prototypeObject->CreationContext( )); 678 ExecutionContext* context = toExecutionContext(prototypeObject->CreationContext( ));
679 ASSERT(context); 679 ASSERT(context);
680 {% for method in conditionally_enabled_methods %} 680 {% for method in conditionally_enabled_methods %}
681 {% filter exposed(method.overloads.exposed_test_all 681 {% filter exposed(method.overloads.exposed_test_all
682 if method.overloads else 682 if method.overloads else
683 method.exposed_test) %} 683 method.exposed_test) %}
684 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all 684 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all
685 if method.overloads else 685 if method.overloads else
686 method.runtime_enabled_function) %} 686 method.runtime_enabled_function) %}
687 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New(iso late, {{cpp_class_or_partial}}V8Internal::{{method.name}}MethodCallback, v8Undef ined(), defaultSignature, {{method.number_of_required_arguments}}); 687 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
688 v8::Local<v8::Function> function = v8CallOrCrash(functionTemplate->GetFunction(i solate->GetCurrentContext())); 688 V8DOMConfiguration::installMethod(isolate, v8::Local<v8::Object>(), prototypeObj ect, interfaceObject, defaultSignature, {{method.name}}MethodConfiguration);
689 v8CallOrCrash(prototypeObject->Set(isolate->GetCurrentContext(), v8AtomicString( isolate, "{{method.name}}"), function));
690 {% endfilter %}{# runtime_enabled() #} 689 {% endfilter %}{# runtime_enabled() #}
691 {% endfilter %}{# exposed() #} 690 {% endfilter %}{# exposed() #}
692 {% endfor %} 691 {% endfor %}
693 {% endif %} 692 {% endif %}
694 {%- endmacro %} 693 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698