Upstream version 7.36.149.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 WebCore {
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     static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*);
31     static v8::Handle<v8::Object> findInstanceInPrototypeChain(v8::Handle<v8::Value>, v8::Isolate*);
32     static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*);
33     static {{cpp_class}}* toNative(v8::Handle<v8::Object> object)
34     {
35         return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex));
36     }
37     static {{cpp_class}}* toNativeWithTypeCheck(v8::Isolate*, v8::Handle<v8::Value>);
38     static const WrapperTypeInfo wrapperTypeInfo;
39     static void derefObject(void*);
40     {% if has_visit_dom_wrapper %}
41     static void visitDOMWrapper(void*, const v8::Persistent<v8::Object>&, v8::Isolate*);
42     {% endif %}
43     {% if is_active_dom_object %}
44     static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>);
45     {% endif %}
46     {% if is_event_target %}
47     static EventTarget* toEventTarget(v8::Handle<v8::Object>);
48     {% endif %}
49     {% if interface_name == 'Window' %}
50     static v8::Handle<v8::ObjectTemplate> getShadowObjectTemplate(v8::Isolate*);
51     {% endif %}
52     {% for method in methods if method.is_custom %}
53     {% filter conditional(method.conditional_string) %}
54     static void {{method.name}}MethodCustom(const v8::FunctionCallbackInfo<v8::Value>&);
55     {% endfilter %}
56     {% endfor %}
57     {% if constructors or has_custom_constructor or has_event_constructor %}
58     static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
59     {% endif %}
60     {% if has_custom_constructor %}
61     static void constructorCustom(const v8::FunctionCallbackInfo<v8::Value>&);
62     {% endif %}
63     {% for attribute in attributes %}
64     {% if attribute.has_custom_getter %}{# FIXME: and not attribute.implemented_by #}
65     {% filter conditional(attribute.conditional_string) %}
66     static void {{attribute.name}}AttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>&);
67     {% endfilter %}
68     {% endif %}
69     {% if attribute.has_custom_setter %}{# FIXME: and not attribute.implemented_by #}
70     {% filter conditional(attribute.conditional_string) %}
71     static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&);
72     {% endfilter %}
73     {% endif %}
74     {% endfor %}
75     {# Custom special operations #}
76     {% if indexed_property_getter and indexed_property_getter.is_custom %}
77     static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Value>&);
78     {% endif %}
79     {% if indexed_property_setter and indexed_property_setter.is_custom %}
80     static void indexedPropertySetterCustom(uint32_t, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
81     {% endif %}
82     {% if indexed_property_deleter and indexed_property_deleter.is_custom %}
83     static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Boolean>&);
84     {% endif %}
85     {% if named_property_getter and named_property_getter.is_custom %}
86     static void namedPropertyGetterCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>&);
87     {% endif %}
88     {% if named_property_setter and named_property_setter.is_custom %}
89     static void namedPropertySetterCustom(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
90     {% endif %}
91     {% if named_property_getter and
92           named_property_getter.is_custom_property_query %}
93     static void namedPropertyQueryCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Integer>&);
94     {% endif %}
95     {% if named_property_deleter and named_property_deleter.is_custom %}
96     static void namedPropertyDeleterCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Boolean>&);
97     {% endif %}
98     {% if named_property_getter and
99           named_property_getter.is_custom_property_enumerator %}
100     static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::Array>&);
101     {% endif %}
102     {# END custom special operations #}
103     {% if has_custom_legacy_call_as_function %}
104     static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&);
105     {% endif %}
106     {# Custom internal fields #}
107     {% set custom_internal_field_counter = 0 %}
108     {% if is_event_target and not is_node %}
109     {# Event listeners on DOM nodes are explicitly supported in the GC controller. #}
110     static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
111     {% set custom_internal_field_counter = custom_internal_field_counter + 1 %}
112     {% endif %}
113     {# persistentHandleIndex must be the last field, if it is present.
114        Detailed explanation: https://codereview.chromium.org/139173012
115        FIXME: Remove this internal field, and share one field for either:
116        * a persistent handle (if the object is in oilpan) or
117        * a C++ pointer to the DOM object (if the object is not in oilpan) #}
118     {% if not gc_type == 'RefCountedObject' %}
119     static const int persistentHandleIndex = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
120     {% set custom_internal_field_counter = custom_internal_field_counter + 1 %}
121     {% endif %}
122     static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
123     {# End custom internal fields #}
124     static inline void* toInternalPointer({{cpp_class}}* impl)
125     {
126         {% if parent_interface %}
127         return V8{{parent_interface}}::toInternalPointer(impl);
128         {% else %}
129         return impl;
130         {% endif %}
131     }
132
133     static inline {{cpp_class}}* fromInternalPointer(void* object)
134     {
135         {% if parent_interface %}
136         return static_cast<{{cpp_class}}*>(V8{{parent_interface}}::fromInternalPointer(object));
137         {% else %}
138         return static_cast<{{cpp_class}}*>(object);
139         {% endif %}
140     }
141     {% if interface_name == 'Window' %}
142     static bool namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType, v8::Local<v8::Value> data);
143     static bool indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data);
144     {% endif %}
145     static void installPerContextEnabledProperties(v8::Handle<v8::Object>, {{cpp_class}}*, v8::Isolate*){% if has_per_context_enabled_attributes %};
146     {% else %} { }
147     {% endif %}
148     static void installPerContextEnabledMethods(v8::Handle<v8::Object>, v8::Isolate*){% if has_per_context_enabled_methods %};
149     {% else %} { }
150     {% endif %}
151     {# Element wrappers #}
152     {% if interface_name == 'HTMLElement' %}
153     friend v8::Handle<v8::Object> createV8HTMLWrapper(HTMLElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
154     friend v8::Handle<v8::Object> createV8HTMLDirectWrapper(HTMLElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
155     {% elif interface_name == 'SVGElement' %}
156     friend v8::Handle<v8::Object> createV8SVGWrapper(SVGElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
157     friend v8::Handle<v8::Object> createV8SVGDirectWrapper(SVGElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
158     friend v8::Handle<v8::Object> createV8SVGFallbackWrapper(SVGElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
159     {% elif interface_name == 'HTMLUnknownElement' %}
160     friend v8::Handle<v8::Object> createV8HTMLFallbackWrapper(HTMLUnknownElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
161     {% elif interface_name == 'Element' %}
162     // This is a performance optimization hack. See V8Element::wrap.
163     friend v8::Handle<v8::Object> wrap(Node*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
164     {% endif %}
165
166 private:
167     {% if not has_custom_to_v8 %}
168     friend v8::Handle<v8::Object> wrap({{cpp_class}}*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
169     static v8::Handle<v8::Object> createWrapper({{pass_cpp_type}}, v8::Handle<v8::Object> creationContext, v8::Isolate*);
170     {% endif %}
171 };
172
173 {% if has_custom_to_v8 %}
174 class {{cpp_class}};
175 v8::Handle<v8::Value> toV8({{cpp_class}}*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
176
177 template<class CallbackInfo>
178 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
179 {
180     v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
181 }
182
183 template<class CallbackInfo>
184 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
185 {
186      v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
187 }
188
189 template<class CallbackInfo, class Wrappable>
190 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable*)
191 {
192      v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
193 }
194 {% else %}{# has_custom_to_v8 #}
195 {% if has_custom_wrap or special_wrap_for or is_document %}
196 v8::Handle<v8::Object> wrap({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate*);
197 {% else %}
198 inline v8::Handle<v8::Object> wrap({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
199 {
200     ASSERT(impl);
201     ASSERT(!DOMDataStore::containsWrapper<{{v8_class}}>(impl, isolate));
202     return {{v8_class}}::createWrapper(impl, creationContext, isolate);
203 }
204 {% endif %}
205
206 inline v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
207 {
208     if (UNLIKELY(!impl))
209         return v8::Null(isolate);
210     v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper<{{v8_class}}>(impl, isolate);
211     if (!wrapper.IsEmpty())
212         return wrapper;
213     return wrap(impl, creationContext, isolate);
214 }
215
216 template<typename CallbackInfo>
217 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
218 {
219     if (UNLIKELY(!impl)) {
220         v8SetReturnValueNull(callbackInfo);
221         return;
222     }
223     if (DOMDataStore::setReturnValueFromWrapper<{{v8_class}}>(callbackInfo.GetReturnValue(), impl))
224         return;
225     v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
226     v8SetReturnValue(callbackInfo, wrapper);
227 }
228
229 template<typename CallbackInfo>
230 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
231 {
232     ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
233     if (UNLIKELY(!impl)) {
234         v8SetReturnValueNull(callbackInfo);
235         return;
236     }
237     if (DOMDataStore::setReturnValueFromWrapperForMainWorld<{{v8_class}}>(callbackInfo.GetReturnValue(), impl))
238         return;
239     v8::Handle<v8::Value> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
240     v8SetReturnValue(callbackInfo, wrapper);
241 }
242
243 template<class CallbackInfo, class Wrappable>
244 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable* wrappable)
245 {
246     if (UNLIKELY(!impl)) {
247         v8SetReturnValueNull(callbackInfo);
248         return;
249     }
250     if (DOMDataStore::setReturnValueFromWrapperFast<{{v8_class}}>(callbackInfo.GetReturnValue(), impl, callbackInfo.Holder(), wrappable))
251         return;
252     v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
253     v8SetReturnValue(callbackInfo, wrapper);
254 }
255 {% endif %}{# has_custom_to_v8 #}
256
257 {% if gc_type != 'GarbageCollectedObject' %}
258 inline v8::Handle<v8::Value> toV8({{pass_cpp_type}} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
259 {
260     return toV8(impl.get(), creationContext, isolate);
261 }
262
263 template<class CallbackInfo>
264 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{pass_cpp_type}} impl)
265 {
266     v8SetReturnValue(callbackInfo, impl.get());
267 }
268
269 template<class CallbackInfo>
270 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{pass_cpp_type}} impl)
271 {
272     v8SetReturnValueForMainWorld(callbackInfo, impl.get());
273 }
274
275 template<class CallbackInfo, class Wrappable>
276 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{pass_cpp_type}} impl, Wrappable* wrappable)
277 {
278     v8SetReturnValueFast(callbackInfo, impl.get(), wrappable);
279 }
280 {% endif %}{# if gc_type != 'GarbageCollectedObject' #}
281
282 {% if has_event_constructor %}
283 bool initialize{{cpp_class}}({{cpp_class}}Init&, const Dictionary&, ExceptionState&, const v8::FunctionCallbackInfo<v8::Value>& info, const String& = "");
284
285 {% endif %}
286 }
287 {% endfilter %}
288 #endif // {{v8_class}}_h