{% endif %}
static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*);
+ {% if is_array_buffer_or_view %}
+ static {{cpp_class}}* toImpl(v8::Handle<v8::Object> object);
+ {% else %}
static v8::Handle<v8::Object> findInstanceInPrototypeChain(v8::Handle<v8::Value>, v8::Isolate*);
static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*);
static {{cpp_class}}* toImpl(v8::Handle<v8::Object> object)
{
- return toImpl(blink::toScriptWrappableBase(object));
+ return blink::toScriptWrappableBase(object)->toImpl<{{cpp_class}}>();
}
+ {% endif %}
static {{cpp_class}}* toImplWithTypeCheck(v8::Isolate*, v8::Handle<v8::Value>);
+ {% if has_partial_interface %}
+ static WrapperTypeInfo wrapperTypeInfo;
+ {% else %}
static const WrapperTypeInfo wrapperTypeInfo;
- static void refObject(ScriptWrappableBase* internalPointer);
- static void derefObject(ScriptWrappableBase* internalPointer);
- static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer);
+ {% endif %}
+ static void refObject(ScriptWrappableBase*);
+ static void derefObject(ScriptWrappableBase*);
+ static void trace(Visitor* visitor, ScriptWrappableBase* scriptWrappableBase)
+ {
+ {% if gc_type == 'GarbageCollectedObject' %}
+ visitor->trace(scriptWrappableBase->toImpl<{{cpp_class}}>());
+ {% elif gc_type == 'WillBeGarbageCollectedObject' %}
+#if ENABLE(OILPAN)
+ visitor->trace(scriptWrappableBase->toImpl<{{cpp_class}}>());
+#endif
+ {% endif %}
+ }
{% if has_visit_dom_wrapper %}
- static void visitDOMWrapper(ScriptWrappableBase* internalPointer, const v8::Persistent<v8::Object>&, v8::Isolate*);
+ static void visitDOMWrapper(v8::Isolate*, ScriptWrappableBase*, const v8::Persistent<v8::Object>&);
{% endif %}
{% if is_active_dom_object %}
static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>);
FIXME: Remove this internal field, and share one field for either:
* a persistent handle (if the object is in oilpan) or
* a C++ pointer to the DOM object (if the object is not in oilpan) #}
- {% if gc_type == 'GarbageCollectedObject' %}
- static const int persistentHandleIndex = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
- static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}} + 1;
- {% elif gc_type == 'WillBeGarbageCollectedObject' %}
-#if ENABLE(OILPAN)
- static const int persistentHandleIndex = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
- static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}} + 1;
-#else
- static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
-#endif
- {% elif gc_type == 'RefCountedObject' %}
static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
- {% endif %}
{# End custom internal fields #}
static inline ScriptWrappableBase* toScriptWrappableBase({{cpp_class}}* impl)
{
return impl->toScriptWrappableBase();
}
-
- static inline {{cpp_class}}* toImpl(ScriptWrappableBase* internalPointer)
- {
- return internalPointer->toImpl<{{cpp_class}}>();
- }
{% if interface_name == 'Window' %}
static bool namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType, v8::Local<v8::Value> data);
static bool indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data);
static void installConditionallyEnabledMethods(v8::Handle<v8::Object>, v8::Isolate*){% if conditionally_enabled_methods %};
{% else %} { }
{% endif %}
+ {% if has_partial_interface %}
+ static void updateWrapperTypeInfo(InstallTemplateFunction, InstallConditionallyEnabledMethodsFunction);
+ static void install{{v8_class}}Template(v8::Handle<v8::FunctionTemplate>, v8::Isolate*);
+ {% for method in methods if method.overloads and method.overloads.has_partial_overloads %}
+ static void register{{method.name | blink_capitalize}}MethodForPartialInterface(void (*)(const v8::FunctionCallbackInfo<v8::Value>&));
+ {% endfor %}
+ {% endif %}
+ {% if has_partial_interface %}
private:
- {% if not has_custom_to_v8 and not is_script_wrappable %}
- friend v8::Handle<v8::Object> wrap({{cpp_class}}*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
- static v8::Handle<v8::Object> createWrapper({{pass_cpp_type}}, v8::Handle<v8::Object> creationContext, v8::Isolate*);
+ static InstallTemplateFunction install{{v8_class}}TemplateFunction;
{% endif %}
};
{% if has_custom_to_v8 %}
-class {{cpp_class}};
v8::Handle<v8::Value> toV8({{cpp_class}}*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
-template<class CallbackInfo>
+template<typename CallbackInfo>
inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
{
v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
}
-template<class CallbackInfo>
+template<typename CallbackInfo>
inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
{
v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
}
-template<class CallbackInfo, class Wrappable>
-inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable*)
+template<typename CallbackInfo>
+inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, const ScriptWrappable*)
{
v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
}
-{% else %}{# has_custom_to_v8 #}
-{% if is_script_wrappable %}
-inline v8::Handle<v8::Object> wrap({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
-{
- return impl->wrap(creationContext, isolate);
-}
-{% else %}
-v8::Handle<v8::Object> wrap({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate*);
-{% endif %}
+
+{% elif has_custom_wrap %}
+v8::Handle<v8::Object> wrapCustom({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate*);
inline v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
if (UNLIKELY(!impl))
return v8::Null(isolate);
- v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper<{{v8_class}}>(impl, isolate);
+ v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
if (!wrapper.IsEmpty())
return wrapper;
-{% if is_script_wrappable %}
- return impl->wrap(creationContext, isolate);
-{% else %}
- return wrap(impl, creationContext, isolate);
-{% endif %}
+ return wrapCustom(impl, creationContext, isolate);
}
template<typename CallbackInfo>
v8SetReturnValueNull(callbackInfo);
return;
}
- if (DOMDataStore::setReturnValueFromWrapper<{{v8_class}}>(callbackInfo.GetReturnValue(), impl))
+ if (DOMDataStore::setReturnValue(callbackInfo.GetReturnValue(), impl))
return;
- v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
+ v8::Handle<v8::Object> wrapper = wrapCustom(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
v8SetReturnValue(callbackInfo, wrapper);
}
inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
{
ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
- if (UNLIKELY(!impl)) {
- v8SetReturnValueNull(callbackInfo);
- return;
- }
- if (DOMDataStore::setReturnValueFromWrapperForMainWorld<{{v8_class}}>(callbackInfo.GetReturnValue(), impl))
- return;
- v8::Handle<v8::Value> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
- v8SetReturnValue(callbackInfo, wrapper);
+ return v8SetReturnValue(callbackInfo, impl);
}
-template<class CallbackInfo, class Wrappable>
-inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable* wrappable)
+template<typename CallbackInfo, typename Wrappable>
+inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable*)
{
- if (UNLIKELY(!impl)) {
- v8SetReturnValueNull(callbackInfo);
- return;
- }
- if (DOMDataStore::setReturnValueFromWrapperFast<{{v8_class}}>(callbackInfo.GetReturnValue(), impl, callbackInfo.Holder(), wrappable))
- return;
- v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
- v8SetReturnValue(callbackInfo, wrapper);
+ return v8SetReturnValue(callbackInfo, impl);
}
-{% endif %}{# has_custom_to_v8 #}
-inline v8::Handle<v8::Value> toV8({{pass_cpp_type}} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+{% elif not is_script_wrappable %}
+inline v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
- return toV8(impl.get(), creationContext, isolate);
+ ScriptWrappableBase* scriptWrappableBase = impl ? impl->toScriptWrappableBase() : 0;
+ return toV8(scriptWrappableBase, creationContext, isolate, &{{v8_class}}::wrapperTypeInfo);
}
-template<class CallbackInfo>
-inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{pass_cpp_type}} impl)
+template<typename CallbackInfo>
+inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
{
- v8SetReturnValue(callbackInfo, impl.get());
+ ScriptWrappableBase* scriptWrappableBase = impl ? impl->toScriptWrappableBase() : 0;
+ return v8SetReturnValue(callbackInfo, scriptWrappableBase, &{{v8_class}}::wrapperTypeInfo);
}
-template<class CallbackInfo>
-inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{pass_cpp_type}} impl)
+template<typename CallbackInfo>
+inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
{
- v8SetReturnValueForMainWorld(callbackInfo, impl.get());
+ ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
+ // Since |impl| is not ScriptWrappable, it doesn't matter much if it's the
+ // main world or not.
+ return v8SetReturnValue(callbackInfo, impl);
}
-template<class CallbackInfo, class Wrappable>
-inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{pass_cpp_type}} impl, Wrappable* wrappable)
+template<typename CallbackInfo, typename Wrappable>
+inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable*)
{
- v8SetReturnValueFast(callbackInfo, impl.get(), wrappable);
+ // Since |impl| is not ScriptWrappable, it doesn't matter much if it's the
+ // main world or not.
+ return v8SetReturnValue(callbackInfo, impl);
}
+{% endif %}{# has_custom_to_v8 #}
{% if has_event_constructor %}
bool initialize{{cpp_class}}({{cpp_class}}Init&, const Dictionary&, ExceptionState&, const v8::FunctionCallbackInfo<v8::Value>& info, const String& = "");
{% endif %}
} // namespace blink
{% endfilter %}
+
#endif // {{v8_class}}_h