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 "V8TestInterfaceNamedConstructor.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 V8TestInterfaceNamedConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructor::domTemplate, V8TestInterfaceNamedConstructor::refObject, V8TestInterfaceNamedConstructor::derefObject, V8TestInterfaceNamedConstructor::createPersistentHandle, V8TestInterfaceNamedConstructor::toActiveDOMObject, 0, 0, V8TestInterfaceNamedConstructor::installConditionallyEnabledMethods, V8TestInterfaceNamedConstructor::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Dependent, WrapperTypeInfo::RefCountedObject };
26 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfaceNamedConstructor.h.
27 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
28 // bindings/core/v8/ScriptWrappable.h.
29 const WrapperTypeInfo& TestInterfaceNamedConstructor::s_wrapperTypeInfo = V8TestInterfaceNamedConstructor::wrapperTypeInfo;
31 namespace TestInterfaceNamedConstructorV8Internal {
33 template <typename T> void V8_USE(T) { }
35 static void TestInterfaceNamedConstructorConstructorGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
37 v8::Handle<v8::Value> data = info.Data();
38 ASSERT(data->IsExternal());
39 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
42 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::unwrap(data)));
45 static void TestInterfaceNamedConstructorForceSetAttributeOnThis(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
47 if (info.This()->IsObject())
48 v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
51 static void TestInterfaceNamedConstructorForceSetAttributeOnThisCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
53 TestInterfaceNamedConstructorV8Internal::TestInterfaceNamedConstructorForceSetAttributeOnThis(name, v8Value, info);
56 } // namespace TestInterfaceNamedConstructorV8Internal
58 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceNamedConstructorAttributes[] = {
59 {"testNamedConstructorConstructorAttribute", TestInterfaceNamedConstructorV8Internal::TestInterfaceNamedConstructorConstructorGetter, TestInterfaceNamedConstructorV8Internal::TestInterfaceNamedConstructorForceSetAttributeOnThisCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8TestNamedConstructor::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
62 const WrapperTypeInfo V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructorConstructor::domTemplate, V8TestInterfaceNamedConstructor::refObject, V8TestInterfaceNamedConstructor::derefObject, V8TestInterfaceNamedConstructor::createPersistentHandle, V8TestInterfaceNamedConstructor::toActiveDOMObject, 0, 0, V8TestInterfaceNamedConstructor::installConditionallyEnabledMethods, V8TestInterfaceNamedConstructor::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Dependent, WrapperTypeInfo::RefCountedObject };
64 static void V8TestInterfaceNamedConstructorConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
66 if (!info.IsConstructCall()) {
67 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("Audio"), info.GetIsolate());
71 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
72 v8SetReturnValue(info, info.Holder());
75 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceNamedConstructor", info.Holder(), info.GetIsolate());
76 if (UNLIKELY(info.Length() < 1)) {
77 setMinimumArityTypeError(exceptionState, 1, info.Length());
78 exceptionState.throwIfNeeded();
81 V8StringResource<> stringArg;
82 bool defaultUndefinedOptionalBooleanArg;
83 int defaultUndefinedOptionalLongArg;
84 V8StringResource<> defaultUndefinedOptionalStringArg;
85 V8StringResource<> defaultNullStringOptionalstringArg;
86 V8StringResource<> optionalStringArg;
88 TOSTRING_VOID_INTERNAL(stringArg, info[0]);
89 defaultUndefinedOptionalBooleanArg = info[1]->BooleanValue();
90 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(defaultUndefinedOptionalLongArg, toInt32(info[2], exceptionState), exceptionState);
91 TOSTRING_VOID_INTERNAL(defaultUndefinedOptionalStringArg, info[3]);
92 if (!info[4]->IsUndefined()) {
93 TOSTRING_VOID_INTERNAL(defaultNullStringOptionalstringArg, info[4]);
95 defaultNullStringOptionalstringArg = nullptr;
97 if (UNLIKELY(info.Length() <= 5)) {
98 Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
99 RefPtr<TestInterfaceNamedConstructor> impl = TestInterfaceNamedConstructor::createForJSConstructor(document, stringArg, defaultUndefinedOptionalBooleanArg, defaultUndefinedOptionalLongArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalstringArg, exceptionState);
100 if (exceptionState.hadException()) {
101 exceptionState.throwIfNeeded();
104 v8::Handle<v8::Object> wrapper = info.Holder();
105 impl->associateWithWrapper(&V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo, wrapper, info.GetIsolate());
106 v8SetReturnValue(info, wrapper);
109 TOSTRING_VOID_INTERNAL(optionalStringArg, info[5]);
111 Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
112 RefPtr<TestInterfaceNamedConstructor> impl = TestInterfaceNamedConstructor::createForJSConstructor(document, stringArg, defaultUndefinedOptionalBooleanArg, defaultUndefinedOptionalLongArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalstringArg, optionalStringArg, exceptionState);
113 if (exceptionState.hadException()) {
114 exceptionState.throwIfNeeded();
117 v8::Handle<v8::Object> wrapper = info.Holder();
118 impl->associateWithWrapper(&V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo, wrapper, info.GetIsolate());
119 v8SetReturnValue(info, wrapper);
122 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructorConstructor::domTemplate(v8::Isolate* isolate)
124 static int domTemplateKey; // This address is used for a key to look up the dom template.
125 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
126 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTemplateKey);
127 if (!result.IsEmpty())
130 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate");
131 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructorConstructorCallback);
132 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
133 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor::internalFieldCount);
134 result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor"));
135 result->Inherit(V8TestInterfaceNamedConstructor::domTemplate(isolate));
136 data->setDOMTemplate(&domTemplateKey, result);
140 static void installV8TestInterfaceNamedConstructorTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
142 functionTemplate->ReadOnlyPrototype();
144 v8::Local<v8::Signature> defaultSignature;
145 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceNamedConstructor", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceNamedConstructor::internalFieldCount,
146 V8TestInterfaceNamedConstructorAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceNamedConstructorAttributes),
150 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
151 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
153 // Custom toString template
154 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
157 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor::domTemplate(v8::Isolate* isolate)
159 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceNamedConstructorTemplate);
162 bool V8TestInterfaceNamedConstructor::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
164 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
167 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
169 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
172 TestInterfaceNamedConstructor* V8TestInterfaceNamedConstructor::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
174 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterfaceNamedConstructor>() : 0;
177 ActiveDOMObject* V8TestInterfaceNamedConstructor::toActiveDOMObject(v8::Handle<v8::Object> wrapper)
179 return toImpl(wrapper);
183 void V8TestInterfaceNamedConstructor::refObject(ScriptWrappableBase* internalPointer)
185 internalPointer->toImpl<TestInterfaceNamedConstructor>()->ref();
188 void V8TestInterfaceNamedConstructor::derefObject(ScriptWrappableBase* internalPointer)
190 internalPointer->toImpl<TestInterfaceNamedConstructor>()->deref();
193 WrapperPersistentNode* V8TestInterfaceNamedConstructor::createPersistentHandle(ScriptWrappableBase* internalPointer)
195 ASSERT_NOT_REACHED();
200 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
202 return toV8(impl, creationContext, isolate);