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 static void initializeScriptWrappableForInterface(TestInterfaceEventTarget* object)
26 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
27 ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceEventTarget::wrapperTypeInfo);
34 void webCoreInitializeScriptWrappableForInterface(blink::TestInterfaceEventTarget* object)
36 blink::initializeScriptWrappableForInterface(object);
40 const WrapperTypeInfo V8TestInterfaceEventTarget::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventTarget::domTemplate, V8TestInterfaceEventTarget::derefObject, 0, V8TestInterfaceEventTarget::toEventTarget, 0, V8TestInterfaceEventTarget::installConditionallyEnabledMethods, &V8EventTarget::wrapperTypeInfo, WrapperTypeObjectPrototype, WillBeGarbageCollectedObject };
42 namespace TestInterfaceEventTargetV8Internal {
44 template <typename T> void V8_USE(T) { }
46 } // namespace TestInterfaceEventTargetV8Internal
48 const WrapperTypeInfo V8TestInterfaceEventTargetConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventTargetConstructor::domTemplate, V8TestInterfaceEventTarget::derefObject, 0, V8TestInterfaceEventTarget::toEventTarget, 0, V8TestInterfaceEventTarget::installConditionallyEnabledMethods, 0, WrapperTypeObjectPrototype, WillBeGarbageCollectedObject };
50 static void V8TestInterfaceEventTargetConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
52 if (!info.IsConstructCall()) {
53 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("Name"), info.GetIsolate());
57 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
58 v8SetReturnValue(info, info.Holder());
61 Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
62 RefPtrWillBeRawPtr<TestInterfaceEventTarget> impl = TestInterfaceEventTarget::createForJSConstructor(document);
63 v8::Handle<v8::Object> wrapper = info.Holder();
64 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventTarget>(impl.release(), &V8TestInterfaceEventTargetConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
65 v8SetReturnValue(info, wrapper);
68 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventTargetConstructor::domTemplate(v8::Isolate* isolate)
70 static int domTemplateKey; // This address is used for a key to look up the dom template.
71 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
72 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTemplateKey);
73 if (!result.IsEmpty())
76 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate");
77 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceEventTargetConstructorCallback);
78 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
79 instanceTemplate->SetInternalFieldCount(V8TestInterfaceEventTarget::internalFieldCount);
80 result->SetClassName(v8AtomicString(isolate, "TestInterfaceEventTarget"));
81 result->Inherit(V8TestInterfaceEventTarget::domTemplate(isolate));
82 data->setDOMTemplate(&domTemplateKey, result);
86 static void installV8TestInterfaceEventTargetTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
88 functionTemplate->ReadOnlyPrototype();
90 v8::Local<v8::Signature> defaultSignature;
91 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceEventTarget", V8EventTarget::domTemplate(isolate), V8TestInterfaceEventTarget::internalFieldCount,
96 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
97 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
99 // Custom toString template
100 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
103 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventTarget::domTemplate(v8::Isolate* isolate)
105 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceEventTargetTemplate);
108 bool V8TestInterfaceEventTarget::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
110 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
113 v8::Handle<v8::Object> V8TestInterfaceEventTarget::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
115 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
118 TestInterfaceEventTarget* V8TestInterfaceEventTarget::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
120 return hasInstance(value, isolate) ? fromInternalPointer(blink::toInternalPointer(v8::Handle<v8::Object>::Cast(value))) : 0;
123 EventTarget* V8TestInterfaceEventTarget::toEventTarget(v8::Handle<v8::Object> object)
125 return toNative(object);
128 v8::Handle<v8::Object> wrap(TestInterfaceEventTarget* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
131 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceEventTarget>(impl, isolate));
132 return V8TestInterfaceEventTarget::createWrapper(impl, creationContext, isolate);
135 v8::Handle<v8::Object> V8TestInterfaceEventTarget::createWrapper(PassRefPtrWillBeRawPtr<TestInterfaceEventTarget> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
138 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceEventTarget>(impl.get(), isolate));
139 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
140 const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
141 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
142 // the same object de-ref functions, though, so use that as the basis of the check.
143 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
146 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
147 if (UNLIKELY(wrapper.IsEmpty()))
150 installConditionallyEnabledProperties(wrapper, isolate);
151 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventTarget>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
155 void V8TestInterfaceEventTarget::derefObject(ScriptWrappableBase* internalPointer)
158 fromInternalPointer(internalPointer)->deref();
159 #endif // !ENABLE(OILPAN)
163 v8::Handle<v8::Value> toV8NoInline(TestInterfaceEventTarget* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
165 return toV8(impl, creationContext, isolate);