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 {% if is_array_buffer_or_view %}
47 static {{cpp_class}}* toImpl(v8::Handle<v8::Object> object);
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)
53 return blink::toScriptWrappableBase(object)->toImpl<{{cpp_class}}>();
56 static {{cpp_class}}* toImplWithTypeCheck(v8::Isolate*, v8::Handle<v8::Value>);
57 {% if has_partial_interface %}
58 static WrapperTypeInfo wrapperTypeInfo;
60 static const WrapperTypeInfo wrapperTypeInfo;
62 static void refObject(ScriptWrappableBase*);
63 static void derefObject(ScriptWrappableBase*);
64 static void trace(Visitor* visitor, ScriptWrappableBase* scriptWrappableBase)
66 {% if gc_type == 'GarbageCollectedObject' %}
67 visitor->trace(scriptWrappableBase->toImpl<{{cpp_class}}>());
68 {% elif gc_type == 'WillBeGarbageCollectedObject' %}
70 visitor->trace(scriptWrappableBase->toImpl<{{cpp_class}}>());
74 {% if has_visit_dom_wrapper %}
75 static void visitDOMWrapper(v8::Isolate*, ScriptWrappableBase*, const v8::Persistent<v8::Object>&);
77 {% if is_active_dom_object %}
78 static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>);
80 {% if is_event_target %}
81 static EventTarget* toEventTarget(v8::Handle<v8::Object>);
83 {% if interface_name == 'Window' %}
84 static v8::Handle<v8::ObjectTemplate> getShadowObjectTemplate(v8::Isolate*);
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>&);
93 {% if constructors or has_custom_constructor or has_event_constructor %}
94 static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
96 {% if has_custom_constructor %}
97 static void constructorCustom(const v8::FunctionCallbackInfo<v8::Value>&);
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>&);
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>&);
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>&);
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>&);
118 {% if indexed_property_deleter and indexed_property_deleter.is_custom %}
119 static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Boolean>&);
121 {% if named_property_getter and named_property_getter.is_custom %}
122 static void namedPropertyGetterCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>&);
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>&);
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>&);
131 {% if named_property_deleter and named_property_deleter.is_custom %}
132 static void namedPropertyDeleterCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Boolean>&);
134 {% if named_property_getter and
135 named_property_getter.is_custom_property_enumerator %}
136 static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::Array>&);
138 {# END custom special operations #}
139 {% if has_custom_legacy_call_as_function %}
140 static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&);
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 %}
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)
158 return impl->toScriptWrappableBase();
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);
164 static void installConditionallyEnabledProperties(v8::Handle<v8::Object>, v8::Isolate*){% if has_conditional_attributes %};
167 static void installConditionallyEnabledMethods(v8::Handle<v8::Object>, v8::Isolate*){% if conditionally_enabled_methods %};
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>&));
177 {% if has_partial_interface %}
180 static InstallTemplateFunction install{{v8_class}}TemplateFunction;
184 {% if has_custom_to_v8 %}
185 v8::Handle<v8::Value> toV8({{cpp_class}}*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
187 template<typename CallbackInfo>
188 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
190 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
193 template<typename CallbackInfo>
194 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
196 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
199 template<typename CallbackInfo>
200 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, const ScriptWrappable*)
202 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
205 {% elif has_custom_wrap %}
206 v8::Handle<v8::Object> wrapCustom({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate*);
208 inline v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
211 return v8::Null(isolate);
212 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
213 if (!wrapper.IsEmpty())
216 return wrapCustom(impl, creationContext, isolate);
219 template<typename CallbackInfo>
220 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
222 if (UNLIKELY(!impl)) {
223 v8SetReturnValueNull(callbackInfo);
226 if (DOMDataStore::setReturnValue(callbackInfo.GetReturnValue(), impl))
228 v8::Handle<v8::Object> wrapper = wrapCustom(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
229 v8SetReturnValue(callbackInfo, wrapper);
232 template<typename CallbackInfo>
233 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
235 ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
236 return v8SetReturnValue(callbackInfo, impl);
239 template<typename CallbackInfo, typename Wrappable>
240 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable*)
242 return v8SetReturnValue(callbackInfo, impl);
245 {% elif not is_script_wrappable %}
246 inline v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
248 ScriptWrappableBase* scriptWrappableBase = impl ? impl->toScriptWrappableBase() : 0;
249 return toV8(scriptWrappableBase, creationContext, isolate, &{{v8_class}}::wrapperTypeInfo);
252 template<typename CallbackInfo>
253 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
255 ScriptWrappableBase* scriptWrappableBase = impl ? impl->toScriptWrappableBase() : 0;
256 return v8SetReturnValue(callbackInfo, scriptWrappableBase, &{{v8_class}}::wrapperTypeInfo);
259 template<typename CallbackInfo>
260 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
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);
268 template<typename CallbackInfo, typename Wrappable>
269 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable*)
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);
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& = "");
284 #endif // {{v8_class}}_h