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 "V8TestNode.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/V8ObjectConstructor.h"
14 #include "core/dom/ContextFeatures.h"
15 #include "core/dom/Document.h"
16 #include "core/frame/LocalDOMWindow.h"
17 #include "platform/RuntimeEnabledFeatures.h"
18 #include "platform/TraceEvent.h"
19 #include "wtf/GetPtr.h"
20 #include "wtf/RefPtr.h"
24 static void initializeScriptWrappableForInterface(TestNode* object)
26 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
27 ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestNode::wrapperTypeInfo);
34 void webCoreInitializeScriptWrappableForInterface(blink::TestNode* object)
36 blink::initializeScriptWrappableForInterface(object);
40 const WrapperTypeInfo V8TestNode::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestNode::domTemplate, V8TestNode::derefObject, 0, V8TestNode::toEventTarget, 0, V8TestNode::installConditionallyEnabledMethods, &V8Node::wrapperTypeInfo, WrapperTypeObjectPrototype, WillBeGarbageCollectedObject };
42 namespace TestNodeV8Internal {
44 template <typename T> void V8_USE(T) { }
46 static void hrefAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
48 v8::Handle<v8::Object> holder = info.Holder();
49 TestNode* impl = V8TestNode::toNative(holder);
50 v8SetReturnValueString(info, impl->href(), info.GetIsolate());
53 static void hrefAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
55 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
56 TestNodeV8Internal::hrefAttributeGetter(info);
57 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
60 static void hrefAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
62 v8::Handle<v8::Object> holder = info.Holder();
63 TestNode* impl = V8TestNode::toNative(holder);
64 TOSTRING_VOID(V8StringResource<>, cppValue, v8Value);
65 impl->setHref(cppValue);
68 static void hrefAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
70 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
71 TestNodeV8Internal::hrefAttributeSetter(v8Value, info);
72 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
75 static void hrefThrowsAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
77 v8::Handle<v8::Object> holder = info.Holder();
78 TestNode* impl = V8TestNode::toNative(holder);
79 v8SetReturnValueString(info, impl->hrefThrows(), info.GetIsolate());
82 static void hrefThrowsAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
84 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
85 TestNodeV8Internal::hrefThrowsAttributeGetter(info);
86 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
89 static void hrefThrowsAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
91 v8::Handle<v8::Object> holder = info.Holder();
92 ExceptionState exceptionState(ExceptionState::SetterContext, "hrefThrows", "TestNode", holder, info.GetIsolate());
93 TestNode* impl = V8TestNode::toNative(holder);
94 TOSTRING_VOID(V8StringResource<>, cppValue, v8Value);
95 impl->setHrefThrows(cppValue, exceptionState);
96 exceptionState.throwIfNeeded();
99 static void hrefThrowsAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
101 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
102 TestNodeV8Internal::hrefThrowsAttributeSetter(v8Value, info);
103 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
106 static void hrefCallWithAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
108 v8::Handle<v8::Object> holder = info.Holder();
109 TestNode* impl = V8TestNode::toNative(holder);
110 v8SetReturnValueString(info, impl->hrefCallWith(), info.GetIsolate());
113 static void hrefCallWithAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
115 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
116 TestNodeV8Internal::hrefCallWithAttributeGetter(info);
117 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
120 static void hrefCallWithAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
122 v8::Handle<v8::Object> holder = info.Holder();
123 TestNode* impl = V8TestNode::toNative(holder);
124 TOSTRING_VOID(V8StringResource<>, cppValue, v8Value);
125 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
126 impl->setHrefCallWith(executionContext, callingDOMWindow(info.GetIsolate()), enteredDOMWindow(info.GetIsolate()), cppValue);
129 static void hrefCallWithAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
131 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
132 TestNodeV8Internal::hrefCallWithAttributeSetter(v8Value, info);
133 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
136 static void hrefByteStringAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
138 v8::Handle<v8::Object> holder = info.Holder();
139 TestNode* impl = V8TestNode::toNative(holder);
140 v8SetReturnValueString(info, impl->hrefByteString(), info.GetIsolate());
143 static void hrefByteStringAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
145 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
146 TestNodeV8Internal::hrefByteStringAttributeGetter(info);
147 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
150 static void hrefByteStringAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
152 v8::Handle<v8::Object> holder = info.Holder();
153 ExceptionState exceptionState(ExceptionState::SetterContext, "hrefByteString", "TestNode", holder, info.GetIsolate());
154 TestNode* impl = V8TestNode::toNative(holder);
155 TONATIVE_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, toByteString(v8Value, exceptionState), exceptionState);
156 impl->setHrefByteString(cppValue);
159 static void hrefByteStringAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
161 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
162 TestNodeV8Internal::hrefByteStringAttributeSetter(v8Value, info);
163 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
166 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
168 RefPtrWillBeRawPtr<TestNode> impl = TestNode::create();
169 v8::Handle<v8::Object> wrapper = info.Holder();
170 V8DOMWrapper::associateObjectWithWrapper<V8TestNode>(impl.release(), &V8TestNode::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
171 v8SetReturnValue(info, wrapper);
174 } // namespace TestNodeV8Internal
176 static const V8DOMConfiguration::AttributeConfiguration V8TestNodeAttributes[] = {
177 {"href", TestNodeV8Internal::hrefAttributeGetterCallback, TestNodeV8Internal::hrefAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
178 {"hrefThrows", TestNodeV8Internal::hrefThrowsAttributeGetterCallback, TestNodeV8Internal::hrefThrowsAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
179 {"hrefCallWith", TestNodeV8Internal::hrefCallWithAttributeGetterCallback, TestNodeV8Internal::hrefCallWithAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
180 {"hrefByteString", TestNodeV8Internal::hrefByteStringAttributeGetterCallback, TestNodeV8Internal::hrefByteStringAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
183 void V8TestNode::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
185 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor");
186 if (!info.IsConstructCall()) {
187 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestNode"), info.GetIsolate());
191 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
192 v8SetReturnValue(info, info.Holder());
196 TestNodeV8Internal::constructor(info);
199 static void installV8TestNodeTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
201 functionTemplate->ReadOnlyPrototype();
203 v8::Local<v8::Signature> defaultSignature;
204 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestNode", V8Node::domTemplate(isolate), V8TestNode::internalFieldCount,
205 V8TestNodeAttributes, WTF_ARRAY_LENGTH(V8TestNodeAttributes),
209 functionTemplate->SetCallHandler(V8TestNode::constructorCallback);
210 functionTemplate->SetLength(0);
211 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
212 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
214 // Custom toString template
215 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
218 v8::Handle<v8::FunctionTemplate> V8TestNode::domTemplate(v8::Isolate* isolate)
220 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestNodeTemplate);
223 bool V8TestNode::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
225 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
228 v8::Handle<v8::Object> V8TestNode::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
230 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
233 TestNode* V8TestNode::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
235 return hasInstance(value, isolate) ? fromInternalPointer(blink::toInternalPointer(v8::Handle<v8::Object>::Cast(value))) : 0;
238 EventTarget* V8TestNode::toEventTarget(v8::Handle<v8::Object> object)
240 return toNative(object);
243 v8::Handle<v8::Object> wrap(TestNode* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
246 ASSERT(!DOMDataStore::containsWrapper<V8TestNode>(impl, isolate));
247 return V8TestNode::createWrapper(impl, creationContext, isolate);
250 v8::Handle<v8::Object> V8TestNode::createWrapper(PassRefPtrWillBeRawPtr<TestNode> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
253 ASSERT(!DOMDataStore::containsWrapper<V8TestNode>(impl.get(), isolate));
254 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
255 const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
256 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
257 // the same object de-ref functions, though, so use that as the basis of the check.
258 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
261 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
262 if (UNLIKELY(wrapper.IsEmpty()))
265 installConditionallyEnabledProperties(wrapper, isolate);
266 V8DOMWrapper::associateObjectWithWrapper<V8TestNode>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent);
270 void V8TestNode::derefObject(ScriptWrappableBase* internalPointer)
273 fromInternalPointer(internalPointer)->deref();
274 #endif // !ENABLE(OILPAN)
278 v8::Handle<v8::Value> toV8NoInline(TestNode* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
280 return toV8(impl, creationContext, isolate);