Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / V8TestInterfaceConstructor4.cpp
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.
4
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
6
7 #include "config.h"
8 #include "V8TestInterfaceConstructor4.h"
9
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"
22
23 namespace blink {
24
25 static void initializeScriptWrappableForInterface(TestInterfaceConstructor4* object)
26 {
27     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
28         ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceConstructor4::wrapperTypeInfo);
29     else
30         ASSERT_NOT_REACHED();
31 }
32
33 } // namespace blink
34
35 void webCoreInitializeScriptWrappableForInterface(blink::TestInterfaceConstructor4* object)
36 {
37     blink::initializeScriptWrappableForInterface(object);
38 }
39
40 namespace blink {
41 const WrapperTypeInfo V8TestInterfaceConstructor4::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceConstructor4::domTemplate, V8TestInterfaceConstructor4::derefObject, 0, 0, 0, V8TestInterfaceConstructor4::installConditionallyEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
42
43 namespace TestInterfaceConstructor4V8Internal {
44
45 template <typename T> void V8_USE(T) { }
46
47 static void constructor1(const v8::FunctionCallbackInfo<v8::Value>& info)
48 {
49     TestInterfaceConstructor4* testInterface4Arg;
50     {
51         v8::TryCatch block;
52         V8RethrowTryCatchScope rethrow(block);
53         TONATIVE_VOID_INTERNAL(testInterface4Arg, V8TestInterfaceConstructor4::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
54     }
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);
59 }
60
61 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info)
62 {
63     ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor4", info.Holder(), info.GetIsolate());
64     V8StringResource<> scalarValueStringArg;
65     {
66         v8::TryCatch block;
67         V8RethrowTryCatchScope rethrow(block);
68         TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(scalarValueStringArg, toScalarValueString(info[0], exceptionState), exceptionState);
69     }
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);
74 }
75
76 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
77 {
78     ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor4", info.Holder(), info.GetIsolate());
79     switch (std::min(1, info.Length())) {
80     case 1:
81         if (V8TestInterfaceConstructor4::hasInstance(info[0], info.GetIsolate())) {
82             TestInterfaceConstructor4V8Internal::constructor1(info);
83             return;
84         }
85         if (true) {
86             TestInterfaceConstructor4V8Internal::constructor2(info);
87             return;
88         }
89         break;
90     default:
91         exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
92         exceptionState.throwIfNeeded();
93         return;
94     }
95     exceptionState.throwTypeError("No matching constructor signature.");
96     exceptionState.throwIfNeeded();
97 }
98
99 } // namespace TestInterfaceConstructor4V8Internal
100
101 void V8TestInterfaceConstructor4::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
102 {
103     TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor");
104     if (!info.IsConstructCall()) {
105         V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestInterfaceConstructor4"), info.GetIsolate());
106         return;
107     }
108
109     if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
110         v8SetReturnValue(info, info.Holder());
111         return;
112     }
113
114     TestInterfaceConstructor4V8Internal::constructor(info);
115 }
116
117 static void installV8TestInterfaceConstructor4Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
118 {
119     functionTemplate->ReadOnlyPrototype();
120
121     v8::Local<v8::Signature> defaultSignature;
122     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceConstructor4", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceConstructor4::internalFieldCount,
123         0, 0,
124         0, 0,
125         0, 0,
126         isolate);
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();
131
132     // Custom toString template
133     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
134 }
135
136 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor4::domTemplate(v8::Isolate* isolate)
137 {
138     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceConstructor4Template);
139 }
140
141 bool V8TestInterfaceConstructor4::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
142 {
143     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
144 }
145
146 v8::Handle<v8::Object> V8TestInterfaceConstructor4::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
147 {
148     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
149 }
150
151 TestInterfaceConstructor4* V8TestInterfaceConstructor4::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
152 {
153     return hasInstance(value, isolate) ? fromInternalPointer(blink::toInternalPointer(v8::Handle<v8::Object>::Cast(value))) : 0;
154 }
155
156 v8::Handle<v8::Object> wrap(TestInterfaceConstructor4* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
157 {
158     ASSERT(impl);
159     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor4>(impl, isolate));
160     return V8TestInterfaceConstructor4::createWrapper(impl, creationContext, isolate);
161 }
162
163 v8::Handle<v8::Object> V8TestInterfaceConstructor4::createWrapper(PassRefPtr<TestInterfaceConstructor4> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
164 {
165     ASSERT(impl);
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);
172     }
173
174     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
175     if (UNLIKELY(wrapper.IsEmpty()))
176         return wrapper;
177
178     installConditionallyEnabledProperties(wrapper, isolate);
179     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor4>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
180     return wrapper;
181 }
182
183 void V8TestInterfaceConstructor4::derefObject(ScriptWrappableBase* internalPointer)
184 {
185     fromInternalPointer(internalPointer)->deref();
186 }
187
188 template<>
189 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor4* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
190 {
191     return toV8(impl, creationContext, isolate);
192 }
193
194 } // namespace blink