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 "V8TestInterfaceWillBeGarbageCollected.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 "bindings/core/v8/V8TestInterfaceWillBeGarbageCollected.h"
15 #include "core/dom/ContextFeatures.h"
16 #include "core/dom/Document.h"
17 #include "core/frame/LocalDOMWindow.h"
18 #include "platform/RuntimeEnabledFeatures.h"
19 #include "platform/TraceEvent.h"
20 #include "wtf/GetPtr.h"
21 #include "wtf/RefPtr.h"
25 const WrapperTypeInfo V8TestInterfaceWillBeGarbageCollected::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceWillBeGarbageCollected::domTemplate, V8TestInterfaceWillBeGarbageCollected::refObject, V8TestInterfaceWillBeGarbageCollected::derefObject, V8TestInterfaceWillBeGarbageCollected::createPersistentHandle, 0, V8TestInterfaceWillBeGarbageCollected::toEventTarget, 0, V8TestInterfaceWillBeGarbageCollected::installConditionallyEnabledMethods, V8TestInterfaceWillBeGarbageCollected::installConditionallyEnabledProperties, &V8EventTarget::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::WillBeGarbageCollectedObject };
27 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfaceWillBeGarbageCollected.h.
28 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
29 // bindings/core/v8/ScriptWrappable.h.
30 const WrapperTypeInfo& TestInterfaceWillBeGarbageCollected::s_wrapperTypeInfo = V8TestInterfaceWillBeGarbageCollected::wrapperTypeInfo;
32 namespace TestInterfaceWillBeGarbageCollectedV8Internal {
34 template <typename T> void V8_USE(T) { }
36 static void attr1AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
38 v8::Handle<v8::Object> holder = info.Holder();
39 TestInterfaceWillBeGarbageCollected* impl = V8TestInterfaceWillBeGarbageCollected::toImpl(holder);
40 v8SetReturnValueFast(info, WTF::getPtr(impl->attr1()), impl);
43 static void attr1AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
45 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
46 TestInterfaceWillBeGarbageCollectedV8Internal::attr1AttributeGetter(info);
47 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
50 static void attr1AttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
52 v8::Handle<v8::Object> holder = info.Holder();
53 TestInterfaceWillBeGarbageCollected* impl = V8TestInterfaceWillBeGarbageCollected::toImpl(holder);
54 TestInterfaceWillBeGarbageCollected* cppValue = V8TestInterfaceWillBeGarbageCollected::toImplWithTypeCheck(info.GetIsolate(), v8Value);
55 impl->setAttr1(WTF::getPtr(cppValue));
58 static void attr1AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
60 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
61 TestInterfaceWillBeGarbageCollectedV8Internal::attr1AttributeSetter(v8Value, info);
62 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
65 static void funcMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
67 if (UNLIKELY(info.Length() < 1)) {
68 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod("func", "TestInterfaceWillBeGarbageCollected", 1, info.Length(), info.GetIsolate()), info.GetIsolate());
71 TestInterfaceWillBeGarbageCollected* impl = V8TestInterfaceWillBeGarbageCollected::toImpl(info.Holder());
72 TestInterfaceWillBeGarbageCollected* arg;
74 arg = V8TestInterfaceWillBeGarbageCollected::toImplWithTypeCheck(info.GetIsolate(), info[0]);
79 static void funcMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
81 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
82 TestInterfaceWillBeGarbageCollectedV8Internal::funcMethod(info);
83 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
86 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
88 if (UNLIKELY(info.Length() < 1)) {
89 V8ThrowException::throwException(createMinimumArityTypeErrorForConstructor("TestInterfaceWillBeGarbageCollected", 1, info.Length(), info.GetIsolate()), info.GetIsolate());
92 V8StringResource<> str;
94 TOSTRING_VOID_INTERNAL(str, info[0]);
96 RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> impl = TestInterfaceWillBeGarbageCollected::create(str);
97 v8::Handle<v8::Object> wrapper = info.Holder();
98 impl->associateWithWrapper(&V8TestInterfaceWillBeGarbageCollected::wrapperTypeInfo, wrapper, info.GetIsolate());
99 v8SetReturnValue(info, wrapper);
102 } // namespace TestInterfaceWillBeGarbageCollectedV8Internal
104 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceWillBeGarbageCollectedAttributes[] = {
105 {"attr1", TestInterfaceWillBeGarbageCollectedV8Internal::attr1AttributeGetterCallback, TestInterfaceWillBeGarbageCollectedV8Internal::attr1AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
108 static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceWillBeGarbageCollectedMethods[] = {
109 {"func", TestInterfaceWillBeGarbageCollectedV8Internal::funcMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
112 const WrapperTypeInfo V8TestInterfaceWillBeGarbageCollectedConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceWillBeGarbageCollectedConstructor::domTemplate, V8TestInterfaceWillBeGarbageCollected::refObject, V8TestInterfaceWillBeGarbageCollected::derefObject, V8TestInterfaceWillBeGarbageCollected::createPersistentHandle, 0, V8TestInterfaceWillBeGarbageCollected::toEventTarget, 0, V8TestInterfaceWillBeGarbageCollected::installConditionallyEnabledMethods, V8TestInterfaceWillBeGarbageCollected::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::WillBeGarbageCollectedObject };
114 static void V8TestInterfaceWillBeGarbageCollectedConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
116 if (!info.IsConstructCall()) {
117 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestInterface"), info.GetIsolate());
121 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
122 v8SetReturnValue(info, info.Holder());
125 if (UNLIKELY(info.Length() < 1)) {
126 V8ThrowException::throwException(createMinimumArityTypeErrorForConstructor("TestInterfaceWillBeGarbageCollected", 1, info.Length(), info.GetIsolate()), info.GetIsolate());
129 V8StringResource<> str;
131 TOSTRING_VOID_INTERNAL(str, info[0]);
133 RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> impl = TestInterfaceWillBeGarbageCollected::createForJSConstructor(str);
134 v8::Handle<v8::Object> wrapper = info.Holder();
135 impl->associateWithWrapper(&V8TestInterfaceWillBeGarbageCollectedConstructor::wrapperTypeInfo, wrapper, info.GetIsolate());
136 v8SetReturnValue(info, wrapper);
139 v8::Handle<v8::FunctionTemplate> V8TestInterfaceWillBeGarbageCollectedConstructor::domTemplate(v8::Isolate* isolate)
141 static int domTemplateKey; // This address is used for a key to look up the dom template.
142 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
143 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTemplateKey);
144 if (!result.IsEmpty())
147 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate");
148 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceWillBeGarbageCollectedConstructorCallback);
149 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
150 instanceTemplate->SetInternalFieldCount(V8TestInterfaceWillBeGarbageCollected::internalFieldCount);
151 result->SetClassName(v8AtomicString(isolate, "TestInterfaceWillBeGarbageCollected"));
152 result->Inherit(V8TestInterfaceWillBeGarbageCollected::domTemplate(isolate));
153 data->setDOMTemplate(&domTemplateKey, result);
157 void V8TestInterfaceWillBeGarbageCollected::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
159 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor");
160 if (!info.IsConstructCall()) {
161 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestInterfaceWillBeGarbageCollected"), info.GetIsolate());
165 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
166 v8SetReturnValue(info, info.Holder());
170 TestInterfaceWillBeGarbageCollectedV8Internal::constructor(info);
173 static void installV8TestInterfaceWillBeGarbageCollectedTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
175 functionTemplate->ReadOnlyPrototype();
177 v8::Local<v8::Signature> defaultSignature;
178 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceWillBeGarbageCollected", V8EventTarget::domTemplate(isolate), V8TestInterfaceWillBeGarbageCollected::internalFieldCount,
179 V8TestInterfaceWillBeGarbageCollectedAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceWillBeGarbageCollectedAttributes),
181 V8TestInterfaceWillBeGarbageCollectedMethods, WTF_ARRAY_LENGTH(V8TestInterfaceWillBeGarbageCollectedMethods),
183 functionTemplate->SetCallHandler(V8TestInterfaceWillBeGarbageCollected::constructorCallback);
184 functionTemplate->SetLength(1);
185 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
186 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
188 // Custom toString template
189 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
192 v8::Handle<v8::FunctionTemplate> V8TestInterfaceWillBeGarbageCollected::domTemplate(v8::Isolate* isolate)
194 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceWillBeGarbageCollectedTemplate);
197 bool V8TestInterfaceWillBeGarbageCollected::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
199 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
202 v8::Handle<v8::Object> V8TestInterfaceWillBeGarbageCollected::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
204 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
207 TestInterfaceWillBeGarbageCollected* V8TestInterfaceWillBeGarbageCollected::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
209 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterfaceWillBeGarbageCollected>() : 0;
212 EventTarget* V8TestInterfaceWillBeGarbageCollected::toEventTarget(v8::Handle<v8::Object> object)
214 return toImpl(object);
218 void V8TestInterfaceWillBeGarbageCollected::refObject(ScriptWrappableBase* internalPointer)
221 internalPointer->toImpl<TestInterfaceWillBeGarbageCollected>()->ref();
225 void V8TestInterfaceWillBeGarbageCollected::derefObject(ScriptWrappableBase* internalPointer)
228 internalPointer->toImpl<TestInterfaceWillBeGarbageCollected>()->deref();
232 WrapperPersistentNode* V8TestInterfaceWillBeGarbageCollected::createPersistentHandle(ScriptWrappableBase* internalPointer)
235 return WrapperPersistent<TestInterfaceWillBeGarbageCollected>::create(internalPointer->toImpl<TestInterfaceWillBeGarbageCollected>());
237 ASSERT_NOT_REACHED();
243 v8::Handle<v8::Value> toV8NoInline(TestInterfaceWillBeGarbageCollected* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
245 return toV8(impl, creationContext, isolate);