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.
5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY!
10 {% filter conditional(conditional_string) %}
11 {% for filename in header_includes %}
12 #include "{{filename}}"
17 {% if has_event_constructor %}
20 {% if named_constructor %}
21 class {{v8_class}}Constructor {
23 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*);
24 static const WrapperTypeInfo wrapperTypeInfo;
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)
35 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex));
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*);
43 {% if is_active_dom_object %}
44 static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>);
46 {% if is_event_target %}
47 static EventTarget* toEventTarget(v8::Handle<v8::Object>);
49 {% if interface_name == 'Window' %}
50 static v8::Handle<v8::ObjectTemplate> getShadowObjectTemplate(v8::Isolate*);
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>&);
57 {% if constructors or has_custom_constructor or has_event_constructor %}
58 static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
60 {% if has_custom_constructor %}
61 static void constructorCustom(const v8::FunctionCallbackInfo<v8::Value>&);
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>&);
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>&);
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>&);
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>&);
82 {% if indexed_property_deleter and indexed_property_deleter.is_custom %}
83 static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Boolean>&);
85 {% if named_property_getter and named_property_getter.is_custom %}
86 static void namedPropertyGetterCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>&);
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>&);
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>&);
95 {% if named_property_deleter and named_property_deleter.is_custom %}
96 static void namedPropertyDeleterCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Boolean>&);
98 {% if named_property_getter and
99 named_property_getter.is_custom_property_enumerator %}
100 static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::Array>&);
102 {# END custom special operations #}
103 {% if has_custom_legacy_call_as_function %}
104 static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&);
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 %}
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 %}
122 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
123 {# End custom internal fields #}
124 static inline void* toInternalPointer({{cpp_class}}* impl)
126 {% if parent_interface %}
127 return V8{{parent_interface}}::toInternalPointer(impl);
133 static inline {{cpp_class}}* fromInternalPointer(void* object)
135 {% if parent_interface %}
136 return static_cast<{{cpp_class}}*>(V8{{parent_interface}}::fromInternalPointer(object));
138 return static_cast<{{cpp_class}}*>(object);
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);
145 static void installPerContextEnabledProperties(v8::Handle<v8::Object>, {{cpp_class}}*, v8::Isolate*){% if has_per_context_enabled_attributes %};
148 static void installPerContextEnabledMethods(v8::Handle<v8::Object>, v8::Isolate*){% if has_per_context_enabled_methods %};
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*);
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*);
173 {% if has_custom_to_v8 %}
175 v8::Handle<v8::Value> toV8({{cpp_class}}*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
177 template<class CallbackInfo>
178 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
180 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
183 template<class CallbackInfo>
184 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
186 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
189 template<class CallbackInfo, class Wrappable>
190 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable*)
192 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
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*);
198 inline v8::Handle<v8::Object> wrap({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
201 ASSERT(!DOMDataStore::containsWrapper<{{v8_class}}>(impl, isolate));
202 return {{v8_class}}::createWrapper(impl, creationContext, isolate);
206 inline v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
209 return v8::Null(isolate);
210 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper<{{v8_class}}>(impl, isolate);
211 if (!wrapper.IsEmpty())
213 return wrap(impl, creationContext, isolate);
216 template<typename CallbackInfo>
217 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
219 if (UNLIKELY(!impl)) {
220 v8SetReturnValueNull(callbackInfo);
223 if (DOMDataStore::setReturnValueFromWrapper<{{v8_class}}>(callbackInfo.GetReturnValue(), impl))
225 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
226 v8SetReturnValue(callbackInfo, wrapper);
229 template<typename CallbackInfo>
230 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
232 ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
233 if (UNLIKELY(!impl)) {
234 v8SetReturnValueNull(callbackInfo);
237 if (DOMDataStore::setReturnValueFromWrapperForMainWorld<{{v8_class}}>(callbackInfo.GetReturnValue(), impl))
239 v8::Handle<v8::Value> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
240 v8SetReturnValue(callbackInfo, wrapper);
243 template<class CallbackInfo, class Wrappable>
244 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable* wrappable)
246 if (UNLIKELY(!impl)) {
247 v8SetReturnValueNull(callbackInfo);
250 if (DOMDataStore::setReturnValueFromWrapperFast<{{v8_class}}>(callbackInfo.GetReturnValue(), impl, callbackInfo.Holder(), wrappable))
252 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
253 v8SetReturnValue(callbackInfo, wrapper);
255 {% endif %}{# has_custom_to_v8 #}
257 {% if gc_type != 'GarbageCollectedObject' %}
258 inline v8::Handle<v8::Value> toV8({{pass_cpp_type}} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
260 return toV8(impl.get(), creationContext, isolate);
263 template<class CallbackInfo>
264 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{pass_cpp_type}} impl)
266 v8SetReturnValue(callbackInfo, impl.get());
269 template<class CallbackInfo>
270 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{pass_cpp_type}} impl)
272 v8SetReturnValueForMainWorld(callbackInfo, impl.get());
275 template<class CallbackInfo, class Wrappable>
276 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{pass_cpp_type}} impl, Wrappable* wrappable)
278 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable);
280 {% endif %}{# if gc_type != 'GarbageCollectedObject' #}
282 {% if has_event_constructor %}
283 bool initialize{{cpp_class}}({{cpp_class}}Init&, const Dictionary&, ExceptionState&, const v8::FunctionCallbackInfo<v8::Value>& info, const String& = "");
288 #endif // {{v8_class}}_h