Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / V8TestInterface3.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 "V8TestInterface3.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/tests/v8/V8Node.h"
15 #include "core/dom/ContextFeatures.h"
16 #include "core/dom/Document.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(TestInterface3* object)
25 {
26     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
27         ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterface3::wrapperTypeInfo);
28     else
29         ASSERT_NOT_REACHED();
30 }
31
32 } // namespace blink
33
34 void webCoreInitializeScriptWrappableForInterface(blink::TestInterface3* object)
35 {
36     blink::initializeScriptWrappableForInterface(object);
37 }
38
39 namespace blink {
40 const WrapperTypeInfo V8TestInterface3::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface3::domTemplate, V8TestInterface3::derefObject, 0, 0, V8TestInterface3::visitDOMWrapper, V8TestInterface3::installConditionallyEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
41
42 namespace TestInterface3V8Internal {
43
44 template <typename T> void V8_USE(T) { }
45
46 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
47 {
48     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty");
49     V8TestInterface3::indexedPropertyGetterCustom(index, info);
50     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
51 }
52
53 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
54 {
55     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty");
56     V8TestInterface3::indexedPropertySetterCustom(index, v8Value, info);
57     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
58 }
59
60 static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info)
61 {
62     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty");
63     V8TestInterface3::indexedPropertyDeleterCustom(index, info);
64     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
65 }
66
67 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
68 {
69     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
70     V8TestInterface3::namedPropertyGetterCustom(name, info);
71     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
72 }
73
74 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
75 {
76     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
77     V8TestInterface3::namedPropertySetterCustom(name, v8Value, info);
78     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
79 }
80
81 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
82 {
83     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
84     V8TestInterface3::namedPropertyQueryCustom(name, info);
85     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
86 }
87
88 static void namedPropertyDeleterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Boolean>& info)
89 {
90     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
91     V8TestInterface3::namedPropertyDeleterCustom(name, info);
92     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
93 }
94
95 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
96 {
97     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
98     V8TestInterface3::namedPropertyEnumeratorCustom(info);
99     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
100 }
101
102 } // namespace TestInterface3V8Internal
103
104 static void installV8TestInterface3Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
105 {
106     functionTemplate->ReadOnlyPrototype();
107
108     v8::Local<v8::Signature> defaultSignature;
109     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterface3", v8::Local<v8::FunctionTemplate>(), V8TestInterface3::internalFieldCount,
110         0, 0,
111         0, 0,
112         0, 0,
113         isolate);
114     v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
115     v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
116     functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler(TestInterface3V8Internal::indexedPropertyGetterCallback, TestInterface3V8Internal::indexedPropertySetterCallback, 0, TestInterface3V8Internal::indexedPropertyDeleterCallback, indexedPropertyEnumerator<TestInterface3>);
117     functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestInterface3V8Internal::namedPropertyGetterCallback, TestInterface3V8Internal::namedPropertySetterCallback, TestInterface3V8Internal::namedPropertyQueryCallback, TestInterface3V8Internal::namedPropertyDeleterCallback, TestInterface3V8Internal::namedPropertyEnumeratorCallback);
118
119     // Custom toString template
120     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
121 }
122
123 v8::Handle<v8::FunctionTemplate> V8TestInterface3::domTemplate(v8::Isolate* isolate)
124 {
125     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterface3Template);
126 }
127
128 bool V8TestInterface3::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
129 {
130     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
131 }
132
133 v8::Handle<v8::Object> V8TestInterface3::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
134 {
135     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
136 }
137
138 TestInterface3* V8TestInterface3::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
139 {
140     return hasInstance(value, isolate) ? fromInternalPointer(blink::toInternalPointer(v8::Handle<v8::Object>::Cast(value))) : 0;
141 }
142
143 v8::Handle<v8::Object> wrap(TestInterface3* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
144 {
145     ASSERT(impl);
146     ASSERT(!DOMDataStore::containsWrapper<V8TestInterface3>(impl, isolate));
147     return V8TestInterface3::createWrapper(impl, creationContext, isolate);
148 }
149
150 v8::Handle<v8::Object> V8TestInterface3::createWrapper(PassRefPtr<TestInterface3> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
151 {
152     ASSERT(impl);
153     ASSERT(!DOMDataStore::containsWrapper<V8TestInterface3>(impl.get(), isolate));
154     if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
155         const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
156         // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
157         // the same object de-ref functions, though, so use that as the basis of the check.
158         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
159     }
160
161     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
162     if (UNLIKELY(wrapper.IsEmpty()))
163         return wrapper;
164
165     installConditionallyEnabledProperties(wrapper, isolate);
166     V8DOMWrapper::associateObjectWithWrapper<V8TestInterface3>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent);
167     return wrapper;
168 }
169
170 void V8TestInterface3::derefObject(ScriptWrappableBase* internalPointer)
171 {
172     fromInternalPointer(internalPointer)->deref();
173 }
174
175 template<>
176 v8::Handle<v8::Value> toV8NoInline(TestInterface3* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
177 {
178     return toV8(impl, creationContext, isolate);
179 }
180
181 } // namespace blink