OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 }; | 423 }; |
424 | 424 |
425 template CORE_EXPORT bool DictionaryHelper::get(const Dictionary&, const String&
key, RefPtr<DOMUint8Array>& value); | 425 template CORE_EXPORT bool DictionaryHelper::get(const Dictionary&, const String&
key, RefPtr<DOMUint8Array>& value); |
426 | 426 |
427 template <typename T> | 427 template <typename T> |
428 struct IntegralTypeTraits { | 428 struct IntegralTypeTraits { |
429 }; | 429 }; |
430 | 430 |
431 template <> | 431 template <> |
432 struct IntegralTypeTraits<uint8_t> { | 432 struct IntegralTypeTraits<uint8_t> { |
433 static inline uint8_t toIntegral(v8::Handle<v8::Value> value, IntegerConvers
ionConfiguration configuration, ExceptionState& exceptionState) | 433 static inline uint8_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionS
tate) |
434 { | 434 { |
435 return toUInt8(value, configuration, exceptionState); | 435 return toUInt8(isolate, value, configuration, exceptionState); |
436 } | 436 } |
437 static const String typeName() { return "UInt8"; } | 437 static const String typeName() { return "UInt8"; } |
438 }; | 438 }; |
439 | 439 |
440 template <> | 440 template <> |
441 struct IntegralTypeTraits<int8_t> { | 441 struct IntegralTypeTraits<int8_t> { |
442 static inline int8_t toIntegral(v8::Handle<v8::Value> value, IntegerConversi
onConfiguration configuration, ExceptionState& exceptionState) | 442 static inline int8_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionSt
ate) |
443 { | 443 { |
444 return toInt8(value, configuration, exceptionState); | 444 return toInt8(isolate, value, configuration, exceptionState); |
445 } | 445 } |
446 static const String typeName() { return "Int8"; } | 446 static const String typeName() { return "Int8"; } |
447 }; | 447 }; |
448 | 448 |
449 template <> | 449 template <> |
450 struct IntegralTypeTraits<unsigned short> { | 450 struct IntegralTypeTraits<unsigned short> { |
451 static inline uint16_t toIntegral(v8::Handle<v8::Value> value, IntegerConver
sionConfiguration configuration, ExceptionState& exceptionState) | 451 static inline uint16_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value
> value, IntegerConversionConfiguration configuration, ExceptionState& exception
State) |
452 { | 452 { |
453 return toUInt16(value, configuration, exceptionState); | 453 return toUInt16(isolate, value, configuration, exceptionState); |
454 } | 454 } |
455 static const String typeName() { return "UInt16"; } | 455 static const String typeName() { return "UInt16"; } |
456 }; | 456 }; |
457 | 457 |
458 template <> | 458 template <> |
459 struct IntegralTypeTraits<short> { | 459 struct IntegralTypeTraits<short> { |
460 static inline int16_t toIntegral(v8::Handle<v8::Value> value, IntegerConvers
ionConfiguration configuration, ExceptionState& exceptionState) | 460 static inline int16_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionS
tate) |
461 { | 461 { |
462 return toInt16(value, configuration, exceptionState); | 462 return toInt16(isolate, value, configuration, exceptionState); |
463 } | 463 } |
464 static const String typeName() { return "Int16"; } | 464 static const String typeName() { return "Int16"; } |
465 }; | 465 }; |
466 | 466 |
467 template <> | 467 template <> |
468 struct IntegralTypeTraits<unsigned> { | 468 struct IntegralTypeTraits<unsigned> { |
469 static inline uint32_t toIntegral(v8::Handle<v8::Value> value, IntegerConver
sionConfiguration configuration, ExceptionState& exceptionState) | 469 static inline uint32_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value
> value, IntegerConversionConfiguration configuration, ExceptionState& exception
State) |
470 { | 470 { |
471 return toUInt32(value, configuration, exceptionState); | 471 return toUInt32(isolate, value, configuration, exceptionState); |
472 } | 472 } |
473 static const String typeName() { return "UInt32"; } | 473 static const String typeName() { return "UInt32"; } |
474 }; | 474 }; |
475 | 475 |
476 template <> | 476 template <> |
477 struct IntegralTypeTraits<unsigned long> { | 477 struct IntegralTypeTraits<unsigned long> { |
478 static inline uint32_t toIntegral(v8::Handle<v8::Value> value, IntegerConver
sionConfiguration configuration, ExceptionState& exceptionState) | 478 static inline uint32_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value
> value, IntegerConversionConfiguration configuration, ExceptionState& exception
State) |
479 { | 479 { |
480 return toUInt32(value, configuration, exceptionState); | 480 return toUInt32(isolate, value, configuration, exceptionState); |
481 } | 481 } |
482 static const String typeName() { return "UInt32"; } | 482 static const String typeName() { return "UInt32"; } |
483 }; | 483 }; |
484 | 484 |
485 template <> | 485 template <> |
486 struct IntegralTypeTraits<int> { | 486 struct IntegralTypeTraits<int> { |
487 static inline int32_t toIntegral(v8::Handle<v8::Value> value, IntegerConvers
ionConfiguration configuration, ExceptionState& exceptionState) | 487 static inline int32_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionS
tate) |
488 { | 488 { |
489 return toInt32(value, configuration, exceptionState); | 489 return toInt32(isolate, value, configuration, exceptionState); |
490 } | 490 } |
491 static const String typeName() { return "Int32"; } | 491 static const String typeName() { return "Int32"; } |
492 }; | 492 }; |
493 | 493 |
494 template <> | 494 template <> |
495 struct IntegralTypeTraits<long> { | 495 struct IntegralTypeTraits<long> { |
496 static inline int32_t toIntegral(v8::Handle<v8::Value> value, IntegerConvers
ionConfiguration configuration, ExceptionState& exceptionState) | 496 static inline int32_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionS
tate) |
497 { | 497 { |
498 return toInt32(value, configuration, exceptionState); | 498 return toInt32(isolate, value, configuration, exceptionState); |
499 } | 499 } |
500 static const String typeName() { return "Int32"; } | 500 static const String typeName() { return "Int32"; } |
501 }; | 501 }; |
502 | 502 |
503 template <> | 503 template <> |
504 struct IntegralTypeTraits<unsigned long long> { | 504 struct IntegralTypeTraits<unsigned long long> { |
505 static inline unsigned long long toIntegral(v8::Handle<v8::Value> value, Int
egerConversionConfiguration configuration, ExceptionState& exceptionState) | 505 static inline unsigned long long toIntegral(v8::Isolate* isolate, v8::Handle
<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState&
exceptionState) |
506 { | 506 { |
507 return toUInt64(value, configuration, exceptionState); | 507 return toUInt64(isolate, value, configuration, exceptionState); |
508 } | 508 } |
509 static const String typeName() { return "UInt64"; } | 509 static const String typeName() { return "UInt64"; } |
510 }; | 510 }; |
511 | 511 |
512 template <> | 512 template <> |
513 struct IntegralTypeTraits<long long> { | 513 struct IntegralTypeTraits<long long> { |
514 static inline long long toIntegral(v8::Handle<v8::Value> value, IntegerConve
rsionConfiguration configuration, ExceptionState& exceptionState) | 514 static inline long long toIntegral(v8::Isolate* isolate, v8::Handle<v8::Valu
e> value, IntegerConversionConfiguration configuration, ExceptionState& exceptio
nState) |
515 { | 515 { |
516 return toInt64(value, configuration, exceptionState); | 516 return toInt64(isolate, value, configuration, exceptionState); |
517 } | 517 } |
518 static const String typeName() { return "Int64"; } | 518 static const String typeName() { return "Int64"; } |
519 }; | 519 }; |
520 | 520 |
521 template<typename T> | 521 template<typename T> |
522 bool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::Convers
ionContext& context, const String& key, T& value) | 522 bool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::Convers
ionContext& context, const String& key, T& value) |
523 { | 523 { |
524 Dictionary::ConversionContextScope scope(context); | 524 Dictionary::ConversionContextScope scope(context); |
525 | 525 |
526 v8::Local<v8::Value> v8Value; | 526 v8::Local<v8::Value> v8Value; |
527 if (!dictionary.get(key, v8Value)) | 527 if (!dictionary.get(key, v8Value)) |
528 return true; | 528 return true; |
529 | 529 |
530 value = IntegralTypeTraits<T>::toIntegral(v8Value, NormalConversion, context
.exceptionState()); | 530 value = IntegralTypeTraits<T>::toIntegral(dictionary.isolate(), v8Value, Nor
malConversion, context.exceptionState()); |
531 if (context.exceptionState().throwIfNeeded()) | 531 if (context.exceptionState().throwIfNeeded()) |
532 return false; | 532 return false; |
533 | 533 |
534 return true; | 534 return true; |
535 } | 535 } |
536 | 536 |
537 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio
nContext&, const String& key, uint8_t& value); | 537 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio
nContext&, const String& key, uint8_t& value); |
538 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio
nContext&, const String& key, int8_t& value); | 538 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio
nContext&, const String& key, int8_t& value); |
539 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio
nContext&, const String& key, unsigned short& value); | 539 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio
nContext&, const String& key, unsigned short& value); |
540 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio
nContext&, const String& key, short& value); | 540 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio
nContext&, const String& key, short& value); |
(...skipping 23 matching lines...) Expand all Loading... |
564 | 564 |
565 value = toRefPtrWillBeMemberNativeArray<MessagePort, V8MessagePort>(v8Value,
key, dictionary.isolate(), context.exceptionState()); | 565 value = toRefPtrWillBeMemberNativeArray<MessagePort, V8MessagePort>(v8Value,
key, dictionary.isolate(), context.exceptionState()); |
566 | 566 |
567 if (context.exceptionState().throwIfNeeded()) | 567 if (context.exceptionState().throwIfNeeded()) |
568 return false; | 568 return false; |
569 | 569 |
570 return true; | 570 return true; |
571 } | 571 } |
572 | 572 |
573 } // namespace blink | 573 } // namespace blink |
OLD | NEW |