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

Side by Side Diff: third_party/WebKit/Source/bindings/templates/interface.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 {% extends 'interface_base.cpp' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% block indexed_property_getter %} 5 {% block indexed_property_getter %}
6 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 6 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
7 {% set getter = indexed_property_getter %} 7 {% set getter = indexed_property_getter %}
8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) 8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info)
9 { 9 {
10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 {% from 'methods.cpp' import generate_constructor with context %} 475 {% from 'methods.cpp' import generate_constructor with context %}
476 {% if named_constructor %} 476 {% if named_constructor %}
477 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class 477 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class
478 if is_active_dom_object else '0' %} 478 if is_active_dom_object else '0' %}
479 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial 479 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial
480 // and does not depend on another global objects. 480 // and does not depend on another global objects.
481 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 481 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
482 #pragma clang diagnostic push 482 #pragma clang diagnostic push
483 #pragma clang diagnostic ignored "-Wglobal-constructors" 483 #pragma clang diagnostic ignored "-Wglobal-constructors"
484 #endif 484 #endif
485 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::refObject, {{v8_clas s}}::derefObject, {{v8_class}}::trace, {{to_active_dom_object}}, 0, {{v8_class}} ::preparePrototypeObject, {{v8_class}}::installConditionallyEnabledProperties, " {{interface_name}}", 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperType Info::{{wrapper_class_id}}, WrapperTypeInfo::{{event_target_inheritance}}, Wrapp erTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type}} }; 485 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::refObject, {{v8_clas s}}::derefObject, {{v8_class}}::trace, {{to_active_dom_object}}, 0, {{v8_class}} ::preparePrototypeAndInterfaceObject, {{v8_class}}::installConditionallyEnabledP roperties, "{{interface_name}}", 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{event_target_inherita nce}}, WrapperTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type}} };
486 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 486 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
487 #pragma clang diagnostic pop 487 #pragma clang diagnostic pop
488 #endif 488 #endif
489 489
490 {{generate_constructor(named_constructor)}} 490 {{generate_constructor(named_constructor)}}
491 v8::Local<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolate * isolate) 491 v8::Local<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolate * isolate)
492 { 492 {
493 static int domTemplateKey; // This address is used for a key to look up the dom template. 493 static int domTemplateKey; // This address is used for a key to look up the dom template.
494 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 494 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
495 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTempl ateKey); 495 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTempl ateKey);
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 780
781 {% endblock %} 781 {% endblock %}
782 782
783 783
784 {##############################################################################} 784 {##############################################################################}
785 {% block install_conditional_attributes %} 785 {% block install_conditional_attributes %}
786 {% from 'attributes.cpp' import attribute_configuration with context %} 786 {% from 'attributes.cpp' import attribute_configuration with context %}
787 {% if has_conditional_attributes_on_instance %} 787 {% if has_conditional_attributes_on_instance %}
788 void {{v8_class}}::installConditionallyEnabledProperties(v8::Local<v8::Object> i nstanceObject, v8::Isolate* isolate) 788 void {{v8_class}}::installConditionallyEnabledProperties(v8::Local<v8::Object> i nstanceObject, v8::Isolate* isolate)
789 { 789 {
790 #error TODO(yukishiino): Rename this function to prepareInstanceObject (c.f. pre parePrototypeObject) and implement this function if necessary. http://crbug.com /503508 790 #error TODO(yukishiino): Rename this function to prepareInstanceObject (c.f. pre parePrototypeAndInterfaceObject) and implement this function if necessary. http ://crbug.com/503508
791 } 791 }
792 792
793 {% endif %} 793 {% endif %}
794 {% endblock %} 794 {% endblock %}
795 795
796 796
797 {##############################################################################} 797 {##############################################################################}
798 {% block prepare_prototype_object %} 798 {% block prepare_prototype_and_interface_object %}
799 {% from 'methods.cpp' import install_conditionally_enabled_methods with context %} 799 {% from 'methods.cpp' import install_conditionally_enabled_methods with context %}
800 {% if unscopeables or has_conditional_attributes_on_prototype or conditionally_e nabled_methods %} 800 {% if unscopeables or has_conditional_attributes_on_prototype or conditionally_e nabled_methods %}
801 void {{v8_class}}::preparePrototypeObject(v8::Isolate* isolate, v8::Local<v8::Ob ject> prototypeObject, v8::Local<v8::FunctionTemplate> interfaceTemplate) 801 void {{v8_class}}::preparePrototypeAndInterfaceObject(v8::Isolate* isolate, v8:: Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject, v8:: Local<v8::FunctionTemplate> interfaceTemplate)
802 { 802 {
803 {% if unscopeables %} 803 {% if unscopeables %}
804 {{install_unscopeables() | indent}} 804 {{install_unscopeables() | indent}}
805 {% endif %} 805 {% endif %}
806 {% if has_conditional_attributes_on_prototype %} 806 {% if has_conditional_attributes_on_prototype %}
807 {{install_conditionally_enabled_attributes_on_prototype() | indent}} 807 {{install_conditionally_enabled_attributes_on_prototype() | indent}}
808 {% endif %} 808 {% endif %}
809 {% if conditionally_enabled_methods %} 809 {% if conditionally_enabled_methods %}
810 {{install_conditionally_enabled_methods() | indent}} 810 {{install_conditionally_enabled_methods() | indent}}
811 {% endif %} 811 {% endif %}
(...skipping 22 matching lines...) Expand all
834 834
835 835
836 {##############################################################################} 836 {##############################################################################}
837 {% macro install_conditionally_enabled_attributes_on_prototype() %} 837 {% macro install_conditionally_enabled_attributes_on_prototype() %}
838 {% from 'attributes.cpp' import attribute_configuration with context %} 838 {% from 'attributes.cpp' import attribute_configuration with context %}
839 ExecutionContext* context = toExecutionContext(prototypeObject->CreationContext( )); 839 ExecutionContext* context = toExecutionContext(prototypeObject->CreationContext( ));
840 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTempla te); 840 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTempla te);
841 {% for attribute in attributes if attribute.exposed_test and attribute.on_protot ype %} 841 {% for attribute in attributes if attribute.exposed_test and attribute.on_protot ype %}
842 {% filter exposed(attribute.exposed_test) %} 842 {% filter exposed(attribute.exposed_test) %}
843 const V8DOMConfiguration::AccessorConfiguration accessorConfiguration = {{attrib ute_configuration(attribute)}}; 843 const V8DOMConfiguration::AccessorConfiguration accessorConfiguration = {{attrib ute_configuration(attribute)}};
844 V8DOMConfiguration::installAccessor(isolate, v8::Local<v8::Object>(), prototypeO bject, v8::Local<v8::Function>(), signature, accessorConfiguration); 844 V8DOMConfiguration::installAccessor(isolate, v8::Local<v8::Object>(), prototypeO bject, interfaceObject, signature, accessorConfiguration);
845 {% endfilter %} 845 {% endfilter %}
846 {% endfor %} 846 {% endfor %}
847 {% endmacro %} 847 {% endmacro %}
848 848
849 849
850 {##############################################################################} 850 {##############################################################################}
851 {% block to_active_dom_object %} 851 {% block to_active_dom_object %}
852 {% if is_active_dom_object %} 852 {% if is_active_dom_object %}
853 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Local<v8::Object> wrapper) 853 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Local<v8::Object> wrapper)
854 { 854 {
(...skipping 28 matching lines...) Expand all
883 {% endif %} 883 {% endif %}
884 } 884 }
885 885
886 {% endblock %} 886 {% endblock %}
887 887
888 {##############################################################################} 888 {##############################################################################}
889 {% block partial_interface %} 889 {% block partial_interface %}
890 {% if has_partial_interface %} 890 {% if has_partial_interface %}
891 InstallTemplateFunction {{v8_class}}::install{{v8_class}}TemplateFunction = (Ins tallTemplateFunction)&{{v8_class}}::install{{v8_class}}Template; 891 InstallTemplateFunction {{v8_class}}::install{{v8_class}}TemplateFunction = (Ins tallTemplateFunction)&{{v8_class}}::install{{v8_class}}Template;
892 892
893 void {{v8_class}}::updateWrapperTypeInfo(InstallTemplateFunction installTemplate Function, PreparePrototypeObjectFunction preparePrototypeObjectFunction) 893 void {{v8_class}}::updateWrapperTypeInfo(InstallTemplateFunction installTemplate Function, PreparePrototypeAndInterfaceObjectFunction preparePrototypeAndInterfac eObjectFunction)
894 { 894 {
895 {{v8_class}}::install{{v8_class}}TemplateFunction = installTemplateFunction; 895 {{v8_class}}::install{{v8_class}}TemplateFunction = installTemplateFunction;
896 if (preparePrototypeObjectFunction) 896 if (preparePrototypeAndInterfaceObjectFunction)
897 {{v8_class}}::wrapperTypeInfo.preparePrototypeObjectFunction = preparePr ototypeObjectFunction; 897 {{v8_class}}::wrapperTypeInfo.preparePrototypeAndInterfaceObjectFunction = preparePrototypeAndInterfaceObjectFunction;
898 } 898 }
899 899
900 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 900 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
901 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) 901 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&))
902 { 902 {
903 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 903 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
904 } 904 }
905 {% endfor %} 905 {% endfor %}
906 {% endif %} 906 {% endif %}
907 {% endblock %} 907 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698