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 {% if has_private_script %}
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(', ')}});
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);
45 static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*);
46 static v8::Handle<v8::Object> findInstanceInPrototypeChain(v8::Handle<v8::Value>, v8::Isolate*);
47 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*);
48 static {{cpp_class}}* toNative(v8::Handle<v8::Object> object)
50 return fromInternalPointer(blink::toInternalPointer(object));
52 static {{cpp_class}}* toNativeWithTypeCheck(v8::Isolate*, v8::Handle<v8::Value>);
53 static const WrapperTypeInfo wrapperTypeInfo;
54 static void derefObject(ScriptWrappableBase* internalPointer);
55 {% if has_visit_dom_wrapper %}
56 static void visitDOMWrapper(ScriptWrappableBase* internalPointer, const v8::Persistent<v8::Object>&, v8::Isolate*);
58 {% if is_active_dom_object %}
59 static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>);
61 {% if is_event_target %}
62 static EventTarget* toEventTarget(v8::Handle<v8::Object>);
64 {% if interface_name == 'Window' %}
65 static v8::Handle<v8::ObjectTemplate> getShadowObjectTemplate(v8::Isolate*);
67 {% for method in methods %}
68 {% if method.is_custom %}
69 {% filter conditional(method.conditional_string) %}
70 static void {{method.name}}MethodCustom(const v8::FunctionCallbackInfo<v8::Value>&);
74 {% if constructors or has_custom_constructor or has_event_constructor %}
75 static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
77 {% if has_custom_constructor %}
78 static void constructorCustom(const v8::FunctionCallbackInfo<v8::Value>&);
80 {% for attribute in attributes %}
81 {% if attribute.has_custom_getter %}{# FIXME: and not attribute.implemented_by #}
82 {% filter conditional(attribute.conditional_string) %}
83 static void {{attribute.name}}AttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>&);
86 {% if attribute.has_custom_setter %}{# FIXME: and not attribute.implemented_by #}
87 {% filter conditional(attribute.conditional_string) %}
88 static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&);
92 {# Custom special operations #}
93 {% if indexed_property_getter and indexed_property_getter.is_custom %}
94 static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Value>&);
96 {% if indexed_property_setter and indexed_property_setter.is_custom %}
97 static void indexedPropertySetterCustom(uint32_t, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
99 {% if indexed_property_deleter and indexed_property_deleter.is_custom %}
100 static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Boolean>&);
102 {% if named_property_getter and named_property_getter.is_custom %}
103 static void namedPropertyGetterCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>&);
105 {% if named_property_setter and named_property_setter.is_custom %}
106 static void namedPropertySetterCustom(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
108 {% if named_property_getter and
109 named_property_getter.is_custom_property_query %}
110 static void namedPropertyQueryCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Integer>&);
112 {% if named_property_deleter and named_property_deleter.is_custom %}
113 static void namedPropertyDeleterCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Boolean>&);
115 {% if named_property_getter and
116 named_property_getter.is_custom_property_enumerator %}
117 static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::Array>&);
119 {# END custom special operations #}
120 {% if has_custom_legacy_call_as_function %}
121 static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&);
123 {# Custom internal fields #}
124 {% set custom_internal_field_counter = 0 %}
125 {% if is_event_target and not is_node %}
126 {# Event listeners on DOM nodes are explicitly supported in the GC controller. #}
127 static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
128 {% set custom_internal_field_counter = custom_internal_field_counter + 1 %}
130 {# persistentHandleIndex must be the last field, if it is present.
131 Detailed explanation: https://codereview.chromium.org/139173012
132 FIXME: Remove this internal field, and share one field for either:
133 * a persistent handle (if the object is in oilpan) or
134 * a C++ pointer to the DOM object (if the object is not in oilpan) #}
135 {% if gc_type == 'GarbageCollectedObject' %}
136 static const int persistentHandleIndex = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
137 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}} + 1;
138 {% elif gc_type == 'WillBeGarbageCollectedObject' %}
140 static const int persistentHandleIndex = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
141 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}} + 1;
143 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
146 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
148 {# End custom internal fields #}
149 static inline ScriptWrappableBase* toInternalPointer({{cpp_class}}* impl)
151 {% if parent_interface %}
152 return V8{{parent_interface}}::toInternalPointer(impl);
154 return reinterpret_cast<ScriptWrappableBase*>(static_cast<void*>(impl));
158 static inline {{cpp_class}}* fromInternalPointer(ScriptWrappableBase* internalPointer)
160 {% if parent_interface %}
161 return static_cast<{{cpp_class}}*>(V8{{parent_interface}}::fromInternalPointer(internalPointer));
163 return reinterpret_cast<{{cpp_class}}*>(static_cast<void*>(internalPointer));
166 {% if interface_name == 'Window' %}
167 static bool namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType, v8::Local<v8::Value> data);
168 static bool indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data);
170 static void installConditionallyEnabledProperties(v8::Handle<v8::Object>, v8::Isolate*){% if has_conditional_attributes %};
173 static void installConditionallyEnabledMethods(v8::Handle<v8::Object>, v8::Isolate*){% if conditionally_enabled_methods %};
176 {# Element wrappers #}
177 {% if interface_name == 'HTMLElement' %}
178 friend v8::Handle<v8::Object> createV8HTMLWrapper(HTMLElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
179 friend v8::Handle<v8::Object> createV8HTMLDirectWrapper(HTMLElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
180 {% elif interface_name == 'SVGElement' %}
181 friend v8::Handle<v8::Object> createV8SVGWrapper(SVGElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
182 friend v8::Handle<v8::Object> createV8SVGDirectWrapper(SVGElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
183 friend v8::Handle<v8::Object> createV8SVGFallbackWrapper(SVGElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
184 {% elif interface_name == 'HTMLUnknownElement' %}
185 friend v8::Handle<v8::Object> createV8HTMLFallbackWrapper(HTMLUnknownElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
186 {% elif interface_name == 'Element' %}
187 // This is a performance optimization hack. See V8Element::wrap.
188 friend v8::Handle<v8::Object> wrap(Node*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
192 {% if not has_custom_to_v8 %}
193 friend v8::Handle<v8::Object> wrap({{cpp_class}}*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
194 static v8::Handle<v8::Object> createWrapper({{pass_cpp_type}}, v8::Handle<v8::Object> creationContext, v8::Isolate*);
198 {% if has_custom_to_v8 %}
200 v8::Handle<v8::Value> toV8({{cpp_class}}*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
202 template<class CallbackInfo>
203 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
205 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
208 template<class CallbackInfo>
209 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
211 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
214 template<class CallbackInfo, class Wrappable>
215 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable*)
217 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
219 {% else %}{# has_custom_to_v8 #}
220 v8::Handle<v8::Object> wrap({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate*);
222 inline v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
225 return v8::Null(isolate);
226 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper<{{v8_class}}>(impl, isolate);
227 if (!wrapper.IsEmpty())
229 return wrap(impl, creationContext, isolate);
232 template<typename CallbackInfo>
233 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
235 if (UNLIKELY(!impl)) {
236 v8SetReturnValueNull(callbackInfo);
239 if (DOMDataStore::setReturnValueFromWrapper<{{v8_class}}>(callbackInfo.GetReturnValue(), impl))
241 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
242 v8SetReturnValue(callbackInfo, wrapper);
245 template<typename CallbackInfo>
246 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
248 ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
249 if (UNLIKELY(!impl)) {
250 v8SetReturnValueNull(callbackInfo);
253 if (DOMDataStore::setReturnValueFromWrapperForMainWorld<{{v8_class}}>(callbackInfo.GetReturnValue(), impl))
255 v8::Handle<v8::Value> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
256 v8SetReturnValue(callbackInfo, wrapper);
259 template<class CallbackInfo, class Wrappable>
260 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable* wrappable)
262 if (UNLIKELY(!impl)) {
263 v8SetReturnValueNull(callbackInfo);
266 if (DOMDataStore::setReturnValueFromWrapperFast<{{v8_class}}>(callbackInfo.GetReturnValue(), impl, callbackInfo.Holder(), wrappable))
268 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
269 v8SetReturnValue(callbackInfo, wrapper);
271 {% endif %}{# has_custom_to_v8 #}
273 inline v8::Handle<v8::Value> toV8({{pass_cpp_type}} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
275 return toV8(impl.get(), creationContext, isolate);
278 template<class CallbackInfo>
279 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{pass_cpp_type}} impl)
281 v8SetReturnValue(callbackInfo, impl.get());
284 template<class CallbackInfo>
285 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{pass_cpp_type}} impl)
287 v8SetReturnValueForMainWorld(callbackInfo, impl.get());
290 template<class CallbackInfo, class Wrappable>
291 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{pass_cpp_type}} impl, Wrappable* wrappable)
293 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable);
296 {% if has_event_constructor %}
297 bool initialize{{cpp_class}}({{cpp_class}}Init&, const Dictionary&, ExceptionState&, const v8::FunctionCallbackInfo<v8::Value>& info, const String& = "");
302 #endif // {{v8_class}}_h