Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / V8TestInterfaceNamedConstructor2.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 "V8TestInterfaceNamedConstructor2.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 "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"
21
22 namespace blink {
23
24 static void initializeScriptWrappableForInterface(TestInterfaceNamedConstructor2* object)
25 {
26     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
27         ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceNamedConstructor2::wrapperTypeInfo);
28     else
29         ASSERT_NOT_REACHED();
30 }
31
32 } // namespace blink
33
34 void webCoreInitializeScriptWrappableForInterface(blink::TestInterfaceNamedConstructor2* object)
35 {
36     blink::initializeScriptWrappableForInterface(object);
37 }
38
39 namespace blink {
40 const WrapperTypeInfo V8TestInterfaceNamedConstructor2::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructor2::domTemplate, V8TestInterfaceNamedConstructor2::derefObject, 0, 0, 0, V8TestInterfaceNamedConstructor2::installConditionallyEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
41
42 namespace TestInterfaceNamedConstructor2V8Internal {
43
44 template <typename T> void V8_USE(T) { }
45
46 } // namespace TestInterfaceNamedConstructor2V8Internal
47
48 const WrapperTypeInfo V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructor2Constructor::domTemplate, V8TestInterfaceNamedConstructor2::derefObject, 0, 0, 0, V8TestInterfaceNamedConstructor2::installConditionallyEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
49
50 static void V8TestInterfaceNamedConstructor2ConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
51 {
52     if (!info.IsConstructCall()) {
53         V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("Audio"), info.GetIsolate());
54         return;
55     }
56
57     if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
58         v8SetReturnValue(info, info.Holder());
59         return;
60     }
61     if (UNLIKELY(info.Length() < 1)) {
62         V8ThrowException::throwException(createMinimumArityTypeErrorForConstructor("TestInterfaceNamedConstructor2", 1, info.Length(), info.GetIsolate()), info.GetIsolate());
63         return;
64     }
65     V8StringResource<> stringArg;
66     {
67         TOSTRING_VOID_INTERNAL(stringArg, info[0]);
68     }
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);
73 }
74
75 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2Constructor::domTemplate(v8::Isolate* isolate)
76 {
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())
81         return result;
82
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);
90     return result;
91 }
92
93 static void installV8TestInterfaceNamedConstructor2Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
94 {
95     functionTemplate->ReadOnlyPrototype();
96
97     v8::Local<v8::Signature> defaultSignature;
98     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceNamedConstructor2", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceNamedConstructor2::internalFieldCount,
99         0, 0,
100         0, 0,
101         0, 0,
102         isolate);
103     v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
104     v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
105
106     // Custom toString template
107     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
108 }
109
110 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2::domTemplate(v8::Isolate* isolate)
111 {
112     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceNamedConstructor2Template);
113 }
114
115 bool V8TestInterfaceNamedConstructor2::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
116 {
117     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
118 }
119
120 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor2::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
121 {
122     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
123 }
124
125 TestInterfaceNamedConstructor2* V8TestInterfaceNamedConstructor2::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
126 {
127     return hasInstance(value, isolate) ? fromInternalPointer(blink::toInternalPointer(v8::Handle<v8::Object>::Cast(value))) : 0;
128 }
129
130 v8::Handle<v8::Object> wrap(TestInterfaceNamedConstructor2* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
131 {
132     ASSERT(impl);
133     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceNamedConstructor2>(impl, isolate));
134     return V8TestInterfaceNamedConstructor2::createWrapper(impl, creationContext, isolate);
135 }
136
137 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor2::createWrapper(PassRefPtr<TestInterfaceNamedConstructor2> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
138 {
139     ASSERT(impl);
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);
146     }
147
148     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
149     if (UNLIKELY(wrapper.IsEmpty()))
150         return wrapper;
151
152     installConditionallyEnabledProperties(wrapper, isolate);
153     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor2>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
154     return wrapper;
155 }
156
157 void V8TestInterfaceNamedConstructor2::derefObject(ScriptWrappableBase* internalPointer)
158 {
159     fromInternalPointer(internalPointer)->deref();
160 }
161
162 template<>
163 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor2* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
164 {
165     return toV8(impl, creationContext, isolate);
166 }
167
168 } // namespace blink