Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / core / V8TestInterfaceGarbageCollected.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 "V8TestInterfaceGarbageCollected.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/core/v8/V8TestInterfaceGarbageCollected.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 const WrapperTypeInfo V8TestInterfaceGarbageCollected::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceGarbageCollected::domTemplate, V8TestInterfaceGarbageCollected::refObject, V8TestInterfaceGarbageCollected::derefObject, V8TestInterfaceGarbageCollected::trace, 0, V8TestInterfaceGarbageCollected::toEventTarget, 0, V8TestInterfaceGarbageCollected::installConditionallyEnabledMethods, V8TestInterfaceGarbageCollected::installConditionallyEnabledProperties, &V8EventTarget::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::GarbageCollectedObject };
26
27 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfaceGarbageCollected.h.
28 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
29 // bindings/core/v8/ScriptWrappable.h.
30 const WrapperTypeInfo& TestInterfaceGarbageCollected::s_wrapperTypeInfo = V8TestInterfaceGarbageCollected::wrapperTypeInfo;
31
32 namespace TestInterfaceGarbageCollectedV8Internal {
33
34 static void attr1AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
35 {
36     v8::Handle<v8::Object> holder = info.Holder();
37     TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(holder);
38     v8SetReturnValueFast(info, WTF::getPtr(impl->attr1()), impl);
39 }
40
41 static void attr1AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
42 {
43     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
44     TestInterfaceGarbageCollectedV8Internal::attr1AttributeGetter(info);
45     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
46 }
47
48 static void attr1AttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
49 {
50     v8::Handle<v8::Object> holder = info.Holder();
51     TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(holder);
52     TestInterfaceGarbageCollected* cppValue = V8TestInterfaceGarbageCollected::toImplWithTypeCheck(info.GetIsolate(), v8Value);
53     impl->setAttr1(WTF::getPtr(cppValue));
54 }
55
56 static void attr1AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
57 {
58     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
59     TestInterfaceGarbageCollectedV8Internal::attr1AttributeSetter(v8Value, info);
60     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
61 }
62
63 static void funcMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
64 {
65     if (UNLIKELY(info.Length() < 1)) {
66         V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(info.GetIsolate(), "func", "TestInterfaceGarbageCollected", 1, info.Length()), info.GetIsolate());
67         return;
68     }
69     TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder());
70     TestInterfaceGarbageCollected* arg;
71     {
72         arg = V8TestInterfaceGarbageCollected::toImplWithTypeCheck(info.GetIsolate(), info[0]);
73     }
74     impl->func(arg);
75 }
76
77 static void funcMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
78 {
79     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
80     TestInterfaceGarbageCollectedV8Internal::funcMethod(info);
81     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
82 }
83
84 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
85 {
86     if (UNLIKELY(info.Length() < 1)) {
87         V8ThrowException::throwException(createMinimumArityTypeErrorForConstructor(info.GetIsolate(), "TestInterfaceGarbageCollected", 1, info.Length()), info.GetIsolate());
88         return;
89     }
90     V8StringResource<> str;
91     {
92         TOSTRING_VOID_INTERNAL(str, info[0]);
93     }
94     RawPtr<TestInterfaceGarbageCollected> impl = TestInterfaceGarbageCollected::create(str);
95     v8::Handle<v8::Object> wrapper = info.Holder();
96     impl->associateWithWrapper(&V8TestInterfaceGarbageCollected::wrapperTypeInfo, wrapper, info.GetIsolate());
97     v8SetReturnValue(info, wrapper);
98 }
99
100 } // namespace TestInterfaceGarbageCollectedV8Internal
101
102 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceGarbageCollectedAttributes[] = {
103     {"attr1", TestInterfaceGarbageCollectedV8Internal::attr1AttributeGetterCallback, TestInterfaceGarbageCollectedV8Internal::attr1AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
104 };
105
106 static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceGarbageCollectedMethods[] = {
107     {"func", TestInterfaceGarbageCollectedV8Internal::funcMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
108 };
109
110 void V8TestInterfaceGarbageCollected::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
111 {
112     TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor");
113     if (!info.IsConstructCall()) {
114         V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("TestInterfaceGarbageCollected"));
115         return;
116     }
117
118     if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
119         v8SetReturnValue(info, info.Holder());
120         return;
121     }
122
123     TestInterfaceGarbageCollectedV8Internal::constructor(info);
124 }
125
126 static void installV8TestInterfaceGarbageCollectedTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
127 {
128     functionTemplate->ReadOnlyPrototype();
129
130     v8::Local<v8::Signature> defaultSignature;
131     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceGarbageCollected", V8EventTarget::domTemplate(isolate), V8TestInterfaceGarbageCollected::internalFieldCount,
132         V8TestInterfaceGarbageCollectedAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceGarbageCollectedAttributes),
133         0, 0,
134         V8TestInterfaceGarbageCollectedMethods, WTF_ARRAY_LENGTH(V8TestInterfaceGarbageCollectedMethods),
135         isolate);
136     functionTemplate->SetCallHandler(V8TestInterfaceGarbageCollected::constructorCallback);
137     functionTemplate->SetLength(1);
138     v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
139     ALLOW_UNUSED_LOCAL(instanceTemplate);
140     v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
141     ALLOW_UNUSED_LOCAL(prototypeTemplate);
142
143     // Custom toString template
144     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
145 }
146
147 v8::Handle<v8::FunctionTemplate> V8TestInterfaceGarbageCollected::domTemplate(v8::Isolate* isolate)
148 {
149     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceGarbageCollectedTemplate);
150 }
151
152 bool V8TestInterfaceGarbageCollected::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
153 {
154     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
155 }
156
157 v8::Handle<v8::Object> V8TestInterfaceGarbageCollected::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
158 {
159     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
160 }
161
162 TestInterfaceGarbageCollected* V8TestInterfaceGarbageCollected::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
163 {
164     return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterfaceGarbageCollected>() : 0;
165 }
166
167 EventTarget* V8TestInterfaceGarbageCollected::toEventTarget(v8::Handle<v8::Object> object)
168 {
169     return toImpl(object);
170 }
171
172 void V8TestInterfaceGarbageCollected::refObject(ScriptWrappableBase* scriptWrappableBase)
173 {
174 }
175
176 void V8TestInterfaceGarbageCollected::derefObject(ScriptWrappableBase* scriptWrappableBase)
177 {
178 }
179
180 template<>
181 v8::Handle<v8::Value> toV8NoInline(TestInterfaceGarbageCollected* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
182 {
183     return toV8(impl, creationContext, isolate);
184 }
185
186 } // namespace blink