OLD | NEW |
| (Empty) |
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. | |
4 | |
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! | |
6 | |
7 #include "config.h" | |
8 #include "V8TestInterfaceGarbageCollected.h" | |
9 | |
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/tests/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" | |
22 | |
23 namespace blink { | |
24 | |
25 const WrapperTypeInfo V8TestInterfaceGarbageCollected::wrapperTypeInfo = { gin::
kEmbedderBlink, V8TestInterfaceGarbageCollected::domTemplate, V8TestInterfaceGar
bageCollected::refObject, V8TestInterfaceGarbageCollected::derefObject, V8TestIn
terfaceGarbageCollected::createPersistentHandle, 0, V8TestInterfaceGarbageCollec
ted::toEventTarget, 0, V8TestInterfaceGarbageCollected::installConditionallyEnab
ledMethods, V8TestInterfaceGarbageCollected::installConditionallyEnabledProperti
es, &V8EventTarget::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype
, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo:
:GarbageCollectedObject }; | |
26 | |
27 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfac
eGarbageCollected.h. | |
28 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in | |
29 // bindings/core/v8/ScriptWrappable.h. | |
30 const WrapperTypeInfo& TestInterfaceGarbageCollected::s_wrapperTypeInfo = V8Test
InterfaceGarbageCollected::wrapperTypeInfo; | |
31 | |
32 namespace TestInterfaceGarbageCollectedV8Internal { | |
33 | |
34 template <typename T> void V8_USE(T) { } | |
35 | |
36 static void attr1AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info
) | |
37 { | |
38 v8::Handle<v8::Object> holder = info.Holder(); | |
39 TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImp
l(holder); | |
40 v8SetReturnValueFast(info, WTF::getPtr(impl->attr1()), impl); | |
41 } | |
42 | |
43 static void attr1AttributeGetterCallback(v8::Local<v8::String>, const v8::Proper
tyCallbackInfo<v8::Value>& info) | |
44 { | |
45 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); | |
46 TestInterfaceGarbageCollectedV8Internal::attr1AttributeGetter(info); | |
47 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | |
48 } | |
49 | |
50 static void attr1AttributeSetter(v8::Local<v8::Value> v8Value, const v8::Propert
yCallbackInfo<void>& info) | |
51 { | |
52 v8::Handle<v8::Object> holder = info.Holder(); | |
53 TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImp
l(holder); | |
54 TONATIVE_VOID(TestInterfaceGarbageCollected*, cppValue, V8TestInterfaceGarba
geCollected::toImplWithTypeCheck(info.GetIsolate(), v8Value)); | |
55 impl->setAttr1(WTF::getPtr(cppValue)); | |
56 } | |
57 | |
58 static void attr1AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Va
lue> v8Value, const v8::PropertyCallbackInfo<void>& info) | |
59 { | |
60 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); | |
61 TestInterfaceGarbageCollectedV8Internal::attr1AttributeSetter(v8Value, info)
; | |
62 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | |
63 } | |
64 | |
65 static void funcMethod(const v8::FunctionCallbackInfo<v8::Value>& info) | |
66 { | |
67 if (UNLIKELY(info.Length() < 1)) { | |
68 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod("f
unc", "TestInterfaceGarbageCollected", 1, info.Length(), info.GetIsolate()), inf
o.GetIsolate()); | |
69 return; | |
70 } | |
71 TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImp
l(info.Holder()); | |
72 TestInterfaceGarbageCollected* arg; | |
73 { | |
74 v8::TryCatch block; | |
75 V8RethrowTryCatchScope rethrow(block); | |
76 TONATIVE_VOID_INTERNAL(arg, V8TestInterfaceGarbageCollected::toImplWithT
ypeCheck(info.GetIsolate(), info[0])); | |
77 } | |
78 impl->func(arg); | |
79 } | |
80 | |
81 static void funcMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) | |
82 { | |
83 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); | |
84 TestInterfaceGarbageCollectedV8Internal::funcMethod(info); | |
85 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | |
86 } | |
87 | |
88 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | |
89 { | |
90 if (UNLIKELY(info.Length() < 1)) { | |
91 V8ThrowException::throwException(createMinimumArityTypeErrorForConstruct
or("TestInterfaceGarbageCollected", 1, info.Length(), info.GetIsolate()), info.G
etIsolate()); | |
92 return; | |
93 } | |
94 V8StringResource<> str; | |
95 { | |
96 TOSTRING_VOID_INTERNAL(str, info[0]); | |
97 } | |
98 RawPtr<TestInterfaceGarbageCollected> impl = TestInterfaceGarbageCollected::
create(str); | |
99 v8::Handle<v8::Object> wrapper = info.Holder(); | |
100 impl->associateWithWrapper(&V8TestInterfaceGarbageCollected::wrapperTypeInfo
, wrapper, info.GetIsolate()); | |
101 v8SetReturnValue(info, wrapper); | |
102 } | |
103 | |
104 } // namespace TestInterfaceGarbageCollectedV8Internal | |
105 | |
106 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceGarbageCo
llectedAttributes[] = { | |
107 {"attr1", TestInterfaceGarbageCollectedV8Internal::attr1AttributeGetterCallb
ack, TestInterfaceGarbageCollectedV8Internal::attr1AttributeSetterCallback, 0, 0
, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttrib
ute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnI
nstance}, | |
108 }; | |
109 | |
110 static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceGarbageColle
ctedMethods[] = { | |
111 {"func", TestInterfaceGarbageCollectedV8Internal::funcMethodCallback, 0, 1,
V8DOMConfiguration::ExposedToAllScripts}, | |
112 }; | |
113 | |
114 void V8TestInterfaceGarbageCollected::constructorCallback(const v8::FunctionCall
backInfo<v8::Value>& info) | |
115 { | |
116 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor"); | |
117 if (!info.IsConstructCall()) { | |
118 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallab
leAsFunction("TestInterfaceGarbageCollected"), info.GetIsolate()); | |
119 return; | |
120 } | |
121 | |
122 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExis
tingObject) { | |
123 v8SetReturnValue(info, info.Holder()); | |
124 return; | |
125 } | |
126 | |
127 TestInterfaceGarbageCollectedV8Internal::constructor(info); | |
128 } | |
129 | |
130 static void installV8TestInterfaceGarbageCollectedTemplate(v8::Handle<v8::Functi
onTemplate> functionTemplate, v8::Isolate* isolate) | |
131 { | |
132 functionTemplate->ReadOnlyPrototype(); | |
133 | |
134 v8::Local<v8::Signature> defaultSignature; | |
135 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceGarbageCollected", V8EventTarget::domTemplate(isolate), V8Tes
tInterfaceGarbageCollected::internalFieldCount, | |
136 V8TestInterfaceGarbageCollectedAttributes, WTF_ARRAY_LENGTH(V8TestInterf
aceGarbageCollectedAttributes), | |
137 0, 0, | |
138 V8TestInterfaceGarbageCollectedMethods, WTF_ARRAY_LENGTH(V8TestInterface
GarbageCollectedMethods), | |
139 isolate); | |
140 functionTemplate->SetCallHandler(V8TestInterfaceGarbageCollected::constructo
rCallback); | |
141 functionTemplate->SetLength(1); | |
142 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTempla
te->InstanceTemplate(); | |
143 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTempl
ate->PrototypeTemplate(); | |
144 | |
145 // Custom toString template | |
146 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:from(isolate)->toStringTemplate()); | |
147 } | |
148 | |
149 v8::Handle<v8::FunctionTemplate> V8TestInterfaceGarbageCollected::domTemplate(v8
::Isolate* isolate) | |
150 { | |
151 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI
nfo*>(&wrapperTypeInfo), installV8TestInterfaceGarbageCollectedTemplate); | |
152 } | |
153 | |
154 bool V8TestInterfaceGarbageCollected::hasInstance(v8::Handle<v8::Value> v8Value,
v8::Isolate* isolate) | |
155 { | |
156 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu
e); | |
157 } | |
158 | |
159 v8::Handle<v8::Object> V8TestInterfaceGarbageCollected::findInstanceInPrototypeC
hain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) | |
160 { | |
161 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); | |
162 } | |
163 | |
164 TestInterfaceGarbageCollected* V8TestInterfaceGarbageCollected::toImplWithTypeCh
eck(v8::Isolate* isolate, v8::Handle<v8::Value> value) | |
165 { | |
166 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle
<v8::Object>::Cast(value))->toImpl<TestInterfaceGarbageCollected>() : 0; | |
167 } | |
168 | |
169 EventTarget* V8TestInterfaceGarbageCollected::toEventTarget(v8::Handle<v8::Objec
t> object) | |
170 { | |
171 return toImpl(object); | |
172 } | |
173 | |
174 | |
175 void V8TestInterfaceGarbageCollected::refObject(ScriptWrappableBase* internalPoi
nter) | |
176 { | |
177 } | |
178 | |
179 void V8TestInterfaceGarbageCollected::derefObject(ScriptWrappableBase* internalP
ointer) | |
180 { | |
181 } | |
182 | |
183 WrapperPersistentNode* V8TestInterfaceGarbageCollected::createPersistentHandle(S
criptWrappableBase* internalPointer) | |
184 { | |
185 return WrapperPersistent<TestInterfaceGarbageCollected>::create(internalPoin
ter->toImpl<TestInterfaceGarbageCollected>()); | |
186 } | |
187 | |
188 template<> | |
189 v8::Handle<v8::Value> toV8NoInline(TestInterfaceGarbageCollected* impl, v8::Hand
le<v8::Object> creationContext, v8::Isolate* isolate) | |
190 { | |
191 return toV8(impl, creationContext, isolate); | |
192 } | |
193 | |
194 } // namespace blink | |
OLD | NEW |