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

Side by Side Diff: third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp

Issue 2709983004: WIP bindings: Add support for the record<K,V> WebIDL type. (Closed)
Patch Set: Rebased patch using NativeValueTraits for IDL types Created 3 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file has been auto-generated by code_generator_v8.py. 5 // This file has been auto-generated by code_generator_v8.py.
6 // DO NOT MODIFY! 6 // DO NOT MODIFY!
7 7
8 // This file has been generated from the Jinja2 template in 8 // This file has been generated from the Jinja2 template in
9 // third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl 9 // third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl
10 10
11 // clang-format off 11 // clang-format off
12 #include "V8TestTypedefs.h" 12 #include "V8TestTypedefs.h"
13 13
14 #include "bindings/core/v8/ByteStringSequenceSequenceOrByteStringByteStringRecor d.h"
14 #include "bindings/core/v8/ExceptionState.h" 15 #include "bindings/core/v8/ExceptionState.h"
16 #include "bindings/core/v8/IDLTypes.h"
15 #include "bindings/core/v8/StringOrDouble.h" 17 #include "bindings/core/v8/StringOrDouble.h"
16 #include "bindings/core/v8/TestInterfaceOrTestInterfaceEmpty.h" 18 #include "bindings/core/v8/TestInterfaceOrTestInterfaceEmpty.h"
17 #include "bindings/core/v8/V8DOMConfiguration.h" 19 #include "bindings/core/v8/V8DOMConfiguration.h"
18 #include "bindings/core/v8/V8ObjectConstructor.h" 20 #include "bindings/core/v8/V8ObjectConstructor.h"
19 #include "bindings/core/v8/V8TestCallbackInterface.h" 21 #include "bindings/core/v8/V8TestCallbackInterface.h"
20 #include "bindings/core/v8/V8TestInterface.h" 22 #include "bindings/core/v8/V8TestInterface.h"
21 #include "bindings/core/v8/V8TestInterfaceEmpty.h" 23 #include "bindings/core/v8/V8TestInterfaceEmpty.h"
24 #include "bindings/core/v8/V8TestObject.h"
22 #include "core/dom/Document.h" 25 #include "core/dom/Document.h"
23 #include "core/frame/LocalDOMWindow.h" 26 #include "core/frame/LocalDOMWindow.h"
24 #include "wtf/GetPtr.h" 27 #include "wtf/GetPtr.h"
25 #include "wtf/RefPtr.h" 28 #include "wtf/RefPtr.h"
26 29
27 namespace blink { 30 namespace blink {
28 31
29 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial 32 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial
30 // and does not depend on another global objects. 33 // and does not depend on another global objects.
31 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 34 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 236 }
234 237
235 Vector<String> stringArrayArg; 238 Vector<String> stringArrayArg;
236 stringArrayArg = toImplArray<Vector<String>>(info[0], 1, info.GetIsolate(), ex ceptionState); 239 stringArrayArg = toImplArray<Vector<String>>(info[0], 1, info.GetIsolate(), ex ceptionState);
237 if (exceptionState.hadException()) 240 if (exceptionState.hadException())
238 return; 241 return;
239 242
240 v8SetReturnValue(info, ToV8(impl->stringArrayMethodStringArrayArg(stringArrayA rg), info.Holder(), info.GetIsolate())); 243 v8SetReturnValue(info, ToV8(impl->stringArrayMethodStringArrayArg(stringArrayA rg), info.Holder(), info.GetIsolate()));
241 } 244 }
242 245
246 static void methodTakingRecordMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
247 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "TestTypedefs", "methodTakingRecord");
248
249 TestTypedefs* impl = V8TestTypedefs::toImpl(info.Holder());
250
251 if (UNLIKELY(info.Length() < 1)) {
252 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info. Length()));
253 return;
254 }
255
256 Vector<std::pair<String, int>> arg;
257 arg = NativeValueTraits<idl::Record<idl::ByteString, idl::Long>>::nativeValue( info.GetIsolate(), info[0], exceptionState);
258 if (exceptionState.hadException())
259 return;
260
261 impl->methodTakingRecord(arg);
262 }
263
264 static void methodTakingOilpanValueRecordMethod(const v8::FunctionCallbackInfo<v 8::Value>& info) {
265 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "TestTypedefs", "methodTakingOilpanValueRecord");
266
267 TestTypedefs* impl = V8TestTypedefs::toImpl(info.Holder());
268
269 if (UNLIKELY(info.Length() < 1)) {
270 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info. Length()));
271 return;
272 }
273
274 HeapVector<std::pair<String, Member<TestObject>>> arg;
275 arg = NativeValueTraits<idl::Record<idl::USVString, TestObject>>::nativeValue( info.GetIsolate(), info[0], exceptionState);
276 if (exceptionState.hadException())
277 return;
278
279 impl->methodTakingOilpanValueRecord(arg);
280 }
281
282 static void unionWithRecordMethodMethod(const v8::FunctionCallbackInfo<v8::Value >& info) {
283 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "TestTypedefs", "unionWithRecordMethod");
284
285 TestTypedefs* impl = V8TestTypedefs::toImpl(info.Holder());
286
287 if (UNLIKELY(info.Length() < 1)) {
288 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info. Length()));
289 return;
290 }
291
292 ByteStringSequenceSequenceOrByteStringByteStringRecord arg;
293 V8ByteStringSequenceSequenceOrByteStringByteStringRecord::toImpl(info.GetIsola te(), info[0], arg, UnionTypeConversionMode::NotNullable, exceptionState);
294 if (exceptionState.hadException())
295 return;
296
297 v8SetReturnValue(info, impl->unionWithRecordMethod(arg));
298 }
299
300 static void methodThatReturnsRecordMethod(const v8::FunctionCallbackInfo<v8::Val ue>& info) {
301 TestTypedefs* impl = V8TestTypedefs::toImpl(info.Holder());
302
303 v8SetReturnValue(info, ToV8(impl->methodThatReturnsRecord(), info.Holder(), in fo.GetIsolate()));
304 }
305
243 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) { 306 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) {
244 if (UNLIKELY(info.Length() < 1)) { 307 if (UNLIKELY(info.Length() < 1)) {
245 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::faile dToConstruct("TestTypedefs", ExceptionMessages::notEnoughArguments(1, info.Lengt h()))); 308 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::faile dToConstruct("TestTypedefs", ExceptionMessages::notEnoughArguments(1, info.Lengt h())));
246 return; 309 return;
247 } 310 }
248 311
249 V8StringResource<> stringArg; 312 V8StringResource<> stringArg;
250 stringArg = info[0]; 313 stringArg = info[0];
251 if (!stringArg.prepare()) 314 if (!stringArg.prepare())
252 return; 315 return;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 367 }
305 368
306 void V8TestTypedefs::arrayOfStringsMethodArrayOfStringsArgMethodCallback(const v 8::FunctionCallbackInfo<v8::Value>& info) { 369 void V8TestTypedefs::arrayOfStringsMethodArrayOfStringsArgMethodCallback(const v 8::FunctionCallbackInfo<v8::Value>& info) {
307 TestTypedefsV8Internal::arrayOfStringsMethodArrayOfStringsArgMethod(info); 370 TestTypedefsV8Internal::arrayOfStringsMethodArrayOfStringsArgMethod(info);
308 } 371 }
309 372
310 void V8TestTypedefs::stringArrayMethodStringArrayArgMethodCallback(const v8::Fun ctionCallbackInfo<v8::Value>& info) { 373 void V8TestTypedefs::stringArrayMethodStringArrayArgMethodCallback(const v8::Fun ctionCallbackInfo<v8::Value>& info) {
311 TestTypedefsV8Internal::stringArrayMethodStringArrayArgMethod(info); 374 TestTypedefsV8Internal::stringArrayMethodStringArrayArgMethod(info);
312 } 375 }
313 376
377 void V8TestTypedefs::methodTakingRecordMethodCallback(const v8::FunctionCallback Info<v8::Value>& info) {
378 TestTypedefsV8Internal::methodTakingRecordMethod(info);
379 }
380
381 void V8TestTypedefs::methodTakingOilpanValueRecordMethodCallback(const v8::Funct ionCallbackInfo<v8::Value>& info) {
382 TestTypedefsV8Internal::methodTakingOilpanValueRecordMethod(info);
383 }
384
385 void V8TestTypedefs::unionWithRecordMethodMethodCallback(const v8::FunctionCallb ackInfo<v8::Value>& info) {
386 TestTypedefsV8Internal::unionWithRecordMethodMethod(info);
387 }
388
389 void V8TestTypedefs::methodThatReturnsRecordMethodCallback(const v8::FunctionCal lbackInfo<v8::Value>& info) {
390 TestTypedefsV8Internal::methodThatReturnsRecordMethod(info);
391 }
392
314 // Suppress warning: global constructors, because AttributeConfiguration is triv ial 393 // Suppress warning: global constructors, because AttributeConfiguration is triv ial
315 // and does not depend on another global objects. 394 // and does not depend on another global objects.
316 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 395 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
317 #pragma clang diagnostic push 396 #pragma clang diagnostic push
318 #pragma clang diagnostic ignored "-Wglobal-constructors" 397 #pragma clang diagnostic ignored "-Wglobal-constructors"
319 #endif 398 #endif
320 const V8DOMConfiguration::AttributeConfiguration V8TestTypedefsLazyDataAttribute s[] = { 399 const V8DOMConfiguration::AttributeConfiguration V8TestTypedefsLazyDataAttribute s[] = {
321 {"tAttribute", v8ConstructorAttributeGetter, nullptr, nullptr, nullptr, null ptr, const_cast<WrapperTypeInfo*>(&V8TestInterface::wrapperTypeInfo), static_cas t<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::OnInstance, V8DOMCon figuration::CheckHolder}, 400 {"tAttribute", v8ConstructorAttributeGetter, nullptr, nullptr, nullptr, null ptr, const_cast<WrapperTypeInfo*>(&V8TestInterface::wrapperTypeInfo), static_cas t<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::OnInstance, V8DOMCon figuration::CheckHolder},
322 }; 401 };
323 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 402 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
324 #pragma clang diagnostic pop 403 #pragma clang diagnostic pop
325 #endif 404 #endif
326 405
327 const V8DOMConfiguration::AccessorConfiguration V8TestTypedefsAccessors[] = { 406 const V8DOMConfiguration::AccessorConfiguration V8TestTypedefsAccessors[] = {
328 {"uLongLongAttribute", V8TestTypedefs::uLongLongAttributeAttributeGetterCall back, V8TestTypedefs::uLongLongAttributeAttributeSetterCallback, nullptr, nullpt r, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfigur ation::OnPrototype, V8DOMConfiguration::CheckHolder}, 407 {"uLongLongAttribute", V8TestTypedefs::uLongLongAttributeAttributeGetterCall back, V8TestTypedefs::uLongLongAttributeAttributeSetterCallback, nullptr, nullpt r, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfigur ation::OnPrototype, V8DOMConfiguration::CheckHolder},
329 {"domStringOrDoubleOrNullAttribute", V8TestTypedefs::domStringOrDoubleOrNull AttributeAttributeGetterCallback, V8TestTypedefs::domStringOrDoubleOrNullAttribu teAttributeSetterCallback, nullptr, nullptr, nullptr, nullptr, static_cast<v8::P ropertyAttribute>(v8::None), V8DOMConfiguration::OnPrototype, V8DOMConfiguration ::CheckHolder}, 408 {"domStringOrDoubleOrNullAttribute", V8TestTypedefs::domStringOrDoubleOrNull AttributeAttributeGetterCallback, V8TestTypedefs::domStringOrDoubleOrNullAttribu teAttributeSetterCallback, nullptr, nullptr, nullptr, nullptr, static_cast<v8::P ropertyAttribute>(v8::None), V8DOMConfiguration::OnPrototype, V8DOMConfiguration ::CheckHolder},
330 }; 409 };
331 410
332 const V8DOMConfiguration::MethodConfiguration V8TestTypedefsMethods[] = { 411 const V8DOMConfiguration::MethodConfiguration V8TestTypedefsMethods[] = {
333 {"voidMethodArrayOfLongsArg", V8TestTypedefs::voidMethodArrayOfLongsArgMetho dCallback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfigura tion::CheckHolder, V8DOMConfiguration::DoNotCheckAccess}, 412 {"voidMethodArrayOfLongsArg", V8TestTypedefs::voidMethodArrayOfLongsArgMetho dCallback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfigura tion::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
334 {"voidMethodFloatArgStringArg", V8TestTypedefs::voidMethodFloatArgStringArgM ethodCallback, nullptr, 2, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfi guration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess}, 413 {"voidMethodFloatArgStringArg", V8TestTypedefs::voidMethodFloatArgStringArgM ethodCallback, nullptr, 2, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfi guration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
335 {"voidMethodTestCallbackInterfaceTypeArg", V8TestTypedefs::voidMethodTestCal lbackInterfaceTypeArgMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::O nPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAcces s}, 414 {"voidMethodTestCallbackInterfaceTypeArg", V8TestTypedefs::voidMethodTestCal lbackInterfaceTypeArgMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::O nPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAcces s},
336 {"uLongLongMethodTestInterfaceEmptyTypeSequenceArg", V8TestTypedefs::uLongLo ngMethodTestInterfaceEmptyTypeSequenceArgMethodCallback, nullptr, 1, v8::None, V 8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfigurat ion::DoNotCheckAccess}, 415 {"uLongLongMethodTestInterfaceEmptyTypeSequenceArg", V8TestTypedefs::uLongLo ngMethodTestInterfaceEmptyTypeSequenceArgMethodCallback, nullptr, 1, v8::None, V 8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfigurat ion::DoNotCheckAccess},
337 {"testInterfaceOrTestInterfaceEmptyMethod", V8TestTypedefs::testInterfaceOrT estInterfaceEmptyMethodMethodCallback, nullptr, 0, v8::None, V8DOMConfiguration: :OnPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAcc ess}, 416 {"testInterfaceOrTestInterfaceEmptyMethod", V8TestTypedefs::testInterfaceOrT estInterfaceEmptyMethodMethodCallback, nullptr, 0, v8::None, V8DOMConfiguration: :OnPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAcc ess},
338 {"domStringOrDoubleMethod", V8TestTypedefs::domStringOrDoubleMethodMethodCal lback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration ::CheckHolder, V8DOMConfiguration::DoNotCheckAccess}, 417 {"domStringOrDoubleMethod", V8TestTypedefs::domStringOrDoubleMethodMethodCal lback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration ::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
339 {"arrayOfStringsMethodArrayOfStringsArg", V8TestTypedefs::arrayOfStringsMeth odArrayOfStringsArgMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnP rototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess} , 418 {"arrayOfStringsMethodArrayOfStringsArg", V8TestTypedefs::arrayOfStringsMeth odArrayOfStringsArgMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnP rototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess} ,
340 {"stringArrayMethodStringArrayArg", V8TestTypedefs::stringArrayMethodStringA rrayArgMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8 DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess}, 419 {"stringArrayMethodStringArrayArg", V8TestTypedefs::stringArrayMethodStringA rrayArgMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8 DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
420 {"methodTakingRecord", V8TestTypedefs::methodTakingRecordMethodCallback, nul lptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHol der, V8DOMConfiguration::DoNotCheckAccess},
421 {"methodTakingOilpanValueRecord", V8TestTypedefs::methodTakingOilpanValueRec ordMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMC onfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
422 {"unionWithRecordMethod", V8TestTypedefs::unionWithRecordMethodMethodCallbac k, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::Ch eckHolder, V8DOMConfiguration::DoNotCheckAccess},
423 {"methodThatReturnsRecord", V8TestTypedefs::methodThatReturnsRecordMethodCal lback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration ::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
341 }; 424 };
342 425
343 void V8TestTypedefs::constructorCallback(const v8::FunctionCallbackInfo<v8::Valu e>& info) { 426 void V8TestTypedefs::constructorCallback(const v8::FunctionCallbackInfo<v8::Valu e>& info) {
344 if (!info.IsConstructCall()) { 427 if (!info.IsConstructCall()) {
345 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::const ructorNotCallableAsFunction("TestTypedefs")); 428 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::const ructorNotCallableAsFunction("TestTypedefs"));
346 return; 429 return;
347 } 430 }
348 431
349 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExisti ngObject) { 432 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExisti ngObject) {
350 v8SetReturnValue(info, info.Holder()); 433 v8SetReturnValue(info, info.Holder());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 466
384 v8::Local<v8::Object> V8TestTypedefs::findInstanceInPrototypeChain(v8::Local<v8: :Value> v8Value, v8::Isolate* isolate) { 467 v8::Local<v8::Object> V8TestTypedefs::findInstanceInPrototypeChain(v8::Local<v8: :Value> v8Value, v8::Isolate* isolate) {
385 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperT ypeInfo, v8Value); 468 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperT ypeInfo, v8Value);
386 } 469 }
387 470
388 TestTypedefs* V8TestTypedefs::toImplWithTypeCheck(v8::Isolate* isolate, v8::Loca l<v8::Value> value) { 471 TestTypedefs* V8TestTypedefs::toImplWithTypeCheck(v8::Isolate* isolate, v8::Loca l<v8::Value> value) {
389 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value) ) : nullptr; 472 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value) ) : nullptr;
390 } 473 }
391 474
392 } // namespace blink 475 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698