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 "V8TestInterfaceGarbageCollected.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/V8TestInterfaceGarbageCollected.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 V8TestInterfaceGarbageCollected::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceGarbageCollected::domTemplate, V8TestInterfaceGarbageCollected::refObject, V8TestInterfaceGarbageCollected::derefObject, V8TestInterfaceGarbageCollected::trace, 0, V8TestInterfaceGarbageCollected::toEventTarget, 0, V8TestInterfaceGarbageCollected::installConditionallyEnabledMethods, V8TestInterfaceGarbageCollected::installConditionallyEnabledProperties, &V8EventTarget::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::GarbageCollectedObject };
27 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfaceGarbageCollected.h.
28 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
29 // bindings/core/v8/ScriptWrappable.h.
30 const WrapperTypeInfo& TestInterfaceGarbageCollected::s_wrapperTypeInfo = V8TestInterfaceGarbageCollected::wrapperTypeInfo;
32 namespace TestInterfaceGarbageCollectedV8Internal {
34 static void attr1AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
36 v8::Handle<v8::Object> holder = info.Holder();
37 TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(holder);
38 v8SetReturnValueFast(info, WTF::getPtr(impl->attr1()), impl);
41 static void attr1AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
43 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
44 TestInterfaceGarbageCollectedV8Internal::attr1AttributeGetter(info);
45 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
48 static void attr1AttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
50 v8::Handle<v8::Object> holder = info.Holder();
51 TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(holder);
52 TestInterfaceGarbageCollected* cppValue = V8TestInterfaceGarbageCollected::toImplWithTypeCheck(info.GetIsolate(), v8Value);
53 impl->setAttr1(WTF::getPtr(cppValue));
56 static void attr1AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
58 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
59 TestInterfaceGarbageCollectedV8Internal::attr1AttributeSetter(v8Value, info);
60 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
63 static void funcMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
65 if (UNLIKELY(info.Length() < 1)) {
66 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(info.GetIsolate(), "func", "TestInterfaceGarbageCollected", 1, info.Length()), info.GetIsolate());
69 TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder());
70 TestInterfaceGarbageCollected* arg;
72 arg = V8TestInterfaceGarbageCollected::toImplWithTypeCheck(info.GetIsolate(), info[0]);
77 static void funcMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
79 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
80 TestInterfaceGarbageCollectedV8Internal::funcMethod(info);
81 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
84 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
86 if (UNLIKELY(info.Length() < 1)) {
87 V8ThrowException::throwException(createMinimumArityTypeErrorForConstructor(info.GetIsolate(), "TestInterfaceGarbageCollected", 1, info.Length()), info.GetIsolate());
90 V8StringResource<> str;
92 TOSTRING_VOID_INTERNAL(str, info[0]);
94 RawPtr<TestInterfaceGarbageCollected> impl = TestInterfaceGarbageCollected::create(str);
95 v8::Handle<v8::Object> wrapper = info.Holder();
96 impl->associateWithWrapper(&V8TestInterfaceGarbageCollected::wrapperTypeInfo, wrapper, info.GetIsolate());
97 v8SetReturnValue(info, wrapper);
100 } // namespace TestInterfaceGarbageCollectedV8Internal
102 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceGarbageCollectedAttributes[] = {
103 {"attr1", TestInterfaceGarbageCollectedV8Internal::attr1AttributeGetterCallback, TestInterfaceGarbageCollectedV8Internal::attr1AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
106 static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceGarbageCollectedMethods[] = {
107 {"func", TestInterfaceGarbageCollectedV8Internal::funcMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
110 void V8TestInterfaceGarbageCollected::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
112 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor");
113 if (!info.IsConstructCall()) {
114 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("TestInterfaceGarbageCollected"));
118 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
119 v8SetReturnValue(info, info.Holder());
123 TestInterfaceGarbageCollectedV8Internal::constructor(info);
126 static void installV8TestInterfaceGarbageCollectedTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
128 functionTemplate->ReadOnlyPrototype();
130 v8::Local<v8::Signature> defaultSignature;
131 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceGarbageCollected", V8EventTarget::domTemplate(isolate), V8TestInterfaceGarbageCollected::internalFieldCount,
132 V8TestInterfaceGarbageCollectedAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceGarbageCollectedAttributes),
134 V8TestInterfaceGarbageCollectedMethods, WTF_ARRAY_LENGTH(V8TestInterfaceGarbageCollectedMethods),
136 functionTemplate->SetCallHandler(V8TestInterfaceGarbageCollected::constructorCallback);
137 functionTemplate->SetLength(1);
138 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
139 ALLOW_UNUSED_LOCAL(instanceTemplate);
140 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
141 ALLOW_UNUSED_LOCAL(prototypeTemplate);
143 // Custom toString template
144 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
147 v8::Handle<v8::FunctionTemplate> V8TestInterfaceGarbageCollected::domTemplate(v8::Isolate* isolate)
149 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceGarbageCollectedTemplate);
152 bool V8TestInterfaceGarbageCollected::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
154 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
157 v8::Handle<v8::Object> V8TestInterfaceGarbageCollected::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
159 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
162 TestInterfaceGarbageCollected* V8TestInterfaceGarbageCollected::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
164 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterfaceGarbageCollected>() : 0;
167 EventTarget* V8TestInterfaceGarbageCollected::toEventTarget(v8::Handle<v8::Object> object)
169 return toImpl(object);
172 void V8TestInterfaceGarbageCollected::refObject(ScriptWrappableBase* scriptWrappableBase)
176 void V8TestInterfaceGarbageCollected::derefObject(ScriptWrappableBase* scriptWrappableBase)
181 v8::Handle<v8::Value> toV8NoInline(TestInterfaceGarbageCollected* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
183 return toV8(impl, creationContext, isolate);