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

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

Issue 2717283002: [Bindings][Refactoring] Move logics of preparePrototypeAndInterfaceObject from .tmpl to .py (Closed)
Patch Set: 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 {% filter format_blink_cpp_source_code %} 1 {% filter format_blink_cpp_source_code %}
2 2
3 {% include 'copyright_block.txt' %} 3 {% include 'copyright_block.txt' %}
4 #include "{{v8_class_or_partial}}.h" 4 #include "{{v8_class_or_partial}}.h"
5 5
6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} 6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %}
7 #include "{{filename}}" 7 #include "{{filename}}"
8 {% endfor %} 8 {% endfor %}
9 9
10 namespace blink { 10 namespace blink {
11 {% set dom_template = '%s::domTemplate' % v8_class if not is_array_buffer_or_vie w else '0' %} 11 {% set dom_template = '%s::domTemplate' % v8_class if not is_array_buffer_or_vie w else '0' %}
12 {% set has_prepare_prototype_and_interface_object =
13 unscopables or has_conditional_attributes_on_prototype or
14 methods | conditionally_exposed(is_partial) %}
15 {% set prepare_prototype_and_interface_object_func =
16 '%s::preparePrototypeAndInterfaceObject' % v8_class
17 if has_prepare_prototype_and_interface_object
18 else 'nullptr' %}
19 {% set parent_wrapper_type_info = '&V8%s::wrapperTypeInfo' % parent_interface 12 {% set parent_wrapper_type_info = '&V8%s::wrapperTypeInfo' % parent_interface
20 if parent_interface else '0' %} 13 if parent_interface else '0' %}
21 {% set wrapper_type_prototype = 'WrapperTypeExceptionPrototype' if is_exception else 14 {% set wrapper_type_prototype = 'WrapperTypeExceptionPrototype' if is_exception else
22 'WrapperTypeObjectPrototype' %} 15 'WrapperTypeObjectPrototype' %}
23 {% set active_scriptwrappable_inheritance = 16 {% set active_scriptwrappable_inheritance =
24 'InheritFromActiveScriptWrappable' 17 'InheritFromActiveScriptWrappable'
25 if active_scriptwrappable else 18 if active_scriptwrappable else
26 'NotInheritFromActiveScriptWrappable' %} 19 'NotInheritFromActiveScriptWrappable' %}
27 20
28 {% set wrapper_type_info_const = '' if has_partial_interface else 'const ' %} 21 {% set wrapper_type_info_const = '' if has_partial_interface else 'const ' %}
29 {% if not is_partial %} 22 {% if not is_partial %}
30 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial 23 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial
31 // and does not depend on another global objects. 24 // and does not depend on another global objects.
32 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 25 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
33 #pragma clang diagnostic push 26 #pragma clang diagnostic push
34 #pragma clang diagnostic ignored "-Wglobal-constructors" 27 #pragma clang diagnostic ignored "-Wglobal-constructors"
35 #endif 28 #endif
36 {{wrapper_type_info_const}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin ::kEmbedderBlink, {{dom_template}}, {{v8_class}}::trace, {{v8_class}}::traceWrap pers, {{prepare_prototype_and_interface_object_func}}, "{{interface_name}}", {{p arent_wrapper_type_info}}, WrapperTypeInfo::{{wrapper_type_prototype}}, WrapperT ypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{active_scriptwrappable_inherit ance}}, WrapperTypeInfo::{{lifetime}} }; 29 {{wrapper_type_info_const}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin ::kEmbedderBlink, {{dom_template}}, {{v8_class}}::trace, {{v8_class}}::traceWrap pers, {{prepare_prototype_and_interface_object_func or 'nullptr'}}, "{{interface _name}}", {{parent_wrapper_type_info}}, WrapperTypeInfo::{{wrapper_type_prototyp e}}, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{active_scriptwrap pable_inheritance}}, WrapperTypeInfo::{{lifetime}} };
37 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 30 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
38 #pragma clang diagnostic pop 31 #pragma clang diagnostic pop
39 #endif 32 #endif
40 33
41 {% if not is_typed_array_type %} 34 {% if not is_typed_array_type %}
42 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in {{cpp_class} }.h. 35 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in {{cpp_class} }.h.
43 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in 36 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
44 // bindings/core/v8/ScriptWrappable.h. 37 // bindings/core/v8/ScriptWrappable.h.
45 const WrapperTypeInfo& {{cpp_class}}::s_wrapperTypeInfo = {{v8_class}}::wrapperT ypeInfo; 38 const WrapperTypeInfo& {{cpp_class}}::s_wrapperTypeInfo = {{v8_class}}::wrapperT ypeInfo;
46 {% endif %} 39 {% endif %}
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 {##############################################################################} 695 {##############################################################################}
703 {% block get_dom_template %}{% endblock %} 696 {% block get_dom_template %}{% endblock %}
704 {% block get_dom_template_for_named_properties_object %}{% endblock %} 697 {% block get_dom_template_for_named_properties_object %}{% endblock %}
705 {% block has_instance %}{% endblock %} 698 {% block has_instance %}{% endblock %}
706 {% block to_impl %}{% endblock %} 699 {% block to_impl %}{% endblock %}
707 {% block to_impl_with_type_check %}{% endblock %} 700 {% block to_impl_with_type_check %}{% endblock %}
708 {##############################################################################} 701 {##############################################################################}
709 {% block prepare_prototype_and_interface_object %} 702 {% block prepare_prototype_and_interface_object %}
710 {% from 'attributes.cpp.tmpl' import install_conditionally_enabled_attributes_on _prototype with context %} 703 {% from 'attributes.cpp.tmpl' import install_conditionally_enabled_attributes_on _prototype with context %}
711 {% from 'methods.cpp.tmpl' import install_conditionally_enabled_methods with con text %} 704 {% from 'methods.cpp.tmpl' import install_conditionally_enabled_methods with con text %}
712 {% if has_prepare_prototype_and_interface_object %} 705 {% if prepare_prototype_and_interface_object_func %}
713 void {{v8_class_or_partial}}::preparePrototypeAndInterfaceObject(v8::Local<v8::C ontext> context, const DOMWrapperWorld& world, v8::Local<v8::Object> prototypeOb ject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> i nterfaceTemplate) { 706 void {{v8_class_or_partial}}::preparePrototypeAndInterfaceObject(v8::Local<v8::C ontext> context, const DOMWrapperWorld& world, v8::Local<v8::Object> prototypeOb ject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> i nterfaceTemplate) {
714 {% if is_partial %} 707 {% if is_partial %}
715 {{v8_class}}::preparePrototypeAndInterfaceObject(context, world, prototypeObje ct, interfaceObject, interfaceTemplate); 708 {{v8_class}}::preparePrototypeAndInterfaceObject(context, world, prototypeObje ct, interfaceObject, interfaceTemplate);
716 {% endif %} 709 {% endif %}
717 710
718 v8::Isolate* isolate = context->GetIsolate(); 711 v8::Isolate* isolate = context->GetIsolate();
719 {% if has_conditional_attributes_on_prototype or methods | conditionally_expos ed(is_partial) %} 712 {% if has_conditional_attributes_on_prototype or methods | conditionally_expos ed(is_partial) %}
720 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late); 713 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late);
721 ExecutionContext* executionContext = toExecutionContext(context); 714 ExecutionContext* executionContext = toExecutionContext(context);
722 DCHECK(executionContext); 715 DCHECK(executionContext);
(...skipping 21 matching lines...) Expand all
744 {% endif %} 737 {% endif %}
745 } 738 }
746 {% endif %} 739 {% endif %}
747 740
748 {% endblock %} 741 {% endblock %}
749 {##############################################################################} 742 {##############################################################################}
750 {% block partial_interface %}{% endblock %} 743 {% block partial_interface %}{% endblock %}
751 } // namespace blink 744 } // namespace blink
752 745
753 {% endfilter %}{# format_blink_cpp_source_code #} 746 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698