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

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

Issue 2446213002: [Bindings] [Reformat] Reformat template files (Closed)
Patch Set: Rebase (Split out Callbackfunctions) Created 4 years, 1 month 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 #ifndef {{v8_class}}_h 4 #ifndef {{v8_class}}_h
5 #define {{v8_class}}_h 5 #define {{v8_class}}_h
6 6
7 {% for filename in header_includes %} 7 {% for filename in header_includes %}
8 #include "{{filename}}" 8 #include "{{filename}}"
9 {% endfor %} 9 {% endfor %}
10 10
11 namespace blink { 11 namespace blink {
12 12
13 {% if has_event_constructor %} 13 {% if has_event_constructor %}
14 class Dictionary; 14 class Dictionary;
15 {% endif %} 15 {% endif %}
16 {% if attributes|origin_trial_enabled_attributes %} 16 {% if attributes|origin_trial_enabled_attributes %}
17 class ScriptState; 17 class ScriptState;
18 {% endif %} 18 {% endif %}
19 {% if named_constructor %} 19 {% if named_constructor %}
20 class {{v8_class}}Constructor { 20 class {{v8_class}}Constructor {
21 STATIC_ONLY({{v8_class}}Constructor); 21 STATIC_ONLY({{v8_class}}Constructor);
22 public: 22 public:
23 static v8::Local<v8::FunctionTemplate> domTemplate(v8::Isolate*, const DOMWr apperWorld&); 23 static v8::Local<v8::FunctionTemplate> domTemplate(v8::Isolate*, const DOMWrap perWorld&);
24 static const WrapperTypeInfo wrapperTypeInfo; 24 static const WrapperTypeInfo wrapperTypeInfo;
25 }; 25 };
26 26
27 {% endif %} 27 {% endif %}
28 class {{v8_class}} { 28 class {{v8_class}} {
29 STATIC_ONLY({{v8_class}}); 29 STATIC_ONLY({{v8_class}});
30 public: 30 public:
31 {% if has_private_script %} 31 {% if has_private_script %}
32 class PrivateScript { 32 class PrivateScript {
33 STATIC_ONLY(PrivateScript); 33 STATIC_ONLY(PrivateScript);
34 public: 34 public:
35 {% for method in methods if method.is_implemented_in_private_script %} 35 {% for method in methods if method.is_implemented_in_private_script %}
36 static bool {{method.name}}Method({{method.argument_declarations_for_pri vate_script | join(', ')}}); 36 static bool {{method.name}}Method({{method.argument_declarations_for_private _script | join(', ')}});
37 {% endfor %} 37 {% endfor %}
38 {% for attribute in attributes if attribute.is_implemented_in_private_sc ript %} 38 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
39 static bool {{attribute.name}}AttributeGetter(LocalFrame* frame, {{cpp_c lass}}* holderImpl, {{attribute.cpp_type}}* result); 39 static bool {{attribute.name}}AttributeGetter(LocalFrame* frame, {{cpp_class }}* holderImpl, {{attribute.cpp_type}}* result);
40 {% if not attribute.is_read_only %} 40 {% if not attribute.is_read_only %}
41 static bool {{attribute.name}}AttributeSetter(LocalFrame* frame, {{cpp_c lass}}* holderImpl, {{attribute.argument_cpp_type}} cppValue); 41 static bool {{attribute.name}}AttributeSetter(LocalFrame* frame, {{cpp_class }}* holderImpl, {{attribute.argument_cpp_type}} cppValue);
42 {% endif %}
43 {% endfor %}
44 };
45
46 {% endif %}
47 {% if is_array_buffer_or_view %}
48 {{exported}}static {{cpp_class}}* toImpl(v8::Local<v8::Object> object);
49 {% else %}
50 {{exported}}static bool hasInstance(v8::Local<v8::Value>, v8::Isolate*);
51 static v8::Local<v8::Object> findInstanceInPrototypeChain(v8::Local<v8::Valu e>, v8::Isolate*);
52 {{exported}}static v8::Local<v8::FunctionTemplate> domTemplate(v8::Isolate*, const DOMWrapperWorld&);
53 {% if has_named_properties_object %}
54 {{exported}}static v8::Local<v8::FunctionTemplate> domTemplateForNamedProper tiesObject(v8::Isolate*, const DOMWrapperWorld&);
55 {% endif %}
56 static {{cpp_class}}* toImpl(v8::Local<v8::Object> object)
57 {
58 return toScriptWrappable(object)->toImpl<{{cpp_class}}>();
59 }
60 {% endif %}
61 {{exported}}static {{cpp_class}}* toImplWithTypeCheck(v8::Isolate*, v8::Loca l<v8::Value>);
62 {% if has_partial_interface %}
63 {{exported}}static WrapperTypeInfo wrapperTypeInfo;
64 {% else %}
65 {{exported}}static const WrapperTypeInfo wrapperTypeInfo;
66 {% endif %}
67 template<typename VisitorDispatcher>
68 static void trace(VisitorDispatcher visitor, ScriptWrappable* scriptWrappabl e)
69 {
70 visitor->trace(scriptWrappable->toImpl<{{cpp_class}}>());
71 }
72 static void traceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWr appable)
73 {
74 visitor->traceWrappers(scriptWrappable->toImpl<{{cpp_class}}>());
75 }
76 {% if has_visit_dom_wrapper %}
77 static void visitDOMWrapper(v8::Isolate*, ScriptWrappable*, const v8::Persis tent<v8::Object>&);
78 {% endif %}
79 {% if has_visit_dom_wrapper_custom %}
80 static void visitDOMWrapperCustom(v8::Isolate*, ScriptWrappable*, const v8:: Persistent<v8::Object>&);
81 {% endif %}
82 {% for method in methods %}
83 {% if method.is_custom %}
84 static void {{method.name}}MethodCustom(const v8::FunctionCallbackInfo<v8::V alue>&);
85 {% endif %}
86 {% if method.is_custom_call_prologue %}
87 static void {{method.name}}MethodPrologueCustom(const v8::FunctionCallbackIn fo<v8::Value>&, {{cpp_class}}*);
88 {% endif %}
89 {% if method.is_custom_call_epilogue %}
90 static void {{method.name}}MethodEpilogueCustom(const v8::FunctionCallbackIn fo<v8::Value>&, {{cpp_class}}*);
91 {% endif %} 42 {% endif %}
92 {% endfor %} 43 {% endfor %}
93 {% if constructors or has_custom_constructor or has_event_constructor or has _html_constructor %} 44 };
94 static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
95 {% endif %}
96 {% if has_custom_constructor %}
97 static void constructorCustom(const v8::FunctionCallbackInfo<v8::Value>&);
98 {% elif has_html_constructor %}
99 static void HTMLConstructor(const v8::FunctionCallbackInfo<v8::Value>&);
100 {% endif %}
101 {% for attribute in attributes %}
102 {% if attribute.has_custom_getter %}{# FIXME: and not attribute.implemented_ by #}
103 {% if attribute.is_data_type_property %}
104 static void {{attribute.name}}AttributeGetterCustom(const v8::PropertyCallba ckInfo<v8::Value>&);
105 {% else %}
106 static void {{attribute.name}}AttributeGetterCustom(const v8::FunctionCallba ckInfo<v8::Value>&);
107 {% endif %}
108 {% endif %}
109 {% if attribute.has_custom_setter %}{# FIXME: and not attribute.implemented_ by #}
110 {% if attribute.is_data_type_property %}
111 static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, co nst v8::PropertyCallbackInfo<void>&);
112 {% else %}
113 static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, co nst v8::FunctionCallbackInfo<v8::Value>&);
114 {% endif %}
115 {% endif %}
116 {% endfor %}
117 {# Custom special operations #}
118 {% if indexed_property_getter and indexed_property_getter.is_custom %}
119 static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallback Info<v8::Value>&);
120 {% endif %}
121 {% if indexed_property_setter and indexed_property_setter.is_custom %}
122 static void indexedPropertySetterCustom(uint32_t, v8::Local<v8::Value>, cons t v8::PropertyCallbackInfo<v8::Value>&);
123 {% endif %}
124 {% if indexed_property_deleter and indexed_property_deleter.is_custom %}
125 static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbac kInfo<v8::Boolean>&);
126 {% endif %}
127 {% if named_property_getter and named_property_getter.is_custom %}
128 static void namedPropertyGetterCustom(const AtomicString&, const v8::Propert yCallbackInfo<v8::Value>&);
129 {% endif %}
130 {% if named_property_setter and named_property_setter.is_custom %}
131 static void namedPropertySetterCustom(const AtomicString&, v8::Local<v8::Val ue>, const v8::PropertyCallbackInfo<v8::Value>&);
132 {% endif %}
133 {% if named_property_getter and
134 named_property_getter.is_custom_property_query %}
135 static void namedPropertyQueryCustom(const AtomicString&, const v8::Property CallbackInfo<v8::Integer>&);
136 {% endif %}
137 {% if named_property_deleter and named_property_deleter.is_custom %}
138 static void namedPropertyDeleterCustom(const AtomicString&, const v8::Proper tyCallbackInfo<v8::Boolean>&);
139 {% endif %}
140 {% if named_property_getter and
141 named_property_getter.is_custom_property_enumerator %}
142 static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8: :Array>&);
143 {% endif %}
144 {# END custom special operations #}
145 {% if has_custom_legacy_call_as_function %}
146 static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&);
147 {% endif %}
148 {# Custom internal fields #}
149 {% set custom_internal_field_counter = 0 %}
150 {% if is_event_target and not is_node %}
151 {# Event listeners on DOM nodes are explicitly supported in the GC controlle r. #}
152 static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCoun t + {{custom_internal_field_counter}};
153 {% set custom_internal_field_counter = custom_internal_field_counter + 1 %}
154 {% endif %}
155 {# persistentHandleIndex must be the last field, if it is present.
156 Detailed explanation: https://codereview.chromium.org/139173012
157 FIXME: Remove this internal field, and share one field for either:
158 * a persistent handle (if the object is in oilpan) or
159 * a C++ pointer to the DOM object (if the object is not in oilpan) #}
160 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + { {custom_internal_field_counter}};
161 {# End custom internal fields #}
162 {% if unscopables or has_conditional_attributes_on_prototype or
163 methods | conditionally_exposed(is_partial) %}
164 {{exported}}static void preparePrototypeAndInterfaceObject(v8::Local<v8::Con text>, const DOMWrapperWorld&, v8::Local<v8::Object> prototypeObject, v8::Local< v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate );
165 {% endif %}
166 {% if has_partial_interface %}
167 {{exported}}static void updateWrapperTypeInfo(InstallTemplateFunction, Prepa rePrototypeAndInterfaceObjectFunction);
168 {{exported}}static void install{{v8_class}}Template(v8::Isolate*, const DOMW rapperWorld&, v8::Local<v8::FunctionTemplate> interfaceTemplate);
169 {% for method in methods if method.overloads and method.overloads.has_partia l_overloads %}
170 {{exported}}static void register{{method.name | blink_capitalize}}MethodForP artialInterface(void (*)(const v8::FunctionCallbackInfo<v8::Value>&));
171 {% endfor %}
172 {% endif %}
173 {% for origin_trial_feature in origin_trial_features %}{{newline}}
174 static void install{{origin_trial_feature.name}}(v8::Isolate*, const DOMWrap perWorld&, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8:: Local<v8::Function> interface);
175 static void install{{origin_trial_feature.name}}(ScriptState*, v8::Local<v8: :Object> instance);
176 {% if not origin_trial_feature.needs_instance %}
177 static void install{{origin_trial_feature.name}}(ScriptState*);
178 {% endif %}
179 {% endfor %}
180 {% if has_partial_interface %}
181 45
182 private: 46 {% endif %}
183 static InstallTemplateFunction install{{v8_class}}TemplateFunction; 47 {% if is_array_buffer_or_view %}
184 {% endif %} 48 {{exported}}static {{cpp_class}}* toImpl(v8::Local<v8::Object> object);
49 {% else %}
50 {{exported}}static bool hasInstance(v8::Local<v8::Value>, v8::Isolate*);
51 static v8::Local<v8::Object> findInstanceInPrototypeChain(v8::Local<v8::Value> , v8::Isolate*);
52 {{exported}}static v8::Local<v8::FunctionTemplate> domTemplate(v8::Isolate*, c onst DOMWrapperWorld&);
53 {% if has_named_properties_object %}
54 {{exported}}static v8::Local<v8::FunctionTemplate> domTemplateForNamedProperti esObject(v8::Isolate*, const DOMWrapperWorld&);
55 {% endif %}
56 static {{cpp_class}}* toImpl(v8::Local<v8::Object> object) {
57 return toScriptWrappable(object)->toImpl<{{cpp_class}}>();
58 }
59 {% endif %}
60 {{exported}}static {{cpp_class}}* toImplWithTypeCheck(v8::Isolate*, v8::Local< v8::Value>);
61 {% if has_partial_interface %}
62 {{exported}}static WrapperTypeInfo wrapperTypeInfo;
63 {% else %}
64 {{exported}}static const WrapperTypeInfo wrapperTypeInfo;
65 {% endif %}
66 template<typename VisitorDispatcher>
67 static void trace(VisitorDispatcher visitor, ScriptWrappable* scriptWrappable) {
68 visitor->trace(scriptWrappable->toImpl<{{cpp_class}}>());
69 }
70 static void traceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrap pable) {
71 visitor->traceWrappers(scriptWrappable->toImpl<{{cpp_class}}>());
72 }
73 {% if has_visit_dom_wrapper %}
74 static void visitDOMWrapper(v8::Isolate*, ScriptWrappable*, const v8::Persiste nt<v8::Object>&);
75 {% endif %}
76 {% if has_visit_dom_wrapper_custom %}
77 static void visitDOMWrapperCustom(v8::Isolate*, ScriptWrappable*, const v8::Pe rsistent<v8::Object>&);
78 {% endif %}
79 {% for method in methods %}
80 {% if method.is_custom %}
81 static void {{method.name}}MethodCustom(const v8::FunctionCallbackInfo<v8::Val ue>&);
82 {% endif %}
83 {% if method.is_custom_call_prologue %}
84 static void {{method.name}}MethodPrologueCustom(const v8::FunctionCallbackInfo <v8::Value>&, {{cpp_class}}*);
85 {% endif %}
86 {% if method.is_custom_call_epilogue %}
87 static void {{method.name}}MethodEpilogueCustom(const v8::FunctionCallbackInfo <v8::Value>&, {{cpp_class}}*);
88 {% endif %}
89 {% endfor %}
90 {% if constructors or has_custom_constructor or has_event_constructor or has_h tml_constructor %}
91 static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
92 {% endif %}
93 {% if has_custom_constructor %}
94 static void constructorCustom(const v8::FunctionCallbackInfo<v8::Value>&);
95 {% elif has_html_constructor %}
96 static void HTMLConstructor(const v8::FunctionCallbackInfo<v8::Value>&);
97 {% endif %}
98 {% for attribute in attributes %}
99 {% if attribute.has_custom_getter %}{# FIXME: and not attribute.implemented_by #}
100 {% if attribute.is_data_type_property %}
101 static void {{attribute.name}}AttributeGetterCustom(const v8::PropertyCallback Info<v8::Value>&);
102 {% else %}
103 static void {{attribute.name}}AttributeGetterCustom(const v8::FunctionCallback Info<v8::Value>&);
104 {% endif %}
105 {% endif %}
106 {% if attribute.has_custom_setter %}{# FIXME: and not attribute.implemented_by #}
107 {% if attribute.is_data_type_property %}
108 static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, cons t v8::PropertyCallbackInfo<void>&);
109 {% else %}
110 static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, cons t v8::FunctionCallbackInfo<v8::Value>&);
111 {% endif %}
112 {% endif %}
113 {% endfor %}
114 {# Custom special operations #}
115 {% if indexed_property_getter and indexed_property_getter.is_custom %}
116 static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackIn fo<v8::Value>&);
117 {% endif %}
118 {% if indexed_property_setter and indexed_property_setter.is_custom %}
119 static void indexedPropertySetterCustom(uint32_t, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
120 {% endif %}
121 {% if indexed_property_deleter and indexed_property_deleter.is_custom %}
122 static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackI nfo<v8::Boolean>&);
123 {% endif %}
124 {% if named_property_getter and named_property_getter.is_custom %}
125 static void namedPropertyGetterCustom(const AtomicString&, const v8::PropertyC allbackInfo<v8::Value>&);
126 {% endif %}
127 {% if named_property_setter and named_property_setter.is_custom %}
128 static void namedPropertySetterCustom(const AtomicString&, v8::Local<v8::Value >, const v8::PropertyCallbackInfo<v8::Value>&);
129 {% endif %}
130 {% if named_property_getter and named_property_getter.is_custom_property_query %}
131 static void namedPropertyQueryCustom(const AtomicString&, const v8::PropertyCa llbackInfo<v8::Integer>&);
132 {% endif %}
133 {% if named_property_deleter and named_property_deleter.is_custom %}
134 static void namedPropertyDeleterCustom(const AtomicString&, const v8::Property CallbackInfo<v8::Boolean>&);
135 {% endif %}
136 {% if named_property_getter and named_property_getter.is_custom_property_enume rator %}
137 static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::A rray>&);
138 {% endif %}
139 {# END custom special operations #}
140 {% if has_custom_legacy_call_as_function %}
141 static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&);
142 {% endif %}
143 {# Custom internal fields #}
144 {% set custom_internal_field_counter = 0 %}
145 {% if is_event_target and not is_node %}
146 {# Event listeners on DOM nodes are explicitly supported in the GC controller. #}
147 static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
148 {% set custom_internal_field_counter = custom_internal_field_counter + 1 %}
149 {% endif %}
150 {# persistentHandleIndex must be the last field, if it is present.
151 Detailed explanation: https://codereview.chromium.org/139173012
152 FIXME: Remove this internal field, and share one field for either:
153 * a persistent handle (if the object is in oilpan) or
154 * a C++ pointer to the DOM object (if the object is not in oilpan) #}
155 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{c ustom_internal_field_counter}};
156 {# End custom internal fields #}
157 {% if unscopables or has_conditional_attributes_on_prototype or
158 methods | conditionally_exposed(is_partial) %}
159 {{exported}}static void preparePrototypeAndInterfaceObject(v8::Local<v8::Conte xt>, const DOMWrapperWorld&, v8::Local<v8::Object> prototypeObject, v8::Local<v8 ::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate);
160 {% endif %}
161 {% if has_partial_interface %}
162 {{exported}}static void updateWrapperTypeInfo(InstallTemplateFunction, Prepare PrototypeAndInterfaceObjectFunction);
163 {{exported}}static void install{{v8_class}}Template(v8::Isolate*, const DOMWra pperWorld&, v8::Local<v8::FunctionTemplate> interfaceTemplate);
164 {% for method in methods if method.overloads and method.overloads.has_partial_ overloads %}
165 {{exported}}static void register{{method.name | blink_capitalize}}MethodForPar tialInterface(void (*)(const v8::FunctionCallbackInfo<v8::Value>&));
166 {% endfor %}
167 {% endif %}
168 {% for origin_trial_feature in origin_trial_features %}{{newline}}
169 static void install{{origin_trial_feature.name}}(v8::Isolate*, const DOMWrappe rWorld&, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Lo cal<v8::Function> interface);
170 static void install{{origin_trial_feature.name}}(ScriptState*, v8::Local<v8::O bject> instance);
171 {% if not origin_trial_feature.needs_instance %}
172 static void install{{origin_trial_feature.name}}(ScriptState*);
173 {% endif %}
174 {% endfor %}
175 {% if has_partial_interface %}
176
177 private:
178 static InstallTemplateFunction install{{v8_class}}TemplateFunction;
179 {% endif %}
185 }; 180 };
186 181
187 {% if has_event_constructor %} 182 {% if has_event_constructor %}
188 {{exported}}bool initialize{{cpp_class}}({{cpp_class}}Init&, const Dictionary&, ExceptionState&, const v8::FunctionCallbackInfo<v8::Value>& info); 183 {{exported}}bool initialize{{cpp_class}}({{cpp_class}}Init&, const Dictionary&, ExceptionState&, const v8::FunctionCallbackInfo<v8::Value>& info);
189 184
190 {% endif %} 185 {% endif %}
191 template <> 186 template <>
192 struct V8TypeOf<{{cpp_class}}> { 187 struct V8TypeOf<{{cpp_class}}> {
193 typedef {{v8_class}} Type; 188 typedef {{v8_class}} Type;
194 }; 189 };
195 190
196 } // namespace blink 191 } // namespace blink
197 192
198 #endif // {{v8_class}}_h 193 #endif // {{v8_class}}_h
199 194
200 {% endfilter %}{# format_blink_cpp_source_code #} 195 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698