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 "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(TestInterfaceNamedConstructor2* object)
26 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
27 ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceNamedConstructor2::wrapperTypeInfo);
34 void webCoreInitializeScriptWrappableForInterface(blink::TestInterfaceNamedConstructor2* object)
36 blink::initializeScriptWrappableForInterface(object);
40 const WrapperTypeInfo V8TestInterfaceNamedConstructor2::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructor2::domTemplate, V8TestInterfaceNamedConstructor2::derefObject, 0, 0, 0, V8TestInterfaceNamedConstructor2::installConditionallyEnabledMethods, 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::installConditionallyEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
50 static void V8TestInterfaceNamedConstructor2ConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
52 if (!info.IsConstructCall()) {
53 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("Audio"), info.GetIsolate());
57 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
58 v8SetReturnValue(info, info.Holder());
61 if (UNLIKELY(info.Length() < 1)) {
62 V8ThrowException::throwException(createMinimumArityTypeErrorForConstructor("TestInterfaceNamedConstructor2", 1, info.Length(), info.GetIsolate()), info.GetIsolate());
65 V8StringResource<> stringArg;
67 TOSTRING_VOID_INTERNAL(stringArg, info[0]);
69 RefPtr<TestInterfaceNamedConstructor2> impl = TestInterfaceNamedConstructor2::createForJSConstructor(stringArg);
70 v8::Handle<v8::Object> wrapper = info.Holder();
71 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor2>(impl.release(), &V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
72 v8SetReturnValue(info, wrapper);
75 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2Constructor::domTemplate(v8::Isolate* isolate)
77 static int domTemplateKey; // This address is used for a key to look up the dom template.
78 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
79 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTemplateKey);
80 if (!result.IsEmpty())
83 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate");
84 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructor2ConstructorCallback);
85 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
86 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor2::internalFieldCount);
87 result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor2"));
88 result->Inherit(V8TestInterfaceNamedConstructor2::domTemplate(isolate));
89 data->setDOMTemplate(&domTemplateKey, result);
93 static void installV8TestInterfaceNamedConstructor2Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
95 functionTemplate->ReadOnlyPrototype();
97 v8::Local<v8::Signature> defaultSignature;
98 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceNamedConstructor2", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceNamedConstructor2::internalFieldCount,
103 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
104 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
106 // Custom toString template
107 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
110 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2::domTemplate(v8::Isolate* isolate)
112 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceNamedConstructor2Template);
115 bool V8TestInterfaceNamedConstructor2::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
117 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
120 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor2::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
122 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
125 TestInterfaceNamedConstructor2* V8TestInterfaceNamedConstructor2::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
127 return hasInstance(value, isolate) ? fromInternalPointer(blink::toInternalPointer(v8::Handle<v8::Object>::Cast(value))) : 0;
130 v8::Handle<v8::Object> wrap(TestInterfaceNamedConstructor2* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
133 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceNamedConstructor2>(impl, isolate));
134 return V8TestInterfaceNamedConstructor2::createWrapper(impl, creationContext, isolate);
137 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor2::createWrapper(PassRefPtr<TestInterfaceNamedConstructor2> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
140 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceNamedConstructor2>(impl.get(), isolate));
141 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
142 const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
143 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
144 // the same object de-ref functions, though, so use that as the basis of the check.
145 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
148 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
149 if (UNLIKELY(wrapper.IsEmpty()))
152 installConditionallyEnabledProperties(wrapper, isolate);
153 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor2>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
157 void V8TestInterfaceNamedConstructor2::derefObject(ScriptWrappableBase* internalPointer)
159 fromInternalPointer(internalPointer)->deref();
163 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor2* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
165 return toV8(impl, creationContext, isolate);