Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / V8TestSpecialOperationsAnonymous.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 "V8TestSpecialOperationsAnonymous.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 "platform/TraceEvent.h"
18 #include "wtf/GetPtr.h"
19 #include "wtf/RefPtr.h"
20
21 namespace WebCore {
22
23 static void initializeScriptWrappableForInterface(TestSpecialOperationsAnonymous* object)
24 {
25     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
26         ScriptWrappable::setTypeInfoInObject(object, &V8TestSpecialOperationsAnonymous::wrapperTypeInfo);
27     else
28         ASSERT_NOT_REACHED();
29 }
30
31 } // namespace WebCore
32
33 void webCoreInitializeScriptWrappableForInterface(WebCore::TestSpecialOperationsAnonymous* object)
34 {
35     WebCore::initializeScriptWrappableForInterface(object);
36 }
37
38 namespace WebCore {
39 const WrapperTypeInfo V8TestSpecialOperationsAnonymous::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestSpecialOperationsAnonymous::domTemplate, V8TestSpecialOperationsAnonymous::derefObject, 0, 0, 0, V8TestSpecialOperationsAnonymous::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, false };
40
41 namespace TestSpecialOperationsAnonymousV8Internal {
42
43 template <typename T> void V8_USE(T) { }
44
45 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
46 {
47     TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toNative(info.Holder());
48     String result = impl->anonymousIndexedGetter(index);
49     if (result.isNull())
50         return;
51     v8SetReturnValueString(info, result, info.GetIsolate());
52 }
53
54 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
55 {
56     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
57     TestSpecialOperationsAnonymousV8Internal::indexedPropertyGetter(index, info);
58     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
59 }
60
61 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
62 {
63     TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toNative(info.Holder());
64     V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, v8Value);
65     bool result = impl->anonymousIndexedSetter(index, propertyValue);
66     if (!result)
67         return;
68     v8SetReturnValue(info, v8Value);
69 }
70
71 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
72 {
73     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
74     TestSpecialOperationsAnonymousV8Internal::indexedPropertySetter(index, v8Value, info);
75     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
76 }
77
78 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info)
79 {
80     TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toNative(info.Holder());
81     DeleteResult result = impl->anonymousIndexedDeleter(index);
82     if (result != DeleteUnknownProperty)
83         return v8SetReturnValueBool(info, result == DeleteSuccess);
84 }
85
86 static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info)
87 {
88     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
89     TestSpecialOperationsAnonymousV8Internal::indexedPropertyDeleter(index, info);
90     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
91 }
92
93 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
94 {
95     if (info.Holder()->HasRealNamedProperty(name))
96         return;
97     if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
98         return;
99
100     TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toNative(info.Holder());
101     AtomicString propertyName = toCoreAtomicString(name);
102     String result = impl->anonymousNamedGetter(propertyName);
103     if (result.isNull())
104         return;
105     v8SetReturnValueString(info, result, info.GetIsolate());
106 }
107
108 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
109 {
110     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
111     TestSpecialOperationsAnonymousV8Internal::namedPropertyGetter(name, info);
112     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
113 }
114
115 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
116 {
117     if (info.Holder()->HasRealNamedProperty(name))
118         return;
119     if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
120         return;
121
122     TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toNative(info.Holder());
123     V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyName, name);
124     V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, v8Value);
125     bool result = impl->anonymousNamedSetter(propertyName, propertyValue);
126     if (!result)
127         return;
128     v8SetReturnValue(info, v8Value);
129 }
130
131 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
132 {
133     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
134     TestSpecialOperationsAnonymousV8Internal::namedPropertySetter(name, v8Value, info);
135     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
136 }
137
138 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
139 {
140     TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toNative(info.Holder());
141     AtomicString propertyName = toCoreAtomicString(name);
142     v8::String::Utf8Value namedProperty(name);
143     ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestSpecialOperationsAnonymous", info.Holder(), info.GetIsolate());
144     bool result = impl->namedPropertyQuery(propertyName, exceptionState);
145     if (exceptionState.throwIfNeeded())
146         return;
147     if (!result)
148         return;
149     v8SetReturnValueInt(info, v8::None);
150 }
151
152 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
153 {
154     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
155     TestSpecialOperationsAnonymousV8Internal::namedPropertyQuery(name, info);
156     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
157 }
158
159 static void namedPropertyDeleter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Boolean>& info)
160 {
161     TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toNative(info.Holder());
162     AtomicString propertyName = toCoreAtomicString(name);
163     DeleteResult result = impl->anonymousNamedDeleter(propertyName);
164     if (result != DeleteUnknownProperty)
165         return v8SetReturnValueBool(info, result == DeleteSuccess);
166 }
167
168 static void namedPropertyDeleterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Boolean>& info)
169 {
170     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
171     TestSpecialOperationsAnonymousV8Internal::namedPropertyDeleter(name, info);
172     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
173 }
174
175 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
176 {
177     TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toNative(info.Holder());
178     v8::Isolate* isolate = info.GetIsolate();
179     Vector<String> names;
180     ExceptionState exceptionState(ExceptionState::EnumerationContext, "TestSpecialOperationsAnonymous", info.Holder(), isolate);
181     impl->namedPropertyEnumerator(names, exceptionState);
182     if (exceptionState.throwIfNeeded())
183         return;
184     v8::Handle<v8::Array> v8names = v8::Array::New(isolate, names.size());
185     for (size_t i = 0; i < names.size(); ++i)
186         v8names->Set(v8::Integer::New(isolate, i), v8String(isolate, names[i]));
187     v8SetReturnValue(info, v8names);
188 }
189
190 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
191 {
192     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
193     TestSpecialOperationsAnonymousV8Internal::namedPropertyEnumerator(info);
194     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
195 }
196
197 } // namespace TestSpecialOperationsAnonymousV8Internal
198
199 static void configureV8TestSpecialOperationsAnonymousTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
200 {
201     functionTemplate->ReadOnlyPrototype();
202
203     v8::Local<v8::Signature> defaultSignature;
204     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestSpecialOperationsAnonymous", v8::Local<v8::FunctionTemplate>(), V8TestSpecialOperationsAnonymous::internalFieldCount,
205         0, 0,
206         0, 0,
207         0, 0,
208         isolate);
209     v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate();
210     v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate();
211     functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler(TestSpecialOperationsAnonymousV8Internal::indexedPropertyGetterCallback, TestSpecialOperationsAnonymousV8Internal::indexedPropertySetterCallback, 0, TestSpecialOperationsAnonymousV8Internal::indexedPropertyDeleterCallback, indexedPropertyEnumerator<TestSpecialOperationsAnonymous>);
212     functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestSpecialOperationsAnonymousV8Internal::namedPropertyGetterCallback, TestSpecialOperationsAnonymousV8Internal::namedPropertySetterCallback, TestSpecialOperationsAnonymousV8Internal::namedPropertyQueryCallback, TestSpecialOperationsAnonymousV8Internal::namedPropertyDeleterCallback, TestSpecialOperationsAnonymousV8Internal::namedPropertyEnumeratorCallback);
213
214     // Custom toString template
215     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::current()->toStringTemplate());
216 }
217
218 v8::Handle<v8::FunctionTemplate> V8TestSpecialOperationsAnonymous::domTemplate(v8::Isolate* isolate)
219 {
220     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
221     v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo));
222     if (!result.IsEmpty())
223         return result;
224
225     TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
226     result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode);
227     configureV8TestSpecialOperationsAnonymousTemplate(result, isolate);
228     data->setDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), result);
229     return result;
230 }
231
232 bool V8TestSpecialOperationsAnonymous::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
233 {
234     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
235 }
236
237 v8::Handle<v8::Object> V8TestSpecialOperationsAnonymous::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
238 {
239     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
240 }
241
242 TestSpecialOperationsAnonymous* V8TestSpecialOperationsAnonymous::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
243 {
244     return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
245 }
246
247 v8::Handle<v8::Object> V8TestSpecialOperationsAnonymous::createWrapper(PassRefPtr<TestSpecialOperationsAnonymous> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
248 {
249     ASSERT(impl);
250     ASSERT(!DOMDataStore::containsWrapper<V8TestSpecialOperationsAnonymous>(impl.get(), isolate));
251     if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
252         const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get());
253         // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
254         // the same object de-ref functions, though, so use that as the basis of the check.
255         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
256     }
257
258     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
259     if (UNLIKELY(wrapper.IsEmpty()))
260         return wrapper;
261
262     installPerContextEnabledProperties(wrapper, impl.get(), isolate);
263     V8DOMWrapper::associateObjectWithWrapper<V8TestSpecialOperationsAnonymous>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
264     return wrapper;
265 }
266
267 void V8TestSpecialOperationsAnonymous::derefObject(void* object)
268 {
269     fromInternalPointer(object)->deref();
270 }
271
272 template<>
273 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperationsAnonymous* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
274 {
275     return toV8(impl, creationContext, isolate);
276 }
277
278 } // namespace WebCore