Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / core / V8TestInterfaceNamedConstructor.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 "V8TestInterfaceNamedConstructor.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 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 };
25
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;
30
31 namespace TestInterfaceNamedConstructorV8Internal {
32
33 static void TestInterfaceNamedConstructorConstructorGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
34 {
35     v8::Handle<v8::Value> data = info.Data();
36     ASSERT(data->IsExternal());
37     V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
38     if (!perContextData)
39         return;
40     v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::unwrap(data)));
41 }
42
43 static void TestInterfaceNamedConstructorForceSetAttributeOnThis(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
44 {
45     if (info.This()->IsObject())
46         v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
47 }
48
49 static void TestInterfaceNamedConstructorForceSetAttributeOnThisCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
50 {
51     TestInterfaceNamedConstructorV8Internal::TestInterfaceNamedConstructorForceSetAttributeOnThis(name, v8Value, info);
52 }
53
54 } // namespace TestInterfaceNamedConstructorV8Internal
55
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},
58 };
59
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 };
61
62 static void V8TestInterfaceNamedConstructorConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
63 {
64     if (!info.IsConstructCall()) {
65         V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("Audio"));
66         return;
67     }
68
69     if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
70         v8SetReturnValue(info, info.Holder());
71         return;
72     }
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();
77         return;
78     }
79     V8StringResource<> stringArg;
80     bool defaultUndefinedOptionalBooleanArg;
81     int defaultUndefinedOptionalLongArg;
82     V8StringResource<> defaultUndefinedOptionalStringArg;
83     V8StringResource<> defaultNullStringOptionalstringArg;
84     V8StringResource<> optionalStringArg;
85     {
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]);
92         } else {
93             defaultNullStringOptionalstringArg = nullptr;
94         }
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();
100                 return;
101             }
102             v8::Handle<v8::Object> wrapper = info.Holder();
103             impl->associateWithWrapper(&V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo, wrapper, info.GetIsolate());
104             v8SetReturnValue(info, wrapper);
105             return;
106         }
107         TOSTRING_VOID_INTERNAL(optionalStringArg, info[5]);
108     }
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();
113         return;
114     }
115     v8::Handle<v8::Object> wrapper = info.Holder();
116     impl->associateWithWrapper(&V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo, wrapper, info.GetIsolate());
117     v8SetReturnValue(info, wrapper);
118 }
119
120 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructorConstructor::domTemplate(v8::Isolate* isolate)
121 {
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())
126         return result;
127
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);
135     return result;
136 }
137
138 static void installV8TestInterfaceNamedConstructorTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
139 {
140     functionTemplate->ReadOnlyPrototype();
141
142     v8::Local<v8::Signature> defaultSignature;
143     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceNamedConstructor", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceNamedConstructor::internalFieldCount,
144         V8TestInterfaceNamedConstructorAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceNamedConstructorAttributes),
145         0, 0,
146         0, 0,
147         isolate);
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);
152
153     // Custom toString template
154     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
155 }
156
157 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor::domTemplate(v8::Isolate* isolate)
158 {
159     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceNamedConstructorTemplate);
160 }
161
162 bool V8TestInterfaceNamedConstructor::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
163 {
164     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
165 }
166
167 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
168 {
169     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
170 }
171
172 TestInterfaceNamedConstructor* V8TestInterfaceNamedConstructor::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
173 {
174     return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterfaceNamedConstructor>() : 0;
175 }
176
177 ActiveDOMObject* V8TestInterfaceNamedConstructor::toActiveDOMObject(v8::Handle<v8::Object> wrapper)
178 {
179     return toImpl(wrapper);
180 }
181
182 void V8TestInterfaceNamedConstructor::refObject(ScriptWrappableBase* scriptWrappableBase)
183 {
184     scriptWrappableBase->toImpl<TestInterfaceNamedConstructor>()->ref();
185 }
186
187 void V8TestInterfaceNamedConstructor::derefObject(ScriptWrappableBase* scriptWrappableBase)
188 {
189     scriptWrappableBase->toImpl<TestInterfaceNamedConstructor>()->deref();
190 }
191
192 template<>
193 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
194 {
195     return toV8(impl, creationContext, isolate);
196 }
197
198 } // namespace blink