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

Side by Side Diff: Source/bindings/v8/Dictionary.cpp

Issue 171533006: V8 Binding: Introduce toNativeWithTypeCheck (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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
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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 value = toDOMWindow(v8Value, m_isolate); 330 value = toDOMWindow(v8Value, m_isolate);
331 return true; 331 return true;
332 } 332 }
333 333
334 bool Dictionary::get(const String& key, RefPtr<Storage>& value) const 334 bool Dictionary::get(const String& key, RefPtr<Storage>& value) const
335 { 335 {
336 v8::Local<v8::Value> v8Value; 336 v8::Local<v8::Value> v8Value;
337 if (!getKey(key, v8Value)) 337 if (!getKey(key, v8Value))
338 return false; 338 return false;
339 339
340 value = 0; 340 value = V8Storage::toNativeWithTypeCheck(m_isolate, v8Value);
341 if (V8Storage::hasInstance(v8Value, m_isolate))
342 value = V8Storage::toNative(v8::Handle<v8::Object>::Cast(v8Value));
343 return true; 341 return true;
344 } 342 }
345 343
346 bool Dictionary::get(const String& key, MessagePortArray& value) const 344 bool Dictionary::get(const String& key, MessagePortArray& value) const
347 { 345 {
348 v8::Local<v8::Value> v8Value; 346 v8::Local<v8::Value> v8Value;
349 if (!getKey(key, v8Value)) 347 if (!getKey(key, v8Value))
350 return false; 348 return false;
351 349
352 ASSERT(m_isolate); 350 ASSERT(m_isolate);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 value = stringValue; 418 value = stringValue;
421 return true; 419 return true;
422 } 420 }
423 421
424 bool Dictionary::get(const String& key, RefPtr<Uint8Array>& value) const 422 bool Dictionary::get(const String& key, RefPtr<Uint8Array>& value) const
425 { 423 {
426 v8::Local<v8::Value> v8Value; 424 v8::Local<v8::Value> v8Value;
427 if (!getKey(key, v8Value)) 425 if (!getKey(key, v8Value))
428 return false; 426 return false;
429 427
430 value = 0; 428 value = V8Uint8Array::toNativeWithTypeCheck(m_isolate, v8Value);
431 if (V8Uint8Array::hasInstance(v8Value, m_isolate))
432 value = V8Uint8Array::toNative(v8::Handle<v8::Object>::Cast(v8Value));
433 return true; 429 return true;
434 } 430 }
435 431
436 bool Dictionary::get(const String& key, RefPtr<ArrayBufferView>& value) const 432 bool Dictionary::get(const String& key, RefPtr<ArrayBufferView>& value) const
437 { 433 {
438 v8::Local<v8::Value> v8Value; 434 v8::Local<v8::Value> v8Value;
439 if (!getKey(key, v8Value)) 435 if (!getKey(key, v8Value))
440 return false; 436 return false;
441 437
442 value = 0; 438 value = V8ArrayBufferView::toNativeWithTypeCheck(m_isolate, v8Value);
443 if (V8ArrayBufferView::hasInstance(v8Value, m_isolate))
444 value = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(v8Value ));
445 return true; 439 return true;
446 } 440 }
447 441
448 bool Dictionary::get(const String& key, RefPtr<MIDIPort>& value) const 442 bool Dictionary::get(const String& key, RefPtr<MIDIPort>& value) const
449 { 443 {
450 v8::Local<v8::Value> v8Value; 444 v8::Local<v8::Value> v8Value;
451 if (!getKey(key, v8Value)) 445 if (!getKey(key, v8Value))
452 return false; 446 return false;
453 447
454 value = 0; 448 value = V8MIDIPort::toNativeWithTypeCheck(m_isolate, v8Value);
455 if (V8MIDIPort::hasInstance(v8Value, m_isolate))
456 value = V8MIDIPort::toNative(v8::Handle<v8::Object>::Cast(v8Value));
457 return true; 449 return true;
458 } 450 }
459 451
460 bool Dictionary::get(const String& key, RefPtr<MediaKeyError>& value) const 452 bool Dictionary::get(const String& key, RefPtr<MediaKeyError>& value) const
461 { 453 {
462 v8::Local<v8::Value> v8Value; 454 v8::Local<v8::Value> v8Value;
463 if (!getKey(key, v8Value)) 455 if (!getKey(key, v8Value))
464 return false; 456 return false;
465 457
466 value = 0; 458 value = V8MediaKeyError::toNativeWithTypeCheck(m_isolate, v8Value);
467 if (V8MediaKeyError::hasInstance(v8Value, m_isolate))
468 value = V8MediaKeyError::toNative(v8::Handle<v8::Object>::Cast(v8Value)) ;
469 return true; 459 return true;
470 } 460 }
471 461
472 bool Dictionary::get(const String& key, RefPtr<TrackBase>& value) const 462 bool Dictionary::get(const String& key, RefPtr<TrackBase>& value) const
473 { 463 {
474 v8::Local<v8::Value> v8Value; 464 v8::Local<v8::Value> v8Value;
475 if (!getKey(key, v8Value)) 465 if (!getKey(key, v8Value))
476 return false; 466 return false;
477 467
478 TrackBase* source = 0; 468 TrackBase* source = 0;
479 if (v8Value->IsObject()) { 469 if (v8Value->IsObject()) {
480 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); 470 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
481 471
482 // FIXME: this will need to be changed so it can also return an AudioTra ck or a VideoTrack once 472 // FIXME: this will need to be changed so it can also return an AudioTra ck or a VideoTrack once
483 // we add them. 473 // we add them.
484 v8::Handle<v8::Object> track = wrapper->FindInstanceInPrototypeChain(V8T extTrack::domTemplate(m_isolate, worldType(m_isolate))); 474 v8::Handle<v8::Object> track = wrapper->FindInstanceInPrototypeChain(V8T extTrack::domTemplate(m_isolate, worldType(m_isolate)));
485 if (!track.IsEmpty()) 475 if (!track.IsEmpty())
486 source = V8TextTrack::toNative(track); 476 source = V8TextTrack::toNative(track);
487 } 477 }
488 value = source; 478 value = source;
489 return true; 479 return true;
490 } 480 }
491 481
492 bool Dictionary::get(const String& key, RefPtr<SpeechRecognitionError>& value) c onst 482 bool Dictionary::get(const String& key, RefPtr<SpeechRecognitionError>& value) c onst
493 { 483 {
494 v8::Local<v8::Value> v8Value; 484 v8::Local<v8::Value> v8Value;
495 if (!getKey(key, v8Value)) 485 if (!getKey(key, v8Value))
496 return false; 486 return false;
497 487
498 value = 0; 488 value = V8SpeechRecognitionError::toNativeWithTypeCheck(m_isolate, v8Value);
499 if (V8SpeechRecognitionError::hasInstance(v8Value, m_isolate))
500 value = V8SpeechRecognitionError::toNative(v8::Handle<v8::Object>::Cast( v8Value));
501 return true; 489 return true;
502 } 490 }
503 491
504 bool Dictionary::get(const String& key, RefPtrWillBeRawPtr<SpeechRecognitionResu lt>& value) const 492 bool Dictionary::get(const String& key, RefPtrWillBeRawPtr<SpeechRecognitionResu lt>& value) const
505 { 493 {
506 v8::Local<v8::Value> v8Value; 494 v8::Local<v8::Value> v8Value;
507 if (!getKey(key, v8Value)) 495 if (!getKey(key, v8Value))
508 return false; 496 return false;
509 497
510 value = 0; 498 value = V8SpeechRecognitionResult::toNativeWithTypeCheck(m_isolate, v8Value) ;
511 if (V8SpeechRecognitionResult::hasInstance(v8Value, m_isolate))
512 value = V8SpeechRecognitionResult::toNative(v8::Handle<v8::Object>::Cast (v8Value));
513 return true; 499 return true;
514 } 500 }
515 501
516 bool Dictionary::get(const String& key, RefPtrWillBeRawPtr<SpeechRecognitionResu ltList>& value) const 502 bool Dictionary::get(const String& key, RefPtrWillBeRawPtr<SpeechRecognitionResu ltList>& value) const
517 { 503 {
518 v8::Local<v8::Value> v8Value; 504 v8::Local<v8::Value> v8Value;
519 if (!getKey(key, v8Value)) 505 if (!getKey(key, v8Value))
520 return false; 506 return false;
521 507
522 value = 0; 508 value = V8SpeechRecognitionResultList::toNativeWithTypeCheck(m_isolate, v8Va lue);
523 if (V8SpeechRecognitionResultList::hasInstance(v8Value, m_isolate))
524 value = V8SpeechRecognitionResultList::toNative(v8::Handle<v8::Object>:: Cast(v8Value));
525 return true; 509 return true;
526 } 510 }
527 511
528 bool Dictionary::get(const String& key, RefPtr<MediaStream>& value) const 512 bool Dictionary::get(const String& key, RefPtr<MediaStream>& value) const
529 { 513 {
530 v8::Local<v8::Value> v8Value; 514 v8::Local<v8::Value> v8Value;
531 if (!getKey(key, v8Value)) 515 if (!getKey(key, v8Value))
532 return false; 516 return false;
533 517
534 value = 0; 518 value = V8MediaStream::toNativeWithTypeCheck(m_isolate, v8Value);
535 if (V8MediaStream::hasInstance(v8Value, m_isolate))
536 value = V8MediaStream::toNative(v8::Handle<v8::Object>::Cast(v8Value));
537 return true; 519 return true;
538 } 520 }
539 521
540 bool Dictionary::get(const String& key, RefPtr<EventTarget>& value) const 522 bool Dictionary::get(const String& key, RefPtr<EventTarget>& value) const
541 { 523 {
542 v8::Local<v8::Value> v8Value; 524 v8::Local<v8::Value> v8Value;
543 if (!getKey(key, v8Value)) 525 if (!getKey(key, v8Value))
544 return false; 526 return false;
545 527
546 value = 0; 528 value = 0;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 { 752 {
771 if (forConstructor()) { 753 if (forConstructor()) {
772 exceptionState().throwTypeError(detail); 754 exceptionState().throwTypeError(detail);
773 } else { 755 } else {
774 ASSERT(!methodName().isEmpty()); 756 ASSERT(!methodName().isEmpty());
775 exceptionState().throwTypeError(ExceptionMessages::failedToExecute(inter faceName(), methodName(), detail)); 757 exceptionState().throwTypeError(ExceptionMessages::failedToExecute(inter faceName(), methodName(), detail));
776 } 758 }
777 } 759 }
778 760
779 } // namespace WebCore 761 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestTypedefs.cpp ('k') | Source/bindings/v8/IDBBindingUtilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698