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

Side by Side Diff: Source/bindings/v8/V8Binding.h

Issue 178363010: Two version of toRefPtrNativeArray 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
« no previous file with comments | « Source/bindings/scripts/code_generator_v8.pm ('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
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Ericsson AB. All rights reserved. 3 * Copyright (C) 2012 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 if (success) 489 if (success)
490 *success = false; 490 *success = false;
491 throwTypeError("Invalid Array element type", isolate); 491 throwTypeError("Invalid Array element type", isolate);
492 return Vector<RefPtr<T> >(); 492 return Vector<RefPtr<T> >();
493 } 493 }
494 } 494 }
495 return result; 495 return result;
496 } 496 }
497 497
498 template <class T, class V8T> 498 template <class T, class V8T>
499 WillBeHeapVector<RefPtrWillBeMember<T> > toRefPtrWillBeMemberNativeArrayUnch ecked(v8::Local<v8::Value> v8Value, uint32_t length, v8::Isolate* isolate, bool* success = 0) 499 HeapVector<Member<T> > toRefPtrNativeArrayUnchecked(v8::Local<v8::Value> v8V alue, uint32_t length, v8::Isolate* isolate, bool* success = 0)
500 { 500 {
501 WillBeHeapVector<RefPtrWillBeMember<T> > result; 501 HeapVector<Member<T> > result;
502 result.reserveInitialCapacity(length); 502 result.reserveInitialCapacity(length);
503 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); 503 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
504 for (uint32_t i = 0; i < length; ++i) { 504 for (uint32_t i = 0; i < length; ++i) {
505 v8::Handle<v8::Value> element = object->Get(i); 505 v8::Handle<v8::Value> element = object->Get(i);
506 506
507 if (V8T::hasInstance(element, isolate)) { 507 if (V8T::hasInstance(element, isolate)) {
508 v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::C ast(element); 508 v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::C ast(element);
509 result.uncheckedAppend(V8T::toNative(elementObject)); 509 result.uncheckedAppend(V8T::toNative(elementObject));
510 } else { 510 } else {
511 if (success) 511 if (success)
512 *success = false; 512 *success = false;
513 throwTypeError("Invalid Array element type", isolate); 513 throwTypeError("Invalid Array element type", isolate);
514 return WillBeHeapVector<RefPtrWillBeMember<T> >(); 514 return HeapVector<Member<T> >();
515 } 515 }
516 } 516 }
517 return result; 517 return result;
518 } 518 }
519 519
520 v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value>, uint32_t& length, v8::Isolate*); 520 v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value>, uint32_t& length, v8::Isolate*);
521 521
522 template <class T, class V8T> 522 template <class T, class V8T>
523 Vector<RefPtr<T> > toRefPtrNativeArray(v8::Handle<v8::Value> value, int argu mentIndex, v8::Isolate* isolate, bool* success = 0) 523 Vector<RefPtr<T> > toRefPtrNativeArray(v8::Handle<v8::Value> value, int argu mentIndex, v8::Isolate* isolate, bool* success = 0)
524 { 524 {
525 if (success) 525 if (success)
526 *success = true; 526 *success = true;
527 527
528 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); 528 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
529 uint32_t length = 0; 529 uint32_t length = 0;
530 if (value->IsArray()) { 530 if (value->IsArray()) {
531 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); 531 length = v8::Local<v8::Array>::Cast(v8Value)->Length();
532 } else if (toV8Sequence(value, length, isolate).IsEmpty()) { 532 } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
533 throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argu mentIndex), isolate); 533 throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argu mentIndex), isolate);
534 return Vector<RefPtr<T> >(); 534 return Vector<RefPtr<T> >();
535 } 535 }
536 536
537 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, su ccess); 537 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, su ccess);
538 } 538 }
539 539
540 template <class T, class V8T> 540 template <class T, class V8T>
541 WillBeHeapVector<RefPtrWillBeMember<T> > toRefPtrWillBeMemberNativeArray(v8: :Handle<v8::Value> value, int argumentIndex, v8::Isolate* isolate, bool* success = 0) 541 HeapVector<Member<T> > toRefPtrNativeArray(v8::Handle<v8::Value> value, int argumentIndex, v8::Isolate* isolate, bool* success = 0)
542 { 542 {
543 if (success) 543 if (success)
544 *success = true; 544 *success = true;
545 545
546 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); 546 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
547 uint32_t length = 0; 547 uint32_t length = 0;
548 if (value->IsArray()) { 548 if (value->IsArray()) {
549 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); 549 length = v8::Local<v8::Array>::Cast(v8Value)->Length();
550 } else if (toV8Sequence(value, length, isolate).IsEmpty()) { 550 } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
551 throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argu mentIndex), isolate); 551 throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argu mentIndex), isolate);
552 return WillBeHeapVector<RefPtrWillBeMember<T> >(); 552 return HeapVector<Member<T> >();
553 } 553 }
554 554
555 return toRefPtrWillBeMemberNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, success); 555 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, su ccess);
556 } 556 }
557 557
558 template <class T, class V8T> 558 template <class T, class V8T>
559 Vector<RefPtr<T> > toRefPtrNativeArray(v8::Handle<v8::Value> value, const St ring& propertyName, v8::Isolate* isolate, bool* success = 0) 559 Vector<RefPtr<T> > toRefPtrNativeArray(v8::Handle<v8::Value> value, const St ring& propertyName, v8::Isolate* isolate, bool* success = 0)
560 { 560 {
561 if (success) 561 if (success)
562 *success = true; 562 *success = true;
563 563
564 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); 564 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
565 uint32_t length = 0; 565 uint32_t length = 0;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 m_isolate->ClearInterrupt(); 750 m_isolate->ClearInterrupt();
751 } 751 }
752 752
753 private: 753 private:
754 v8::Isolate* m_isolate; 754 v8::Isolate* m_isolate;
755 }; 755 };
756 756
757 } // namespace WebCore 757 } // namespace WebCore
758 758
759 #endif // V8Binding_h 759 #endif // V8Binding_h
OLDNEW
« no previous file with comments | « Source/bindings/scripts/code_generator_v8.pm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698