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

Side by Side Diff: runtime/lib/typeddata.dart

Issue 12544015: Implement 'dart:typeddata' directly in the VM instead of using 'dart:scalarlist' (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // TODO(asiva): Remove this import of dart:scalarlist when we are ready to
6 // drop scalarlist and move this implementation as the default.
7 import "dart:scalarlist" as sl;
8
9 // patch classes for Int8List ..... Float64List and ByteData implementations. 5 // patch classes for Int8List ..... Float64List and ByteData implementations.
10 6
11 patch class Int8List { 7 patch class Int8List {
12 /* patch */ factory Int8List(int length) { 8 /* patch */ factory Int8List(int length) {
13 return new _Int8Array(length); 9 return new _Int8Array(length);
14 } 10 }
15 11
16 /* patch */ factory Int8List.transferable(int length) { 12 /* patch */ factory Int8List.transferable(int length) {
17 return _newTransferable(length); 13 return _newTransferable(length);
18 } 14 }
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 274 }
279 275
280 Collection where(bool f(int element)) { 276 Collection where(bool f(int element)) {
281 return IterableMixinWorkaround.where(this, f); 277 return IterableMixinWorkaround.where(this, f);
282 } 278 }
283 279
284 Iterable expand(Iterable f(int element)) { 280 Iterable expand(Iterable f(int element)) {
285 return IterableMixinWorkaround.expand(this, f); 281 return IterableMixinWorkaround.expand(this, f);
286 } 282 }
287 283
288 Iterable<int> take(int n) { 284 Iterable take(int n) {
289 return IterableMixinWorkaround.takeList(this, n); 285 return IterableMixinWorkaround.takeList(this, n);
290 } 286 }
291 287
292 Iterable<int> takeWhile(bool test(int value)) { 288 Iterable takeWhile(bool test(int value)) {
293 return IterableMixinWorkaround.takeWhile(this, test); 289 return IterableMixinWorkaround.takeWhile(this, test);
294 } 290 }
295 291
296 Iterable<int> skip(int n) { 292 Iterable skip(int n) {
297 return IterableMixinWorkaround.skipList(this, n); 293 return IterableMixinWorkaround.skipList(this, n);
298 } 294 }
299 295
300 Iterable<int> skipWhile(bool test(int value)) { 296 Iterable skipWhile(bool test(int value)) {
301 return IterableMixinWorkaround.skipWhile(this, test); 297 return IterableMixinWorkaround.skipWhile(this, test);
302 } 298 }
303 299
304 bool every(bool f(element)) { 300 bool every(bool f(element)) {
305 return IterableMixinWorkaround.every(this, f); 301 return IterableMixinWorkaround.every(this, f);
306 } 302 }
307 303
308 bool any(bool f(element)) { 304 bool any(bool f(element)) {
309 return IterableMixinWorkaround.any(this, f); 305 return IterableMixinWorkaround.any(this, f);
310 } 306 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 void removeRange(int start, int length) { 419 void removeRange(int start, int length) {
424 throw new UnsupportedError( 420 throw new UnsupportedError(
425 "Cannot remove from a non-extendable array"); 421 "Cannot remove from a non-extendable array");
426 } 422 }
427 423
428 void insertRange(int start, int length, [initialValue]) { 424 void insertRange(int start, int length, [initialValue]) {
429 throw new UnsupportedError( 425 throw new UnsupportedError(
430 "Cannot add to a non-extendable array"); 426 "Cannot add to a non-extendable array");
431 } 427 }
432 428
433 List<int> toList() { 429 List toList() {
434 return new List<int>.from(this); 430 return new List.from(this);
435 } 431 }
436 432
437 Set<int> toSet() { 433 Set toSet() {
438 return new Set<int>.from(this); 434 return new Set.from(this);
435 }
436
437 List getRange(int start, int length) {
438 _rangeCheck(this.length, start, length);
439 List result = _new(length);
440 result.setRange(0, length, this, start);
441 return result;
442 }
443
444 void setRange(int start, int length, List from, [int startFrom = 0]) {
445 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
446 }
447
448 // Method(s) implementing Object interface.
449
450 String toString() {
451 return Collections.collectionToString(this);
439 } 452 }
440 } 453 }
441 454
442 455
443 abstract class _TypedList extends _TypedListBase implements ByteBuffer { 456 abstract class _TypedList extends _TypedListBase implements ByteBuffer {
444 // Default method implementing parts of the TypedData interface. 457 // Default method implementing parts of the TypedData interface.
445 int get offsetInBytes { 458 int get offsetInBytes {
446 return 0; 459 return 0;
447 } 460 }
448 461
449 int get lengthInBytes { 462 int get lengthInBytes {
450 return _length() * elementSizeInBytes; 463 return length * elementSizeInBytes;
451 } 464 }
452 465
453 ByteBuffer get buffer { 466 ByteBuffer get buffer {
454 return this; 467 return this;
455 } 468 }
456 469
457 470
458 // Methods implementing the collection interface. 471 // Methods implementing the collection interface.
459 472
460 int get length { 473 int get length native "TypedData_length";
461 return _length();
462 }
463 474
464 475
465 // Internal utility methods. 476 // Internal utility methods.
466 477
467 int _length() { 478 int _getInt8(int index) native "TypedData_GetInt8";
468 return _array.length; 479 void _setInt8(int index, int value) native "TypedData_SetInt8";
469 }
470 480
471 sl.ByteArrayViewable _array; 481 int _getUint8(int index) native "TypedData_GetUint8";
482 void _setUint8(int index, int value) native "TypedData_SetUint8";
483
484 int _getInt16(int index) native "TypedData_GetInt16";
485 void _setInt16(int index, int value) native "TypedData_SetInt16";
486
487 int _getUint16(int index) native "TypedData_GetUint16";
488 void _setUint16(int index, int value) native "TypedData_SetUint16";
489
490 int _getInt32(int index) native "TypedData_GetInt32";
491 void _setInt32(int index, int value) native "TypedData_SetInt32";
492
493 int _getUint32(int index) native "TypedData_GetUint32";
494 void _setUint32(int index, int value) native "TypedData_SetUint32";
495
496 int _getInt64(int index) native "TypedData_GetInt64";
497 void _setInt64(int index, int value) native "TypedData_SetInt64";
498
499 int _getUint64(int index) native "TypedData_GetUint64";
500 void _setUint64(int index, int value) native "TypedData_SetUint64";
501
502 double _getFloat32(int index) native "TypedData_GetFloat32";
503 void _setFloat32(int index, double value) native "TypedData_SetFloat32";
504
505 double _getFloat64(int index) native "TypedData_GetFloat64";
506 void _setFloat64(int index, double value) native "TypedData_SetFloat64";
472 } 507 }
473 508
474 509
475 class _Int8Array extends _TypedList implements Int8List { 510 class _Int8Array extends _TypedList implements Int8List {
476 // Factory constructors. 511 // Factory constructors.
477 512
478 _Int8Array(int length) { 513 factory _Int8Array(int length) {
479 _array = new sl.Int8List(length); 514 if (length < 0) {
515 String message = "$length must be greater than 0";
516 throw new ArgumentError(message);
517 }
518 return _new(length);
480 } 519 }
481 520
482 factory _Int8Array.view(ByteBuffer buffer, 521 factory _Int8Array.view(ByteBuffer buffer,
483 [int offsetInBytes = 0, int length]) { 522 [int offsetInBytes = 0, int length]) {
484 if (length == null) { 523 if (length == null) {
485 length = buffer.lengthInBytes; 524 length = buffer.lengthInBytes;
486 } 525 }
487 return new _Int8ArrayView(buffer, offsetInBytes, length); 526 return new _Int8ArrayView(buffer, offsetInBytes, length);
488 } 527 }
489 528
490 529
491 // Method(s) implementing List interface. 530 // Method(s) implementing List interface.
492 531
493 int operator[](int index) { 532 int operator[](int index) {
494 return _getIndexed(index); 533 if (index < 0 || index >= length) {
534 String message = "$index must be in the range [0..$length)";
535 throw new RangeError(message);
536 }
537 return _getInt8(index);
495 } 538 }
496 539
497 void operator[]=(int index, int value) { 540 void operator[]=(int index, int value) {
498 _setIndexed(index, _toInt8(value)); 541 if (index < 0 || index >= length) {
542 String message = "$index must be in the range [0..$length)";
543 throw new RangeError(message);
544 }
545 _setInt8(index, _toInt8(value));
499 } 546 }
500 547
501 Iterator<int> get iterator { 548 Iterator<int> get iterator {
502 return new _TypedListIterator<int>(this); 549 return new _TypedListIterator<int>(this);
503 } 550 }
504 551
505 List<int> getRange(int start, int length) {
506 _rangeCheck(this.length, start, length);
507 List<int> result = _new(length);
508 result.setRange(0, length, this, start);
509 return result;
510 }
511
512 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
513 /**
514 if (from is _Int8Array) {
515 _setRange(start * Int8List.BYTES_PER_ELEMENT,
516 length * Int8List.BYTES_PER_ELEMENT,
517 from,
518 startFrom * Int8List.BYTES_PER_ELEMENT);
519 } else {
520 Arrays.copy(from, startFrom, this, start, length);
521 }
522 */
523 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
524 }
525
526
527 // Method(s) implementing Object interface.
528
529 String toString() {
530 return Collections.collectionToString(this);
531 }
532
533 552
534 // Method(s) implementing TypedData interface. 553 // Method(s) implementing TypedData interface.
535 554
536 int get elementSizeInBytes { 555 int get elementSizeInBytes {
537 return Int8List.BYTES_PER_ELEMENT; 556 return Int8List.BYTES_PER_ELEMENT;
538 } 557 }
539 558
540 559
541 // Internal utility methods. 560 // Internal utility methods.
542 561
543 int _getIndexed(int index) { 562 static _Int8Array _new(int length) native "TypedData_Int8Array_new";
544 return _array[index];
545 }
546 void _setIndexed(int index, int value) {
547 _array[index] = value;
548 }
549 } 563 }
550 564
551 565
552 class _Uint8Array extends _TypedList implements Uint8List { 566 class _Uint8Array extends _TypedList implements Uint8List {
553 // Factory constructors. 567 // Factory constructors.
554 568
555 _Uint8Array(int length) { 569 factory _Uint8Array(int length) {
556 _array = new sl.Uint8List(length); 570 if (length < 0) {
571 String message = "$length must be greater than 0";
572 throw new ArgumentError(message);
573 }
574 return _new(length);
557 } 575 }
558 576
559 factory _Uint8Array.view(ByteBuffer buffer, 577 factory _Uint8Array.view(ByteBuffer buffer,
560 [int offsetInBytes = 0, int length]) { 578 [int offsetInBytes = 0, int length]) {
561 if (length == null) { 579 if (length == null) {
562 length = buffer.lengthInBytes; 580 length = buffer.lengthInBytes;
563 } 581 }
564 return new _Uint8ArrayView(buffer, offsetInBytes, length); 582 return new _Uint8ArrayView(buffer, offsetInBytes, length);
565 } 583 }
566 584
585
567 // Methods implementing List interface. 586 // Methods implementing List interface.
568 int operator[](int index) { 587 int operator[](int index) {
569 return _getIndexed(index); 588 if (index < 0 || index >= length) {
589 String message = "$index must be in the range [0..$length)";
590 throw new RangeError(message);
591 }
592 return _getUint8(index);
570 } 593 }
571 594
572 void operator[]=(int index, int value) { 595 void operator[]=(int index, int value) {
573 _setIndexed(index, _toUint8(value)); 596 if (index < 0 || index >= length) {
597 String message = "$index must be in the range [0..$length)";
598 throw new RangeError(message);
599 }
600 _setUint8(index, _toUint8(value));
574 } 601 }
575 602
576 Iterator<int> get iterator { 603 Iterator<int> get iterator {
577 return new _TypedListIterator<int>(this); 604 return new _TypedListIterator<int>(this);
578 } 605 }
579 606
580 List<int> getRange(int start, int length) {
581 _rangeCheck(this.length, start, length);
582 List<int> result = _new(length);
583 result.setRange(0, length, this, start);
584 return result;
585 }
586
587 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
588 /**
589 if (from is _Uint8Array || from is _ExternalUint8Array ||
590 from is _Uint8ClampedArray || from is _ExternalUint8ClampedArray) {
591 _setRange(start * Uint8List.BYTES_PER_ELEMENT,
592 length * Uint8List.BYTES_PER_ELEMENT,
593 from,
594 startFrom * Uint8List.BYTES_PER_ELEMENT);
595 } else {
596 Arrays.copy(from, startFrom, this, start, length);
597 }
598 */
599 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
600 }
601
602 // Methods implementing Object interface.
603 String toString() {
604 return Collections.collectionToString(this);
605 }
606 607
607 // Methods implementing TypedData interface. 608 // Methods implementing TypedData interface.
608 int get elementSizeInBytes { 609 int get elementSizeInBytes {
609 return Uint8List.BYTES_PER_ELEMENT; 610 return Uint8List.BYTES_PER_ELEMENT;
610 } 611 }
611 612
612 // Internal utility methods. 613 // Internal utility methods.
613 614
614 int _getIndexed(int index) { 615 static _Uint8Array _new(int length) native "TypedData_Uint8Array_new";
615 return _array[index];
616 }
617 void _setIndexed(int index, int value) {
618 _array[index] = value;
619 }
620 } 616 }
621 617
622 618
623 class _Uint8ClampedArray extends _TypedList implements Uint8ClampedList { 619 class _Uint8ClampedArray extends _TypedList implements Uint8ClampedList {
624 // Factory constructors. 620 // Factory constructors.
625 621
626 _Uint8ClampedArray(int length) { 622 factory _Uint8ClampedArray(int length) {
627 _array = new sl.Uint8ClampedList(length); 623 if (length < 0) {
624 String message = "$length must be greater than 0";
625 throw new ArgumentError(message);
626 }
627 return _new(length);
628 } 628 }
629 629
630 factory _Uint8ClampedArray.view(ByteBuffer buffer, 630 factory _Uint8ClampedArray.view(ByteBuffer buffer,
631 [int offsetInBytes = 0, int length]) { 631 [int offsetInBytes = 0, int length]) {
632 if (length == null) { 632 if (length == null) {
633 length = buffer.lengthInBytes; 633 length = buffer.lengthInBytes;
634 } 634 }
635 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); 635 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length);
636 } 636 }
637 637
638
638 // Methods implementing List interface. 639 // Methods implementing List interface.
640
639 int operator[](int index) { 641 int operator[](int index) {
640 return _getIndexed(index); 642 if (index < 0 || index >= length) {
643 String message = "$index must be in the range [0..$length)";
644 throw new RangeError(message);
645 }
646 return _getUint8(index);
641 } 647 }
642 648
643 void operator[]=(int index, int value) { 649 void operator[]=(int index, int value) {
644 _setIndexed(index, _toClampedUint8(value)); 650 if (index < 0 || index >= length) {
651 String message = "$index must be in the range [0..$length)";
652 throw new RangeError(message);
653 }
654 _setUint8(index, _toClampedUint8(value));
645 } 655 }
646 656
647 Iterator<int> get iterator { 657 Iterator<int> get iterator {
648 return new _TypedListIterator<int>(this); 658 return new _TypedListIterator<int>(this);
649 } 659 }
650 660
651 List<int> getRange(int start, int length) {
652 _rangeCheck(this.length, start, length);
653 List<int> result = _new(length);
654 result.setRange(0, length, this, start);
655 return result;
656 }
657
658 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
659 /**
660 if (from is _Uint8Array || from is _ExternalUint8Array ||
661 from is _Uint8ClampedArray || from is _ExternalUint8ClampedArray) {
662 _setRange(start * Uint8List.BYTES_PER_ELEMENT,
663 length * Uint8List.BYTES_PER_ELEMENT,
664 from,
665 startFrom * Uint8List.BYTES_PER_ELEMENT);
666 } else {
667 Arrays.copy(from, startFrom, this, start, length);
668 }
669 */
670 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
671 }
672
673 // Methods implementing Object interface.
674 String toString() {
675 return Collections.collectionToString(this);
676 }
677 661
678 // Methods implementing TypedData interface. 662 // Methods implementing TypedData interface.
679 int get elementSizeInBytes { 663 int get elementSizeInBytes {
680 return Uint8List.BYTES_PER_ELEMENT; 664 return Uint8List.BYTES_PER_ELEMENT;
681 } 665 }
682 666
667
683 // Internal utility methods. 668 // Internal utility methods.
684 669
685 int _getIndexed(int index) { 670 static _Uint8ClampedArray _new(int length)
686 return _array[index]; 671 native "TypedData_Uint8ClampedArray_new";
687 }
688 void _setIndexed(int index, int value) {
689 _array[index] = value;
690 }
691 } 672 }
692 673
693 674
694 class _Int16Array extends _TypedList implements Int16List { 675 class _Int16Array extends _TypedList implements Int16List {
695 // Factory constructors. 676 // Factory constructors.
696 677
697 _Int16Array(int length) { 678 factory _Int16Array(int length) {
698 _array = new sl.Int16List(length); 679 if (length < 0) {
680 String message = "$length must be greater than 0";
681 throw new ArgumentError(message);
682 }
683 return _new(length);
699 } 684 }
700 685
701 factory _Int16Array.view(ByteBuffer buffer, 686 factory _Int16Array.view(ByteBuffer buffer,
702 [int offsetInBytes = 0, int length]) { 687 [int offsetInBytes = 0, int length]) {
703 if (length == null) { 688 if (length == null) {
704 length = (buffer.lengthInBytes - offsetInBytes) ~/ 689 length = (buffer.lengthInBytes - offsetInBytes) ~/
705 Int16List.BYTES_PER_ELEMENT; 690 Int16List.BYTES_PER_ELEMENT;
706 } 691 }
707 return new _Int16ArrayView(buffer, offsetInBytes, length); 692 return new _Int16ArrayView(buffer, offsetInBytes, length);
708 } 693 }
709 694
710 695
711 // Method(s) implementing List interface. 696 // Method(s) implementing List interface.
712 697
713 int operator[](int index) { 698 int operator[](int index) {
714 return _getIndexed(index); 699 if (index < 0 || index >= length) {
700 String message = "$index must be in the range [0..$length)";
701 throw new RangeError(message);
702 }
703 return _getInt16(index);
715 } 704 }
716 705
717 void operator[]=(int index, int value) { 706 void operator[]=(int index, int value) {
718 _setIndexed(index, _toInt16(value)); 707 if (index < 0 || index >= length) {
708 String message = "$index must be in the range [0..$length)";
709 throw new RangeError(message);
710 }
711 _setInt16(index, _toInt16(value));
719 } 712 }
720 713
721 Iterator<int> get iterator { 714 Iterator<int> get iterator {
722 return new _TypedListIterator<int>(this); 715 return new _TypedListIterator<int>(this);
723 } 716 }
724 717
725 List<int> getRange(int start, int length) {
726 _rangeCheck(this.length, start, length);
727 List<int> result = _new(length);
728 result.setRange(0, length, this, start);
729 return result;
730 }
731
732 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
733 /**
734 if (from is _Int16Array) {
735 _setRange(start * Int16List.BYTES_PER_ELEMENT,
736 length * Int16List.BYTES_PER_ELEMENT,
737 from,
738 startFrom * Int16List.BYTES_PER_ELEMENT);
739 } else {
740 Arrays.copy(from, startFrom, this, start, length);
741 }
742 */
743 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
744 }
745
746
747 // Method(s) implementing Object interface.
748
749 String toString() {
750 return Collections.collectionToString(this);
751 }
752
753 718
754 // Method(s) implementing TypedData interface. 719 // Method(s) implementing TypedData interface.
755 720
756 int get elementSizeInBytes { 721 int get elementSizeInBytes {
757 return Int16List.BYTES_PER_ELEMENT; 722 return Int16List.BYTES_PER_ELEMENT;
758 } 723 }
759 724
760 725
761 // Internal utility methods. 726 // Internal utility methods.
762 727
763 int _getIndexed(int index) { 728 static _Int16Array _new(int length) native "TypedData_Int16Array_new";
764 return _array[index];
765 }
766 void _setIndexed(int index, int value) {
767 _array[index] = value;
768 }
769 } 729 }
770 730
771 731
772 class _Uint16Array extends _TypedList implements Uint16List { 732 class _Uint16Array extends _TypedList implements Uint16List {
773 // Factory constructors. 733 // Factory constructors.
774 734
775 _Uint16Array(int length) { 735 factory _Uint16Array(int length) {
776 _array = new sl.Uint16List(length); 736 if (length < 0) {
737 String message = "$length must be greater than 0";
738 throw new ArgumentError(message);
739 }
740 return _new(length);
777 } 741 }
778 742
779 factory _Uint16Array.view(ByteBuffer buffer, 743 factory _Uint16Array.view(ByteBuffer buffer,
780 [int offsetInBytes = 0, int length]) { 744 [int offsetInBytes = 0, int length]) {
781 if (length == null) { 745 if (length == null) {
782 length = (buffer.lengthInBytes - offsetInBytes) ~/ 746 length = (buffer.lengthInBytes - offsetInBytes) ~/
783 Uint16List.BYTES_PER_ELEMENT; 747 Uint16List.BYTES_PER_ELEMENT;
784 } 748 }
785 return new _Uint16ArrayView(buffer, offsetInBytes, length); 749 return new _Uint16ArrayView(buffer, offsetInBytes, length);
786 } 750 }
787 751
788 752
789 // Method(s) implementing the List interface. 753 // Method(s) implementing the List interface.
790 754
791 int operator[](int index) { 755 int operator[](int index) {
792 return _getIndexed(index); 756 if (index < 0 || index >= length) {
757 String message = "$index must be in the range [0..$length)";
758 throw new RangeError(message);
759 }
760 return _getUint16(index);
793 } 761 }
794 762
795 void operator[]=(int index, int value) { 763 void operator[]=(int index, int value) {
796 _setIndexed(index, _toUint16(value)); 764 if (index < 0 || index >= length) {
765 String message = "$index must be in the range [0..$length)";
766 throw new RangeError(message);
767 }
768 _setUint16(index, _toUint16(value));
797 } 769 }
798 770
799 Iterator<int> get iterator { 771 Iterator<int> get iterator {
800 return new _TypedListIterator<int>(this); 772 return new _TypedListIterator<int>(this);
801 } 773 }
802 774
803 List<int> getRange(int start, int length) {
804 _rangeCheck(this.length, start, length);
805 List<int> result = _new(length);
806 result.setRange(0, length, this, start);
807 return result;
808 }
809
810 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
811 /**
812 if (from is _Uint16Array) {
813 _setRange(start * Uint16List.BYTES_PER_ELEMENT,
814 length * Uint16List.BYTES_PER_ELEMENT,
815 from,
816 startFrom * Uint16List.BYTES_PER_ELEMENT);
817 } else {
818 Arrays.copy(from, startFrom, this, start, length);
819 }
820 */
821 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
822 }
823
824
825 // Method(s) implementing the Object interface.
826
827 String toString() {
828 return Collections.collectionToString(this);
829 }
830
831 775
832 // Method(s) implementing the TypedData interface. 776 // Method(s) implementing the TypedData interface.
833 777
834 int get elementSizeInBytes { 778 int get elementSizeInBytes {
835 return Uint16List.BYTES_PER_ELEMENT; 779 return Uint16List.BYTES_PER_ELEMENT;
836 } 780 }
837 781
838 782
839 // Internal utility methods. 783 // Internal utility methods.
840 784
841 int _getIndexed(int index) { 785 static _Uint16Array _new(int length) native "TypedData_Uint16Array_new";
842 return _array[index];
843 }
844 void _setIndexed(int index, int value) {
845 _array[index] = value;
846 }
847 } 786 }
848 787
849 788
850 class _Int32Array extends _TypedList implements Int32List { 789 class _Int32Array extends _TypedList implements Int32List {
851 // Factory constructors. 790 // Factory constructors.
852 791
853 _Int32Array(int length) { 792 factory _Int32Array(int length) {
854 _array = new sl.Int32List(length); 793 if (length < 0) {
794 String message = "$length must be greater than 0";
795 throw new ArgumentError(message);
796 }
797 return _new(length);
855 } 798 }
856 799
857 factory _Int32Array.view(ByteBuffer buffer, 800 factory _Int32Array.view(ByteBuffer buffer,
858 [int offsetInBytes = 0, int length]) { 801 [int offsetInBytes = 0, int length]) {
859 if (length == null) { 802 if (length == null) {
860 length = (buffer.lengthInBytes - offsetInBytes) ~/ 803 length = (buffer.lengthInBytes - offsetInBytes) ~/
861 Int32List.BYTES_PER_ELEMENT; 804 Int32List.BYTES_PER_ELEMENT;
862 } 805 }
863 return new _Int32ArrayView(buffer, offsetInBytes, length); 806 return new _Int32ArrayView(buffer, offsetInBytes, length);
864 } 807 }
865 808
866 809
867 // Method(s) implementing the List interface. 810 // Method(s) implementing the List interface.
868 811
869 int operator[](int index) { 812 int operator[](int index) {
870 return _getIndexed(index); 813 if (index < 0 || index >= length) {
814 String message = "$index must be in the range [0..$length)";
815 throw new RangeError(message);
816 }
817 return _getInt32(index);
871 } 818 }
872 819
873 void operator[]=(int index, int value) { 820 void operator[]=(int index, int value) {
874 _setIndexed(index, _toInt32(value)); 821 if (index < 0 || index >= length) {
822 String message = "$index must be in the range [0..$length)";
823 throw new RangeError(message);
824 }
825 _setInt32(index, _toInt32(value));
875 } 826 }
876 827
877 Iterator<int> get iterator { 828 Iterator<int> get iterator {
878 return new _TypedListIterator<int>(this); 829 return new _TypedListIterator<int>(this);
879 } 830 }
880 831
881 List<int> getRange(int start, int length) {
882 _rangeCheck(this.length, start, length);
883 List<int> result = _new(length);
884 result.setRange(0, length, this, start);
885 return result;
886 }
887
888 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
889 /**
890 if (from is _Int32Array) {
891 _setRange(start * Int32List.BYTES_PER_ELEMENT,
892 length * Int32List.BYTES_PER_ELEMENT,
893 from,
894 startFrom * Int32List.BYTES_PER_ELEMENT);
895 } else {
896 Arrays.copy(from, startFrom, this, start, length);
897 }
898 */
899 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
900 }
901
902
903 // Method(s) implementing Object interface.
904
905 String toString() {
906 return Collections.collectionToString(this);
907 }
908
909 832
910 // Method(s) implementing TypedData interface. 833 // Method(s) implementing TypedData interface.
911 834
912 int get elementSizeInBytes { 835 int get elementSizeInBytes {
913 return Int32List.BYTES_PER_ELEMENT; 836 return Int32List.BYTES_PER_ELEMENT;
914 } 837 }
915 838
916 839
917 // Internal utility methods. 840 // Internal utility methods.
918 841
919 int _getIndexed(int index) { 842 static _Int32Array _new(int length) native "TypedData_Int32Array_new";
920 return _array[index];
921 }
922 void _setIndexed(int index, int value) {
923 _array[index] = value;
924 }
925 } 843 }
926 844
927 845
928 class _Uint32Array extends _TypedList implements Uint32List { 846 class _Uint32Array extends _TypedList implements Uint32List {
929 // Factory constructors. 847 // Factory constructors.
930 848
931 _Uint32Array(int length) { 849 factory _Uint32Array(int length) {
932 _array = new sl.Uint32List(length); 850 if (length < 0) {
851 String message = "$length must be greater than 0";
852 throw new ArgumentError(message);
853 }
854 return _new(length);
933 } 855 }
934 856
935 factory _Uint32Array.view(ByteBuffer buffer, 857 factory _Uint32Array.view(ByteBuffer buffer,
936 [int offsetInBytes = 0, int length]) { 858 [int offsetInBytes = 0, int length]) {
937 if (length == null) { 859 if (length == null) {
938 length = (buffer.lengthInBytes - offsetInBytes) ~/ 860 length = (buffer.lengthInBytes - offsetInBytes) ~/
939 Uint32List.BYTES_PER_ELEMENT; 861 Uint32List.BYTES_PER_ELEMENT;
940 } 862 }
941 return new _Uint32ArrayView(buffer, offsetInBytes, length); 863 return new _Uint32ArrayView(buffer, offsetInBytes, length);
942 } 864 }
943 865
944 866
945 // Method(s) implementing the List interface. 867 // Method(s) implementing the List interface.
946 868
947 int operator[](int index) { 869 int operator[](int index) {
948 return _getIndexed(index); 870 if (index < 0 || index >= length) {
871 String message = "$index must be in the range [0..$length)";
872 throw new RangeError(message);
873 }
874 return _getUint32(index);
949 } 875 }
950 876
951 void operator[]=(int index, int value) { 877 void operator[]=(int index, int value) {
952 _setIndexed(index, _toUint32(value)); 878 if (index < 0 || index >= length) {
879 String message = "$index must be in the range [0..$length)";
880 throw new RangeError(message);
881 }
882 _setUint32(index, _toUint32(value));
953 } 883 }
954 884
955 Iterator<int> get iterator { 885 Iterator<int> get iterator {
956 return new _TypedListIterator<int>(this); 886 return new _TypedListIterator<int>(this);
957 } 887 }
958 888
959 List<int> getRange(int start, int length) {
960 _rangeCheck(this.length, start, length);
961 List<int> result = _new(length);
962 result.setRange(0, length, this, start);
963 return result;
964 }
965
966 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
967 /**
968 if (from is _Uint32Array) {
969 _setRange(start * Uint32List.BYTES_PER_ELEMENT,
970 length * Uint32List.BYTES_PER_ELEMENT,
971 from,
972 startFrom * Uint32List.BYTES_PER_ELEMENT);
973 } else {
974 Arrays.copy(from, startFrom, this, start, length);
975 }
976 */
977 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
978 }
979
980
981 // Method(s) implementing the Object interface.
982
983 String toString() {
984 return Collections.collectionToString(this);
985 }
986
987 889
988 // Method(s) implementing the TypedData interface. 890 // Method(s) implementing the TypedData interface.
989 891
990 int get elementSizeInBytes { 892 int get elementSizeInBytes {
991 return Uint32List.BYTES_PER_ELEMENT; 893 return Uint32List.BYTES_PER_ELEMENT;
992 } 894 }
993 895
994 896
995 // Internal utility methods. 897 // Internal utility methods.
996 898
997 int _getIndexed(int index) { 899 static _Uint32Array _new(int length) native "TypedData_Uint32Array_new";
998 return _array[index];
999 }
1000 void _setIndexed(int index, int value) {
1001 _array[index] = value;
1002 }
1003 } 900 }
1004 901
1005 902
1006 class _Int64Array extends _TypedList implements Int64List { 903 class _Int64Array extends _TypedList implements Int64List {
1007 // Factory constructors. 904 // Factory constructors.
1008 905
1009 _Int64Array(int length) { 906 factory _Int64Array(int length) {
1010 _array = new sl.Int64List(length); 907 if (length < 0) {
908 String message = "$length must be greater than 0";
909 throw new ArgumentError(message);
910 }
911 return _new(length);
1011 } 912 }
1012 913
1013 factory _Int64Array.view(ByteBuffer buffer, 914 factory _Int64Array.view(ByteBuffer buffer,
1014 [int offsetInBytes = 0, int length]) { 915 [int offsetInBytes = 0, int length]) {
1015 if (length == null) { 916 if (length == null) {
1016 length = (buffer.lengthInBytes - offsetInBytes) ~/ 917 length = (buffer.lengthInBytes - offsetInBytes) ~/
1017 Int32List.BYTES_PER_ELEMENT; 918 Int32List.BYTES_PER_ELEMENT;
1018 } 919 }
1019 return new _Int64ArrayView(buffer, offsetInBytes, length); 920 return new _Int64ArrayView(buffer, offsetInBytes, length);
1020 } 921 }
1021 922
1022 923
1023 // Method(s) implementing the List interface. 924 // Method(s) implementing the List interface.
1024 925
1025 int operator[](int index) { 926 int operator[](int index) {
1026 return _getIndexed(index); 927 if (index < 0 || index >= length) {
928 String message = "$index must be in the range [0..$length)";
929 throw new RangeError(message);
930 }
931 return _getInt64(index);
1027 } 932 }
1028 933
1029 void operator[]=(int index, int value) { 934 void operator[]=(int index, int value) {
1030 _setIndexed(index, _toInt64(value)); 935 if (index < 0 || index >= length) {
936 String message = "$index must be in the range [0..$length)";
937 throw new RangeError(message);
938 }
939 _setInt64(index, _toInt64(value));
1031 } 940 }
1032 941
1033 Iterator<int> get iterator { 942 Iterator<int> get iterator {
1034 return new _TypedListIterator<int>(this); 943 return new _TypedListIterator<int>(this);
1035 } 944 }
1036 945
1037 List<int> getRange(int start, int length) {
1038 _rangeCheck(this.length, start, length);
1039 List<int> result = _new(length);
1040 result.setRange(0, length, this, start);
1041 return result;
1042 }
1043
1044 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1045 /**
1046 if (from is _Int64Array) {
1047 _setRange(start * Int64List.BYTES_PER_ELEMENT,
1048 length * Int64List.BYTES_PER_ELEMENT,
1049 from,
1050 startFrom * Int64List.BYTES_PER_ELEMENT);
1051 } else {
1052 Arrays.copy(from, startFrom, this, start, length);
1053 }
1054 */
1055 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1056 }
1057
1058
1059 // Method(s) implementing the Object interface.
1060
1061 String toString() {
1062 return Collections.collectionToString(this);
1063 }
1064
1065 946
1066 // Method(s) implementing the TypedData interface. 947 // Method(s) implementing the TypedData interface.
1067 948
1068 int get elementSizeInBytes { 949 int get elementSizeInBytes {
1069 return Int64List.BYTES_PER_ELEMENT; 950 return Int64List.BYTES_PER_ELEMENT;
1070 } 951 }
1071 952
1072 953
1073 // Internal utility methods. 954 // Internal utility methods.
1074 955
1075 int _getIndexed(int index) { 956 static _Int64Array _new(int length) native "TypedData_Int64Array_new";
1076 return _array[index];
1077 }
1078 void _setIndexed(int index, int value) {
1079 _array[index] = value;
1080 }
1081 } 957 }
1082 958
1083 959
1084 class _Uint64Array extends _TypedList implements Uint64List { 960 class _Uint64Array extends _TypedList implements Uint64List {
1085 // Factory constructors. 961 // Factory constructors.
1086 962
1087 _Uint64Array(int length) { 963 factory _Uint64Array(int length) {
1088 _array = new sl.Uint64List(length); 964 if (length < 0) {
965 String message = "$length must be greater than 0";
966 throw new ArgumentError(message);
967 }
968 return _new(length);
1089 } 969 }
1090 970
1091 factory _Uint64Array.view(ByteBuffer buffer, 971 factory _Uint64Array.view(ByteBuffer buffer,
1092 [int offsetInBytes = 0, int length]) { 972 [int offsetInBytes = 0, int length]) {
1093 if (length == null) { 973 if (length == null) {
1094 length = (buffer.lengthInBytes - offsetInBytes) ~/ 974 length = (buffer.lengthInBytes - offsetInBytes) ~/
1095 Uint64List.BYTES_PER_ELEMENT; 975 Uint64List.BYTES_PER_ELEMENT;
1096 } 976 }
1097 return new _Uint64ArrayView(buffer, offsetInBytes, length); 977 return new _Uint64ArrayView(buffer, offsetInBytes, length);
1098 } 978 }
1099 979
1100 980
1101 // Method(s) implementing the List interface. 981 // Method(s) implementing the List interface.
1102 982
1103 int operator[](int index) { 983 int operator[](int index) {
1104 return _getIndexed(index); 984 if (index < 0 || index >= length) {
985 String message = "$index must be in the range [0..$length)";
986 throw new RangeError(message);
987 }
988 return _getUint64(index);
1105 } 989 }
1106 990
1107 void operator[]=(int index, int value) { 991 void operator[]=(int index, int value) {
1108 _setIndexed(index, _toUint64(value)); 992 if (index < 0 || index >= length) {
993 String message = "$index must be in the range [0..$length)";
994 throw new RangeError(message);
995 }
996 _setUint64(index, _toUint64(value));
1109 } 997 }
1110 998
1111 Iterator<int> get iterator { 999 Iterator<int> get iterator {
1112 return new _TypedListIterator<int>(this); 1000 return new _TypedListIterator<int>(this);
1113 } 1001 }
1114 1002
1115 List<int> getRange(int start, int length) {
1116 _rangeCheck(this.length, start, length);
1117 List<int> result = _new(length);
1118 result.setRange(0, length, this, start);
1119 return result;
1120 }
1121
1122 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1123 /**
1124 if (from is _Uint64Array) {
1125 _setRange(start * Uint64List.BYTES_PER_ELEMENT,
1126 length * Uint64List.BYTES_PER_ELEMENT,
1127 from,
1128 startFrom * Uint64List.BYTES_PER_ELEMENT);
1129 } else {
1130 Arrays.copy(from, startFrom, this, start, length);
1131 }
1132 */
1133 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1134 }
1135
1136
1137 // Method(s) implementing the Object interface.
1138
1139 String toString() {
1140 return Collections.collectionToString(this);
1141 }
1142
1143 1003
1144 // Method(s) implementing the TypedData interface. 1004 // Method(s) implementing the TypedData interface.
1145 1005
1146 int get elementSizeInBytes { 1006 int get elementSizeInBytes {
1147 return Uint64List.BYTES_PER_ELEMENT; 1007 return Uint64List.BYTES_PER_ELEMENT;
1148 } 1008 }
1149 1009
1150 1010
1151 // Internal utility methods. 1011 // Internal utility methods.
1152 1012
1153 int _getIndexed(int index) { 1013 static _Uint64Array _new(int length) native "TypedData_Uint64Array_new";
1154 return _array[index];
1155 }
1156 void _setIndexed(int index, int value) {
1157 _array[index] = value;
1158 }
1159 } 1014 }
1160 1015
1161 1016
1162 class _Float32Array extends _TypedList implements Float32List { 1017 class _Float32Array extends _TypedList implements Float32List {
1163 // Factory constructors. 1018 // Factory constructors.
1164 1019
1165 _Float32Array(int length) { 1020 factory _Float32Array(int length) {
1166 _array = new sl.Float32List(length); 1021 if (length < 0) {
1022 String message = "$length must be greater than 0";
1023 throw new ArgumentError(message);
1024 }
1025 return _new(length);
1167 } 1026 }
1168 1027
1169 factory _Float32Array.view(ByteBuffer buffer, 1028 factory _Float32Array.view(ByteBuffer buffer,
1170 [int offsetInBytes = 0, int length]) { 1029 [int offsetInBytes = 0, int length]) {
1171 if (length == null) { 1030 if (length == null) {
1172 length = (buffer.lengthInBytes - offsetInBytes) ~/ 1031 length = (buffer.lengthInBytes - offsetInBytes) ~/
1173 Float32List.BYTES_PER_ELEMENT; 1032 Float32List.BYTES_PER_ELEMENT;
1174 } 1033 }
1175 return new _Float32ArrayView(buffer, offsetInBytes, length); 1034 return new _Float32ArrayView(buffer, offsetInBytes, length);
1176 } 1035 }
1177 1036
1178 1037
1179 // Method(s) implementing the List interface. 1038 // Method(s) implementing the List interface.
1180 1039
1181 double operator[](int index) { 1040 double operator[](int index) {
1182 return _getIndexed(index); 1041 if (index < 0 || index >= length) {
1042 String message = "$index must be in the range [0..$length)";
1043 throw new RangeError(message);
1044 }
1045 return _getFloat32(index);
1183 } 1046 }
1184 1047
1185 void operator[]=(int index, double value) { 1048 void operator[]=(int index, double value) {
1186 _setIndexed(index, value); 1049 if (index < 0 || index >= length) {
1050 String message = "$index must be in the range [0..$length)";
1051 throw new RangeError(message);
1052 }
1053 _setFloat32(index, value);
1187 } 1054 }
1188 1055
1189 Iterator<double> get iterator { 1056 Iterator<double> get iterator {
1190 return new _TypedListIterator<double>(this); 1057 return new _TypedListIterator<double>(this);
1191 } 1058 }
1192 1059
1193 List<double> getRange(int start, int length) {
1194 _rangeCheck(this.length, start, length);
1195 List<double> result = _new(length);
1196 result.setRange(0, length, this, start);
1197 return result;
1198 }
1199
1200 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
1201 /**
1202 if (from is _Float32Array) {
1203 _setRange(start * Float32List.BYTES_PER_ELEMENT,
1204 length * Float32List.BYTES_PER_ELEMENT,
1205 from,
1206 startFrom * Float32List.BYTES_PER_ELEMENT);
1207 } else {
1208 Arrays.copy(from, startFrom, this, start, length);
1209 }
1210 */
1211 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1212 }
1213
1214
1215 // Method(s) implementing the Object interface.
1216
1217 String toString() {
1218 return Collections.collectionToString(this);
1219 }
1220
1221 1060
1222 // Method(s) implementing the TypedData interface. 1061 // Method(s) implementing the TypedData interface.
1223 1062
1224 int get elementSizeInBytes { 1063 int get elementSizeInBytes {
1225 return Float32List.BYTES_PER_ELEMENT; 1064 return Float32List.BYTES_PER_ELEMENT;
1226 } 1065 }
1227 1066
1228 1067
1229 // Internal utility methods. 1068 // Internal utility methods.
1230 1069
1231 double _getIndexed(int index) { 1070 static _Float32Array _new(int length) native "TypedData_Float32Array_new";
1232 return _array[index];
1233 }
1234 void _setIndexed(int index, double value) {
1235 _array[index] = value;
1236 }
1237 } 1071 }
1238 1072
1239 1073
1240 class _Float64Array extends _TypedList implements Float64List { 1074 class _Float64Array extends _TypedList implements Float64List {
1241 // Factory constructors. 1075 // Factory constructors.
1242 1076
1243 _Float64Array(int length) { 1077 factory _Float64Array(int length) {
1244 _array = new sl.Float64List(length); 1078 if (length < 0) {
1079 String message = "$length must be greater than 0";
1080 throw new ArgumentError(message);
1081 }
1082 return _new(length);
1245 } 1083 }
1246 1084
1247 factory _Float64Array.view(ByteBuffer buffer, 1085 factory _Float64Array.view(ByteBuffer buffer,
1248 [int offsetInBytes = 0, int length]) { 1086 [int offsetInBytes = 0, int length]) {
1249 if (length == null) { 1087 if (length == null) {
1250 length = (buffer.lengthInBytes - offsetInBytes) ~/ 1088 length = (buffer.lengthInBytes - offsetInBytes) ~/
1251 Float64List.BYTES_PER_ELEMENT; 1089 Float64List.BYTES_PER_ELEMENT;
1252 } 1090 }
1253 return new _Float64ArrayView(buffer, offsetInBytes, length); 1091 return new _Float64ArrayView(buffer, offsetInBytes, length);
1254 } 1092 }
1255 1093
1256 1094
1257 // Method(s) implementing the List interface. 1095 // Method(s) implementing the List interface.
1258 1096
1259 double operator[](int index) { 1097 double operator[](int index) {
1260 return _getIndexed(index); 1098 if (index < 0 || index >= length) {
1099 String message = "$index must be in the range [0..$length)";
1100 throw new RangeError(message);
1101 }
1102 return _getFloat64(index);
1261 } 1103 }
1262 1104
1263 void operator[]=(int index, double value) { 1105 void operator[]=(int index, double value) {
1264 _setIndexed(index, value); 1106 if (index < 0 || index >= length) {
1107 String message = "$index must be in the range [0..$length)";
1108 throw new RangeError(message);
1109 }
1110 _setFloat64(index, value);
1265 } 1111 }
1266 1112
1267 Iterator<double> get iterator { 1113 Iterator<double> get iterator {
1268 return new _TypedListIterator<double>(this); 1114 return new _TypedListIterator<double>(this);
1269 } 1115 }
1270 1116
1271 List<double> getRange(int start, int length) {
1272 _rangeCheck(this.length, start, length);
1273 List<double> result = _new(length);
1274 result.setRange(0, length, this, start);
1275 return result;
1276 }
1277
1278 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
1279 /**
1280 if (from is _Float64Array) {
1281 _setRange(start * Float64List.BYTES_PER_ELEMENT,
1282 length * Float64List.BYTES_PER_ELEMENT,
1283 from,
1284 startFrom * Float64List.BYTES_PER_ELEMENT);
1285 } else {
1286 Arrays.copy(from, startFrom, this, start, length);
1287 }
1288 */
1289 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1290 }
1291
1292
1293 // Method(s) implementing the Object interface.
1294
1295 String toString() {
1296 return Collections.collectionToString(this);
1297 }
1298
1299 1117
1300 // Method(s) implementing the TypedData interface. 1118 // Method(s) implementing the TypedData interface.
1301 1119
1302 int get elementSizeInBytes { 1120 int get elementSizeInBytes {
1303 return Float64List.BYTES_PER_ELEMENT; 1121 return Float64List.BYTES_PER_ELEMENT;
1304 } 1122 }
1305 1123
1306 1124
1307 // Internal utility methods. 1125 // Internal utility methods.
1308 1126
1309 double _getIndexed(int index) { 1127 static _Float64Array _new(int length) native "TypedData_Float64Array_new";
1310 return _array[index];
1311 }
1312 void _setIndexed(int index, double value) {
1313 _array[index] = value;
1314 }
1315 } 1128 }
1316 1129
1317 1130
1318 class _ExternalInt8Array extends _TypedList implements Int8List { 1131 class _ExternalInt8Array extends _TypedList implements Int8List {
1319 // Factory constructors. 1132 // Factory constructors.
1320 1133
1321 _ExternalInt8Array(int length) { 1134 factory _ExternalInt8Array(int length) {
1322 _array = new sl.Int8List.transferable(length); 1135 if (length < 0) {
1136 String message = "$length must be greater than 0";
1137 throw new ArgumentError(message);
1138 }
1139 return _new(length);
1323 } 1140 }
1324 1141
1325 1142
1326 // Method(s) implementing the List interface. 1143 // Method(s) implementing the List interface.
1327 int operator[](int index) { 1144 int operator[](int index) {
1328 return _getIndexed(index); 1145 if (index < 0 || index >= length) {
1146 String message = "$index must be in the range [0..$length)";
1147 throw new RangeError(message);
1148 }
1149 return _getInt8(index);
1329 } 1150 }
1330 1151
1331 void operator[]=(int index, int value) { 1152 void operator[]=(int index, int value) {
1332 _setIndexed(index, _toInt8(value)); 1153 if (index < 0 || index >= length) {
1154 String message = "$index must be in the range [0..$length)";
1155 throw new RangeError(message);
1156 }
1157 _setInt8(index, value);
1333 } 1158 }
1334 1159
1335 Iterator<int> get iterator { 1160 Iterator<int> get iterator {
1336 return new _TypedListIterator<int>(this); 1161 return new _TypedListIterator<int>(this);
1337 } 1162 }
1338 1163
1339 List<int> getRange(int start, int length) {
1340 _rangeCheck(this.length, start, length);
1341 List<int> result = new Int8List(length);
1342 result.setRange(0, length, this, start);
1343 return result;
1344 }
1345
1346 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1347 /**
1348 if (from is _ExternalInt8Array) {
1349 _setRange(start * Int8List.BYTES_PER_ELEMENT,
1350 length * Int8List.BYTES_PER_ELEMENT,
1351 from,
1352 startFrom * Int8List.BYTES_PER_ELEMENT);
1353 } else {
1354 Arrays.copy(from, startFrom, this, start, length);
1355 }
1356 */
1357 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1358 }
1359
1360
1361 // Method(s) implementing the Object interface.
1362
1363 String toString() {
1364 return Collections.collectionToString(this);
1365 }
1366
1367 1164
1368 // Method(s) implementing the TypedData interface. 1165 // Method(s) implementing the TypedData interface.
1369 1166
1370 int get elementSizeInBytes { 1167 int get elementSizeInBytes {
1371 return Int8List.BYTES_PER_ELEMENT; 1168 return Int8List.BYTES_PER_ELEMENT;
1372 } 1169 }
1373 1170
1374 1171
1375 // Internal utility methods. 1172 // Internal utility methods.
1376 1173
1377 int _getIndexed(int index) { 1174 static _ExternalInt8Array _new(int length) native
1378 return _array[index]; 1175 "ExternalTypedData_Int8Array_new";
1379 }
1380 void _setIndexed(int index, int value) {
1381 _array[index] = value;
1382 }
1383 } 1176 }
1384 1177
1385 1178
1386 class _ExternalUint8Array extends _TypedList implements Uint8List { 1179 class _ExternalUint8Array extends _TypedList implements Uint8List {
1387 // Factory constructors. 1180 // Factory constructors.
1388 1181
1389 _ExternalUint8Array(int length) { 1182 factory _ExternalUint8Array(int length) {
1390 _array = new sl.Uint8List.transferable(length); 1183 if (length < 0) {
1184 String message = "$length must be greater than 0";
1185 throw new ArgumentError(message);
1186 }
1187 return _new(length);
1391 } 1188 }
1392 1189
1393 1190
1394 // Method(s) implementing the List interface. 1191 // Method(s) implementing the List interface.
1395 1192
1396 int operator[](int index) { 1193 int operator[](int index) {
1397 return _getIndexed(index); 1194 if (index < 0 || index >= length) {
1195 String message = "$index must be in the range [0..$length)";
1196 throw new RangeError(message);
1197 }
1198 return _getUint8(index);
1398 } 1199 }
1399 1200
1400 void operator[]=(int index, int value) { 1201 void operator[]=(int index, int value) {
1401 _setIndexed(index, _toUint8(value)); 1202 if (index < 0 || index >= length) {
1203 String message = "$index must be in the range [0..$length)";
1204 throw new RangeError(message);
1205 }
1206 _setUint8(index, _toUint8(value));
1402 } 1207 }
1403 1208
1404 Iterator<int> get iterator { 1209 Iterator<int> get iterator {
1405 return new _TypedListIterator<int>(this); 1210 return new _TypedListIterator<int>(this);
1406 } 1211 }
1407 1212
1408 List<int> getRange(int start, int length) {
1409 _rangeCheck(this.length, start, length);
1410 List<int> result = new Uint8List(length);
1411 result.setRange(0, length, this, start);
1412 return result;
1413 }
1414
1415 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1416 /**
1417 if (from is _ExternalUint8Array || from is _Uint8Array) {
1418 _setRange(start * Uint8List.BYTES_PER_ELEMENT,
1419 length * Uint8List.BYTES_PER_ELEMENT,
1420 from,
1421 startFrom * Uint8List.BYTES_PER_ELEMENT);
1422 } else {
1423 Arrays.copy(from, startFrom, this, start, length);
1424 }
1425 */
1426 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1427 }
1428
1429
1430 // Method(s) implementing the Object interface.
1431
1432 String toString() {
1433 return Collections.collectionToString(this);
1434 }
1435
1436 1213
1437 // Method(s) implementing the TypedData interface. 1214 // Method(s) implementing the TypedData interface.
1438 1215
1439 int get elementSizeInBytes { 1216 int get elementSizeInBytes {
1440 return Uint8List.BYTES_PER_ELEMENT; 1217 return Uint8List.BYTES_PER_ELEMENT;
1441 } 1218 }
1442 1219
1443 1220
1444 // Internal utility methods. 1221 // Internal utility methods.
1445 1222
1446 int _getIndexed(int index) { 1223 static _ExternalUint8Array _new(int length) native
1447 return _array[index]; 1224 "ExternalTypedData_Uint8Array_new";
1448 }
1449 void _setIndexed(int index, int value) {
1450 _array[index] = value;
1451 }
1452 } 1225 }
1453 1226
1454 1227
1455 class _ExternalUint8ClampedArray extends _TypedList implements Uint8ClampedList { 1228 class _ExternalUint8ClampedArray extends _TypedList implements Uint8ClampedList {
1456 // Factory constructors. 1229 // Factory constructors.
1457 1230
1458 _ExternalUint8ClampedArray(int length) { 1231 factory _ExternalUint8ClampedArray(int length) {
1459 _array = new sl.Uint8ClampedList.transferable(length); 1232 if (length < 0) {
1233 String message = "$length must be greater than 0";
1234 throw new ArgumentError(message);
1235 }
1236 return _new(length);
1460 } 1237 }
1461 1238
1462 1239
1463 // Method(s) implementing the List interface. 1240 // Method(s) implementing the List interface.
1464 1241
1465 int operator[](int index) { 1242 int operator[](int index) {
1466 return _getIndexed(index); 1243 if (index < 0 || index >= length) {
1244 String message = "$index must be in the range [0..$length)";
1245 throw new RangeError(message);
1246 }
1247 return _getUint8(index);
1467 } 1248 }
1468 1249
1469 void operator[]=(int index, int value) { 1250 void operator[]=(int index, int value) {
1470 _setIndexed(index, _toClampedUint8(value)); 1251 if (index < 0 || index >= length) {
1252 String message = "$index must be in the range [0..$length)";
1253 throw new RangeError(message);
1254 }
1255 _setUint8(index, _toClampedUint8(value));
1471 } 1256 }
1472 1257
1473 Iterator<int> get iterator { 1258 Iterator<int> get iterator {
1474 return new _TypedListIterator<int>(this); 1259 return new _TypedListIterator<int>(this);
1475 } 1260 }
1476 1261
1477 List<int> getRange(int start, int length) {
1478 _rangeCheck(this.length, start, length);
1479 List<int> result = new Uint8ClampedList(length);
1480 result.setRange(0, length, this, start);
1481 return result;
1482 }
1483
1484 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1485 /**
1486 if (from is _ExternalUint8ClampedArray || from is _Uint8ClampedArray) {
1487 _setRange(start * Uint8List.BYTES_PER_ELEMENT,
1488 length * Uint8List.BYTES_PER_ELEMENT,
1489 from,
1490 startFrom * Uint8List.BYTES_PER_ELEMENT);
1491 } else {
1492 Arrays.copy(from, startFrom, this, start, length);
1493 }
1494 */
1495 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1496 }
1497
1498
1499 // Method(s) implementing the Object interface.
1500
1501 String toString() {
1502 return Collections.collectionToString(this);
1503 }
1504
1505 1262
1506 // Method(s) implementing the TypedData interface. 1263 // Method(s) implementing the TypedData interface.
1507 1264
1508 int get elementSizeInBytes { 1265 int get elementSizeInBytes {
1509 return Uint8List.BYTES_PER_ELEMENT; 1266 return Uint8List.BYTES_PER_ELEMENT;
1510 } 1267 }
1511 1268
1512 1269
1513 // Internal utility methods. 1270 // Internal utility methods.
1514 1271
1515 int _getIndexed(int index) { 1272 static _ExternalUint8ClampedArray _new(int length) native
1516 return _array[index]; 1273 "ExternalTypedData_Uint8ClampedArray_new";
1517 }
1518 void _setIndexed(int index, int value) {
1519 _array[index] = value;
1520 }
1521 } 1274 }
1522 1275
1523 1276
1524 class _ExternalInt16Array extends _TypedList implements Int16List { 1277 class _ExternalInt16Array extends _TypedList implements Int16List {
1525 // Factory constructors. 1278 // Factory constructors.
1526 1279
1527 _ExternalInt16Array(int length) { 1280 factory _ExternalInt16Array(int length) {
1528 _array = new sl.Int16List.transferable(length); 1281 if (length < 0) {
1282 String message = "$length must be greater than 0";
1283 throw new ArgumentError(message);
1284 }
1285 return _new(length);
1529 } 1286 }
1530 1287
1531 1288
1532 // Method(s) implementing the List interface. 1289 // Method(s) implementing the List interface.
1533 1290
1534 int operator[](int index) { 1291 int operator[](int index) {
1535 return _getIndexed(index); 1292 if (index < 0 || index >= length) {
1293 String message = "$index must be in the range [0..$length)";
1294 throw new RangeError(message);
1295 }
1296 return _getInt16(index);
1536 } 1297 }
1537 1298
1538 void operator[]=(int index, int value) { 1299 void operator[]=(int index, int value) {
1539 _setIndexed(index, _toInt16(value)); 1300 if (index < 0 || index >= length) {
1301 String message = "$index must be in the range [0..$length)";
1302 throw new RangeError(message);
1303 }
1304 _setInt16(index, _toInt16(value));
1540 } 1305 }
1541 1306
1542 Iterator<int> get iterator { 1307 Iterator<int> get iterator {
1543 return new _TypedListIterator<int>(this); 1308 return new _TypedListIterator<int>(this);
1544 } 1309 }
1545 1310
1546 List<int> getRange(int start, int length) {
1547 _rangeCheck(this.length, start, length);
1548 List<int> result = new Int16List(length);
1549 result.setRange(0, length, this, start);
1550 return result;
1551 }
1552
1553 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1554 /**
1555 if (from is _ExternalInt16Array) {
1556 _setRange(start * Int16List.BYTES_PER_ELEMENT,
1557 length * Int16List.BYTES_PER_ELEMENT,
1558 from,
1559 startFrom * Int16List.BYTES_PER_ELEMENT);
1560 } else {
1561 Arrays.copy(from, startFrom, this, start, length);
1562 }
1563 */
1564 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1565 }
1566
1567
1568 // Method(s) implementing the Object interface.
1569
1570 String toString() {
1571 return Collections.collectionToString(this);
1572 }
1573
1574 1311
1575 // Method(s) implementing the TypedData interface. 1312 // Method(s) implementing the TypedData interface.
1576 1313
1577 int get elementSizeInBytes { 1314 int get elementSizeInBytes {
1578 return Int16List.BYTES_PER_ELEMENT; 1315 return Int16List.BYTES_PER_ELEMENT;
1579 } 1316 }
1580 1317
1581 1318
1582 // Internal utility methods. 1319 // Internal utility methods.
1583 1320
1584 int _getIndexed(int index) { 1321 static _ExternalInt16Array _new(int length) native
1585 return _array[index]; 1322 "ExternalTypedData_Int16Array_new";
1586 }
1587 void _setIndexed(int index, int value) {
1588 _array[index] = value;
1589 }
1590 } 1323 }
1591 1324
1592 1325
1593 class _ExternalUint16Array extends _TypedList implements Uint16List { 1326 class _ExternalUint16Array extends _TypedList implements Uint16List {
1594 // Factory constructors. 1327 // Factory constructors.
1595 1328
1596 _ExternalUint16Array(int length) { 1329 factory _ExternalUint16Array(int length) {
1597 _array = new sl.Uint16List.transferable(length); 1330 if (length < 0) {
1331 String message = "$length must be greater than 0";
1332 throw new ArgumentError(message);
1333 }
1334 return _new(length);
1598 } 1335 }
1599 1336
1600 1337
1601 // Method(s) implementing the List interface. 1338 // Method(s) implementing the List interface.
1602 1339
1603 int operator[](int index) { 1340 int operator[](int index) {
1604 return _getIndexed(index); 1341 if (index < 0 || index >= length) {
1342 String message = "$index must be in the range [0..$length)";
1343 throw new RangeError(message);
1344 }
1345 return _getUint16(index);
1605 } 1346 }
1606 1347
1607 void operator[]=(int index, int value) { 1348 void operator[]=(int index, int value) {
1608 _setIndexed(index, _toUint16(value)); 1349 if (index < 0 || index >= length) {
1350 String message = "$index must be in the range [0..$length)";
1351 throw new RangeError(message);
1352 }
1353 _setUint16(index, _toUint16(value));
1609 } 1354 }
1610 1355
1611 Iterator<int> get iterator { 1356 Iterator<int> get iterator {
1612 return new _TypedListIterator<int>(this); 1357 return new _TypedListIterator<int>(this);
1613 } 1358 }
1614 1359
1615 List<int> getRange(int start, int length) {
1616 _rangeCheck(this.length, start, length);
1617 List<int> result = new Uint16List(length);
1618 result.setRange(0, length, this, start);
1619 return result;
1620 }
1621
1622 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1623 /**
1624 if (from is _ExternalUint16Array) {
1625 _setRange(start * Uint16List.BYTES_PER_ELEMENT,
1626 length * Uint16List.BYTES_PER_ELEMENT,
1627 from,
1628 startFrom * Uint16List.BYTES_PER_ELEMENT);
1629 } else {
1630 Arrays.copy(from, startFrom, this, start, length);
1631 }
1632 */
1633 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1634 }
1635
1636
1637 // Method(s) implementing the Object interface.
1638
1639 String toString() {
1640 return Collections.collectionToString(this);
1641 }
1642
1643 1360
1644 // Method(s) implementing the TypedData interface. 1361 // Method(s) implementing the TypedData interface.
1645 1362
1646 int get elementSizeInBytes { 1363 int get elementSizeInBytes {
1647 return Uint16List.BYTES_PER_ELEMENT; 1364 return Uint16List.BYTES_PER_ELEMENT;
1648 } 1365 }
1649 1366
1650 1367
1651 // Internal utility methods. 1368 // Internal utility methods.
1652 1369
1653 int _getIndexed(int index) { 1370 static _ExternalUint16Array _new(int length) native
1654 return _array[index]; 1371 "ExternalTypedData_Uint16Array_new";
1655 }
1656 void _setIndexed(int index, int value) {
1657 _array[index] = value;
1658 }
1659 } 1372 }
1660 1373
1661 1374
1662 class _ExternalInt32Array extends _TypedList implements Int32List { 1375 class _ExternalInt32Array extends _TypedList implements Int32List {
1663 // Factory constructors. 1376 // Factory constructors.
1664 1377
1665 _ExternalInt32Array(int length) { 1378 factory _ExternalInt32Array(int length) {
1666 _array = new sl.Int32List.transferable(length); 1379 if (length < 0) {
1380 String message = "$length must be greater than 0";
1381 throw new ArgumentError(message);
1382 }
1383 return _new(length);
1667 } 1384 }
1668 1385
1669 1386
1670 // Method(s) implementing the List interface. 1387 // Method(s) implementing the List interface.
1671 1388
1672 int operator[](int index) { 1389 int operator[](int index) {
1673 return _getIndexed(index); 1390 if (index < 0 || index >= length) {
1391 String message = "$index must be in the range [0..$length)";
1392 throw new RangeError(message);
1393 }
1394 return _getInt32(index);
1674 } 1395 }
1675 1396
1676 void operator[]=(int index, int value) { 1397 void operator[]=(int index, int value) {
1677 _setIndexed(index, _toInt32(value)); 1398 if (index < 0 || index >= length) {
1399 String message = "$index must be in the range [0..$length)";
1400 throw new RangeError(message);
1401 }
1402 _setInt32(index, _toInt32(value));
1678 } 1403 }
1679 1404
1680 Iterator<int> get iterator { 1405 Iterator<int> get iterator {
1681 return new _TypedListIterator<int>(this); 1406 return new _TypedListIterator<int>(this);
1682 } 1407 }
1683 1408
1684 List<int> getRange(int start, int length) {
1685 _rangeCheck(this.length, start, length);
1686 List<int> result = new Int32List(length);
1687 result.setRange(0, length, this, start);
1688 return result;
1689 }
1690
1691 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1692 /**
1693 if (from is _ExternalInt32Array) {
1694 _setRange(start * Int32List.BYTES_PER_ELEMENT,
1695 length * Int32List.BYTES_PER_ELEMENT,
1696 from,
1697 startFrom * Int32List.BYTES_PER_ELEMENT);
1698 } else {
1699 Arrays.copy(from, startFrom, this, start, length);
1700 }
1701 */
1702 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1703 }
1704
1705
1706 // Method(s) implementing the Object interface.
1707
1708 String toString() {
1709 return Collections.collectionToString(this);
1710 }
1711
1712 1409
1713 // Method(s) implementing the TypedData interface. 1410 // Method(s) implementing the TypedData interface.
1714 1411
1715 int get elementSizeInBytes { 1412 int get elementSizeInBytes {
1716 return Int32List.BYTES_PER_ELEMENT; 1413 return Int32List.BYTES_PER_ELEMENT;
1717 } 1414 }
1718 1415
1719 1416
1720 // Internal utility methods. 1417 // Internal utility methods.
1721 1418
1722 int _getIndexed(int index) { 1419 static _ExternalInt32Array _new(int length) native
1723 return _array[index]; 1420 "ExternalTypedData_Int32Array_new";
1724 }
1725 void _setIndexed(int index, int value) {
1726 _array[index] = value;
1727 }
1728 } 1421 }
1729 1422
1730 1423
1731 class _ExternalUint32Array extends _TypedList implements Uint32List { 1424 class _ExternalUint32Array extends _TypedList implements Uint32List {
1732 // Factory constructors. 1425 // Factory constructors.
1733 1426
1734 _ExternalUint32Array(int length) { 1427 factory _ExternalUint32Array(int length) {
1735 _array = new sl.Uint32List.transferable(length); 1428 if (length < 0) {
1429 String message = "$length must be greater than 0";
1430 throw new ArgumentError(message);
1431 }
1432 return _new(length);
1736 } 1433 }
1737 1434
1738 1435
1739 // Method(s) implementing the List interface. 1436 // Method(s) implementing the List interface.
1740 1437
1741 int operator[](int index) { 1438 int operator[](int index) {
1742 return _getIndexed(index); 1439 if (index < 0 || index >= length) {
1440 String message = "$index must be in the range [0..$length)";
1441 throw new RangeError(message);
1442 }
1443 return _getUint32(index);
1743 } 1444 }
1744 1445
1745 void operator[]=(int index, int value) { 1446 void operator[]=(int index, int value) {
1746 _setIndexed(index, _toUint32(value)); 1447 if (index < 0 || index >= length) {
1448 String message = "$index must be in the range [0..$length)";
1449 throw new RangeError(message);
1450 }
1451 _setUint32(index, _toUint32(value));
1747 } 1452 }
1748 1453
1749 Iterator<int> get iterator { 1454 Iterator<int> get iterator {
1750 return new _TypedListIterator<int>(this); 1455 return new _TypedListIterator<int>(this);
1751 } 1456 }
1752 1457
1753 List<int> getRange(int start, int length) {
1754 _rangeCheck(this.length, start, length);
1755 List<int> result = new Uint32List(length);
1756 result.setRange(0, length, this, start);
1757 return result;
1758 }
1759
1760 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1761 /**
1762 if (from is _ExternalUint32Array) {
1763 _setRange(start * Uint32List.BYTES_PER_ELEMENT,
1764 length * Uint32List.BYTES_PER_ELEMENT,
1765 from,
1766 startFrom * Uint32List.BYTES_PER_ELEMENT);
1767 } else {
1768 Arrays.copy(from, startFrom, this, start, length);
1769 }
1770 */
1771 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1772 }
1773
1774
1775 // Method(s) implementing the Object interface.
1776
1777 String toString() {
1778 return Collections.collectionToString(this);
1779 }
1780
1781 1458
1782 // Method(s) implementing the TypedData interface. 1459 // Method(s) implementing the TypedData interface.
1783 1460
1784 int get elementSizeInBytes { 1461 int get elementSizeInBytes {
1785 return Uint32List.BYTES_PER_ELEMENT; 1462 return Uint32List.BYTES_PER_ELEMENT;
1786 } 1463 }
1787 1464
1788 1465
1789 // Internal utility methods. 1466 // Internal utility methods.
1790 1467
1791 int _getIndexed(int index) { 1468 static _ExternalUint32Array _new(int length) native
1792 return _array[index]; 1469 "ExternalTypedData_Uint32Array_new";
1793 }
1794 void _setIndexed(int index, int value) {
1795 _array[index] = value;
1796 }
1797 } 1470 }
1798 1471
1799 1472
1800 class _ExternalInt64Array extends _TypedList implements Int64List { 1473 class _ExternalInt64Array extends _TypedList implements Int64List {
1801 // Factory constructors. 1474 // Factory constructors.
1802 1475
1803 _ExternalInt64Array(int length) { 1476 factory _ExternalInt64Array(int length) {
1804 _array = new sl.Int64List.transferable(length); 1477 if (length < 0) {
1478 String message = "$length must be greater than 0";
1479 throw new ArgumentError(message);
1480 }
1481 return _new(length);
1805 } 1482 }
1806 1483
1807 1484
1808 // Method(s) implementing the List interface. 1485 // Method(s) implementing the List interface.
1809 1486
1810 int operator[](int index) { 1487 int operator[](int index) {
1811 return _getIndexed(index); 1488 if (index < 0 || index >= length) {
1489 String message = "$index must be in the range [0..$length)";
1490 throw new RangeError(message);
1491 }
1492 return _getInt64(index);
1812 } 1493 }
1813 1494
1814 void operator[]=(int index, int value) { 1495 void operator[]=(int index, int value) {
1815 _setIndexed(index, _toInt64(value)); 1496 if (index < 0 || index >= length) {
1497 String message = "$index must be in the range [0..$length)";
1498 throw new RangeError(message);
1499 }
1500 _setInt64(index, _toInt64(value));
1816 } 1501 }
1817 1502
1818 Iterator<int> get iterator { 1503 Iterator<int> get iterator {
1819 return new _TypedListIterator<int>(this); 1504 return new _TypedListIterator<int>(this);
1820 } 1505 }
1821 1506
1822 List<int> getRange(int start, int length) {
1823 _rangeCheck(this.length, start, length);
1824 List<int> result = new Int64List(length);
1825 result.setRange(0, length, this, start);
1826 return result;
1827 }
1828
1829 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1830 /**
1831 if (from is _ExternalInt64Array) {
1832 _setRange(start * Int64List.BYTES_PER_ELEMENT,
1833 length * Int64List.BYTES_PER_ELEMENT,
1834 from,
1835 startFrom * Int64List.BYTES_PER_ELEMENT);
1836 } else {
1837 Arrays.copy(from, startFrom, this, start, length);
1838 }
1839 */
1840 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1841 }
1842
1843
1844 // Method(s) implementing the Object interface.
1845
1846 String toString() {
1847 return Collections.collectionToString(this);
1848 }
1849
1850 1507
1851 // Method(s) implementing the TypedData interface. 1508 // Method(s) implementing the TypedData interface.
1852 1509
1853 int get elementSizeInBytes { 1510 int get elementSizeInBytes {
1854 return Int64List.BYTES_PER_ELEMENT; 1511 return Int64List.BYTES_PER_ELEMENT;
1855 } 1512 }
1856 1513
1857 1514
1858 // Internal utility methods. 1515 // Internal utility methods.
1859 1516
1860 int _getIndexed(int index) { 1517 static _ExternalInt64Array _new(int length) native
1861 return _array[index]; 1518 "ExternalTypedData_Int64Array_new";
1862 }
1863 void _setIndexed(int index, int value) {
1864 _array[index] = value;
1865 }
1866 } 1519 }
1867 1520
1868 1521
1869 class _ExternalUint64Array extends _TypedList implements Uint64List { 1522 class _ExternalUint64Array extends _TypedList implements Uint64List {
1870 // Factory constructors. 1523 // Factory constructors.
1871 1524
1872 _ExternalUint64Array(int length) { 1525 factory _ExternalUint64Array(int length) {
1873 _array = new sl.Uint64List.transferable(length); 1526 if (length < 0) {
1527 String message = "$length must be greater than 0";
1528 throw new ArgumentError(message);
1529 }
1530 return _new(length);
1874 } 1531 }
1875 1532
1876 1533
1877 // Method(s) implementing the List interface. 1534 // Method(s) implementing the List interface.
1878 1535
1879 int operator[](int index) { 1536 int operator[](int index) {
1880 return _getIndexed(index); 1537 if (index < 0 || index >= length) {
1538 String message = "$index must be in the range [0..$length)";
1539 throw new RangeError(message);
1540 }
1541 return _getUint64(index);
1881 } 1542 }
1882 1543
1883 void operator[]=(int index, int value) { 1544 void operator[]=(int index, int value) {
1884 _setIndexed(index, _toUint64(value)); 1545 if (index < 0 || index >= length) {
1546 String message = "$index must be in the range [0..$length)";
1547 throw new RangeError(message);
1548 }
1549 _setUint64(index, _toUint64(value));
1885 } 1550 }
1886 1551
1887 Iterator<int> get iterator { 1552 Iterator<int> get iterator {
1888 return new _TypedListIterator<int>(this); 1553 return new _TypedListIterator<int>(this);
1889 } 1554 }
1890 1555
1891 List<int> getRange(int start, int length) {
1892 _rangeCheck(this.length, start, length);
1893 List<int> result = new Uint64List(length);
1894 result.setRange(0, length, this, start);
1895 return result;
1896 }
1897
1898 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1899 /**
1900 if (from is _ExternalUint64Array) {
1901 _setRange(start * Uint64List.BYTES_PER_ELEMENT,
1902 length * Uint64List.BYTES_PER_ELEMENT,
1903 from,
1904 startFrom * Uint64List.BYTES_PER_ELEMENT);
1905 } else {
1906 Arrays.copy(from, startFrom, this, start, length);
1907 }
1908 */
1909 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1910 }
1911
1912
1913 // Method(s) implementing the Object interface.
1914
1915 String toString() {
1916 return Collections.collectionToString(this);
1917 }
1918
1919 1556
1920 // Method(s) implementing the TypedData interface. 1557 // Method(s) implementing the TypedData interface.
1921 1558
1922 int get elementSizeInBytes { 1559 int get elementSizeInBytes {
1923 return Uint64List.BYTES_PER_ELEMENT; 1560 return Uint64List.BYTES_PER_ELEMENT;
1924 } 1561 }
1925 1562
1926 1563
1927 // Internal utility methods. 1564 // Internal utility methods.
1928 1565
1929 int _getIndexed(int index) { 1566 static _ExternalUint64Array _new(int length) native
1930 return _array[index]; 1567 "ExternalTypedData_Uint64Array_new";
1931 }
1932 void _setIndexed(int index, int value) {
1933 _array[index] = value;
1934 }
1935 } 1568 }
1936 1569
1937 1570
1938 class _ExternalFloat32Array extends _TypedList implements Float32List { 1571 class _ExternalFloat32Array extends _TypedList implements Float32List {
1939 // Factory constructors. 1572 // Factory constructors.
1940 1573
1941 _ExternalFloat32Array(int length) { 1574 factory _ExternalFloat32Array(int length) {
1942 _array = new sl.Float32List.transferable(length); 1575 if (length < 0) {
1576 String message = "$length must be greater than 0";
1577 throw new ArgumentError(message);
1578 }
1579 return _new(length);
1943 } 1580 }
1944 1581
1945 1582
1946 // Method(s) implementing the List interface. 1583 // Method(s) implementing the List interface.
1947 1584
1948 double operator[](int index) { 1585 double operator[](int index) {
1949 return _getIndexed(index); 1586 if (index < 0 || index >= length) {
1587 String message = "$index must be in the range [0..$length)";
1588 throw new RangeError(message);
1589 }
1590 return _getFloat32(index);
1950 } 1591 }
1951 1592
1952 void operator[]=(int index, double value) { 1593 void operator[]=(int index, double value) {
1953 _setIndexed(index, value); 1594 if (index < 0 || index >= length) {
1595 String message = "$index must be in the range [0..$length)";
1596 throw new RangeError(message);
1597 }
1598 _setFloat32(index, value);
1954 } 1599 }
1955 1600
1956 Iterator<double> get iterator { 1601 Iterator<double> get iterator {
1957 return new _TypedListIterator<double>(this); 1602 return new _TypedListIterator<double>(this);
1958 } 1603 }
1959 1604
1960 List<double> getRange(int start, int length) {
1961 _rangeCheck(this.length, start, length);
1962 List<double> result = new Float32List(length);
1963 result.setRange(0, length, this, start);
1964 return result;
1965 }
1966
1967 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
1968 /**
1969 if (from is _ExternalFloat32Array) {
1970 _setRange(start * Float32List.BYTES_PER_ELEMENT,
1971 length * Float32List.BYTES_PER_ELEMENT,
1972 from,
1973 startFrom * Float32List.BYTES_PER_ELEMENT);
1974 } else {
1975 Arrays.copy(from, startFrom, this, start, length);
1976 }
1977 */
1978 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
1979 }
1980
1981
1982 // Method(s) implementing the Object interface.
1983
1984 String toString() {
1985 return Collections.collectionToString(this);
1986 }
1987
1988 1605
1989 // Method(s) implementing the TypedData interface. 1606 // Method(s) implementing the TypedData interface.
1990 1607
1991 int get elementSizeInBytes { 1608 int get elementSizeInBytes {
1992 return Float32List.BYTES_PER_ELEMENT; 1609 return Float32List.BYTES_PER_ELEMENT;
1993 } 1610 }
1994 1611
1995 1612
1996 // Internal utility methods. 1613 // Internal utility methods.
1997 1614
1998 double _getIndexed(int index) { 1615 static _ExternalFloat32Array _new(int length) native
1999 return _array[index]; 1616 "ExternalTypedData_Float32Array_new";
2000 }
2001 void _setIndexed(int index, double value) {
2002 _array[index] = value;
2003 }
2004 } 1617 }
2005 1618
2006 1619
2007 class _ExternalFloat64Array extends _TypedList implements Float64List { 1620 class _ExternalFloat64Array extends _TypedList implements Float64List {
2008 // Factory constructors. 1621 // Factory constructors.
2009 1622
2010 _ExternalFloat64Array(int length) { 1623 factory _ExternalFloat64Array(int length) {
2011 _array = new sl.Float64List.transferable(length); 1624 if (length < 0) {
1625 String message = "$length must be greater than 0";
1626 throw new ArgumentError(message);
1627 }
1628 return _new(length);
2012 } 1629 }
2013 1630
2014 1631
2015 // Method(s) implementing the List interface. 1632 // Method(s) implementing the List interface.
2016 1633
2017 double operator[](int index) { 1634 double operator[](int index) {
2018 return _getIndexed(index); 1635 if (index < 0 || index >= length) {
1636 String message = "$index must be in the range [0..$length)";
1637 throw new RangeError(message);
1638 }
1639 return _getFloat64(index);
2019 } 1640 }
2020 1641
2021 void operator[]=(int index, double value) { 1642 void operator[]=(int index, double value) {
2022 _setIndexed(index, value); 1643 if (index < 0 || index >= length) {
1644 String message = "$index must be in the range [0..$length)";
1645 throw new RangeError(message);
1646 }
1647 _setFloat64(index, value);
2023 } 1648 }
2024 1649
2025 Iterator<double> get iterator { 1650 Iterator<double> get iterator {
2026 return new _TypedListIterator<double>(this); 1651 return new _TypedListIterator<double>(this);
2027 } 1652 }
2028 1653
2029 List<double> getRange(int start, int length) {
2030 _rangeCheck(this.length, start, length);
2031 List<double> result = new Float64List(length);
2032 result.setRange(0, length, this, start);
2033 return result;
2034 }
2035
2036 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
2037 /**
2038 if (from is _ExternalFloat64Array) {
2039 _setRange(start * Float64List.BYTES_PER_ELEMENT,
2040 length * Float64List.BYTES_PER_ELEMENT,
2041 from,
2042 startFrom * Float64List.BYTES_PER_ELEMENT);
2043 } else {
2044 Arrays.copy(from, startFrom, this, start, length);
2045 }
2046 */
2047 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
2048 }
2049
2050
2051 // Method(s) implementing the Object interface.
2052
2053 String toString() {
2054 return Collections.collectionToString(this);
2055 }
2056
2057 1654
2058 // Method(s) implementing the TypedData interface. 1655 // Method(s) implementing the TypedData interface.
2059 1656
2060 int get elementSizeInBytes { 1657 int get elementSizeInBytes {
2061 return Float64List.BYTES_PER_ELEMENT; 1658 return Float64List.BYTES_PER_ELEMENT;
2062 } 1659 }
2063 1660
2064 1661
2065 // Internal utility methods. 1662 // Internal utility methods.
2066 1663
2067 double _getIndexed(int index) { 1664 static _ExternalFloat64Array _new(int length) native
2068 return _array[index]; 1665 "ExternalTypedData_Float64Array_new";
2069 }
2070 void _setIndexed(int index, double value) {
2071 _array[index] = value;
2072 }
2073 } 1666 }
2074 1667
2075 1668
2076 class _TypedListIterator<E> implements Iterator<E> { 1669 class _TypedListIterator<E> implements Iterator<E> {
2077 final List<E> _array; 1670 final List<E> _array;
2078 final int _length; 1671 final int _length;
2079 int _position; 1672 int _position;
2080 E _current; 1673 E _current;
2081 1674
2082 _TypedListIterator(List array) 1675 _TypedListIterator(List array)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 throw new RangeError(message); 1747 throw new RangeError(message);
2155 } 1748 }
2156 _typeddata.setInt8(offsetInBytes + (index * Int8List.BYTES_PER_ELEMENT), 1749 _typeddata.setInt8(offsetInBytes + (index * Int8List.BYTES_PER_ELEMENT),
2157 _toInt8(value)); 1750 _toInt8(value));
2158 } 1751 }
2159 1752
2160 Iterator<int> get iterator { 1753 Iterator<int> get iterator {
2161 return new _TypedListIterator<int>(this); 1754 return new _TypedListIterator<int>(this);
2162 } 1755 }
2163 1756
2164 List<int> getRange(int start, int length) {
2165 _rangeCheck(this.length, start, length);
2166 List<int> result = new Int8List(length);
2167 result.setRange(0, length, this, start);
2168 return result;
2169 }
2170
2171 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2172 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
2173 }
2174
2175
2176 // Method(s) implementing Object interface.
2177
2178 String toString() {
2179 return Collections.collectionToString(this);
2180 }
2181
2182 1757
2183 // Method(s) implementing TypedData interface. 1758 // Method(s) implementing TypedData interface.
2184 1759
2185 int get elementSizeInBytes { 1760 int get elementSizeInBytes {
2186 return Int8List.BYTES_PER_ELEMENT; 1761 return Int8List.BYTES_PER_ELEMENT;
2187 } 1762 }
2188 } 1763 }
2189 1764
2190 1765
2191 class _Uint8ArrayView extends _TypedListView implements Uint8List { 1766 class _Uint8ArrayView extends _TypedListView implements Uint8List {
(...skipping 26 matching lines...) Expand all
2218 throw new RangeError(message); 1793 throw new RangeError(message);
2219 } 1794 }
2220 _typeddata.setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT), 1795 _typeddata.setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT),
2221 _toUint8(value)); 1796 _toUint8(value));
2222 } 1797 }
2223 1798
2224 Iterator<int> get iterator { 1799 Iterator<int> get iterator {
2225 return new _TypedListIterator<int>(this); 1800 return new _TypedListIterator<int>(this);
2226 } 1801 }
2227 1802
2228 List<int> getRange(int start, int length) {
2229 _rangeCheck(this.length, start, length);
2230 List<int> result = new Uint8List(length);
2231 result.setRange(0, length, this, start);
2232 return result;
2233 }
2234
2235 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2236 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
2237 }
2238
2239
2240 // Method(s) implementing Object interface.
2241
2242 String toString() {
2243 return Collections.collectionToString(this);
2244 }
2245
2246 1803
2247 // Method(s) implementing TypedData interface. 1804 // Method(s) implementing TypedData interface.
2248 1805
2249 int get elementSizeInBytes { 1806 int get elementSizeInBytes {
2250 return Uint8List.BYTES_PER_ELEMENT; 1807 return Uint8List.BYTES_PER_ELEMENT;
2251 } 1808 }
2252 } 1809 }
2253 1810
2254 1811
2255 class _Uint8ClampedArrayView extends _TypedListView implements Uint8List { 1812 class _Uint8ClampedArrayView extends _TypedListView implements Uint8List {
(...skipping 27 matching lines...) Expand all
2283 throw new RangeError(message); 1840 throw new RangeError(message);
2284 } 1841 }
2285 _typeddata.setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT), 1842 _typeddata.setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT),
2286 _toClampedUint8(value)); 1843 _toClampedUint8(value));
2287 } 1844 }
2288 1845
2289 Iterator<int> get iterator { 1846 Iterator<int> get iterator {
2290 return new _TypedListIterator<int>(this); 1847 return new _TypedListIterator<int>(this);
2291 } 1848 }
2292 1849
2293 List<int> getRange(int start, int length) {
2294 _rangeCheck(this.length, start, length);
2295 List<int> result = new Uint8List(length);
2296 result.setRange(0, length, this, start);
2297 return result;
2298 }
2299
2300 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2301 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
2302 }
2303
2304
2305 // Method(s) implementing Object interface.
2306
2307 String toString() {
2308 return Collections.collectionToString(this);
2309 }
2310
2311 1850
2312 // Method(s) implementing TypedData interface. 1851 // Method(s) implementing TypedData interface.
2313 1852
2314 int get elementSizeInBytes { 1853 int get elementSizeInBytes {
2315 return Uint8List.BYTES_PER_ELEMENT; 1854 return Uint8List.BYTES_PER_ELEMENT;
2316 } 1855 }
2317 } 1856 }
2318 1857
2319 1858
2320 class _Int16ArrayView extends _TypedListView implements Int16List { 1859 class _Int16ArrayView extends _TypedListView implements Int16List {
(...skipping 26 matching lines...) Expand all
2347 throw new RangeError(message); 1886 throw new RangeError(message);
2348 } 1887 }
2349 _typeddata.setInt16(offsetInBytes + (index * Int16List.BYTES_PER_ELEMENT), 1888 _typeddata.setInt16(offsetInBytes + (index * Int16List.BYTES_PER_ELEMENT),
2350 _toInt16(value)); 1889 _toInt16(value));
2351 } 1890 }
2352 1891
2353 Iterator<int> get iterator { 1892 Iterator<int> get iterator {
2354 return new _TypedListIterator<int>(this); 1893 return new _TypedListIterator<int>(this);
2355 } 1894 }
2356 1895
2357 List<int> getRange(int start, int length) {
2358 _rangeCheck(this.length, start, length);
2359 List<int> result = new Int16List(length);
2360 result.setRange(0, length, this, start);
2361 return result;
2362 }
2363
2364 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2365 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
2366 }
2367
2368
2369 // Method(s) implementing Object interface.
2370
2371 String toString() {
2372 return Collections.collectionToString(this);
2373 }
2374
2375 1896
2376 // Method(s) implementing TypedData interface. 1897 // Method(s) implementing TypedData interface.
2377 1898
2378 int get elementSizeInBytes { 1899 int get elementSizeInBytes {
2379 return Int16List.BYTES_PER_ELEMENT; 1900 return Int16List.BYTES_PER_ELEMENT;
2380 } 1901 }
2381 } 1902 }
2382 1903
2383 1904
2384 class _Uint16ArrayView extends _TypedListView implements Uint16List { 1905 class _Uint16ArrayView extends _TypedListView implements Uint16List {
(...skipping 26 matching lines...) Expand all
2411 throw new RangeError(message); 1932 throw new RangeError(message);
2412 } 1933 }
2413 _typeddata.setUint16(offsetInBytes + (index * Uint16List.BYTES_PER_ELEMENT), 1934 _typeddata.setUint16(offsetInBytes + (index * Uint16List.BYTES_PER_ELEMENT),
2414 _toUint16(value)); 1935 _toUint16(value));
2415 } 1936 }
2416 1937
2417 Iterator<int> get iterator { 1938 Iterator<int> get iterator {
2418 return new _TypedListIterator<int>(this); 1939 return new _TypedListIterator<int>(this);
2419 } 1940 }
2420 1941
2421 List<int> getRange(int start, int length) {
2422 _rangeCheck(this.length, start, length);
2423 List<int> result = new Uint16List(length);
2424 result.setRange(0, length, this, start);
2425 return result;
2426 }
2427
2428 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2429 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
2430 }
2431
2432
2433 // Method(s) implementing Object interface.
2434
2435 String toString() {
2436 return Collections.collectionToString(this);
2437 }
2438
2439 1942
2440 // Method(s) implementing TypedData interface. 1943 // Method(s) implementing TypedData interface.
2441 1944
2442 int get elementSizeInBytes { 1945 int get elementSizeInBytes {
2443 return Uint16List.BYTES_PER_ELEMENT; 1946 return Uint16List.BYTES_PER_ELEMENT;
2444 } 1947 }
2445 } 1948 }
2446 1949
2447 1950
2448 class _Int32ArrayView extends _TypedListView implements Int32List { 1951 class _Int32ArrayView extends _TypedListView implements Int32List {
(...skipping 26 matching lines...) Expand all
2475 throw new RangeError(message); 1978 throw new RangeError(message);
2476 } 1979 }
2477 _typeddata.setInt32(offsetInBytes + (index * Int32List.BYTES_PER_ELEMENT), 1980 _typeddata.setInt32(offsetInBytes + (index * Int32List.BYTES_PER_ELEMENT),
2478 _toInt32(value)); 1981 _toInt32(value));
2479 } 1982 }
2480 1983
2481 Iterator<int> get iterator { 1984 Iterator<int> get iterator {
2482 return new _TypedListIterator<int>(this); 1985 return new _TypedListIterator<int>(this);
2483 } 1986 }
2484 1987
2485 List<int> getRange(int start, int length) {
2486 _rangeCheck(this.length, start, length);
2487 List<int> result = new Int32List(length);
2488 result.setRange(0, length, this, start);
2489 return result;
2490 }
2491
2492 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2493 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
2494 }
2495
2496
2497 // Method(s) implementing Object interface.
2498
2499 String toString() {
2500 return Collections.collectionToString(this);
2501 }
2502
2503 1988
2504 // Method(s) implementing TypedData interface. 1989 // Method(s) implementing TypedData interface.
2505 1990
2506 int get elementSizeInBytes { 1991 int get elementSizeInBytes {
2507 return Int32List.BYTES_PER_ELEMENT; 1992 return Int32List.BYTES_PER_ELEMENT;
2508 } 1993 }
2509 } 1994 }
2510 1995
2511 1996
2512 class _Uint32ArrayView extends _TypedListView implements Uint32List { 1997 class _Uint32ArrayView extends _TypedListView implements Uint32List {
(...skipping 26 matching lines...) Expand all
2539 throw new RangeError(message); 2024 throw new RangeError(message);
2540 } 2025 }
2541 _typeddata.setUint32(offsetInBytes + (index * Uint32List.BYTES_PER_ELEMENT), 2026 _typeddata.setUint32(offsetInBytes + (index * Uint32List.BYTES_PER_ELEMENT),
2542 _toUint32(value)); 2027 _toUint32(value));
2543 } 2028 }
2544 2029
2545 Iterator<int> get iterator { 2030 Iterator<int> get iterator {
2546 return new _TypedListIterator<int>(this); 2031 return new _TypedListIterator<int>(this);
2547 } 2032 }
2548 2033
2549 List<int> getRange(int start, int length) {
2550 _rangeCheck(this.length, start, length);
2551 List<int> result = new Uint32List(length);
2552 result.setRange(0, length, this, start);
2553 return result;
2554 }
2555
2556 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2557 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
2558 }
2559
2560
2561 // Method(s) implementing Object interface.
2562
2563 String toString() {
2564 return Collections.collectionToString(this);
2565 }
2566
2567 2034
2568 // Method(s) implementing TypedData interface. 2035 // Method(s) implementing TypedData interface.
2569 2036
2570 int get elementSizeInBytes { 2037 int get elementSizeInBytes {
2571 return Uint32List.BYTES_PER_ELEMENT; 2038 return Uint32List.BYTES_PER_ELEMENT;
2572 } 2039 }
2573 } 2040 }
2574 2041
2575 2042
2576 class _Int64ArrayView extends _TypedListView implements Int64List { 2043 class _Int64ArrayView extends _TypedListView implements Int64List {
(...skipping 26 matching lines...) Expand all
2603 throw new RangeError(message); 2070 throw new RangeError(message);
2604 } 2071 }
2605 _typeddata.setInt64(offsetInBytes + (index * Int64List.BYTES_PER_ELEMENT), 2072 _typeddata.setInt64(offsetInBytes + (index * Int64List.BYTES_PER_ELEMENT),
2606 _toInt64(value)); 2073 _toInt64(value));
2607 } 2074 }
2608 2075
2609 Iterator<int> get iterator { 2076 Iterator<int> get iterator {
2610 return new _TypedListIterator<int>(this); 2077 return new _TypedListIterator<int>(this);
2611 } 2078 }
2612 2079
2613 List<int> getRange(int start, int length) {
2614 _rangeCheck(this.length, start, length);
2615 List<int> result = new Int64List(length);
2616 result.setRange(0, length, this, start);
2617 return result;
2618 }
2619
2620 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2621 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
2622 }
2623
2624
2625 // Method(s) implementing Object interface.
2626
2627 String toString() {
2628 return Collections.collectionToString(this);
2629 }
2630
2631 2080
2632 // Method(s) implementing TypedData interface. 2081 // Method(s) implementing TypedData interface.
2633 2082
2634 int get elementSizeInBytes { 2083 int get elementSizeInBytes {
2635 return Int64List.BYTES_PER_ELEMENT; 2084 return Int64List.BYTES_PER_ELEMENT;
2636 } 2085 }
2637 } 2086 }
2638 2087
2639 2088
2640 class _Uint64ArrayView extends _TypedListView implements Uint64List { 2089 class _Uint64ArrayView extends _TypedListView implements Uint64List {
(...skipping 26 matching lines...) Expand all
2667 throw new RangeError(message); 2116 throw new RangeError(message);
2668 } 2117 }
2669 _typeddata.setUint64(offsetInBytes + (index * Uint64List.BYTES_PER_ELEMENT), 2118 _typeddata.setUint64(offsetInBytes + (index * Uint64List.BYTES_PER_ELEMENT),
2670 _toUint64(value)); 2119 _toUint64(value));
2671 } 2120 }
2672 2121
2673 Iterator<int> get iterator { 2122 Iterator<int> get iterator {
2674 return new _TypedListIterator<int>(this); 2123 return new _TypedListIterator<int>(this);
2675 } 2124 }
2676 2125
2677 List<int> getRange(int start, int length) {
2678 _rangeCheck(this.length, start, length);
2679 List<int> result = new Uint64List(length);
2680 result.setRange(0, length, this, start);
2681 return result;
2682 }
2683
2684 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2685 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
2686 }
2687
2688
2689 // Method(s) implementing Object interface.
2690
2691 String toString() {
2692 return Collections.collectionToString(this);
2693 }
2694
2695 2126
2696 // Method(s) implementing TypedData interface. 2127 // Method(s) implementing TypedData interface.
2697 2128
2698 int get elementSizeInBytes { 2129 int get elementSizeInBytes {
2699 return Uint64List.BYTES_PER_ELEMENT; 2130 return Uint64List.BYTES_PER_ELEMENT;
2700 } 2131 }
2701 } 2132 }
2702 2133
2703 2134
2704 class _Float32ArrayView extends _TypedListView implements Float32List { 2135 class _Float32ArrayView extends _TypedListView implements Float32List {
(...skipping 26 matching lines...) Expand all
2731 throw new RangeError(message); 2162 throw new RangeError(message);
2732 } 2163 }
2733 _typeddata.setFloat32(offsetInBytes + 2164 _typeddata.setFloat32(offsetInBytes +
2734 (index * Float32List.BYTES_PER_ELEMENT), value); 2165 (index * Float32List.BYTES_PER_ELEMENT), value);
2735 } 2166 }
2736 2167
2737 Iterator<double> get iterator { 2168 Iterator<double> get iterator {
2738 return new _TypedListIterator<double>(this); 2169 return new _TypedListIterator<double>(this);
2739 } 2170 }
2740 2171
2741 List<double> getRange(int start, int length) {
2742 _rangeCheck(this.length, start, length);
2743 List<double> result = new Float32List(length);
2744 result.setRange(0, length, this, start);
2745 return result;
2746 }
2747
2748 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
2749 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
2750 }
2751
2752
2753 // Method(s) implementing Object interface.
2754
2755 String toString() {
2756 return Collections.collectionToString(this);
2757 }
2758
2759 2172
2760 // Method(s) implementing TypedData interface. 2173 // Method(s) implementing TypedData interface.
2761 2174
2762 int get elementSizeInBytes { 2175 int get elementSizeInBytes {
2763 return Float32List.BYTES_PER_ELEMENT; 2176 return Float32List.BYTES_PER_ELEMENT;
2764 } 2177 }
2765 } 2178 }
2766 2179
2767 2180
2768 class _Float64ArrayView extends _TypedListView implements Float64List { 2181 class _Float64ArrayView extends _TypedListView implements Float64List {
(...skipping 26 matching lines...) Expand all
2795 throw new RangeError(message); 2208 throw new RangeError(message);
2796 } 2209 }
2797 _typeddata.setFloat64(offsetInBytes + 2210 _typeddata.setFloat64(offsetInBytes +
2798 (index * Float64List.BYTES_PER_ELEMENT), value); 2211 (index * Float64List.BYTES_PER_ELEMENT), value);
2799 } 2212 }
2800 2213
2801 Iterator<double> get iterator { 2214 Iterator<double> get iterator {
2802 return new _TypedListIterator<double>(this); 2215 return new _TypedListIterator<double>(this);
2803 } 2216 }
2804 2217
2805 List<double> getRange(int start, int length) {
2806 _rangeCheck(this.length, start, length);
2807 List<double> result = new Float64List(length);
2808 result.setRange(0, length, this, start);
2809 return result;
2810 }
2811
2812 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
2813 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
2814 }
2815
2816
2817 // Method(s) implementing Object interface.
2818
2819 String toString() {
2820 return Collections.collectionToString(this);
2821 }
2822
2823 2218
2824 // Method(s) implementing TypedData interface. 2219 // Method(s) implementing TypedData interface.
2825 2220
2826 int get elementSizeInBytes { 2221 int get elementSizeInBytes {
2827 return Float64List.BYTES_PER_ELEMENT; 2222 return Float64List.BYTES_PER_ELEMENT;
2828 } 2223 }
2829 } 2224 }
2830 2225
2831 2226
2832 class _ByteDataView implements ByteData { 2227 class _ByteDataView implements ByteData {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2996 throw new RangeError.value(start + length); 2391 throw new RangeError.value(start + length);
2997 } 2392 }
2998 } 2393 }
2999 2394
3000 2395
3001 int _defaultIfNull(object, value) { 2396 int _defaultIfNull(object, value) {
3002 if (object == null) { 2397 if (object == null) {
3003 return value; 2398 return value;
3004 } 2399 }
3005 } 2400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698