Upstream version 7.36.149.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 "RuntimeEnabledFeatures.h"
11 #include "bindings/v8/ExceptionState.h"
12 #include "bindings/v8/V8DOMConfiguration.h"
13 #include "bindings/v8/V8HiddenValue.h"
14 #include "bindings/v8/V8ObjectConstructor.h"
15 #include "core/dom/ContextFeatures.h"
16 #include "core/dom/Document.h"
17 #include "core/frame/DOMWindow.h"
18 #include "platform/TraceEvent.h"
19 #include "wtf/GetPtr.h"
20 #include "wtf/RefPtr.h"
21
22 namespace WebCore {
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 WebCore
33
34 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceNamedConstructor2* object)
35 {
36     WebCore::initializeScriptWrappableForInterface(object);
37 }
38
39 namespace WebCore {
40 const WrapperTypeInfo V8TestInterfaceNamedConstructor2::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructor2::domTemplate, V8TestInterfaceNamedConstructor2::derefObject, 0, 0, 0, V8TestInterfaceNamedConstructor2::installPerContextEnabledMethods, 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::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
49
50 static void V8TestInterfaceNamedConstructor2ConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
51 {
52     v8::Isolate* isolate = info.GetIsolate();
53     if (!info.IsConstructCall()) {
54         throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("Audio"), isolate);
55         return;
56     }
57
58     if (ConstructorMode::current(isolate) == ConstructorMode::WrapExistingObject) {
59         v8SetReturnValue(info, info.Holder());
60         return;
61     }
62
63     Document* document = currentDOMWindow(isolate)->document();
64     ASSERT(document);
65
66     // Make sure the document is added to the DOM Node map. Otherwise, the TestInterfaceNamedConstructor2 instance
67     // may end up being the only node in the map and get garbage-collected prematurely.
68     toV8(document, info.Holder(), isolate);
69
70     if (UNLIKELY(info.Length() < 1)) {
71         throwArityTypeErrorForConstructor("TestInterfaceNamedConstructor2", 1, info.Length(), info.GetIsolate());
72         return;
73     }
74     TOSTRING_VOID(V8StringResource<>, stringArg, info[0]);
75     RefPtr<TestInterfaceNamedConstructor2> impl = TestInterfaceNamedConstructor2::createForJSConstructor(*document, stringArg);
76
77     v8::Handle<v8::Object> wrapper = info.Holder();
78     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor2>(impl.release(), &V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
79     v8SetReturnValue(info, wrapper);
80 }
81
82 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2Constructor::domTemplate(v8::Isolate* isolate)
83 {
84     static int domTemplateKey; // This address is used for a key to look up the dom template.
85     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
86     v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTemplateKey);
87     if (!result.IsEmpty())
88         return result;
89
90     TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
91     result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructor2ConstructorCallback);
92     v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
93     instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor2::internalFieldCount);
94     result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor2"));
95     result->Inherit(V8TestInterfaceNamedConstructor2::domTemplate(isolate));
96     data->setDOMTemplate(&domTemplateKey, result);
97     return result;
98 }
99
100 static void configureV8TestInterfaceNamedConstructor2Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
101 {
102     functionTemplate->ReadOnlyPrototype();
103
104     v8::Local<v8::Signature> defaultSignature;
105     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceNamedConstructor2", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceNamedConstructor2::internalFieldCount,
106         0, 0,
107         0, 0,
108         0, 0,
109         isolate);
110     v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
111     v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
112
113     // Custom toString template
114     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
115 }
116
117 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor2::domTemplate(v8::Isolate* isolate)
118 {
119     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
120     v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo));
121     if (!result.IsEmpty())
122         return result;
123
124     TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
125     result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode);
126     configureV8TestInterfaceNamedConstructor2Template(result, isolate);
127     data->setDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), result);
128     return result;
129 }
130
131 bool V8TestInterfaceNamedConstructor2::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
132 {
133     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
134 }
135
136 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor2::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
137 {
138     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
139 }
140
141 TestInterfaceNamedConstructor2* V8TestInterfaceNamedConstructor2::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
142 {
143     return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
144 }
145
146 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor2::createWrapper(PassRefPtr<TestInterfaceNamedConstructor2> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
147 {
148     ASSERT(impl);
149     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceNamedConstructor2>(impl.get(), isolate));
150     if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
151         const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
152         // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
153         // the same object de-ref functions, though, so use that as the basis of the check.
154         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
155     }
156
157     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
158     if (UNLIKELY(wrapper.IsEmpty()))
159         return wrapper;
160
161     installPerContextEnabledProperties(wrapper, impl.get(), isolate);
162     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor2>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
163     return wrapper;
164 }
165
166 void V8TestInterfaceNamedConstructor2::derefObject(void* object)
167 {
168     fromInternalPointer(object)->deref();
169 }
170
171 template<>
172 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor2* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
173 {
174     return toV8(impl, creationContext, isolate);
175 }
176
177 } // namespace WebCore