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

Unified Diff: third_party/WebKit/Source/bindings/templates/interface.h.tmpl

Issue 2454133002: [Bindings] Reformat template files for Interface (1/4) (Closed)
Patch Set: Rebase Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/templates/interface.h.tmpl
diff --git a/third_party/WebKit/Source/bindings/templates/interface.h.tmpl b/third_party/WebKit/Source/bindings/templates/interface.h.tmpl
index 3b08508f4fd4f37833a587eb32e1fe3581983377..081b3bb9a9ccf4ba933cfca1a5b0a664ca06fdb1 100644
--- a/third_party/WebKit/Source/bindings/templates/interface.h.tmpl
+++ b/third_party/WebKit/Source/bindings/templates/interface.h.tmpl
@@ -18,168 +18,163 @@ class ScriptState;
{% endif %}
{% if named_constructor %}
class {{v8_class}}Constructor {
- STATIC_ONLY({{v8_class}}Constructor);
-public:
- static v8::Local<v8::FunctionTemplate> domTemplate(v8::Isolate*, const DOMWrapperWorld&);
- static const WrapperTypeInfo wrapperTypeInfo;
+ STATIC_ONLY({{v8_class}}Constructor);
+ public:
+ static v8::Local<v8::FunctionTemplate> domTemplate(v8::Isolate*, const DOMWrapperWorld&);
+ static const WrapperTypeInfo wrapperTypeInfo;
};
{% endif %}
class {{v8_class}} {
- STATIC_ONLY({{v8_class}});
-public:
- {% if has_private_script %}
- class PrivateScript {
- STATIC_ONLY(PrivateScript);
- public:
- {% for method in methods if method.is_implemented_in_private_script %}
- static bool {{method.name}}Method({{method.argument_declarations_for_private_script | join(', ')}});
- {% endfor %}
- {% for attribute in attributes if attribute.is_implemented_in_private_script %}
- static bool {{attribute.name}}AttributeGetter(LocalFrame* frame, {{cpp_class}}* holderImpl, {{attribute.cpp_type}}* result);
- {% if not attribute.is_read_only %}
- static bool {{attribute.name}}AttributeSetter(LocalFrame* frame, {{cpp_class}}* holderImpl, {{attribute.argument_cpp_type}} cppValue);
- {% endif %}
- {% endfor %}
- };
-
- {% endif %}
- {% if is_array_buffer_or_view %}
- {{exported}}static {{cpp_class}}* toImpl(v8::Local<v8::Object> object);
- {% else %}
- {{exported}}static bool hasInstance(v8::Local<v8::Value>, v8::Isolate*);
- static v8::Local<v8::Object> findInstanceInPrototypeChain(v8::Local<v8::Value>, v8::Isolate*);
- {{exported}}static v8::Local<v8::FunctionTemplate> domTemplate(v8::Isolate*, const DOMWrapperWorld&);
- {% if has_named_properties_object %}
- {{exported}}static v8::Local<v8::FunctionTemplate> domTemplateForNamedPropertiesObject(v8::Isolate*, const DOMWrapperWorld&);
- {% endif %}
- static {{cpp_class}}* toImpl(v8::Local<v8::Object> object)
- {
- return toScriptWrappable(object)->toImpl<{{cpp_class}}>();
- }
- {% endif %}
- {{exported}}static {{cpp_class}}* toImplWithTypeCheck(v8::Isolate*, v8::Local<v8::Value>);
- {% if has_partial_interface %}
- {{exported}}static WrapperTypeInfo wrapperTypeInfo;
- {% else %}
- {{exported}}static const WrapperTypeInfo wrapperTypeInfo;
- {% endif %}
- template<typename VisitorDispatcher>
- static void trace(VisitorDispatcher visitor, ScriptWrappable* scriptWrappable)
- {
- visitor->trace(scriptWrappable->toImpl<{{cpp_class}}>());
- }
- static void traceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable)
- {
- visitor->traceWrappers(scriptWrappable->toImpl<{{cpp_class}}>());
- }
- {% if has_visit_dom_wrapper %}
- static void visitDOMWrapper(v8::Isolate*, ScriptWrappable*, const v8::Persistent<v8::Object>&);
- {% endif %}
- {% if has_visit_dom_wrapper_custom %}
- static void visitDOMWrapperCustom(v8::Isolate*, ScriptWrappable*, const v8::Persistent<v8::Object>&);
- {% endif %}
- {% for method in methods %}
- {% if method.is_custom %}
- static void {{method.name}}MethodCustom(const v8::FunctionCallbackInfo<v8::Value>&);
- {% endif %}
- {% if method.is_custom_call_prologue %}
- static void {{method.name}}MethodPrologueCustom(const v8::FunctionCallbackInfo<v8::Value>&, {{cpp_class}}*);
- {% endif %}
- {% if method.is_custom_call_epilogue %}
- static void {{method.name}}MethodEpilogueCustom(const v8::FunctionCallbackInfo<v8::Value>&, {{cpp_class}}*);
- {% endif %}
- {% endfor %}
- {% if constructors or has_custom_constructor or has_event_constructor or has_html_constructor %}
- static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
- {% endif %}
- {% if has_custom_constructor %}
- static void constructorCustom(const v8::FunctionCallbackInfo<v8::Value>&);
- {% endif %}
- {% for attribute in attributes %}
- {% if attribute.has_custom_getter %}{# FIXME: and not attribute.implemented_by #}
- {% if attribute.is_data_type_property %}
- static void {{attribute.name}}AttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>&);
- {% else %}
- static void {{attribute.name}}AttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>&);
- {% endif %}
- {% endif %}
- {% if attribute.has_custom_setter %}{# FIXME: and not attribute.implemented_by #}
- {% if attribute.is_data_type_property %}
- static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&);
- {% else %}
- static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, const v8::FunctionCallbackInfo<v8::Value>&);
- {% endif %}
- {% endif %}
- {% endfor %}
- {# Custom special operations #}
- {% if indexed_property_getter and indexed_property_getter.is_custom %}
- static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Value>&);
- {% endif %}
- {% if indexed_property_setter and indexed_property_setter.is_custom %}
- static void indexedPropertySetterCustom(uint32_t, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
- {% endif %}
- {% if indexed_property_deleter and indexed_property_deleter.is_custom %}
- static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Boolean>&);
- {% endif %}
- {% if named_property_getter and named_property_getter.is_custom %}
- static void namedPropertyGetterCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Value>&);
- {% endif %}
- {% if named_property_setter and named_property_setter.is_custom %}
- static void namedPropertySetterCustom(const AtomicString&, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
- {% endif %}
- {% if named_property_getter and
- named_property_getter.is_custom_property_query %}
- static void namedPropertyQueryCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Integer>&);
- {% endif %}
- {% if named_property_deleter and named_property_deleter.is_custom %}
- static void namedPropertyDeleterCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Boolean>&);
- {% endif %}
- {% if named_property_getter and
- named_property_getter.is_custom_property_enumerator %}
- static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::Array>&);
- {% endif %}
- {# END custom special operations #}
- {% if has_custom_legacy_call_as_function %}
- static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&);
- {% endif %}
- {# Custom internal fields #}
- {% set custom_internal_field_counter = 0 %}
- {% if is_event_target and not is_node %}
- {# Event listeners on DOM nodes are explicitly supported in the GC controller. #}
- static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
- {% set custom_internal_field_counter = custom_internal_field_counter + 1 %}
- {% endif %}
- {# persistentHandleIndex must be the last field, if it is present.
- Detailed explanation: https://codereview.chromium.org/139173012
- FIXME: Remove this internal field, and share one field for either:
- * a persistent handle (if the object is in oilpan) or
- * a C++ pointer to the DOM object (if the object is not in oilpan) #}
- static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
- {# End custom internal fields #}
- {% if unscopables or has_conditional_attributes_on_prototype or
- methods | conditionally_exposed(is_partial) %}
- {{exported}}static void preparePrototypeAndInterfaceObject(v8::Local<v8::Context>, const DOMWrapperWorld&, v8::Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate);
- {% endif %}
- {% if has_partial_interface %}
- {{exported}}static void updateWrapperTypeInfo(InstallTemplateFunction, PreparePrototypeAndInterfaceObjectFunction);
- {{exported}}static void install{{v8_class}}Template(v8::Isolate*, const DOMWrapperWorld&, v8::Local<v8::FunctionTemplate> interfaceTemplate);
- {% for method in methods if method.overloads and method.overloads.has_partial_overloads %}
- {{exported}}static void register{{method.name | blink_capitalize}}MethodForPartialInterface(void (*)(const v8::FunctionCallbackInfo<v8::Value>&));
+ STATIC_ONLY({{v8_class}});
+ public:
+ {% if has_private_script %}
+ class PrivateScript {
+ STATIC_ONLY(PrivateScript);
+ public:
+ {% for method in methods if method.is_implemented_in_private_script %}
+ static bool {{method.name}}Method({{method.argument_declarations_for_private_script | join(', ')}});
{% endfor %}
- {% endif %}
- {% for origin_trial_feature in origin_trial_features %}{{newline}}
- static void install{{origin_trial_feature.name}}(v8::Isolate*, const DOMWrapperWorld&, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface);
- static void install{{origin_trial_feature.name}}(ScriptState*, v8::Local<v8::Object> instance);
- {% if not origin_trial_feature.needs_instance %}
- static void install{{origin_trial_feature.name}}(ScriptState*);
+ {% for attribute in attributes if attribute.is_implemented_in_private_script %}
+ static bool {{attribute.name}}AttributeGetter(LocalFrame* frame, {{cpp_class}}* holderImpl, {{attribute.cpp_type}}* result);
+ {% if not attribute.is_read_only %}
+ static bool {{attribute.name}}AttributeSetter(LocalFrame* frame, {{cpp_class}}* holderImpl, {{attribute.argument_cpp_type}} cppValue);
{% endif %}
{% endfor %}
- {% if has_partial_interface %}
+ };
-private:
- static InstallTemplateFunction install{{v8_class}}TemplateFunction;
- {% endif %}
+ {% endif %}
+ {% if is_array_buffer_or_view %}
+ {{exported}}static {{cpp_class}}* toImpl(v8::Local<v8::Object> object);
+ {% else %}
+ {{exported}}static bool hasInstance(v8::Local<v8::Value>, v8::Isolate*);
+ static v8::Local<v8::Object> findInstanceInPrototypeChain(v8::Local<v8::Value>, v8::Isolate*);
+ {{exported}}static v8::Local<v8::FunctionTemplate> domTemplate(v8::Isolate*, const DOMWrapperWorld&);
+ {% if has_named_properties_object %}
+ {{exported}}static v8::Local<v8::FunctionTemplate> domTemplateForNamedPropertiesObject(v8::Isolate*, const DOMWrapperWorld&);
+ {% endif %}
+ static {{cpp_class}}* toImpl(v8::Local<v8::Object> object) {
+ return toScriptWrappable(object)->toImpl<{{cpp_class}}>();
+ }
+ {% endif %}
+ {{exported}}static {{cpp_class}}* toImplWithTypeCheck(v8::Isolate*, v8::Local<v8::Value>);
+ {% if has_partial_interface %}
+ {{exported}}static WrapperTypeInfo wrapperTypeInfo;
+ {% else %}
+ {{exported}}static const WrapperTypeInfo wrapperTypeInfo;
+ {% endif %}
+ template<typename VisitorDispatcher>
+ static void trace(VisitorDispatcher visitor, ScriptWrappable* scriptWrappable) {
+ visitor->trace(scriptWrappable->toImpl<{{cpp_class}}>());
+ }
+ static void traceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) {
+ visitor->traceWrappers(scriptWrappable->toImpl<{{cpp_class}}>());
+ }
+ {% if has_visit_dom_wrapper %}
+ static void visitDOMWrapper(v8::Isolate*, ScriptWrappable*, const v8::Persistent<v8::Object>&);
+ {% endif %}
+ {% if has_visit_dom_wrapper_custom %}
+ static void visitDOMWrapperCustom(v8::Isolate*, ScriptWrappable*, const v8::Persistent<v8::Object>&);
+ {% endif %}
+ {% for method in methods %}
+ {% if method.is_custom %}
+ static void {{method.name}}MethodCustom(const v8::FunctionCallbackInfo<v8::Value>&);
+ {% endif %}
+ {% if method.is_custom_call_prologue %}
+ static void {{method.name}}MethodPrologueCustom(const v8::FunctionCallbackInfo<v8::Value>&, {{cpp_class}}*);
+ {% endif %}
+ {% if method.is_custom_call_epilogue %}
+ static void {{method.name}}MethodEpilogueCustom(const v8::FunctionCallbackInfo<v8::Value>&, {{cpp_class}}*);
+ {% endif %}
+ {% endfor %}
+ {% if constructors or has_custom_constructor or has_event_constructor or has_html_constructor %}
+ static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
+ {% endif %}
+ {% if has_custom_constructor %}
+ static void constructorCustom(const v8::FunctionCallbackInfo<v8::Value>&);
+ {% endif %}
+ {% for attribute in attributes %}
+ {% if attribute.has_custom_getter %}{# FIXME: and not attribute.implemented_by #}
+ {% if attribute.is_data_type_property %}
+ static void {{attribute.name}}AttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>&);
+ {% else %}
+ static void {{attribute.name}}AttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>&);
+ {% endif %}
+ {% endif %}
+ {% if attribute.has_custom_setter %}{# FIXME: and not attribute.implemented_by #}
+ {% if attribute.is_data_type_property %}
+ static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&);
+ {% else %}
+ static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, const v8::FunctionCallbackInfo<v8::Value>&);
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+ {# Custom special operations #}
+ {% if indexed_property_getter and indexed_property_getter.is_custom %}
+ static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Value>&);
+ {% endif %}
+ {% if indexed_property_setter and indexed_property_setter.is_custom %}
+ static void indexedPropertySetterCustom(uint32_t, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
+ {% endif %}
+ {% if indexed_property_deleter and indexed_property_deleter.is_custom %}
+ static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Boolean>&);
+ {% endif %}
+ {% if named_property_getter and named_property_getter.is_custom %}
+ static void namedPropertyGetterCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Value>&);
+ {% endif %}
+ {% if named_property_setter and named_property_setter.is_custom %}
+ static void namedPropertySetterCustom(const AtomicString&, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
+ {% endif %}
+ {% if named_property_getter and named_property_getter.is_custom_property_query %}
+ static void namedPropertyQueryCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Integer>&);
+ {% endif %}
+ {% if named_property_deleter and named_property_deleter.is_custom %}
+ static void namedPropertyDeleterCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Boolean>&);
+ {% endif %}
+ {% if named_property_getter and named_property_getter.is_custom_property_enumerator %}
+ static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::Array>&);
+ {% endif %}
+ {# END custom special operations #}
+ {% if has_custom_legacy_call_as_function %}
+ static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&);
+ {% endif %}
+ {# Custom internal fields #}
+ {% set custom_internal_field_counter = 0 %}
+ {% if is_event_target and not is_node %}
+ {# Event listeners on DOM nodes are explicitly supported in the GC controller. #}
+ static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
+ {% set custom_internal_field_counter = custom_internal_field_counter + 1 %}
+ {% endif %}
+ {# persistentHandleIndex must be the last field, if it is present.
+ Detailed explanation: https://codereview.chromium.org/139173012
+ FIXME: Remove this internal field, and share one field for either:
+ * a persistent handle (if the object is in oilpan) or
+ * a C++ pointer to the DOM object (if the object is not in oilpan) #}
+ static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
+ {# End custom internal fields #}
+ {% if unscopables or has_conditional_attributes_on_prototype or
+ methods | conditionally_exposed(is_partial) %}
+ {{exported}}static void preparePrototypeAndInterfaceObject(v8::Local<v8::Context>, const DOMWrapperWorld&, v8::Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate);
+ {% endif %}
+ {% if has_partial_interface %}
+ {{exported}}static void updateWrapperTypeInfo(InstallTemplateFunction, PreparePrototypeAndInterfaceObjectFunction);
+ {{exported}}static void install{{v8_class}}Template(v8::Isolate*, const DOMWrapperWorld&, v8::Local<v8::FunctionTemplate> interfaceTemplate);
+ {% for method in methods if method.overloads and method.overloads.has_partial_overloads %}
+ {{exported}}static void register{{method.name | blink_capitalize}}MethodForPartialInterface(void (*)(const v8::FunctionCallbackInfo<v8::Value>&));
+ {% endfor %}
+ {% endif %}
+ {% for origin_trial_feature in origin_trial_features %}{{newline}}
+ static void install{{origin_trial_feature.name}}(v8::Isolate*, const DOMWrapperWorld&, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface);
+ static void install{{origin_trial_feature.name}}(ScriptState*, v8::Local<v8::Object> instance);
+ {% if not origin_trial_feature.needs_instance %}
+ static void install{{origin_trial_feature.name}}(ScriptState*);
+ {% endif %}
+ {% endfor %}
+ {% if has_partial_interface %}
+
+ private:
+ static InstallTemplateFunction install{{v8_class}}TemplateFunction;
+ {% endif %}
};
{% if has_event_constructor %}
@@ -188,11 +183,11 @@ private:
{% endif %}
template <>
struct V8TypeOf<{{cpp_class}}> {
- typedef {{v8_class}} Type;
+ typedef {{v8_class}} Type;
};
-} // namespace blink
+} // namespace blink
-#endif // {{v8_class}}_h
+#endif // {{v8_class}}_h
{% endfilter %}{# format_blink_cpp_source_code #}

Powered by Google App Engine
This is Rietveld 408576698