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_v8.py. DO NOT MODIFY!
8 #include "V8TestInterfaceEventTarget.h"
10 #include "bindings/core/v8/ExceptionState.h"
11 #include "bindings/core/v8/V8DOMConfiguration.h"
12 #include "bindings/core/v8/V8HiddenValue.h"
13 #include "bindings/core/v8/V8ObjectConstructor.h"
14 #include "core/dom/ContextFeatures.h"
15 #include "core/dom/Document.h"
16 #include "core/frame/LocalDOMWindow.h"
17 #include "platform/RuntimeEnabledFeatures.h"
18 #include "platform/TraceEvent.h"
19 #include "wtf/GetPtr.h"
20 #include "wtf/RefPtr.h"
24 const WrapperTypeInfo V8TestInterfaceEventTarget::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventTarget::domTemplate, V8TestInterfaceEventTarget::refObject, V8TestInterfaceEventTarget::derefObject, V8TestInterfaceEventTarget::trace, 0, V8TestInterfaceEventTarget::toEventTarget, 0, V8TestInterfaceEventTarget::installConditionallyEnabledMethods, V8TestInterfaceEventTarget::installConditionallyEnabledProperties, &V8EventTarget::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::WillBeGarbageCollectedObject };
26 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfaceEventTarget.h.
27 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
28 // bindings/core/v8/ScriptWrappable.h.
29 const WrapperTypeInfo& TestInterfaceEventTarget::s_wrapperTypeInfo = V8TestInterfaceEventTarget::wrapperTypeInfo;
31 namespace TestInterfaceEventTargetV8Internal {
33 } // namespace TestInterfaceEventTargetV8Internal
35 const WrapperTypeInfo V8TestInterfaceEventTargetConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventTargetConstructor::domTemplate, V8TestInterfaceEventTarget::refObject, V8TestInterfaceEventTarget::derefObject, V8TestInterfaceEventTarget::trace, 0, V8TestInterfaceEventTarget::toEventTarget, 0, V8TestInterfaceEventTarget::installConditionallyEnabledMethods, V8TestInterfaceEventTarget::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::WillBeGarbageCollectedObject };
37 static void V8TestInterfaceEventTargetConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
39 if (!info.IsConstructCall()) {
40 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("Name"));
44 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
45 v8SetReturnValue(info, info.Holder());
48 Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
49 RefPtrWillBeRawPtr<TestInterfaceEventTarget> impl = TestInterfaceEventTarget::createForJSConstructor(document);
50 v8::Handle<v8::Object> wrapper = info.Holder();
51 impl->associateWithWrapper(&V8TestInterfaceEventTargetConstructor::wrapperTypeInfo, wrapper, info.GetIsolate());
52 v8SetReturnValue(info, wrapper);
55 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventTargetConstructor::domTemplate(v8::Isolate* isolate)
57 static int domTemplateKey; // This address is used for a key to look up the dom template.
58 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
59 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTemplateKey);
60 if (!result.IsEmpty())
63 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate");
64 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceEventTargetConstructorCallback);
65 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
66 instanceTemplate->SetInternalFieldCount(V8TestInterfaceEventTarget::internalFieldCount);
67 result->SetClassName(v8AtomicString(isolate, "TestInterfaceEventTarget"));
68 result->Inherit(V8TestInterfaceEventTarget::domTemplate(isolate));
69 data->setDOMTemplate(&domTemplateKey, result);
73 static void installV8TestInterfaceEventTargetTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
75 functionTemplate->ReadOnlyPrototype();
77 v8::Local<v8::Signature> defaultSignature;
78 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceEventTarget", V8EventTarget::domTemplate(isolate), V8TestInterfaceEventTarget::internalFieldCount,
83 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
84 ALLOW_UNUSED_LOCAL(instanceTemplate);
85 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
86 ALLOW_UNUSED_LOCAL(prototypeTemplate);
88 // Custom toString template
89 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
92 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventTarget::domTemplate(v8::Isolate* isolate)
94 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceEventTargetTemplate);
97 bool V8TestInterfaceEventTarget::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
99 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
102 v8::Handle<v8::Object> V8TestInterfaceEventTarget::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
104 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
107 TestInterfaceEventTarget* V8TestInterfaceEventTarget::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
109 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterfaceEventTarget>() : 0;
112 EventTarget* V8TestInterfaceEventTarget::toEventTarget(v8::Handle<v8::Object> object)
114 return toImpl(object);
117 void V8TestInterfaceEventTarget::refObject(ScriptWrappableBase* scriptWrappableBase)
120 scriptWrappableBase->toImpl<TestInterfaceEventTarget>()->ref();
124 void V8TestInterfaceEventTarget::derefObject(ScriptWrappableBase* scriptWrappableBase)
127 scriptWrappableBase->toImpl<TestInterfaceEventTarget>()->deref();
132 v8::Handle<v8::Value> toV8NoInline(TestInterfaceEventTarget* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
134 return toV8(impl, creationContext, isolate);