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/V8DOMConfiguration.h"
12 #include "bindings/core/v8/V8HiddenValue.h"
13 #include "bindings/core/v8/V8NodeList.h"
14 #include "bindings/core/v8/V8ObjectConstructor.h"
15 #include "bindings/tests/v8/V8Node.h"
16 #include "core/dom/ContextFeatures.h"
17 #include "core/dom/Document.h"
18 #include "core/dom/NameNodeList.h"
19 #include "core/dom/NodeList.h"
20 #include "core/dom/StaticNodeList.h"
21 #include "core/html/LabelsNodeList.h"
22 #include "platform/RuntimeEnabledFeatures.h"
23 #include "platform/TraceEvent.h"
24 #include "wtf/GetPtr.h"
25 #include "wtf/RefPtr.h"
29 static void initializeScriptWrappableForInterface(TestSpecialOperations* object)
31 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
32 ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestSpecialOperations::wrapperTypeInfo);
39 void webCoreInitializeScriptWrappableForInterface(blink::TestSpecialOperations* object)
41 blink::initializeScriptWrappableForInterface(object);
45 const WrapperTypeInfo V8TestSpecialOperations::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestSpecialOperations::domTemplate, V8TestSpecialOperations::derefObject, 0, 0, 0, V8TestSpecialOperations::installConditionallyEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
47 namespace TestSpecialOperationsV8Internal {
49 template <typename T> void V8_USE(T) { }
51 static void namedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
53 if (UNLIKELY(info.Length() < 1)) {
54 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod("namedItem", "TestSpecialOperations", 1, info.Length(), info.GetIsolate()), info.GetIsolate());
57 TestSpecialOperations* impl = V8TestSpecialOperations::toNative(info.Holder());
58 V8StringResource<> name;
60 TOSTRING_VOID_INTERNAL(name, info[0]);
62 RefPtrWillBeRawPtr<Node> result0;
63 RefPtrWillBeRawPtr<NodeList> result1;
64 impl->getItem(name, result0, result1);
66 v8SetReturnValue(info, result0.release());
70 v8SetReturnValue(info, result1.release());
73 v8SetReturnValueNull(info);
76 static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
78 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
79 TestSpecialOperationsV8Internal::namedItemMethod(info);
80 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
83 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
85 TestSpecialOperations* impl = V8TestSpecialOperations::toNative(info.Holder());
86 AtomicString propertyName = toCoreAtomicString(name);
87 RefPtrWillBeRawPtr<Node> result0;
88 RefPtrWillBeRawPtr<NodeList> result1;
89 impl->getItem(propertyName, result0, result1);
90 if (!(result0 || result1))
93 v8SetReturnValue(info, result0.release());
97 v8SetReturnValue(info, result1.release());
100 ASSERT_NOT_REACHED();
103 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
105 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
106 TestSpecialOperationsV8Internal::namedPropertyGetter(name, info);
107 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
110 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
112 TestSpecialOperations* impl = V8TestSpecialOperations::toNative(info.Holder());
113 TOSTRING_VOID(V8StringResource<>, propertyName, name);
114 TONATIVE_VOID(Node*, propertyValue, V8Node::toNativeWithTypeCheck(info.GetIsolate(), v8Value));
115 bool result = impl->anonymousNamedSetter(propertyName, propertyValue);
118 v8SetReturnValue(info, v8Value);
121 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
123 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
124 TestSpecialOperationsV8Internal::namedPropertySetter(name, v8Value, info);
125 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
128 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
130 TestSpecialOperations* impl = V8TestSpecialOperations::toNative(info.Holder());
131 AtomicString propertyName = toCoreAtomicString(name);
132 v8::String::Utf8Value namedProperty(name);
133 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestSpecialOperations", info.Holder(), info.GetIsolate());
134 bool result = impl->namedPropertyQuery(propertyName, exceptionState);
135 if (exceptionState.throwIfNeeded())
139 v8SetReturnValueInt(info, v8::None);
142 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
144 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
145 TestSpecialOperationsV8Internal::namedPropertyQuery(name, info);
146 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
149 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
151 TestSpecialOperations* impl = V8TestSpecialOperations::toNative(info.Holder());
152 Vector<String> names;
153 ExceptionState exceptionState(ExceptionState::EnumerationContext, "TestSpecialOperations", info.Holder(), info.GetIsolate());
154 impl->namedPropertyEnumerator(names, exceptionState);
155 if (exceptionState.throwIfNeeded())
157 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size());
158 for (size_t i = 0; i < names.size(); ++i)
159 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIsolate(), names[i]));
160 v8SetReturnValue(info, v8names);
163 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
165 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
166 TestSpecialOperationsV8Internal::namedPropertyEnumerator(info);
167 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
170 } // namespace TestSpecialOperationsV8Internal
172 static const V8DOMConfiguration::MethodConfiguration V8TestSpecialOperationsMethods[] = {
173 {"namedItem", TestSpecialOperationsV8Internal::namedItemMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
176 static void installV8TestSpecialOperationsTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
178 functionTemplate->ReadOnlyPrototype();
180 v8::Local<v8::Signature> defaultSignature;
181 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestSpecialOperations", v8::Local<v8::FunctionTemplate>(), V8TestSpecialOperations::internalFieldCount,
184 V8TestSpecialOperationsMethods, WTF_ARRAY_LENGTH(V8TestSpecialOperationsMethods),
186 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
187 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
188 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestSpecialOperationsV8Internal::namedPropertyGetterCallback, TestSpecialOperationsV8Internal::namedPropertySetterCallback, TestSpecialOperationsV8Internal::namedPropertyQueryCallback, 0, TestSpecialOperationsV8Internal::namedPropertyEnumeratorCallback);
190 // Custom toString template
191 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
194 v8::Handle<v8::FunctionTemplate> V8TestSpecialOperations::domTemplate(v8::Isolate* isolate)
196 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestSpecialOperationsTemplate);
199 bool V8TestSpecialOperations::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
201 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
204 v8::Handle<v8::Object> V8TestSpecialOperations::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
206 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
209 TestSpecialOperations* V8TestSpecialOperations::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
211 return hasInstance(value, isolate) ? fromInternalPointer(blink::toInternalPointer(v8::Handle<v8::Object>::Cast(value))) : 0;
214 v8::Handle<v8::Object> wrap(TestSpecialOperations* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
217 ASSERT(!DOMDataStore::containsWrapper<V8TestSpecialOperations>(impl, isolate));
218 return V8TestSpecialOperations::createWrapper(impl, creationContext, isolate);
221 v8::Handle<v8::Object> V8TestSpecialOperations::createWrapper(PassRefPtr<TestSpecialOperations> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
224 ASSERT(!DOMDataStore::containsWrapper<V8TestSpecialOperations>(impl.get(), isolate));
225 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
226 const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
227 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
228 // the same object de-ref functions, though, so use that as the basis of the check.
229 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
232 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
233 if (UNLIKELY(wrapper.IsEmpty()))
236 installConditionallyEnabledProperties(wrapper, isolate);
237 V8DOMWrapper::associateObjectWithWrapper<V8TestSpecialOperations>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
241 void V8TestSpecialOperations::derefObject(ScriptWrappableBase* internalPointer)
243 fromInternalPointer(internalPointer)->deref();
247 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperations* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
249 return toV8(impl, creationContext, isolate);