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::trace, 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 static void TestInterfaceNamedConstructorConstructorGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
35 v8::Handle<v8::Value> data = info.Data();
36 ASSERT(data->IsExternal());
37 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
40 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::unwrap(data)));
43 static void TestInterfaceNamedConstructorForceSetAttributeOnThis(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
45 if (info.This()->IsObject())
46 v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
49 static void TestInterfaceNamedConstructorForceSetAttributeOnThisCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
51 TestInterfaceNamedConstructorV8Internal::TestInterfaceNamedConstructorForceSetAttributeOnThis(name, v8Value, info);
54 } // namespace TestInterfaceNamedConstructorV8Internal
56 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceNamedConstructorAttributes[] = {
57 {"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},
60 const WrapperTypeInfo V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructorConstructor::domTemplate, V8TestInterfaceNamedConstructor::refObject, V8TestInterfaceNamedConstructor::derefObject, V8TestInterfaceNamedConstructor::trace, V8TestInterfaceNamedConstructor::toActiveDOMObject, 0, 0, V8TestInterfaceNamedConstructor::installConditionallyEnabledMethods, V8TestInterfaceNamedConstructor::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Dependent, WrapperTypeInfo::RefCountedObject };
62 static void V8TestInterfaceNamedConstructorConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
64 if (!info.IsConstructCall()) {
65 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("Audio"));
69 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
70 v8SetReturnValue(info, info.Holder());
73 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceNamedConstructor", info.Holder(), info.GetIsolate());
74 if (UNLIKELY(info.Length() < 1)) {
75 setMinimumArityTypeError(exceptionState, 1, info.Length());
76 exceptionState.throwIfNeeded();
79 V8StringResource<> stringArg;
80 bool defaultUndefinedOptionalBooleanArg;
81 int defaultUndefinedOptionalLongArg;
82 V8StringResource<> defaultUndefinedOptionalStringArg;
83 V8StringResource<> defaultNullStringOptionalstringArg;
84 V8StringResource<> optionalStringArg;
86 TOSTRING_VOID_INTERNAL(stringArg, info[0]);
87 defaultUndefinedOptionalBooleanArg = info[1]->BooleanValue();
88 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(defaultUndefinedOptionalLongArg, toInt32(info[2], exceptionState), exceptionState);
89 TOSTRING_VOID_INTERNAL(defaultUndefinedOptionalStringArg, info[3]);
90 if (!info[4]->IsUndefined()) {
91 TOSTRING_VOID_INTERNAL(defaultNullStringOptionalstringArg, info[4]);
93 defaultNullStringOptionalstringArg = nullptr;
95 if (UNLIKELY(info.Length() <= 5)) {
96 Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
97 RefPtr<TestInterfaceNamedConstructor> impl = TestInterfaceNamedConstructor::createForJSConstructor(document, stringArg, defaultUndefinedOptionalBooleanArg, defaultUndefinedOptionalLongArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalstringArg, exceptionState);
98 if (exceptionState.hadException()) {
99 exceptionState.throwIfNeeded();
102 v8::Handle<v8::Object> wrapper = info.Holder();
103 impl->associateWithWrapper(&V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo, wrapper, info.GetIsolate());
104 v8SetReturnValue(info, wrapper);
107 TOSTRING_VOID_INTERNAL(optionalStringArg, info[5]);
109 Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
110 RefPtr<TestInterfaceNamedConstructor> impl = TestInterfaceNamedConstructor::createForJSConstructor(document, stringArg, defaultUndefinedOptionalBooleanArg, defaultUndefinedOptionalLongArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalstringArg, optionalStringArg, exceptionState);
111 if (exceptionState.hadException()) {
112 exceptionState.throwIfNeeded();
115 v8::Handle<v8::Object> wrapper = info.Holder();
116 impl->associateWithWrapper(&V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo, wrapper, info.GetIsolate());
117 v8SetReturnValue(info, wrapper);
120 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructorConstructor::domTemplate(v8::Isolate* isolate)
122 static int domTemplateKey; // This address is used for a key to look up the dom template.
123 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
124 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTemplateKey);
125 if (!result.IsEmpty())
128 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate");
129 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructorConstructorCallback);
130 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
131 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor::internalFieldCount);
132 result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor"));
133 result->Inherit(V8TestInterfaceNamedConstructor::domTemplate(isolate));
134 data->setDOMTemplate(&domTemplateKey, result);
138 static void installV8TestInterfaceNamedConstructorTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
140 functionTemplate->ReadOnlyPrototype();
142 v8::Local<v8::Signature> defaultSignature;
143 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceNamedConstructor", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceNamedConstructor::internalFieldCount,
144 V8TestInterfaceNamedConstructorAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceNamedConstructorAttributes),
148 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
149 ALLOW_UNUSED_LOCAL(instanceTemplate);
150 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
151 ALLOW_UNUSED_LOCAL(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);
182 void V8TestInterfaceNamedConstructor::refObject(ScriptWrappableBase* scriptWrappableBase)
184 scriptWrappableBase->toImpl<TestInterfaceNamedConstructor>()->ref();
187 void V8TestInterfaceNamedConstructor::derefObject(ScriptWrappableBase* scriptWrappableBase)
189 scriptWrappableBase->toImpl<TestInterfaceNamedConstructor>()->deref();
193 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
195 return toV8(impl, creationContext, isolate);