Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / templates / interface.h
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY!
6
7 #ifndef {{v8_class}}_h
8 #define {{v8_class}}_h
9
10 {% filter conditional(conditional_string) %}
11 {% for filename in header_includes %}
12 #include "{{filename}}"
13 {% endfor %}
14
15 namespace blink {
16
17 {% if has_event_constructor %}
18 class Dictionary;
19 {% endif %}
20 {% if named_constructor %}
21 class {{v8_class}}Constructor {
22 public:
23     static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*);
24     static const WrapperTypeInfo wrapperTypeInfo;
25 };
26
27 {% endif %}
28 class {{v8_class}} {
29 public:
30     {% if has_private_script %}
31     class PrivateScript {
32     public:
33         {% for method in methods if method.is_implemented_in_private_script %}
34         static bool {{method.name}}Method({{method.argument_declarations_for_private_script | join(', ')}});
35         {% endfor %}
36         {% for attribute in attributes if attribute.is_implemented_in_private_script %}
37         static bool {{attribute.name}}AttributeGetter(LocalFrame* frame, {{cpp_class}}* holderImpl, {{attribute.cpp_type}}* result);
38         {% if not attribute.is_read_only %}
39         static bool {{attribute.name}}AttributeSetter(LocalFrame* frame, {{cpp_class}}* holderImpl, {{attribute.argument_cpp_type}} cppValue);
40         {% endif %}
41         {% endfor %}
42     };
43
44     {% endif %}
45     static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*);
46     {% if is_array_buffer_or_view %}
47     static {{cpp_class}}* toImpl(v8::Handle<v8::Object> object);
48     {% else %}
49     static v8::Handle<v8::Object> findInstanceInPrototypeChain(v8::Handle<v8::Value>, v8::Isolate*);
50     static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*);
51     static {{cpp_class}}* toImpl(v8::Handle<v8::Object> object)
52     {
53         return blink::toScriptWrappableBase(object)->toImpl<{{cpp_class}}>();
54     }
55     {% endif %}
56     static {{cpp_class}}* toImplWithTypeCheck(v8::Isolate*, v8::Handle<v8::Value>);
57     {% if has_partial_interface %}
58     static WrapperTypeInfo wrapperTypeInfo;
59     {% else %}
60     static const WrapperTypeInfo wrapperTypeInfo;
61     {% endif %}
62     static void refObject(ScriptWrappableBase*);
63     static void derefObject(ScriptWrappableBase*);
64     static void trace(Visitor* visitor, ScriptWrappableBase* scriptWrappableBase)
65     {
66         {% if gc_type == 'GarbageCollectedObject' %}
67         visitor->trace(scriptWrappableBase->toImpl<{{cpp_class}}>());
68         {% elif gc_type == 'WillBeGarbageCollectedObject' %}
69 #if ENABLE(OILPAN)
70         visitor->trace(scriptWrappableBase->toImpl<{{cpp_class}}>());
71 #endif
72         {% endif %}
73     }
74     {% if has_visit_dom_wrapper %}
75     static void visitDOMWrapper(v8::Isolate*, ScriptWrappableBase*, const v8::Persistent<v8::Object>&);
76     {% endif %}
77     {% if is_active_dom_object %}
78     static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>);
79     {% endif %}
80     {% if is_event_target %}
81     static EventTarget* toEventTarget(v8::Handle<v8::Object>);
82     {% endif %}
83     {% if interface_name == 'Window' %}
84     static v8::Handle<v8::ObjectTemplate> getShadowObjectTemplate(v8::Isolate*);
85     {% endif %}
86     {% for method in methods %}
87     {% if method.is_custom %}
88     {% filter conditional(method.conditional_string) %}
89     static void {{method.name}}MethodCustom(const v8::FunctionCallbackInfo<v8::Value>&);
90     {% endfilter %}
91     {% endif %}
92     {% endfor %}
93     {% if constructors or has_custom_constructor or has_event_constructor %}
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     {% filter conditional(attribute.conditional_string) %}
102     static void {{attribute.name}}AttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>&);
103     {% endfilter %}
104     {% endif %}
105     {% if attribute.has_custom_setter %}{# FIXME: and not attribute.implemented_by #}
106     {% filter conditional(attribute.conditional_string) %}
107     static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&);
108     {% endfilter %}
109     {% endif %}
110     {% endfor %}
111     {# Custom special operations #}
112     {% if indexed_property_getter and indexed_property_getter.is_custom %}
113     static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Value>&);
114     {% endif %}
115     {% if indexed_property_setter and indexed_property_setter.is_custom %}
116     static void indexedPropertySetterCustom(uint32_t, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
117     {% endif %}
118     {% if indexed_property_deleter and indexed_property_deleter.is_custom %}
119     static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Boolean>&);
120     {% endif %}
121     {% if named_property_getter and named_property_getter.is_custom %}
122     static void namedPropertyGetterCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>&);
123     {% endif %}
124     {% if named_property_setter and named_property_setter.is_custom %}
125     static void namedPropertySetterCustom(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
126     {% endif %}
127     {% if named_property_getter and
128           named_property_getter.is_custom_property_query %}
129     static void namedPropertyQueryCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Integer>&);
130     {% endif %}
131     {% if named_property_deleter and named_property_deleter.is_custom %}
132     static void namedPropertyDeleterCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Boolean>&);
133     {% endif %}
134     {% if named_property_getter and
135           named_property_getter.is_custom_property_enumerator %}
136     static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::Array>&);
137     {% endif %}
138     {# END custom special operations #}
139     {% if has_custom_legacy_call_as_function %}
140     static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&);
141     {% endif %}
142     {# Custom internal fields #}
143     {% set custom_internal_field_counter = 0 %}
144     {% if is_event_target and not is_node %}
145     {# Event listeners on DOM nodes are explicitly supported in the GC controller. #}
146     static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
147     {% set custom_internal_field_counter = custom_internal_field_counter + 1 %}
148     {% endif %}
149     {# persistentHandleIndex must be the last field, if it is present.
150        Detailed explanation: https://codereview.chromium.org/139173012
151        FIXME: Remove this internal field, and share one field for either:
152        * a persistent handle (if the object is in oilpan) or
153        * a C++ pointer to the DOM object (if the object is not in oilpan) #}
154     static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
155     {# End custom internal fields #}
156     static inline ScriptWrappableBase* toScriptWrappableBase({{cpp_class}}* impl)
157     {
158         return impl->toScriptWrappableBase();
159     }
160     {% if interface_name == 'Window' %}
161     static bool namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType, v8::Local<v8::Value> data);
162     static bool indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data);
163     {% endif %}
164     static void installConditionallyEnabledProperties(v8::Handle<v8::Object>, v8::Isolate*){% if has_conditional_attributes %};
165     {% else %} { }
166     {% endif %}
167     static void installConditionallyEnabledMethods(v8::Handle<v8::Object>, v8::Isolate*){% if conditionally_enabled_methods %};
168     {% else %} { }
169     {% endif %}
170     {% if has_partial_interface %}
171     static void updateWrapperTypeInfo(InstallTemplateFunction, InstallConditionallyEnabledMethodsFunction);
172     static void install{{v8_class}}Template(v8::Handle<v8::FunctionTemplate>, v8::Isolate*);
173     {% for method in methods if method.overloads and method.overloads.has_partial_overloads %}
174     static void register{{method.name | blink_capitalize}}MethodForPartialInterface(void (*)(const v8::FunctionCallbackInfo<v8::Value>&));
175     {% endfor %}
176     {% endif %}
177     {% if has_partial_interface %}
178
179 private:
180     static InstallTemplateFunction install{{v8_class}}TemplateFunction;
181     {% endif %}
182 };
183
184 {% if has_custom_to_v8 %}
185 v8::Handle<v8::Value> toV8({{cpp_class}}*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
186
187 template<typename CallbackInfo>
188 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
189 {
190     v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
191 }
192
193 template<typename CallbackInfo>
194 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
195 {
196      v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
197 }
198
199 template<typename CallbackInfo>
200 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, const ScriptWrappable*)
201 {
202      v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
203 }
204
205 {% elif has_custom_wrap %}
206 v8::Handle<v8::Object> wrapCustom({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate*);
207
208 inline v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
209 {
210     if (UNLIKELY(!impl))
211         return v8::Null(isolate);
212     v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
213     if (!wrapper.IsEmpty())
214         return wrapper;
215
216     return wrapCustom(impl, creationContext, isolate);
217 }
218
219 template<typename CallbackInfo>
220 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
221 {
222     if (UNLIKELY(!impl)) {
223         v8SetReturnValueNull(callbackInfo);
224         return;
225     }
226     if (DOMDataStore::setReturnValue(callbackInfo.GetReturnValue(), impl))
227         return;
228     v8::Handle<v8::Object> wrapper = wrapCustom(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
229     v8SetReturnValue(callbackInfo, wrapper);
230 }
231
232 template<typename CallbackInfo>
233 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
234 {
235     ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
236     return v8SetReturnValue(callbackInfo, impl);
237 }
238
239 template<typename CallbackInfo, typename Wrappable>
240 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable*)
241 {
242     return v8SetReturnValue(callbackInfo, impl);
243 }
244
245 {% elif not is_script_wrappable %}
246 inline v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
247 {
248     ScriptWrappableBase* scriptWrappableBase = impl ? impl->toScriptWrappableBase() : 0;
249     return toV8(scriptWrappableBase, creationContext, isolate, &{{v8_class}}::wrapperTypeInfo);
250 }
251
252 template<typename CallbackInfo>
253 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
254 {
255     ScriptWrappableBase* scriptWrappableBase = impl ? impl->toScriptWrappableBase() : 0;
256     return v8SetReturnValue(callbackInfo, scriptWrappableBase, &{{v8_class}}::wrapperTypeInfo);
257 }
258
259 template<typename CallbackInfo>
260 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
261 {
262     ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
263     // Since |impl| is not ScriptWrappable, it doesn't matter much if it's the
264     // main world or not.
265     return v8SetReturnValue(callbackInfo, impl);
266 }
267
268 template<typename CallbackInfo, typename Wrappable>
269 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable*)
270 {
271     // Since |impl| is not ScriptWrappable, it doesn't matter much if it's the
272     // main world or not.
273     return v8SetReturnValue(callbackInfo, impl);
274 }
275
276 {% endif %}{# has_custom_to_v8 #}
277 {% if has_event_constructor %}
278 bool initialize{{cpp_class}}({{cpp_class}}Init&, const Dictionary&, ExceptionState&, const v8::FunctionCallbackInfo<v8::Value>& info, const String& = "");
279
280 {% endif %}
281 } // namespace blink
282 {% endfilter %}
283
284 #endif // {{v8_class}}_h