Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: Source/bindings/tests/results/V8TestExposedInterface.cpp

Issue 424163002: Enable the WebIDL [Exposed] annotation on an interface's members. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 "V8TestExposedInterface.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 "core/dom/ContextFeatures.h"
15 #include "core/dom/Document.h"
16 #include "platform/RuntimeEnabledFeatures.h"
17 #include "platform/TraceEvent.h"
18 #include "wtf/GetPtr.h"
19 #include "wtf/RefPtr.h"
20
21 namespace blink {
22
23 static void initializeScriptWrappableForInterface(TestExposedInterface* object)
24 {
25 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
26 ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestExposedInterface ::wrapperTypeInfo);
27 else
28 ASSERT_NOT_REACHED();
29 }
30
31 } // namespace blink
32
33 void webCoreInitializeScriptWrappableForInterface(blink::TestExposedInterface* o bject)
34 {
35 blink::initializeScriptWrappableForInterface(object);
36 }
37
38 namespace blink {
39 const WrapperTypeInfo V8TestExposedInterface::wrapperTypeInfo = { gin::kEmbedder Blink, V8TestExposedInterface::domTemplate, V8TestExposedInterface::derefObject, 0, 0, 0, V8TestExposedInterface::installConditionallyEnabledMethods, 0, Wrapper TypeObjectPrototype, RefCountedObject };
40
41 namespace TestExposedInterfaceV8Internal {
42
43 template <typename T> void V8_USE(T) { }
44
45 static void alwaysExposedAttributeAttributeGetter(const v8::PropertyCallbackInfo <v8::Value>& info)
46 {
47 v8::Handle<v8::Object> holder = info.Holder();
48 TestExposedInterface* impl = V8TestExposedInterface::toNative(holder);
49 v8SetReturnValueInt(info, impl->alwaysExposedAttribute());
50 }
51
52 static void alwaysExposedAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
53 {
54 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
55 TestExposedInterfaceV8Internal::alwaysExposedAttributeAttributeGetter(info);
56 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
57 }
58
59 static void alwaysExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
60 {
61 v8::Handle<v8::Object> holder = info.Holder();
62 ExceptionState exceptionState(ExceptionState::SetterContext, "alwaysExposedA ttribute", "TestExposedInterface", holder, info.GetIsolate());
63 TestExposedInterface* impl = V8TestExposedInterface::toNative(holder);
64 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState) , exceptionState);
65 impl->setAlwaysExposedAttribute(cppValue);
66 }
67
68 static void alwaysExposedAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
69 {
70 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
71 TestExposedInterfaceV8Internal::alwaysExposedAttributeAttributeSetter(v8Valu e, info);
72 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
73 }
74
75 static void workerExposedAttributeAttributeGetter(const v8::PropertyCallbackInfo <v8::Value>& info)
76 {
77 v8::Handle<v8::Object> holder = info.Holder();
78 TestExposedInterface* impl = V8TestExposedInterface::toNative(holder);
79 v8SetReturnValueInt(info, impl->workerExposedAttribute());
80 }
81
82 static void workerExposedAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
83 {
84 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
85 TestExposedInterfaceV8Internal::workerExposedAttributeAttributeGetter(info);
86 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
87 }
88
89 static void workerExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
90 {
91 v8::Handle<v8::Object> holder = info.Holder();
92 ExceptionState exceptionState(ExceptionState::SetterContext, "workerExposedA ttribute", "TestExposedInterface", holder, info.GetIsolate());
93 TestExposedInterface* impl = V8TestExposedInterface::toNative(holder);
94 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState) , exceptionState);
95 impl->setWorkerExposedAttribute(cppValue);
96 }
97
98 static void workerExposedAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
99 {
100 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
101 TestExposedInterfaceV8Internal::workerExposedAttributeAttributeSetter(v8Valu e, info);
102 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
103 }
104
105 static void windowExposedAttributeAttributeGetter(const v8::PropertyCallbackInfo <v8::Value>& info)
106 {
107 v8::Handle<v8::Object> holder = info.Holder();
108 TestExposedInterface* impl = V8TestExposedInterface::toNative(holder);
109 v8SetReturnValueInt(info, impl->windowExposedAttribute());
110 }
111
112 static void windowExposedAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
113 {
114 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
115 TestExposedInterfaceV8Internal::windowExposedAttributeAttributeGetter(info);
116 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
117 }
118
119 static void windowExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
120 {
121 v8::Handle<v8::Object> holder = info.Holder();
122 ExceptionState exceptionState(ExceptionState::SetterContext, "windowExposedA ttribute", "TestExposedInterface", holder, info.GetIsolate());
123 TestExposedInterface* impl = V8TestExposedInterface::toNative(holder);
124 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState) , exceptionState);
125 impl->setWindowExposedAttribute(cppValue);
126 }
127
128 static void windowExposedAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
129 {
130 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
131 TestExposedInterfaceV8Internal::windowExposedAttributeAttributeSetter(v8Valu e, info);
132 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
133 }
134
135 static void alwaysExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
136 {
137 TestExposedInterface* impl = V8TestExposedInterface::toNative(info.Holder()) ;
138 impl->alwaysExposedMethod();
139 }
140
141 static void alwaysExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8: :Value>& info)
142 {
143 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
144 TestExposedInterfaceV8Internal::alwaysExposedMethodMethod(info);
145 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
146 }
147
148 static void workerExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
149 {
150 TestExposedInterface* impl = V8TestExposedInterface::toNative(info.Holder()) ;
151 impl->workerExposedMethod();
152 }
153
154 static void workerExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8: :Value>& info)
155 {
156 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
157 TestExposedInterfaceV8Internal::workerExposedMethodMethod(info);
158 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
159 }
160
161 static void windowExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
162 {
163 TestExposedInterface* impl = V8TestExposedInterface::toNative(info.Holder()) ;
164 impl->windowExposedMethod();
165 }
166
167 static void windowExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8: :Value>& info)
168 {
169 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
170 TestExposedInterfaceV8Internal::windowExposedMethodMethod(info);
171 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
172 }
173
174 static void alwaysExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::V alue>& info)
175 {
176 TestExposedInterface::alwaysExposedStaticMethod();
177 }
178
179 static void alwaysExposedStaticMethodMethodCallback(const v8::FunctionCallbackIn fo<v8::Value>& info)
180 {
181 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
182 TestExposedInterfaceV8Internal::alwaysExposedStaticMethodMethod(info);
183 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
184 }
185
186 static void workerExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::V alue>& info)
187 {
188 TestExposedInterface::workerExposedStaticMethod();
189 }
190
191 static void workerExposedStaticMethodMethodCallback(const v8::FunctionCallbackIn fo<v8::Value>& info)
192 {
193 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
194 TestExposedInterfaceV8Internal::workerExposedStaticMethodMethod(info);
195 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
196 }
197
198 static void windowExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::V alue>& info)
199 {
200 TestExposedInterface::windowExposedStaticMethod();
201 }
202
203 static void windowExposedStaticMethodMethodCallback(const v8::FunctionCallbackIn fo<v8::Value>& info)
204 {
205 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
206 TestExposedInterfaceV8Internal::windowExposedStaticMethodMethod(info);
207 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
208 }
209
210 static void windowAndServiceWorkerExposedMethodMethod(const v8::FunctionCallback Info<v8::Value>& info)
211 {
212 TestExposedInterface* impl = V8TestExposedInterface::toNative(info.Holder()) ;
213 impl->windowAndServiceWorkerExposedMethod();
214 }
215
216 static void windowAndServiceWorkerExposedMethodMethodCallback(const v8::Function CallbackInfo<v8::Value>& info)
217 {
218 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
219 TestExposedInterfaceV8Internal::windowAndServiceWorkerExposedMethodMethod(in fo);
220 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
221 }
222
223 } // namespace TestExposedInterfaceV8Internal
224
225 static const V8DOMConfiguration::AttributeConfiguration V8TestExposedInterfaceAt tributes[] = {
226 {"alwaysExposedAttribute", TestExposedInterfaceV8Internal::alwaysExposedAttr ibuteAttributeGetterCallback, TestExposedInterfaceV8Internal::alwaysExposedAttri buteAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT ), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAl lScripts, V8DOMConfiguration::OnInstance},
227 };
228
229 static const V8DOMConfiguration::MethodConfiguration V8TestExposedInterfaceMetho ds[] = {
230 {"alwaysExposedMethod", TestExposedInterfaceV8Internal::alwaysExposedMethodM ethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
231 };
232
233 static void installV8TestExposedInterfaceTemplate(v8::Handle<v8::FunctionTemplat e> functionTemplate, v8::Isolate* isolate)
234 {
235 functionTemplate->ReadOnlyPrototype();
236
237 v8::Local<v8::Signature> defaultSignature;
238 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestExposedInterface", v8::Local<v8::FunctionTemplate>(), V8TestExposedInt erface::internalFieldCount,
239 V8TestExposedInterfaceAttributes, WTF_ARRAY_LENGTH(V8TestExposedInterfac eAttributes),
240 0, 0,
241 V8TestExposedInterfaceMethods, WTF_ARRAY_LENGTH(V8TestExposedInterfaceMe thods),
242 isolate);
243 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTempla te->InstanceTemplate();
244 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTempl ate->PrototypeTemplate();
245 static const V8DOMConfiguration::MethodConfiguration alwaysExposedStaticMeth odMethodConfiguration = {
246 "alwaysExposedStaticMethod", TestExposedInterfaceV8Internal::alwaysExpos edStaticMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts,
247 };
248 V8DOMConfiguration::installMethodCustomSignature(functionTemplate, v8::Local <v8::Signature>(), v8::None, alwaysExposedStaticMethodMethodConfiguration, isola te);
249
250 // Custom toString template
251 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData: :from(isolate)->toStringTemplate());
252 }
253
254 v8::Handle<v8::FunctionTemplate> V8TestExposedInterface::domTemplate(v8::Isolate * isolate)
255 {
256 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI nfo*>(&wrapperTypeInfo), installV8TestExposedInterfaceTemplate);
257 }
258
259 bool V8TestExposedInterface::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isol ate* isolate)
260 {
261 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu e);
262 }
263
264 v8::Handle<v8::Object> V8TestExposedInterface::findInstanceInPrototypeChain(v8:: Handle<v8::Value> v8Value, v8::Isolate* isolate)
265 {
266 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe rTypeInfo, v8Value);
267 }
268
269 TestExposedInterface* V8TestExposedInterface::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
270 {
271 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
272 }
273
274 void V8TestExposedInterface::installConditionallyEnabledProperties(v8::Handle<v8 ::Object> instanceTemplate, TestExposedInterface* impl, v8::Isolate* isolate)
275 {
276 v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instan ceTemplate->GetPrototype());
277 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext());
278
279 if (context && (context->isWorkerGlobalScope())) {
280 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\
281 {"workerExposedAttribute", TestExposedInterfaceV8Internal::workerExposed AttributeAttributeGetterCallback, TestExposedInterfaceV8Internal::workerExposedA ttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEF AULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::Exposed ToAllScripts, V8DOMConfiguration::OnInstance};
282 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate);
283 }
284 if (context && (context->isDocument())) {
285 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\
286 {"windowExposedAttribute", TestExposedInterfaceV8Internal::windowExposed AttributeAttributeGetterCallback, TestExposedInterfaceV8Internal::windowExposedA ttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEF AULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::Exposed ToAllScripts, V8DOMConfiguration::OnInstance};
287 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate);
288 }
289 }
290
291 void V8TestExposedInterface::installConditionallyEnabledMethods(v8::Handle<v8::O bject> prototypeTemplate, v8::Isolate* isolate)
292 {
293 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate));
294
295 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext());
296 if (context && (context->isWorkerGlobalScope()))
297 prototypeTemplate->Set(v8AtomicString(isolate, "workerExposedMethod"), v 8::FunctionTemplate::New(isolate, TestExposedInterfaceV8Internal::workerExposedM ethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction());
haraken 2014/07/30 16:32:03 bashi@: We might want to improve the IDL compiler
298 if (context && (context->isDocument()))
299 prototypeTemplate->Set(v8AtomicString(isolate, "windowExposedMethod"), v 8::FunctionTemplate::New(isolate, TestExposedInterfaceV8Internal::windowExposedM ethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunction());
300 if (context && (context->isWorkerGlobalScope()))
301 prototypeTemplate->Set(v8AtomicString(isolate, "workerExposedStaticMetho d"), v8::FunctionTemplate::New(isolate, TestExposedInterfaceV8Internal::workerEx posedStaticMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunctio n());
302 if (context && (context->isDocument()))
303 prototypeTemplate->Set(v8AtomicString(isolate, "windowExposedStaticMetho d"), v8::FunctionTemplate::New(isolate, TestExposedInterfaceV8Internal::windowEx posedStaticMethodMethodCallback, v8Undefined(), defaultSignature, 0)->GetFunctio n());
304 if (context && (context->isServiceWorkerGlobalScope() || context->isDocument ()))
305 prototypeTemplate->Set(v8AtomicString(isolate, "windowAndServiceWorkerEx posedMethod"), v8::FunctionTemplate::New(isolate, TestExposedInterfaceV8Internal ::windowAndServiceWorkerExposedMethodMethodCallback, v8Undefined(), defaultSigna ture, 0)->GetFunction());
306 }
307
308 v8::Handle<v8::Object> wrap(TestExposedInterface* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
309 {
310 ASSERT(impl);
311 ASSERT(!DOMDataStore::containsWrapper<V8TestExposedInterface>(impl, isolate) );
312 return V8TestExposedInterface::createWrapper(impl, creationContext, isolate) ;
313 }
314
315 v8::Handle<v8::Object> V8TestExposedInterface::createWrapper(PassRefPtr<TestExpo sedInterface> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate )
316 {
317 ASSERT(impl);
318 ASSERT(!DOMDataStore::containsWrapper<V8TestExposedInterface>(impl.get(), is olate));
319 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
320 const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get ())->typeInfo();
321 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
322 // the same object de-ref functions, though, so use that as the basis of the check.
323 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
324 }
325
326 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
327 if (UNLIKELY(wrapper.IsEmpty()))
328 return wrapper;
329
330 installConditionallyEnabledProperties(wrapper, impl.get(), isolate);
331 V8DOMWrapper::associateObjectWithWrapper<V8TestExposedInterface>(impl, &wrap perTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
332 return wrapper;
333 }
334
335 void V8TestExposedInterface::derefObject(void* object)
336 {
337 fromInternalPointer(object)->deref();
338 }
339
340 template<>
341 v8::Handle<v8::Value> toV8NoInline(TestExposedInterface* impl, v8::Handle<v8::Ob ject> creationContext, v8::Isolate* isolate)
342 {
343 return toV8(impl, creationContext, isolate);
344 }
345
346 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698