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

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

Issue 12730013: - Use dart:typedata types in the Dart API calls. (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 // patch classes for Int8List ..... Float64List and ByteData implementations. 5 // patch classes for Int8List ..... Float64List and ByteData implementations.
6 6
7 patch class Int8List { 7 patch class Int8List {
8 /* patch */ factory Int8List(int length) { 8 /* patch */ factory Int8List(int length) {
9 return new _Int8Array(length); 9 return new _Int8Array(length);
10 } 10 }
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 List toList() { 429 List toList() {
430 return new List.from(this); 430 return new List.from(this);
431 } 431 }
432 432
433 Set toSet() { 433 Set toSet() {
434 return new Set.from(this); 434 return new Set.from(this);
435 } 435 }
436 436
437 List getRange(int start, int length) { 437 List getRange(int start, int length) {
438 _rangeCheck(this.length, start, length); 438 _rangeCheck(this.length, start, length);
439 List result = _new(length); 439 List result = _createList(length);
440 result.setRange(0, length, this, start); 440 result.setRange(0, length, this, start);
441 return result; 441 return result;
442 } 442 }
443 443
444 void setRange(int start, int length, List from, [int startFrom = 0]) { 444 void setRange(int start, int length, List from, [int startFrom = 0]) {
445 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); 445 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
446 } 446 }
447 447
448 // Method(s) implementing Object interface. 448 // Method(s) implementing Object interface.
449 449
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 552
553 // Method(s) implementing TypedData interface. 553 // Method(s) implementing TypedData interface.
554 554
555 int get elementSizeInBytes { 555 int get elementSizeInBytes {
556 return Int8List.BYTES_PER_ELEMENT; 556 return Int8List.BYTES_PER_ELEMENT;
557 } 557 }
558 558
559 559
560 // Internal utility methods. 560 // Internal utility methods.
561 561
562 _Int8Array _createList(int length) {
563 return _new(length);
564 }
565
562 static _Int8Array _new(int length) native "TypedData_Int8Array_new"; 566 static _Int8Array _new(int length) native "TypedData_Int8Array_new";
563 } 567 }
564 568
565 569
566 class _Uint8Array extends _TypedList implements Uint8List { 570 class _Uint8Array extends _TypedList implements Uint8List {
567 // Factory constructors. 571 // Factory constructors.
568 572
569 factory _Uint8Array(int length) { 573 factory _Uint8Array(int length) {
570 if (length < 0) { 574 if (length < 0) {
571 String message = "$length must be greater than 0"; 575 String message = "$length must be greater than 0";
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 Iterator<int> get iterator { 607 Iterator<int> get iterator {
604 return new _TypedListIterator<int>(this); 608 return new _TypedListIterator<int>(this);
605 } 609 }
606 610
607 611
608 // Methods implementing TypedData interface. 612 // Methods implementing TypedData interface.
609 int get elementSizeInBytes { 613 int get elementSizeInBytes {
610 return Uint8List.BYTES_PER_ELEMENT; 614 return Uint8List.BYTES_PER_ELEMENT;
611 } 615 }
612 616
617
613 // Internal utility methods. 618 // Internal utility methods.
614 619
620 _Uint8Array _createList(int length) {
621 return _new(length);
622 }
623
Ivan Posva 2013/03/12 09:32:02 Missing line.
siva 2013/03/12 10:31:46 It seems to have a blank line. On 2013/03/12 09:3
615 static _Uint8Array _new(int length) native "TypedData_Uint8Array_new"; 624 static _Uint8Array _new(int length) native "TypedData_Uint8Array_new";
616 } 625 }
617 626
618 627
619 class _Uint8ClampedArray extends _TypedList implements Uint8ClampedList { 628 class _Uint8ClampedArray extends _TypedList implements Uint8ClampedList {
620 // Factory constructors. 629 // Factory constructors.
621 630
622 factory _Uint8ClampedArray(int length) { 631 factory _Uint8ClampedArray(int length) {
623 if (length < 0) { 632 if (length < 0) {
624 String message = "$length must be greater than 0"; 633 String message = "$length must be greater than 0";
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 669
661 670
662 // Methods implementing TypedData interface. 671 // Methods implementing TypedData interface.
663 int get elementSizeInBytes { 672 int get elementSizeInBytes {
664 return Uint8List.BYTES_PER_ELEMENT; 673 return Uint8List.BYTES_PER_ELEMENT;
665 } 674 }
666 675
667 676
668 // Internal utility methods. 677 // Internal utility methods.
669 678
679 _Uint8ClampedArray _createList(int length) {
680 return _new(length);
681 }
682
Ivan Posva 2013/03/12 09:32:02 ditto here and more below.
siva 2013/03/12 10:31:46 Seems to have it. The pattern in the file was one
670 static _Uint8ClampedArray _new(int length) 683 static _Uint8ClampedArray _new(int length)
671 native "TypedData_Uint8ClampedArray_new"; 684 native "TypedData_Uint8ClampedArray_new";
672 } 685 }
673 686
674 687
675 class _Int16Array extends _TypedList implements Int16List { 688 class _Int16Array extends _TypedList implements Int16List {
676 // Factory constructors. 689 // Factory constructors.
677 690
678 factory _Int16Array(int length) { 691 factory _Int16Array(int length) {
679 if (length < 0) { 692 if (length < 0) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 731
719 // Method(s) implementing TypedData interface. 732 // Method(s) implementing TypedData interface.
720 733
721 int get elementSizeInBytes { 734 int get elementSizeInBytes {
722 return Int16List.BYTES_PER_ELEMENT; 735 return Int16List.BYTES_PER_ELEMENT;
723 } 736 }
724 737
725 738
726 // Internal utility methods. 739 // Internal utility methods.
727 740
741 _Int16Array _createList(int length) {
742 return _new(length);
743 }
744
728 static _Int16Array _new(int length) native "TypedData_Int16Array_new"; 745 static _Int16Array _new(int length) native "TypedData_Int16Array_new";
729 } 746 }
730 747
731 748
732 class _Uint16Array extends _TypedList implements Uint16List { 749 class _Uint16Array extends _TypedList implements Uint16List {
733 // Factory constructors. 750 // Factory constructors.
734 751
735 factory _Uint16Array(int length) { 752 factory _Uint16Array(int length) {
736 if (length < 0) { 753 if (length < 0) {
737 String message = "$length must be greater than 0"; 754 String message = "$length must be greater than 0";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 792
776 // Method(s) implementing the TypedData interface. 793 // Method(s) implementing the TypedData interface.
777 794
778 int get elementSizeInBytes { 795 int get elementSizeInBytes {
779 return Uint16List.BYTES_PER_ELEMENT; 796 return Uint16List.BYTES_PER_ELEMENT;
780 } 797 }
781 798
782 799
783 // Internal utility methods. 800 // Internal utility methods.
784 801
802 _Uint16Array _createList(int length) {
803 return _new(length);
804 }
805
785 static _Uint16Array _new(int length) native "TypedData_Uint16Array_new"; 806 static _Uint16Array _new(int length) native "TypedData_Uint16Array_new";
786 } 807 }
787 808
788 809
789 class _Int32Array extends _TypedList implements Int32List { 810 class _Int32Array extends _TypedList implements Int32List {
790 // Factory constructors. 811 // Factory constructors.
791 812
792 factory _Int32Array(int length) { 813 factory _Int32Array(int length) {
793 if (length < 0) { 814 if (length < 0) {
794 String message = "$length must be greater than 0"; 815 String message = "$length must be greater than 0";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 853
833 // Method(s) implementing TypedData interface. 854 // Method(s) implementing TypedData interface.
834 855
835 int get elementSizeInBytes { 856 int get elementSizeInBytes {
836 return Int32List.BYTES_PER_ELEMENT; 857 return Int32List.BYTES_PER_ELEMENT;
837 } 858 }
838 859
839 860
840 // Internal utility methods. 861 // Internal utility methods.
841 862
863 _Int32Array _createList(int length) {
864 return _new(length);
865 }
866
842 static _Int32Array _new(int length) native "TypedData_Int32Array_new"; 867 static _Int32Array _new(int length) native "TypedData_Int32Array_new";
843 } 868 }
844 869
845 870
846 class _Uint32Array extends _TypedList implements Uint32List { 871 class _Uint32Array extends _TypedList implements Uint32List {
847 // Factory constructors. 872 // Factory constructors.
848 873
849 factory _Uint32Array(int length) { 874 factory _Uint32Array(int length) {
850 if (length < 0) { 875 if (length < 0) {
851 String message = "$length must be greater than 0"; 876 String message = "$length must be greater than 0";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 914
890 // Method(s) implementing the TypedData interface. 915 // Method(s) implementing the TypedData interface.
891 916
892 int get elementSizeInBytes { 917 int get elementSizeInBytes {
893 return Uint32List.BYTES_PER_ELEMENT; 918 return Uint32List.BYTES_PER_ELEMENT;
894 } 919 }
895 920
896 921
897 // Internal utility methods. 922 // Internal utility methods.
898 923
924 _Uint32Array _createList(int length) {
925 return _new(length);
926 }
927
899 static _Uint32Array _new(int length) native "TypedData_Uint32Array_new"; 928 static _Uint32Array _new(int length) native "TypedData_Uint32Array_new";
900 } 929 }
901 930
902 931
903 class _Int64Array extends _TypedList implements Int64List { 932 class _Int64Array extends _TypedList implements Int64List {
904 // Factory constructors. 933 // Factory constructors.
905 934
906 factory _Int64Array(int length) { 935 factory _Int64Array(int length) {
907 if (length < 0) { 936 if (length < 0) {
908 String message = "$length must be greater than 0"; 937 String message = "$length must be greater than 0";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 975
947 // Method(s) implementing the TypedData interface. 976 // Method(s) implementing the TypedData interface.
948 977
949 int get elementSizeInBytes { 978 int get elementSizeInBytes {
950 return Int64List.BYTES_PER_ELEMENT; 979 return Int64List.BYTES_PER_ELEMENT;
951 } 980 }
952 981
953 982
954 // Internal utility methods. 983 // Internal utility methods.
955 984
985 _Int64Array _createList(int length) {
986 return _new(length);
987 }
988
956 static _Int64Array _new(int length) native "TypedData_Int64Array_new"; 989 static _Int64Array _new(int length) native "TypedData_Int64Array_new";
957 } 990 }
958 991
959 992
960 class _Uint64Array extends _TypedList implements Uint64List { 993 class _Uint64Array extends _TypedList implements Uint64List {
961 // Factory constructors. 994 // Factory constructors.
962 995
963 factory _Uint64Array(int length) { 996 factory _Uint64Array(int length) {
964 if (length < 0) { 997 if (length < 0) {
965 String message = "$length must be greater than 0"; 998 String message = "$length must be greater than 0";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 1036
1004 // Method(s) implementing the TypedData interface. 1037 // Method(s) implementing the TypedData interface.
1005 1038
1006 int get elementSizeInBytes { 1039 int get elementSizeInBytes {
1007 return Uint64List.BYTES_PER_ELEMENT; 1040 return Uint64List.BYTES_PER_ELEMENT;
1008 } 1041 }
1009 1042
1010 1043
1011 // Internal utility methods. 1044 // Internal utility methods.
1012 1045
1046 _Uint64Array _createList(int length) {
1047 return _new(length);
1048 }
1049
1013 static _Uint64Array _new(int length) native "TypedData_Uint64Array_new"; 1050 static _Uint64Array _new(int length) native "TypedData_Uint64Array_new";
1014 } 1051 }
1015 1052
1016 1053
1017 class _Float32Array extends _TypedList implements Float32List { 1054 class _Float32Array extends _TypedList implements Float32List {
1018 // Factory constructors. 1055 // Factory constructors.
1019 1056
1020 factory _Float32Array(int length) { 1057 factory _Float32Array(int length) {
1021 if (length < 0) { 1058 if (length < 0) {
1022 String message = "$length must be greater than 0"; 1059 String message = "$length must be greater than 0";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 1097
1061 // Method(s) implementing the TypedData interface. 1098 // Method(s) implementing the TypedData interface.
1062 1099
1063 int get elementSizeInBytes { 1100 int get elementSizeInBytes {
1064 return Float32List.BYTES_PER_ELEMENT; 1101 return Float32List.BYTES_PER_ELEMENT;
1065 } 1102 }
1066 1103
1067 1104
1068 // Internal utility methods. 1105 // Internal utility methods.
1069 1106
1107 _Float32Array _createList(int length) {
1108 return _new(length);
1109 }
1110
1070 static _Float32Array _new(int length) native "TypedData_Float32Array_new"; 1111 static _Float32Array _new(int length) native "TypedData_Float32Array_new";
1071 } 1112 }
1072 1113
1073 1114
1074 class _Float64Array extends _TypedList implements Float64List { 1115 class _Float64Array extends _TypedList implements Float64List {
1075 // Factory constructors. 1116 // Factory constructors.
1076 1117
1077 factory _Float64Array(int length) { 1118 factory _Float64Array(int length) {
1078 if (length < 0) { 1119 if (length < 0) {
1079 String message = "$length must be greater than 0"; 1120 String message = "$length must be greater than 0";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 1158
1118 // Method(s) implementing the TypedData interface. 1159 // Method(s) implementing the TypedData interface.
1119 1160
1120 int get elementSizeInBytes { 1161 int get elementSizeInBytes {
1121 return Float64List.BYTES_PER_ELEMENT; 1162 return Float64List.BYTES_PER_ELEMENT;
1122 } 1163 }
1123 1164
1124 1165
1125 // Internal utility methods. 1166 // Internal utility methods.
1126 1167
1168 _Float64Array _createList(int length) {
1169 return _new(length);
1170 }
1171
1127 static _Float64Array _new(int length) native "TypedData_Float64Array_new"; 1172 static _Float64Array _new(int length) native "TypedData_Float64Array_new";
1128 } 1173 }
1129 1174
1130 1175
1131 class _ExternalInt8Array extends _TypedList implements Int8List { 1176 class _ExternalInt8Array extends _TypedList implements Int8List {
1132 // Factory constructors. 1177 // Factory constructors.
1133 1178
1134 factory _ExternalInt8Array(int length) { 1179 factory _ExternalInt8Array(int length) {
1135 if (length < 0) { 1180 if (length < 0) {
1136 String message = "$length must be greater than 0"; 1181 String message = "$length must be greater than 0";
(...skipping 27 matching lines...) Expand all
1164 1209
1165 // Method(s) implementing the TypedData interface. 1210 // Method(s) implementing the TypedData interface.
1166 1211
1167 int get elementSizeInBytes { 1212 int get elementSizeInBytes {
1168 return Int8List.BYTES_PER_ELEMENT; 1213 return Int8List.BYTES_PER_ELEMENT;
1169 } 1214 }
1170 1215
1171 1216
1172 // Internal utility methods. 1217 // Internal utility methods.
1173 1218
1219 List<int> _createList(int length) {
Mads Ager (google) 2013/03/12 08:18:03 List<int> -> Int8List? Similarly for the ones bel
siva 2013/03/12 10:31:46 Good point. Changed all the return values. On 201
1220 return new Int8List(length);
1221 }
1222
1174 static _ExternalInt8Array _new(int length) native 1223 static _ExternalInt8Array _new(int length) native
1175 "ExternalTypedData_Int8Array_new"; 1224 "ExternalTypedData_Int8Array_new";
1176 } 1225 }
1177 1226
1178 1227
1179 class _ExternalUint8Array extends _TypedList implements Uint8List { 1228 class _ExternalUint8Array extends _TypedList implements Uint8List {
1180 // Factory constructors. 1229 // Factory constructors.
1181 1230
1182 factory _ExternalUint8Array(int length) { 1231 factory _ExternalUint8Array(int length) {
1183 if (length < 0) { 1232 if (length < 0) {
(...skipping 19 matching lines...) Expand all
1203 String message = "$index must be in the range [0..$length)"; 1252 String message = "$index must be in the range [0..$length)";
1204 throw new RangeError(message); 1253 throw new RangeError(message);
1205 } 1254 }
1206 _setUint8(index, _toUint8(value)); 1255 _setUint8(index, _toUint8(value));
1207 } 1256 }
1208 1257
1209 Iterator<int> get iterator { 1258 Iterator<int> get iterator {
1210 return new _TypedListIterator<int>(this); 1259 return new _TypedListIterator<int>(this);
1211 } 1260 }
1212 1261
1213
Ivan Posva 2013/03/12 09:32:02 ?
siva 2013/03/12 10:31:46 Done.
1214 // Method(s) implementing the TypedData interface. 1262 // Method(s) implementing the TypedData interface.
1215 1263
1216 int get elementSizeInBytes { 1264 int get elementSizeInBytes {
1217 return Uint8List.BYTES_PER_ELEMENT; 1265 return Uint8List.BYTES_PER_ELEMENT;
1218 } 1266 }
1219 1267
1220 1268
1221 // Internal utility methods. 1269 // Internal utility methods.
1222 1270
1271 List<int> _createList(int length) {
1272 return new Uint8List(length);
1273 }
1274
1223 static _ExternalUint8Array _new(int length) native 1275 static _ExternalUint8Array _new(int length) native
1224 "ExternalTypedData_Uint8Array_new"; 1276 "ExternalTypedData_Uint8Array_new";
1225 } 1277 }
1226 1278
1227 1279
1228 class _ExternalUint8ClampedArray extends _TypedList implements Uint8ClampedList { 1280 class _ExternalUint8ClampedArray extends _TypedList implements Uint8ClampedList {
1229 // Factory constructors. 1281 // Factory constructors.
1230 1282
1231 factory _ExternalUint8ClampedArray(int length) { 1283 factory _ExternalUint8ClampedArray(int length) {
1232 if (length < 0) { 1284 if (length < 0) {
(...skipping 29 matching lines...) Expand all
1262 1314
1263 // Method(s) implementing the TypedData interface. 1315 // Method(s) implementing the TypedData interface.
1264 1316
1265 int get elementSizeInBytes { 1317 int get elementSizeInBytes {
1266 return Uint8List.BYTES_PER_ELEMENT; 1318 return Uint8List.BYTES_PER_ELEMENT;
1267 } 1319 }
1268 1320
1269 1321
1270 // Internal utility methods. 1322 // Internal utility methods.
1271 1323
1324 List<int> _createList(int length) {
1325 return new Uint8ClampedList(length);
1326 }
1327
1272 static _ExternalUint8ClampedArray _new(int length) native 1328 static _ExternalUint8ClampedArray _new(int length) native
1273 "ExternalTypedData_Uint8ClampedArray_new"; 1329 "ExternalTypedData_Uint8ClampedArray_new";
1274 } 1330 }
1275 1331
1276 1332
1277 class _ExternalInt16Array extends _TypedList implements Int16List { 1333 class _ExternalInt16Array extends _TypedList implements Int16List {
1278 // Factory constructors. 1334 // Factory constructors.
1279 1335
1280 factory _ExternalInt16Array(int length) { 1336 factory _ExternalInt16Array(int length) {
1281 if (length < 0) { 1337 if (length < 0) {
(...skipping 29 matching lines...) Expand all
1311 1367
1312 // Method(s) implementing the TypedData interface. 1368 // Method(s) implementing the TypedData interface.
1313 1369
1314 int get elementSizeInBytes { 1370 int get elementSizeInBytes {
1315 return Int16List.BYTES_PER_ELEMENT; 1371 return Int16List.BYTES_PER_ELEMENT;
1316 } 1372 }
1317 1373
1318 1374
1319 // Internal utility methods. 1375 // Internal utility methods.
1320 1376
1377 List<int> _createList(int length) {
1378 return new Int16List(length);
1379 }
1380
1321 static _ExternalInt16Array _new(int length) native 1381 static _ExternalInt16Array _new(int length) native
1322 "ExternalTypedData_Int16Array_new"; 1382 "ExternalTypedData_Int16Array_new";
1323 } 1383 }
1324 1384
1325 1385
1326 class _ExternalUint16Array extends _TypedList implements Uint16List { 1386 class _ExternalUint16Array extends _TypedList implements Uint16List {
1327 // Factory constructors. 1387 // Factory constructors.
1328 1388
1329 factory _ExternalUint16Array(int length) { 1389 factory _ExternalUint16Array(int length) {
1330 if (length < 0) { 1390 if (length < 0) {
(...skipping 29 matching lines...) Expand all
1360 1420
1361 // Method(s) implementing the TypedData interface. 1421 // Method(s) implementing the TypedData interface.
1362 1422
1363 int get elementSizeInBytes { 1423 int get elementSizeInBytes {
1364 return Uint16List.BYTES_PER_ELEMENT; 1424 return Uint16List.BYTES_PER_ELEMENT;
1365 } 1425 }
1366 1426
1367 1427
1368 // Internal utility methods. 1428 // Internal utility methods.
1369 1429
1430 List<int> _createList(int length) {
1431 return new Uint16List(length);
1432 }
1433
1370 static _ExternalUint16Array _new(int length) native 1434 static _ExternalUint16Array _new(int length) native
1371 "ExternalTypedData_Uint16Array_new"; 1435 "ExternalTypedData_Uint16Array_new";
1372 } 1436 }
1373 1437
1374 1438
1375 class _ExternalInt32Array extends _TypedList implements Int32List { 1439 class _ExternalInt32Array extends _TypedList implements Int32List {
1376 // Factory constructors. 1440 // Factory constructors.
1377 1441
1378 factory _ExternalInt32Array(int length) { 1442 factory _ExternalInt32Array(int length) {
1379 if (length < 0) { 1443 if (length < 0) {
(...skipping 29 matching lines...) Expand all
1409 1473
1410 // Method(s) implementing the TypedData interface. 1474 // Method(s) implementing the TypedData interface.
1411 1475
1412 int get elementSizeInBytes { 1476 int get elementSizeInBytes {
1413 return Int32List.BYTES_PER_ELEMENT; 1477 return Int32List.BYTES_PER_ELEMENT;
1414 } 1478 }
1415 1479
1416 1480
1417 // Internal utility methods. 1481 // Internal utility methods.
1418 1482
1483 List<int> _createList(int length) {
1484 return new Int32List(length);
1485 }
1486
1419 static _ExternalInt32Array _new(int length) native 1487 static _ExternalInt32Array _new(int length) native
1420 "ExternalTypedData_Int32Array_new"; 1488 "ExternalTypedData_Int32Array_new";
1421 } 1489 }
1422 1490
1423 1491
1424 class _ExternalUint32Array extends _TypedList implements Uint32List { 1492 class _ExternalUint32Array extends _TypedList implements Uint32List {
1425 // Factory constructors. 1493 // Factory constructors.
1426 1494
1427 factory _ExternalUint32Array(int length) { 1495 factory _ExternalUint32Array(int length) {
1428 if (length < 0) { 1496 if (length < 0) {
(...skipping 29 matching lines...) Expand all
1458 1526
1459 // Method(s) implementing the TypedData interface. 1527 // Method(s) implementing the TypedData interface.
1460 1528
1461 int get elementSizeInBytes { 1529 int get elementSizeInBytes {
1462 return Uint32List.BYTES_PER_ELEMENT; 1530 return Uint32List.BYTES_PER_ELEMENT;
1463 } 1531 }
1464 1532
1465 1533
1466 // Internal utility methods. 1534 // Internal utility methods.
1467 1535
1536 List<int> _createList(int length) {
1537 return new Uint32List(length);
1538 }
1539
1468 static _ExternalUint32Array _new(int length) native 1540 static _ExternalUint32Array _new(int length) native
1469 "ExternalTypedData_Uint32Array_new"; 1541 "ExternalTypedData_Uint32Array_new";
1470 } 1542 }
1471 1543
1472 1544
1473 class _ExternalInt64Array extends _TypedList implements Int64List { 1545 class _ExternalInt64Array extends _TypedList implements Int64List {
1474 // Factory constructors. 1546 // Factory constructors.
1475 1547
1476 factory _ExternalInt64Array(int length) { 1548 factory _ExternalInt64Array(int length) {
1477 if (length < 0) { 1549 if (length < 0) {
(...skipping 29 matching lines...) Expand all
1507 1579
1508 // Method(s) implementing the TypedData interface. 1580 // Method(s) implementing the TypedData interface.
1509 1581
1510 int get elementSizeInBytes { 1582 int get elementSizeInBytes {
1511 return Int64List.BYTES_PER_ELEMENT; 1583 return Int64List.BYTES_PER_ELEMENT;
1512 } 1584 }
1513 1585
1514 1586
1515 // Internal utility methods. 1587 // Internal utility methods.
1516 1588
1589 List<int> _createList(int length) {
1590 return new Int64List(length);
1591 }
1592
1517 static _ExternalInt64Array _new(int length) native 1593 static _ExternalInt64Array _new(int length) native
1518 "ExternalTypedData_Int64Array_new"; 1594 "ExternalTypedData_Int64Array_new";
1519 } 1595 }
1520 1596
1521 1597
1522 class _ExternalUint64Array extends _TypedList implements Uint64List { 1598 class _ExternalUint64Array extends _TypedList implements Uint64List {
1523 // Factory constructors. 1599 // Factory constructors.
1524 1600
1525 factory _ExternalUint64Array(int length) { 1601 factory _ExternalUint64Array(int length) {
1526 if (length < 0) { 1602 if (length < 0) {
(...skipping 22 matching lines...) Expand all
1549 _setUint64(index, _toUint64(value)); 1625 _setUint64(index, _toUint64(value));
1550 } 1626 }
1551 1627
1552 Iterator<int> get iterator { 1628 Iterator<int> get iterator {
1553 return new _TypedListIterator<int>(this); 1629 return new _TypedListIterator<int>(this);
1554 } 1630 }
1555 1631
1556 1632
1557 // Method(s) implementing the TypedData interface. 1633 // Method(s) implementing the TypedData interface.
1558 1634
1635 List<int> _createList(int length) {
1636 return new Uint64List(length);
1637 }
1638
1559 int get elementSizeInBytes { 1639 int get elementSizeInBytes {
1560 return Uint64List.BYTES_PER_ELEMENT; 1640 return Uint64List.BYTES_PER_ELEMENT;
1561 } 1641 }
1562 1642
1563 1643
1564 // Internal utility methods. 1644 // Internal utility methods.
1565 1645
1566 static _ExternalUint64Array _new(int length) native 1646 static _ExternalUint64Array _new(int length) native
1567 "ExternalTypedData_Uint64Array_new"; 1647 "ExternalTypedData_Uint64Array_new";
1568 } 1648 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 1685
1606 // Method(s) implementing the TypedData interface. 1686 // Method(s) implementing the TypedData interface.
1607 1687
1608 int get elementSizeInBytes { 1688 int get elementSizeInBytes {
1609 return Float32List.BYTES_PER_ELEMENT; 1689 return Float32List.BYTES_PER_ELEMENT;
1610 } 1690 }
1611 1691
1612 1692
1613 // Internal utility methods. 1693 // Internal utility methods.
1614 1694
1695 List<double> _createList(int length) {
1696 return new Float32List(length);
1697 }
1698
1615 static _ExternalFloat32Array _new(int length) native 1699 static _ExternalFloat32Array _new(int length) native
1616 "ExternalTypedData_Float32Array_new"; 1700 "ExternalTypedData_Float32Array_new";
1617 } 1701 }
1618 1702
1619 1703
1620 class _ExternalFloat64Array extends _TypedList implements Float64List { 1704 class _ExternalFloat64Array extends _TypedList implements Float64List {
1621 // Factory constructors. 1705 // Factory constructors.
1622 1706
1623 factory _ExternalFloat64Array(int length) { 1707 factory _ExternalFloat64Array(int length) {
1624 if (length < 0) { 1708 if (length < 0) {
(...skipping 29 matching lines...) Expand all
1654 1738
1655 // Method(s) implementing the TypedData interface. 1739 // Method(s) implementing the TypedData interface.
1656 1740
1657 int get elementSizeInBytes { 1741 int get elementSizeInBytes {
1658 return Float64List.BYTES_PER_ELEMENT; 1742 return Float64List.BYTES_PER_ELEMENT;
1659 } 1743 }
1660 1744
1661 1745
1662 // Internal utility methods. 1746 // Internal utility methods.
1663 1747
1748 List<double> _createList(int length) {
1749 return new Float64List(length);
1750 }
1751
1664 static _ExternalFloat64Array _new(int length) native 1752 static _ExternalFloat64Array _new(int length) native
1665 "ExternalTypedData_Float64Array_new"; 1753 "ExternalTypedData_Float64Array_new";
1666 } 1754 }
1667 1755
1668 1756
1669 class _TypedListIterator<E> implements Iterator<E> { 1757 class _TypedListIterator<E> implements Iterator<E> {
1670 final List<E> _array; 1758 final List<E> _array;
1671 final int _length; 1759 final int _length;
1672 int _position; 1760 int _position;
1673 E _current; 1761 E _current;
(...skipping 14 matching lines...) Expand all
1688 _current = null; 1776 _current = null;
1689 return false; 1777 return false;
1690 } 1778 }
1691 1779
1692 E get current => _current; 1780 E get current => _current;
1693 } 1781 }
1694 1782
1695 1783
1696 class _TypedListView extends _TypedListBase implements TypedData { 1784 class _TypedListView extends _TypedListBase implements TypedData {
1697 _TypedListView(ByteBuffer _buffer, int _offset, int _length) 1785 _TypedListView(ByteBuffer _buffer, int _offset, int _length)
1698 : _typeddata = _buffer, // This assignment is type safe. 1786 : super(),
Anton Muhin 2013/03/12 08:31:46 nit: as per style guide, shouldn't super ctor invo
siva 2013/03/12 10:31:46 Removed the explicit invoke of the default ctor, I
1787 _typeddata = _buffer, // This assignment is type safe.
1699 offsetInBytes = _offset, 1788 offsetInBytes = _offset,
1700 length = _length { 1789 length = _length {
1701 } 1790 }
1702 1791
1703 1792
1704 // Method(s) implementing the TypedData interface. 1793 // Method(s) implementing the TypedData interface.
1705 1794
1706 int get lengthInBytes { 1795 int get lengthInBytes {
1707 return length * elementSizeInBytes; 1796 return length * elementSizeInBytes;
1708 } 1797 }
1709 1798
1710 ByteBuffer get buffer { 1799 ByteBuffer get buffer {
1711 return _typeddata.buffer; 1800 return _typeddata.buffer;
1712 } 1801 }
1713 1802
1714 final TypedData _typeddata; 1803 final TypedData _typeddata;
1715 final int offsetInBytes; 1804 final int offsetInBytes;
1716 final int length; 1805 final int length;
1717 } 1806 }
1718 1807
1719 1808
1720 class _Int8ArrayView extends _TypedListView implements Int8List { 1809 class _Int8ArrayView extends _TypedListView implements Int8List {
1721 // Constructor. 1810 // Constructor.
1722 _Int8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 1811 _Int8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
1723 : super(buffer, _offsetInBytes, 1812 : super(buffer, _offsetInBytes,
1724 _defaultIfNull(_length, 1813 _defaultIfNull(_length,
1725 ((buffer.lengthInBytes - _offsetInBytes) ~/ 1814 ((buffer.lengthInBytes - _offsetInBytes) ~/
1726 Int8List.BYTES_PER_ELEMENT))) { 1815 Int8List.BYTES_PER_ELEMENT))) {
1727 _rangeCheck(buffer.lengthInBytes, 1816 _rangeCheck(buffer.lengthInBytes,
1728 offsetInBytes, 1817 _offsetInBytes,
1729 length * Int8List.BYTES_PER_ELEMENT); 1818 _length * Int8List.BYTES_PER_ELEMENT);
1730 } 1819 }
1731 1820
1732 1821
1733 // Method(s) implementing List interface. 1822 // Method(s) implementing List interface.
1734 1823
1735 int operator[](int index) { 1824 int operator[](int index) {
1736 if (index < 0 || index >= length) { 1825 if (index < 0 || index >= length) {
1737 String message = "$index must be in the range [0..$length)"; 1826 String message = "$index must be in the range [0..$length)";
1738 throw new RangeError(message); 1827 throw new RangeError(message);
1739 } 1828 }
(...skipping 24 matching lines...) Expand all
1764 1853
1765 1854
1766 class _Uint8ArrayView extends _TypedListView implements Uint8List { 1855 class _Uint8ArrayView extends _TypedListView implements Uint8List {
1767 // Constructor. 1856 // Constructor.
1768 _Uint8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 1857 _Uint8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
1769 : super(buffer, _offsetInBytes, 1858 : super(buffer, _offsetInBytes,
1770 _defaultIfNull(_length, 1859 _defaultIfNull(_length,
1771 ((buffer.lengthInBytes - _offsetInBytes) ~/ 1860 ((buffer.lengthInBytes - _offsetInBytes) ~/
1772 Uint8List.BYTES_PER_ELEMENT))) { 1861 Uint8List.BYTES_PER_ELEMENT))) {
1773 _rangeCheck(buffer.lengthInBytes, 1862 _rangeCheck(buffer.lengthInBytes,
1774 offsetInBytes, 1863 _offsetInBytes,
1775 length * Uint8List.BYTES_PER_ELEMENT); 1864 _length * Uint8List.BYTES_PER_ELEMENT);
1776 } 1865 }
1777 1866
1778 1867
1779 // Method(s) implementing List interface. 1868 // Method(s) implementing List interface.
1780 1869
1781 int operator[](int index) { 1870 int operator[](int index) {
1782 if (index < 0 || index >= length) { 1871 if (index < 0 || index >= length) {
1783 String message = "$index must be in the range [0..$length)"; 1872 String message = "$index must be in the range [0..$length)";
1784 throw new RangeError(message); 1873 throw new RangeError(message);
1785 } 1874 }
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 if (start + length > listLength) { 2479 if (start + length > listLength) {
2391 throw new RangeError.value(start + length); 2480 throw new RangeError.value(start + length);
2392 } 2481 }
2393 } 2482 }
2394 2483
2395 2484
2396 int _defaultIfNull(object, value) { 2485 int _defaultIfNull(object, value) {
2397 if (object == null) { 2486 if (object == null) {
2398 return value; 2487 return value;
2399 } 2488 }
2489 return object;
2400 } 2490 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698