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. 4 5// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! 6 7#include "config.h" 8#include "V8TestInterfaceEventTarget.h" 9 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" 21 22namespace blink { 23 24const WrapperTypeInfo V8TestInterfaceEventTarget::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventTarget::domTemplate, V8TestInterfaceEventTarget::refObject, V8TestInterfaceEventTarget::derefObject, V8TestInterfaceEventTarget::createPersistentHandle, 0, V8TestInterfaceEventTarget::toEventTarget, 0, V8TestInterfaceEventTarget::installConditionallyEnabledMethods, V8TestInterfaceEventTarget::installConditionallyEnabledProperties, &V8EventTarget::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::WillBeGarbageCollectedObject }; 25 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. 29const WrapperTypeInfo& TestInterfaceEventTarget::s_wrapperTypeInfo = V8TestInterfaceEventTarget::wrapperTypeInfo; 30 31namespace TestInterfaceEventTargetV8Internal { 32 33template <typename T> void V8_USE(T) { } 34 35} // namespace TestInterfaceEventTargetV8Internal 36 37const WrapperTypeInfo V8TestInterfaceEventTargetConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventTargetConstructor::domTemplate, V8TestInterfaceEventTarget::refObject, V8TestInterfaceEventTarget::derefObject, V8TestInterfaceEventTarget::createPersistentHandle, 0, V8TestInterfaceEventTarget::toEventTarget, 0, V8TestInterfaceEventTarget::installConditionallyEnabledMethods, V8TestInterfaceEventTarget::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::WillBeGarbageCollectedObject }; 38 39static void V8TestInterfaceEventTargetConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 40{ 41 if (!info.IsConstructCall()) { 42 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("Name"), info.GetIsolate()); 43 return; 44 } 45 46 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) { 47 v8SetReturnValue(info, info.Holder()); 48 return; 49 } 50 Document& document = *toDocument(currentExecutionContext(info.GetIsolate())); 51 RefPtrWillBeRawPtr<TestInterfaceEventTarget> impl = TestInterfaceEventTarget::createForJSConstructor(document); 52 v8::Handle<v8::Object> wrapper = info.Holder(); 53 impl->associateWithWrapper(&V8TestInterfaceEventTargetConstructor::wrapperTypeInfo, wrapper, info.GetIsolate()); 54 v8SetReturnValue(info, wrapper); 55} 56 57v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventTargetConstructor::domTemplate(v8::Isolate* isolate) 58{ 59 static int domTemplateKey; // This address is used for a key to look up the dom template. 60 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 61 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTemplateKey); 62 if (!result.IsEmpty()) 63 return result; 64 65 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate"); 66 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceEventTargetConstructorCallback); 67 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); 68 instanceTemplate->SetInternalFieldCount(V8TestInterfaceEventTarget::internalFieldCount); 69 result->SetClassName(v8AtomicString(isolate, "TestInterfaceEventTarget")); 70 result->Inherit(V8TestInterfaceEventTarget::domTemplate(isolate)); 71 data->setDOMTemplate(&domTemplateKey, result); 72 return result; 73} 74 75static void installV8TestInterfaceEventTargetTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) 76{ 77 functionTemplate->ReadOnlyPrototype(); 78 79 v8::Local<v8::Signature> defaultSignature; 80 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceEventTarget", V8EventTarget::domTemplate(isolate), V8TestInterfaceEventTarget::internalFieldCount, 81 0, 0, 82 0, 0, 83 0, 0, 84 isolate); 85 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate(); 86 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate(); 87 88 // Custom toString template 89 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate()); 90} 91 92v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventTarget::domTemplate(v8::Isolate* isolate) 93{ 94 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceEventTargetTemplate); 95} 96 97bool V8TestInterfaceEventTarget::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 98{ 99 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value); 100} 101 102v8::Handle<v8::Object> V8TestInterfaceEventTarget::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 103{ 104 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value); 105} 106 107TestInterfaceEventTarget* V8TestInterfaceEventTarget::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value) 108{ 109 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterfaceEventTarget>() : 0; 110} 111 112EventTarget* V8TestInterfaceEventTarget::toEventTarget(v8::Handle<v8::Object> object) 113{ 114 return toImpl(object); 115} 116 117 118void V8TestInterfaceEventTarget::refObject(ScriptWrappableBase* internalPointer) 119{ 120#if !ENABLE(OILPAN) 121 internalPointer->toImpl<TestInterfaceEventTarget>()->ref(); 122#endif 123} 124 125void V8TestInterfaceEventTarget::derefObject(ScriptWrappableBase* internalPointer) 126{ 127#if !ENABLE(OILPAN) 128 internalPointer->toImpl<TestInterfaceEventTarget>()->deref(); 129#endif 130} 131 132WrapperPersistentNode* V8TestInterfaceEventTarget::createPersistentHandle(ScriptWrappableBase* internalPointer) 133{ 134#if ENABLE(OILPAN) 135 return WrapperPersistent<TestInterfaceEventTarget>::create(internalPointer->toImpl<TestInterfaceEventTarget>()); 136#else 137 ASSERT_NOT_REACHED(); 138 return 0; 139#endif 140} 141 142template<> 143v8::Handle<v8::Value> toV8NoInline(TestInterfaceEventTarget* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 144{ 145 return toV8(impl, creationContext, isolate); 146} 147 148} // namespace blink 149