ddb04a4543aacb3ed2fb80512aa6c0d69d309408
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / core / V8TestSpecialOperations.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 "V8TestSpecialOperations.h"
9
10 #include "bindings/core/v8/ExceptionState.h"
11 #include "bindings/core/v8/UnionTypesCore.h"
12 #include "bindings/core/v8/V8DOMConfiguration.h"
13 #include "bindings/core/v8/V8HiddenValue.h"
14 #include "bindings/core/v8/V8Node.h"
15 #include "bindings/core/v8/V8NodeList.h"
16 #include "bindings/core/v8/V8ObjectConstructor.h"
17 #include "core/dom/ContextFeatures.h"
18 #include "core/dom/Document.h"
19 #include "core/dom/NameNodeList.h"
20 #include "core/dom/NodeList.h"
21 #include "core/dom/StaticNodeList.h"
22 #include "core/html/LabelsNodeList.h"
23 #include "platform/RuntimeEnabledFeatures.h"
24 #include "platform/TraceEvent.h"
25 #include "wtf/GetPtr.h"
26 #include "wtf/RefPtr.h"
27
28 namespace blink {
29
30 const WrapperTypeInfo V8TestSpecialOperations::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestSpecialOperations::domTemplate, V8TestSpecialOperations::refObject, V8TestSpecialOperations::derefObject, V8TestSpecialOperations::trace, 0, 0, 0, V8TestSpecialOperations::installConditionallyEnabledMethods, V8TestSpecialOperations::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::RefCountedObject };
31
32 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestSpecialOperations.h.
33 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
34 // bindings/core/v8/ScriptWrappable.h.
35 const WrapperTypeInfo& TestSpecialOperations::s_wrapperTypeInfo = V8TestSpecialOperations::wrapperTypeInfo;
36
37 namespace TestSpecialOperationsV8Internal {
38
39 static void namedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
40 {
41     if (UNLIKELY(info.Length() < 1)) {
42         V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(info.GetIsolate(), "namedItem", "TestSpecialOperations", 1, info.Length()), info.GetIsolate());
43         return;
44     }
45     TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder());
46     V8StringResource<> name;
47     {
48         TOSTRING_VOID_INTERNAL(name, info[0]);
49     }
50     NodeOrNodeList result;
51     impl->getItem(name, result);
52     v8SetReturnValue(info, result);
53 }
54
55 static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
56 {
57     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
58     TestSpecialOperationsV8Internal::namedItemMethod(info);
59     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
60 }
61
62 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
63 {
64     TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder());
65     AtomicString propertyName = toCoreAtomicString(name);
66     NodeOrNodeList result;
67     impl->getItem(propertyName, result);
68     if (result.isNull())
69         return;
70     v8SetReturnValue(info, result);
71 }
72
73 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
74 {
75     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
76     TestSpecialOperationsV8Internal::namedPropertyGetter(name, info);
77     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
78 }
79
80 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
81 {
82     TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder());
83     TOSTRING_VOID(V8StringResource<>, propertyName, name);
84     Node* propertyValue = V8Node::toImplWithTypeCheck(info.GetIsolate(), v8Value);
85     bool result = impl->anonymousNamedSetter(propertyName, propertyValue);
86     if (!result)
87         return;
88     v8SetReturnValue(info, v8Value);
89 }
90
91 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
92 {
93     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
94     TestSpecialOperationsV8Internal::namedPropertySetter(name, v8Value, info);
95     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
96 }
97
98 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
99 {
100     TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder());
101     AtomicString propertyName = toCoreAtomicString(name);
102     v8::String::Utf8Value namedProperty(name);
103     ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestSpecialOperations", info.Holder(), info.GetIsolate());
104     bool result = impl->namedPropertyQuery(propertyName, exceptionState);
105     if (exceptionState.throwIfNeeded())
106         return;
107     if (!result)
108         return;
109     v8SetReturnValueInt(info, v8::None);
110 }
111
112 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
113 {
114     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
115     TestSpecialOperationsV8Internal::namedPropertyQuery(name, info);
116     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
117 }
118
119 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
120 {
121     TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder());
122     Vector<String> names;
123     ExceptionState exceptionState(ExceptionState::EnumerationContext, "TestSpecialOperations", info.Holder(), info.GetIsolate());
124     impl->namedPropertyEnumerator(names, exceptionState);
125     if (exceptionState.throwIfNeeded())
126         return;
127     v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size());
128     for (size_t i = 0; i < names.size(); ++i)
129         v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIsolate(), names[i]));
130     v8SetReturnValue(info, v8names);
131 }
132
133 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
134 {
135     TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
136     TestSpecialOperationsV8Internal::namedPropertyEnumerator(info);
137     TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
138 }
139
140 } // namespace TestSpecialOperationsV8Internal
141
142 static const V8DOMConfiguration::MethodConfiguration V8TestSpecialOperationsMethods[] = {
143     {"namedItem", TestSpecialOperationsV8Internal::namedItemMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
144 };
145
146 static void installV8TestSpecialOperationsTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
147 {
148     functionTemplate->ReadOnlyPrototype();
149
150     v8::Local<v8::Signature> defaultSignature;
151     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestSpecialOperations", v8::Local<v8::FunctionTemplate>(), V8TestSpecialOperations::internalFieldCount,
152         0, 0,
153         0, 0,
154         V8TestSpecialOperationsMethods, WTF_ARRAY_LENGTH(V8TestSpecialOperationsMethods),
155         isolate);
156     v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
157     ALLOW_UNUSED_LOCAL(instanceTemplate);
158     v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
159     ALLOW_UNUSED_LOCAL(prototypeTemplate);
160     functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestSpecialOperationsV8Internal::namedPropertyGetterCallback, TestSpecialOperationsV8Internal::namedPropertySetterCallback, TestSpecialOperationsV8Internal::namedPropertyQueryCallback, 0, TestSpecialOperationsV8Internal::namedPropertyEnumeratorCallback);
161
162     // Custom toString template
163     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
164 }
165
166 v8::Handle<v8::FunctionTemplate> V8TestSpecialOperations::domTemplate(v8::Isolate* isolate)
167 {
168     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestSpecialOperationsTemplate);
169 }
170
171 bool V8TestSpecialOperations::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
172 {
173     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
174 }
175
176 v8::Handle<v8::Object> V8TestSpecialOperations::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
177 {
178     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
179 }
180
181 TestSpecialOperations* V8TestSpecialOperations::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
182 {
183     return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestSpecialOperations>() : 0;
184 }
185
186 void V8TestSpecialOperations::refObject(ScriptWrappableBase* scriptWrappableBase)
187 {
188     scriptWrappableBase->toImpl<TestSpecialOperations>()->ref();
189 }
190
191 void V8TestSpecialOperations::derefObject(ScriptWrappableBase* scriptWrappableBase)
192 {
193     scriptWrappableBase->toImpl<TestSpecialOperations>()->deref();
194 }
195
196 template<>
197 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperations* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
198 {
199     return toV8(impl, creationContext, isolate);
200 }
201
202 } // namespace blink