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

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

Issue 101403002: IDL compiler: Consolidate test IDL files (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More Created 7 years 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
« no previous file with comments | « Source/bindings/tests/results/V8TestSerializedScriptValueInterface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY!
32
33 #include "config.h"
34 #if ENABLE(Condition1) || ENABLE(Condition2)
35 #include "V8TestSerializedScriptValueInterface.h"
36
37 #include "RuntimeEnabledFeatures.h"
38 #include "bindings/v8/ScriptController.h"
39 #include "bindings/v8/ScriptState.h"
40 #include "bindings/v8/ScriptValue.h"
41 #include "bindings/v8/SerializedScriptValue.h"
42 #include "bindings/v8/V8Binding.h"
43 #include "bindings/v8/V8DOMConfiguration.h"
44 #include "bindings/v8/V8DOMWrapper.h"
45 #include "core/dom/ContextFeatures.h"
46 #include "core/dom/Document.h"
47 #include "platform/TraceEvent.h"
48 #include "wtf/UnusedParam.h"
49
50 namespace WebCore {
51
52 static void initializeScriptWrappableForInterface(TestSerializedScriptValueInter face* object)
53 {
54 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
55 ScriptWrappable::setTypeInfoInObject(object, &V8TestSerializedScriptValu eInterface::wrapperTypeInfo);
56 else
57 ASSERT_NOT_REACHED();
58 }
59
60 } // namespace WebCore
61
62 // In ScriptWrappable::init, the use of a local function declaration has an issu e on Windows:
63 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
64 // in the global namespace.
65 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe edback/details/664619/the-namespace-of-local-function-declarations-in-c)
66 void webCoreInitializeScriptWrappableForInterface(WebCore::TestSerializedScriptV alueInterface* object)
67 {
68 WebCore::initializeScriptWrappableForInterface(object);
69 }
70
71 namespace WebCore {
72 const WrapperTypeInfo V8TestSerializedScriptValueInterface::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestSerializedScriptValueInterface::GetTemplate, V8TestSe rializedScriptValueInterface::derefObject, 0, 0, 0, V8TestSerializedScriptValueI nterface::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype };
73
74 namespace TestSerializedScriptValueInterfaceV8Internal {
75
76 template <typename T> void V8_USE(T) { }
77
78 static void valueAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info )
79 {
80 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
81 v8SetReturnValue(info, imp->value() ? imp->value()->deserialize() : v8::Hand le<v8::Value>(v8::Null(info.GetIsolate())));
82 }
83
84 static void valueAttributeGetterCallback(v8::Local<v8::String>, const v8::Proper tyCallbackInfo<v8::Value>& info)
85 {
86 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
87 TestSerializedScriptValueInterfaceV8Internal::valueAttributeGetter(info);
88 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
89 }
90
91 static void valueAttributeSetter(v8::Local<v8::Value> jsValue, const v8::Propert yCallbackInfo<void>& info)
92 {
93 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
94 V8TRYCATCH_VOID(RefPtr<SerializedScriptValue>, cppValue, SerializedScriptVal ue::create(jsValue, info.GetIsolate()));
95 imp->setValue(WTF::getPtr(cppValue));
96 }
97
98 static void valueAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Va lue> jsValue, const v8::PropertyCallbackInfo<void>& info)
99 {
100 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
101 TestSerializedScriptValueInterfaceV8Internal::valueAttributeSetter(jsValue, info);
102 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
103 }
104
105 static void readonlyValueAttributeGetter(const v8::PropertyCallbackInfo<v8::Valu e>& info)
106 {
107 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
108 v8SetReturnValue(info, imp->readonlyValue() ? imp->readonlyValue()->deserial ize() : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));
109 }
110
111 static void readonlyValueAttributeGetterCallback(v8::Local<v8::String>, const v8 ::PropertyCallbackInfo<v8::Value>& info)
112 {
113 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
114 TestSerializedScriptValueInterfaceV8Internal::readonlyValueAttributeGetter(i nfo);
115 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
116 }
117
118 static void dirtySerializedValueAttributeGetter(const v8::PropertyCallbackInfo<v 8::Value>& info)
119 {
120 v8::Handle<v8::String> propertyName = v8::String::NewFromUtf8(info.GetIsolat e(), "dirtySerializedValue", v8::String::kInternalizedString);
121 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
122 if (!imp->isValueDirty()) {
123 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa me);
124 if (!jsValue.IsEmpty()) {
125 v8SetReturnValue(info, jsValue);
126 return;
127 }
128 }
129 RefPtr<SerializedScriptValue> serialized = imp->dirtySerializedValue();
130 ScriptValue jsValue = serialized ? serialized->deserialize() : v8::Handle<v8 ::Value>(v8::Null(info.GetIsolate()));
131 info.Holder()->SetHiddenValue(propertyName, jsValue);
132 v8SetReturnValue(info, jsValue);
133 }
134
135 static void dirtySerializedValueAttributeGetterCallback(v8::Local<v8::String>, c onst v8::PropertyCallbackInfo<v8::Value>& info)
136 {
137 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
138 TestSerializedScriptValueInterfaceV8Internal::dirtySerializedValueAttributeG etter(info);
139 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
140 }
141
142 static void dirtySerializedValueAttributeSetter(v8::Local<v8::Value> jsValue, co nst v8::PropertyCallbackInfo<void>& info)
143 {
144 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
145 V8TRYCATCH_VOID(RefPtr<SerializedScriptValue>, cppValue, SerializedScriptVal ue::create(jsValue, info.GetIsolate()));
146 imp->setDirtySerializedValue(WTF::getPtr(cppValue));
147 info.Holder()->DeleteHiddenValue(v8::String::NewFromUtf8(info.GetIsolate(), "dirtySerializedValue", v8::String::kInternalizedString)); // Invalidate the cac hed value.
148 }
149
150 static void dirtySerializedValueAttributeSetterCallback(v8::Local<v8::String>, v 8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
151 {
152 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
153 TestSerializedScriptValueInterfaceV8Internal::dirtySerializedValueAttributeS etter(jsValue, info);
154 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
155 }
156
157 static void dirtyScriptValueAttributeGetter(const v8::PropertyCallbackInfo<v8::V alue>& info)
158 {
159 v8::Handle<v8::String> propertyName = v8::String::NewFromUtf8(info.GetIsolat e(), "dirtyScriptValue", v8::String::kInternalizedString);
160 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
161 if (!imp->isValueDirty()) {
162 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa me);
163 if (!jsValue.IsEmpty()) {
164 v8SetReturnValue(info, jsValue);
165 return;
166 }
167 }
168 ScriptValue jsValue = imp->dirtyScriptValue();
169 info.Holder()->SetHiddenValue(propertyName, jsValue.v8Value());
170 v8SetReturnValue(info, jsValue.v8Value());
171 }
172
173 static void dirtyScriptValueAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
174 {
175 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
176 TestSerializedScriptValueInterfaceV8Internal::dirtyScriptValueAttributeGette r(info);
177 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
178 }
179
180 static void dirtyScriptValueAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
181 {
182 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
183 V8TRYCATCH_VOID(ScriptValue, cppValue, ScriptValue(jsValue, info.GetIsolate( )));
184 imp->setDirtyScriptValue(cppValue);
185 info.Holder()->DeleteHiddenValue(v8::String::NewFromUtf8(info.GetIsolate(), "dirtyScriptValue", v8::String::kInternalizedString)); // Invalidate the cached value.
186 }
187
188 static void dirtyScriptValueAttributeSetterCallback(v8::Local<v8::String>, v8::L ocal<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
189 {
190 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
191 TestSerializedScriptValueInterfaceV8Internal::dirtyScriptValueAttributeSette r(jsValue, info);
192 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
193 }
194
195 static void cachedValueCallWithAttributeGetter(const v8::PropertyCallbackInfo<v8 ::Value>& info)
196 {
197 v8::Handle<v8::String> propertyName = v8::String::NewFromUtf8(info.GetIsolat e(), "cachedValueCallWith", v8::String::kInternalizedString);
198 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
199 if (!imp->isValueDirty()) {
200 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa me);
201 if (!jsValue.IsEmpty()) {
202 v8SetReturnValue(info, jsValue);
203 return;
204 }
205 }
206 ScriptState* currentState = ScriptState::current();
207 if (!currentState)
208 return v8Undefined();
209 ScriptState& state = *currentState;
210 RefPtr<SerializedScriptValue> serialized = imp->cachedValueCallWith(&state);
211 ScriptValue jsValue = serialized ? serialized->deserialize() : v8::Handle<v8 ::Value>(v8::Null(info.GetIsolate()));
212 info.Holder()->SetHiddenValue(propertyName, jsValue);
213 v8SetReturnValue(info, jsValue);
214 }
215
216 static void cachedValueCallWithAttributeGetterCallback(v8::Local<v8::String>, co nst v8::PropertyCallbackInfo<v8::Value>& info)
217 {
218 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
219 TestSerializedScriptValueInterfaceV8Internal::cachedValueCallWithAttributeGe tter(info);
220 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
221 }
222
223 static void cachedValueCallWithAttributeSetter(v8::Local<v8::Value> jsValue, con st v8::PropertyCallbackInfo<void>& info)
224 {
225 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
226 V8TRYCATCH_VOID(RefPtr<SerializedScriptValue>, cppValue, SerializedScriptVal ue::create(jsValue, info.GetIsolate()));
227 ScriptState* currentState = ScriptState::current();
228 if (!currentState)
229 return;
230 ScriptState& state = *currentState;
231 imp->setCachedValueCallWith(&state, WTF::getPtr(cppValue));
232 if (state.hadException())
233 throwError(state.exception(), info.GetIsolate());
234 info.Holder()->DeleteHiddenValue(v8::String::NewFromUtf8(info.GetIsolate(), "cachedValueCallWith", v8::String::kInternalizedString)); // Invalidate the cach ed value.
235 }
236
237 static void cachedValueCallWithAttributeSetterCallback(v8::Local<v8::String>, v8 ::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
238 {
239 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
240 TestSerializedScriptValueInterfaceV8Internal::cachedValueCallWithAttributeSe tter(jsValue, info);
241 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
242 }
243
244 } // namespace TestSerializedScriptValueInterfaceV8Internal
245
246 static const V8DOMConfiguration::AttributeConfiguration V8TestSerializedScriptVa lueInterfaceAttributes[] = {
247 {"value", TestSerializedScriptValueInterfaceV8Internal::valueAttributeGetter Callback, TestSerializedScriptValueInterfaceV8Internal::valueAttributeSetterCall back, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::Prop ertyAttribute>(v8::None), 0 /* on instance */},
248 {"readonlyValue", TestSerializedScriptValueInterfaceV8Internal::readonlyValu eAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT ), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
249 {"dirtySerializedValue", TestSerializedScriptValueInterfaceV8Internal::dirty SerializedValueAttributeGetterCallback, TestSerializedScriptValueInterfaceV8Inte rnal::dirtySerializedValueAttributeSetterCallback, 0, 0, 0, static_cast<v8::Acce ssControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on i nstance */},
250 {"dirtyScriptValue", TestSerializedScriptValueInterfaceV8Internal::dirtyScri ptValueAttributeGetterCallback, TestSerializedScriptValueInterfaceV8Internal::di rtyScriptValueAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v 8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
251 {"cachedValueCallWith", TestSerializedScriptValueInterfaceV8Internal::cached ValueCallWithAttributeGetterCallback, TestSerializedScriptValueInterfaceV8Intern al::cachedValueCallWithAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessC ontrol>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on inst ance */},
252 };
253
254 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestSerializedScriptValueInte rfaceTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* is olate, WrapperWorldType currentWorldType)
255 {
256 functionTemplate->ReadOnlyPrototype();
257
258 v8::Local<v8::Signature> defaultSignature;
259 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestSerializedScriptValueInterface", v8::Local<v8::FunctionTemplate>(), V8 TestSerializedScriptValueInterface::internalFieldCount,
260 V8TestSerializedScriptValueInterfaceAttributes, WTF_ARRAY_LENGTH(V8TestS erializedScriptValueInterfaceAttributes),
261 0, 0,
262 0, 0,
263 isolate, currentWorldType);
264 UNUSED_PARAM(defaultSignature);
265 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate();
266 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate();
267 UNUSED_PARAM(instanceTemplate);
268 UNUSED_PARAM(prototypeTemplate);
269
270 // Custom toString template
271 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate());
272 return functionTemplate;
273 }
274
275 v8::Handle<v8::FunctionTemplate> V8TestSerializedScriptValueInterface::GetTempla te(v8::Isolate* isolate, WrapperWorldType currentWorldType)
276 {
277 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
278 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo);
279 if (result != data->templateMap(currentWorldType).end())
280 return result->value.newLocal(isolate);
281
282 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
283 v8::EscapableHandleScope handleScope(isolate);
284 v8::Local<v8::FunctionTemplate> templ =
285 ConfigureV8TestSerializedScriptValueInterfaceTemplate(data->rawTemplate( &wrapperTypeInfo, currentWorldType), isolate, currentWorldType);
286 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
287 return handleScope.Escape(templ);
288 }
289
290 bool V8TestSerializedScriptValueInterface::hasInstance(v8::Handle<v8::Value> jsV alue, v8::Isolate* isolate, WrapperWorldType currentWorldType)
291 {
292 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, currentWorldType);
293 }
294
295 bool V8TestSerializedScriptValueInterface::hasInstanceInAnyWorld(v8::Handle<v8:: Value> jsValue, v8::Isolate* isolate)
296 {
297 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, MainWorld)
298 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, IsolatedWorld)
299 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, WorkerWorld);
300 }
301
302 v8::Handle<v8::Object> V8TestSerializedScriptValueInterface::createWrapper(PassR efPtr<TestSerializedScriptValueInterface> impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate)
303 {
304 ASSERT(impl);
305 ASSERT(!DOMDataStore::containsWrapper<V8TestSerializedScriptValueInterface>( impl.get(), isolate));
306 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
307 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
308 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
309 // the same object de-ref functions, though, so use that as the basis of the check.
310 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
311 }
312
313 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
314 if (UNLIKELY(wrapper.IsEmpty()))
315 return wrapper;
316
317 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
318 V8DOMWrapper::associateObjectWithWrapper<V8TestSerializedScriptValueInterfac e>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
319 return wrapper;
320 }
321
322 void V8TestSerializedScriptValueInterface::derefObject(void* object)
323 {
324 fromInternalPointer(object)->deref();
325 }
326
327 template<>
328 v8::Handle<v8::Value> toV8NoInline(TestSerializedScriptValueInterface* impl, v8: :Handle<v8::Object> creationContext, v8::Isolate* isolate)
329 {
330 return toV8(impl, creationContext, isolate);
331 }
332
333 } // namespace WebCore
334 #endif // ENABLE(Condition1) || ENABLE(Condition2)
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestSerializedScriptValueInterface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698