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 "V8TestInterfaceNamedConstructor2.h"
10 #include "RuntimeEnabledFeatures.h"
11 #include "bindings/v8/ExceptionState.h"
12 #include "bindings/v8/V8DOMConfiguration.h"
13 #include "bindings/v8/V8HiddenValue.h"
14 #include "bindings/v8/V8ObjectConstructor.h"
15 #include "core/dom/ContextFeatures.h"
16 #include "core/dom/Document.h"
17 #include "core/frame/DOMWindow.h"
18 #include "platform/TraceEvent.h"
19 #include "wtf/GetPtr.h"
20 #include "wtf/RefPtr.h"
24 static void initializeScriptWrappableForInterface(TestInterfaceNamedConstructor2* object)
26 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
27 ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceNamedConstructor2::wrapperTypeInfo);
32 } // namespace WebCore
34 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceNamedConstructor2* object)
36 WebCore::initializeScriptWrappableForInterface(object);
40 const WrapperTypeInfo V8TestInterfaceNamedConstructor2::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructor2::domTemplate, V8TestInterfaceNamedConstructor2::derefObject, 0, 0, 0, V8TestInterfaceNamedConstructor2::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
42 namespace TestInterfaceNamedConstructor2V8Internal {
44 template <typename T> void V8_USE(T) { }
46 } // namespace TestInterfaceNamedConstructor2V8Internal
48 const WrapperTypeInfo V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructor2Constructor::domTemplate, V8TestInterfaceNamedConstructor2::derefObject, 0, 0, 0, V8TestInterfaceNamedConstructor2::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
50 static void V8TestInterfaceNamedConstructor2ConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
52 v8::Isolate* isolate = info.GetIsolate();
53 if (!info.IsConstructCall()) {
54 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("Audio"), isolate);
58 if (ConstructorMode::current(isolate) == ConstructorMode::WrapExistingObject) {
59 v8SetReturnValue(info, info.Holder());
63 Document* document = currentDOMWindow(isolate)->document();
66 // Make sure the document is added to the DOM Node map. Otherwise, the TestInterfaceNamedConstructor2 instance
67 // may end up being the only node in the map and get garbage-collected prematurely.
68 toV8(document, info.Holder(), isolate);
70 if (UNLIKELY(info.Length() < 1)) {
71 throwArityTypeErrorForConstructor("TestInterfaceNamedConstructor2", 1, info.Length(), info.GetIsolate());
74 TOSTRING_VOID(V8StringResource<>, stringArg, info[0]);
75 RefPtr<TestInterfaceNamedConstructor2> impl = TestInterfaceNamedConstructor2::createForJSConstructor(*document, stringArg);
77 v8::Handle<v8::Object> wrapper = info.Holder();
78 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor2>(impl.release(), &V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
79 v8SetReturnValue(info, wrapper);
82 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2Constructor::domTemplate(v8::Isolate* isolate)
84 static int domTemplateKey; // This address is used for a key to look up the dom template.
85 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
86 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTemplateKey);
87 if (!result.IsEmpty())
90 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
91 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructor2ConstructorCallback);
92 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
93 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor2::internalFieldCount);
94 result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor2"));
95 result->Inherit(V8TestInterfaceNamedConstructor2::domTemplate(isolate));
96 data->setDOMTemplate(&domTemplateKey, result);
100 static void configureV8TestInterfaceNamedConstructor2Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
102 functionTemplate->ReadOnlyPrototype();
104 v8::Local<v8::Signature> defaultSignature;
105 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceNamedConstructor2", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceNamedConstructor2::internalFieldCount,
110 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
111 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
113 // Custom toString template
114 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
117 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2::domTemplate(v8::Isolate* isolate)
119 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
120 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo));
121 if (!result.IsEmpty())
124 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
125 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode);
126 configureV8TestInterfaceNamedConstructor2Template(result, isolate);
127 data->setDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), result);
131 bool V8TestInterfaceNamedConstructor2::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
133 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
136 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor2::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
138 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
141 TestInterfaceNamedConstructor2* V8TestInterfaceNamedConstructor2::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
143 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
146 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor2::createWrapper(PassRefPtr<TestInterfaceNamedConstructor2> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
149 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceNamedConstructor2>(impl.get(), isolate));
150 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
151 const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
152 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
153 // the same object de-ref functions, though, so use that as the basis of the check.
154 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
157 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
158 if (UNLIKELY(wrapper.IsEmpty()))
161 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
162 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor2>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
166 void V8TestInterfaceNamedConstructor2::derefObject(void* object)
168 fromInternalPointer(object)->deref();
172 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor2* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
174 return toV8(impl, creationContext, isolate);
177 } // namespace WebCore