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

Side by Side 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, 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 {% endif %}
99 {% for attribute in attributes %}
100 {% if attribute.has_custom_getter %}{# FIXME: and not attribute.implemented_ by #}
101 {% if attribute.is_data_type_property %}
102 static void {{attribute.name}}AttributeGetterCustom(const v8::PropertyCallba ckInfo<v8::Value>&);
103 {% else %}
104 static void {{attribute.name}}AttributeGetterCustom(const v8::FunctionCallba ckInfo<v8::Value>&);
105 {% endif %}
106 {% endif %}
107 {% if attribute.has_custom_setter %}{# FIXME: and not attribute.implemented_ by #}
108 {% if attribute.is_data_type_property %}
109 static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, co nst v8::PropertyCallbackInfo<void>&);
110 {% else %}
111 static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, co nst v8::FunctionCallbackInfo<v8::Value>&);
112 {% endif %}
113 {% endif %}
114 {% endfor %}
115 {# Custom special operations #}
116 {% if indexed_property_getter and indexed_property_getter.is_custom %}
117 static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallback Info<v8::Value>&);
118 {% endif %}
119 {% if indexed_property_setter and indexed_property_setter.is_custom %}
120 static void indexedPropertySetterCustom(uint32_t, v8::Local<v8::Value>, cons t v8::PropertyCallbackInfo<v8::Value>&);
121 {% endif %}
122 {% if indexed_property_deleter and indexed_property_deleter.is_custom %}
123 static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbac kInfo<v8::Boolean>&);
124 {% endif %}
125 {% if named_property_getter and named_property_getter.is_custom %}
126 static void namedPropertyGetterCustom(const AtomicString&, const v8::Propert yCallbackInfo<v8::Value>&);
127 {% endif %}
128 {% if named_property_setter and named_property_setter.is_custom %}
129 static void namedPropertySetterCustom(const AtomicString&, v8::Local<v8::Val ue>, const v8::PropertyCallbackInfo<v8::Value>&);
130 {% endif %}
131 {% if named_property_getter and
132 named_property_getter.is_custom_property_query %}
133 static void namedPropertyQueryCustom(const AtomicString&, const v8::Property CallbackInfo<v8::Integer>&);
134 {% endif %}
135 {% if named_property_deleter and named_property_deleter.is_custom %}
136 static void namedPropertyDeleterCustom(const AtomicString&, const v8::Proper tyCallbackInfo<v8::Boolean>&);
137 {% endif %}
138 {% if named_property_getter and
139 named_property_getter.is_custom_property_enumerator %}
140 static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8: :Array>&);
141 {% endif %}
142 {# END custom special operations #}
143 {% if has_custom_legacy_call_as_function %}
144 static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&);
145 {% endif %}
146 {# Custom internal fields #}
147 {% set custom_internal_field_counter = 0 %}
148 {% if is_event_target and not is_node %}
149 {# Event listeners on DOM nodes are explicitly supported in the GC controlle r. #}
150 static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCoun t + {{custom_internal_field_counter}};
151 {% set custom_internal_field_counter = custom_internal_field_counter + 1 %}
152 {% endif %}
153 {# persistentHandleIndex must be the last field, if it is present.
154 Detailed explanation: https://codereview.chromium.org/139173012
155 FIXME: Remove this internal field, and share one field for either:
156 * a persistent handle (if the object is in oilpan) or
157 * a C++ pointer to the DOM object (if the object is not in oilpan) #}
158 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + { {custom_internal_field_counter}};
159 {# End custom internal fields #}
160 {% if unscopables or has_conditional_attributes_on_prototype or
161 methods | conditionally_exposed(is_partial) %}
162 {{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 );
163 {% endif %}
164 {% if has_partial_interface %}
165 {{exported}}static void updateWrapperTypeInfo(InstallTemplateFunction, Prepa rePrototypeAndInterfaceObjectFunction);
166 {{exported}}static void install{{v8_class}}Template(v8::Isolate*, const DOMW rapperWorld&, v8::Local<v8::FunctionTemplate> interfaceTemplate);
167 {% for method in methods if method.overloads and method.overloads.has_partia l_overloads %}
168 {{exported}}static void register{{method.name | blink_capitalize}}MethodForP artialInterface(void (*)(const v8::FunctionCallbackInfo<v8::Value>&));
169 {% endfor %}
170 {% endif %}
171 {% for origin_trial_feature in origin_trial_features %}{{newline}}
172 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);
173 static void install{{origin_trial_feature.name}}(ScriptState*, v8::Local<v8: :Object> instance);
174 {% if not origin_trial_feature.needs_instance %}
175 static void install{{origin_trial_feature.name}}(ScriptState*);
176 {% endif %}
177 {% endfor %}
178 {% if has_partial_interface %}
179 45
180 private: 46 {% endif %}
181 static InstallTemplateFunction install{{v8_class}}TemplateFunction; 47 {% if is_array_buffer_or_view %}
182 {% 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 {% endif %}
96 {% for attribute in attributes %}
97 {% if attribute.has_custom_getter %}{# FIXME: and not attribute.implemented_by #}
98 {% if attribute.is_data_type_property %}
99 static void {{attribute.name}}AttributeGetterCustom(const v8::PropertyCallback Info<v8::Value>&);
100 {% else %}
101 static void {{attribute.name}}AttributeGetterCustom(const v8::FunctionCallback Info<v8::Value>&);
102 {% endif %}
103 {% endif %}
104 {% if attribute.has_custom_setter %}{# FIXME: and not attribute.implemented_by #}
105 {% if attribute.is_data_type_property %}
106 static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, cons t v8::PropertyCallbackInfo<void>&);
107 {% else %}
108 static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, cons t v8::FunctionCallbackInfo<v8::Value>&);
109 {% endif %}
110 {% endif %}
111 {% endfor %}
112 {# Custom special operations #}
113 {% if indexed_property_getter and indexed_property_getter.is_custom %}
114 static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackIn fo<v8::Value>&);
115 {% endif %}
116 {% if indexed_property_setter and indexed_property_setter.is_custom %}
117 static void indexedPropertySetterCustom(uint32_t, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
118 {% endif %}
119 {% if indexed_property_deleter and indexed_property_deleter.is_custom %}
120 static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackI nfo<v8::Boolean>&);
121 {% endif %}
122 {% if named_property_getter and named_property_getter.is_custom %}
123 static void namedPropertyGetterCustom(const AtomicString&, const v8::PropertyC allbackInfo<v8::Value>&);
124 {% endif %}
125 {% if named_property_setter and named_property_setter.is_custom %}
126 static void namedPropertySetterCustom(const AtomicString&, v8::Local<v8::Value >, const v8::PropertyCallbackInfo<v8::Value>&);
127 {% endif %}
128 {% if named_property_getter and named_property_getter.is_custom_property_query %}
129 static void namedPropertyQueryCustom(const AtomicString&, const v8::PropertyCa llbackInfo<v8::Integer>&);
130 {% endif %}
131 {% if named_property_deleter and named_property_deleter.is_custom %}
132 static void namedPropertyDeleterCustom(const AtomicString&, const v8::Property CallbackInfo<v8::Boolean>&);
133 {% endif %}
134 {% if named_property_getter and named_property_getter.is_custom_property_enume rator %}
135 static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::A rray>&);
136 {% endif %}
137 {# END custom special operations #}
138 {% if has_custom_legacy_call_as_function %}
139 static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&);
140 {% endif %}
141 {# Custom internal fields #}
142 {% set custom_internal_field_counter = 0 %}
143 {% if is_event_target and not is_node %}
144 {# Event listeners on DOM nodes are explicitly supported in the GC controller. #}
145 static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
146 {% set custom_internal_field_counter = custom_internal_field_counter + 1 %}
147 {% endif %}
148 {# persistentHandleIndex must be the last field, if it is present.
149 Detailed explanation: https://codereview.chromium.org/139173012
150 FIXME: Remove this internal field, and share one field for either:
151 * a persistent handle (if the object is in oilpan) or
152 * a C++ pointer to the DOM object (if the object is not in oilpan) #}
153 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{c ustom_internal_field_counter}};
154 {# End custom internal fields #}
155 {% if unscopables or has_conditional_attributes_on_prototype or
156 methods | conditionally_exposed(is_partial) %}
157 {{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);
158 {% endif %}
159 {% if has_partial_interface %}
160 {{exported}}static void updateWrapperTypeInfo(InstallTemplateFunction, Prepare PrototypeAndInterfaceObjectFunction);
161 {{exported}}static void install{{v8_class}}Template(v8::Isolate*, const DOMWra pperWorld&, v8::Local<v8::FunctionTemplate> interfaceTemplate);
162 {% for method in methods if method.overloads and method.overloads.has_partial_ overloads %}
163 {{exported}}static void register{{method.name | blink_capitalize}}MethodForPar tialInterface(void (*)(const v8::FunctionCallbackInfo<v8::Value>&));
164 {% endfor %}
165 {% endif %}
166 {% for origin_trial_feature in origin_trial_features %}{{newline}}
167 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);
168 static void install{{origin_trial_feature.name}}(ScriptState*, v8::Local<v8::O bject> instance);
169 {% if not origin_trial_feature.needs_instance %}
170 static void install{{origin_trial_feature.name}}(ScriptState*);
171 {% endif %}
172 {% endfor %}
173 {% if has_partial_interface %}
174
175 private:
176 static InstallTemplateFunction install{{v8_class}}TemplateFunction;
177 {% endif %}
183 }; 178 };
184 179
185 {% if has_event_constructor %} 180 {% if has_event_constructor %}
186 {{exported}}bool initialize{{cpp_class}}({{cpp_class}}Init&, const Dictionary&, ExceptionState&, const v8::FunctionCallbackInfo<v8::Value>& info); 181 {{exported}}bool initialize{{cpp_class}}({{cpp_class}}Init&, const Dictionary&, ExceptionState&, const v8::FunctionCallbackInfo<v8::Value>& info);
187 182
188 {% endif %} 183 {% endif %}
189 template <> 184 template <>
190 struct V8TypeOf<{{cpp_class}}> { 185 struct V8TypeOf<{{cpp_class}}> {
191 typedef {{v8_class}} Type; 186 typedef {{v8_class}} Type;
192 }; 187 };
193 188
194 } // namespace blink 189 } // namespace blink
195 190
196 #endif // {{v8_class}}_h 191 #endif // {{v8_class}}_h
197 192
198 {% endfilter %}{# format_blink_cpp_source_code #} 193 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698