Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / core / V8TestInterfaceConstructor3.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 "V8TestInterfaceConstructor3.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 V8TestInterfaceConstructor3::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceConstructor3::domTemplate, V8TestInterfaceConstructor3::refObject, V8TestInterfaceConstructor3::derefObject, V8TestInterfaceConstructor3::createPersistentHandle, 0, 0, 0, V8TestInterfaceConstructor3::installConditionallyEnabledMethods, V8TestInterfaceConstructor3::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::RefCountedObject };
25
26 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfaceConstructor3.h.
27 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
28 // bindings/core/v8/ScriptWrappable.h.
29 const WrapperTypeInfo& TestInterfaceConstructor3::s_wrapperTypeInfo = V8TestInterfaceConstructor3::wrapperTypeInfo;
30
31 namespace TestInterfaceConstructor3V8Internal {
32
33 template <typename T> void V8_USE(T) { }
34
35 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
36 {
37     if (UNLIKELY(info.Length() < 1)) {
38         V8ThrowException::throwException(createMinimumArityTypeErrorForConstructor("TestInterfaceConstructor3", 1, info.Length(), info.GetIsolate()), info.GetIsolate());
39         return;
40     }
41     V8StringResource<> stringArg;
42     {
43         TOSTRING_VOID_INTERNAL(stringArg, info[0]);
44     }
45     RefPtr<TestInterfaceConstructor3> impl = TestInterfaceConstructor3::create(stringArg);
46     v8::Handle<v8::Object> wrapper = info.Holder();
47     impl->associateWithWrapper(&V8TestInterfaceConstructor3::wrapperTypeInfo, wrapper, info.GetIsolate());
48     v8SetReturnValue(info, wrapper);
49 }
50
51 } // namespace TestInterfaceConstructor3V8Internal
52
53 void V8TestInterfaceConstructor3::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
54 {
55     TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor");
56     if (!info.IsConstructCall()) {
57         V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestInterfaceConstructor3"), info.GetIsolate());
58         return;
59     }
60
61     if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
62         v8SetReturnValue(info, info.Holder());
63         return;
64     }
65
66     TestInterfaceConstructor3V8Internal::constructor(info);
67 }
68
69 static void installV8TestInterfaceConstructor3Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
70 {
71     functionTemplate->ReadOnlyPrototype();
72
73     v8::Local<v8::Signature> defaultSignature;
74     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceConstructor3", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceConstructor3::internalFieldCount,
75         0, 0,
76         0, 0,
77         0, 0,
78         isolate);
79     functionTemplate->SetCallHandler(V8TestInterfaceConstructor3::constructorCallback);
80     functionTemplate->SetLength(1);
81     v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
82     v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
83
84     // Custom toString template
85     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
86 }
87
88 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor3::domTemplate(v8::Isolate* isolate)
89 {
90     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceConstructor3Template);
91 }
92
93 bool V8TestInterfaceConstructor3::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
94 {
95     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
96 }
97
98 v8::Handle<v8::Object> V8TestInterfaceConstructor3::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
99 {
100     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
101 }
102
103 TestInterfaceConstructor3* V8TestInterfaceConstructor3::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
104 {
105     return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterfaceConstructor3>() : 0;
106 }
107
108
109 void V8TestInterfaceConstructor3::refObject(ScriptWrappableBase* internalPointer)
110 {
111     internalPointer->toImpl<TestInterfaceConstructor3>()->ref();
112 }
113
114 void V8TestInterfaceConstructor3::derefObject(ScriptWrappableBase* internalPointer)
115 {
116     internalPointer->toImpl<TestInterfaceConstructor3>()->deref();
117 }
118
119 WrapperPersistentNode* V8TestInterfaceConstructor3::createPersistentHandle(ScriptWrappableBase* internalPointer)
120 {
121     ASSERT_NOT_REACHED();
122     return 0;
123 }
124
125 template<>
126 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor3* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
127 {
128     return toV8(impl, creationContext, isolate);
129 }
130
131 } // namespace blink