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.
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
8 #include "V8TestSpecialOperations.h"
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"
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 };
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;
37 namespace TestSpecialOperationsV8Internal {
39 static void namedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
41 if (UNLIKELY(info.Length() < 1)) {
42 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(info.GetIsolate(), "namedItem", "TestSpecialOperations", 1, info.Length()), info.GetIsolate());
45 TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder());
46 V8StringResource<> name;
48 TOSTRING_VOID_INTERNAL(name, info[0]);
50 NodeOrNodeList result;
51 impl->getItem(name, result);
52 v8SetReturnValue(info, result);
55 static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
57 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
58 TestSpecialOperationsV8Internal::namedItemMethod(info);
59 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
62 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
64 TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder());
65 AtomicString propertyName = toCoreAtomicString(name);
66 NodeOrNodeList result;
67 impl->getItem(propertyName, result);
70 v8SetReturnValue(info, result);
73 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
75 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
76 TestSpecialOperationsV8Internal::namedPropertyGetter(name, info);
77 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
80 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
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);
88 v8SetReturnValue(info, v8Value);
91 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
93 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
94 TestSpecialOperationsV8Internal::namedPropertySetter(name, v8Value, info);
95 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
98 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
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())
109 v8SetReturnValueInt(info, v8::None);
112 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
114 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
115 TestSpecialOperationsV8Internal::namedPropertyQuery(name, info);
116 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
119 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
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())
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);
133 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
135 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
136 TestSpecialOperationsV8Internal::namedPropertyEnumerator(info);
137 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
140 } // namespace TestSpecialOperationsV8Internal
142 static const V8DOMConfiguration::MethodConfiguration V8TestSpecialOperationsMethods[] = {
143 {"namedItem", TestSpecialOperationsV8Internal::namedItemMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
146 static void installV8TestSpecialOperationsTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
148 functionTemplate->ReadOnlyPrototype();
150 v8::Local<v8::Signature> defaultSignature;
151 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestSpecialOperations", v8::Local<v8::FunctionTemplate>(), V8TestSpecialOperations::internalFieldCount,
154 V8TestSpecialOperationsMethods, WTF_ARRAY_LENGTH(V8TestSpecialOperationsMethods),
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);
162 // Custom toString template
163 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
166 v8::Handle<v8::FunctionTemplate> V8TestSpecialOperations::domTemplate(v8::Isolate* isolate)
168 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestSpecialOperationsTemplate);
171 bool V8TestSpecialOperations::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
173 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
176 v8::Handle<v8::Object> V8TestSpecialOperations::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
178 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
181 TestSpecialOperations* V8TestSpecialOperations::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
183 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestSpecialOperations>() : 0;
186 void V8TestSpecialOperations::refObject(ScriptWrappableBase* scriptWrappableBase)
188 scriptWrappableBase->toImpl<TestSpecialOperations>()->ref();
191 void V8TestSpecialOperations::derefObject(ScriptWrappableBase* scriptWrappableBase)
193 scriptWrappableBase->toImpl<TestSpecialOperations>()->deref();
197 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperations* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
199 return toV8(impl, creationContext, isolate);