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 "V8TestInterfaceConstructor4.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 "bindings/tests/v8/V8TestInterfaceConstructor4.h"
15 #include "core/dom/ContextFeatures.h"
16 #include "core/dom/Document.h"
17 #include "core/frame/LocalDOMWindow.h"
18 #include "platform/RuntimeEnabledFeatures.h"
19 #include "platform/TraceEvent.h"
20 #include "wtf/GetPtr.h"
21 #include "wtf/RefPtr.h"
25 static void initializeScriptWrappableForInterface(TestInterfaceConstructor4* object)
27 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
28 ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceConstructor4::wrapperTypeInfo);
35 void webCoreInitializeScriptWrappableForInterface(blink::TestInterfaceConstructor4* object)
37 blink::initializeScriptWrappableForInterface(object);
41 const WrapperTypeInfo V8TestInterfaceConstructor4::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceConstructor4::domTemplate, V8TestInterfaceConstructor4::derefObject, 0, 0, 0, V8TestInterfaceConstructor4::installConditionallyEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
43 namespace TestInterfaceConstructor4V8Internal {
45 template <typename T> void V8_USE(T) { }
47 static void constructor1(const v8::FunctionCallbackInfo<v8::Value>& info)
49 TestInterfaceConstructor4* testInterface4Arg;
52 V8RethrowTryCatchScope rethrow(block);
53 TONATIVE_VOID_INTERNAL(testInterface4Arg, V8TestInterfaceConstructor4::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
55 RefPtr<TestInterfaceConstructor4> impl = TestInterfaceConstructor4::create(testInterface4Arg);
56 v8::Handle<v8::Object> wrapper = info.Holder();
57 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor4>(impl.release(), &V8TestInterfaceConstructor4::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
58 v8SetReturnValue(info, wrapper);
61 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info)
63 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor4", info.Holder(), info.GetIsolate());
64 V8StringResource<> scalarValueStringArg;
67 V8RethrowTryCatchScope rethrow(block);
68 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(scalarValueStringArg, toScalarValueString(info[0], exceptionState), exceptionState);
70 RefPtr<TestInterfaceConstructor4> impl = TestInterfaceConstructor4::create(scalarValueStringArg);
71 v8::Handle<v8::Object> wrapper = info.Holder();
72 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor4>(impl.release(), &V8TestInterfaceConstructor4::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
73 v8SetReturnValue(info, wrapper);
76 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
78 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor4", info.Holder(), info.GetIsolate());
79 switch (std::min(1, info.Length())) {
81 if (V8TestInterfaceConstructor4::hasInstance(info[0], info.GetIsolate())) {
82 TestInterfaceConstructor4V8Internal::constructor1(info);
86 TestInterfaceConstructor4V8Internal::constructor2(info);
91 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
92 exceptionState.throwIfNeeded();
95 exceptionState.throwTypeError("No matching constructor signature.");
96 exceptionState.throwIfNeeded();
99 } // namespace TestInterfaceConstructor4V8Internal
101 void V8TestInterfaceConstructor4::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
103 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor");
104 if (!info.IsConstructCall()) {
105 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestInterfaceConstructor4"), info.GetIsolate());
109 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
110 v8SetReturnValue(info, info.Holder());
114 TestInterfaceConstructor4V8Internal::constructor(info);
117 static void installV8TestInterfaceConstructor4Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
119 functionTemplate->ReadOnlyPrototype();
121 v8::Local<v8::Signature> defaultSignature;
122 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceConstructor4", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceConstructor4::internalFieldCount,
127 functionTemplate->SetCallHandler(V8TestInterfaceConstructor4::constructorCallback);
128 functionTemplate->SetLength(1);
129 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
130 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
132 // Custom toString template
133 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
136 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor4::domTemplate(v8::Isolate* isolate)
138 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceConstructor4Template);
141 bool V8TestInterfaceConstructor4::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
143 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
146 v8::Handle<v8::Object> V8TestInterfaceConstructor4::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
148 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
151 TestInterfaceConstructor4* V8TestInterfaceConstructor4::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
153 return hasInstance(value, isolate) ? fromInternalPointer(blink::toInternalPointer(v8::Handle<v8::Object>::Cast(value))) : 0;
156 v8::Handle<v8::Object> wrap(TestInterfaceConstructor4* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
159 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor4>(impl, isolate));
160 return V8TestInterfaceConstructor4::createWrapper(impl, creationContext, isolate);
163 v8::Handle<v8::Object> V8TestInterfaceConstructor4::createWrapper(PassRefPtr<TestInterfaceConstructor4> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
166 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor4>(impl.get(), isolate));
167 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
168 const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
169 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
170 // the same object de-ref functions, though, so use that as the basis of the check.
171 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
174 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
175 if (UNLIKELY(wrapper.IsEmpty()))
178 installConditionallyEnabledProperties(wrapper, isolate);
179 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor4>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
183 void V8TestInterfaceConstructor4::derefObject(ScriptWrappableBase* internalPointer)
185 fromInternalPointer(internalPointer)->deref();
189 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor4* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
191 return toV8(impl, creationContext, isolate);