OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class Int8List { | 5 patch class Int8List { |
6 /* patch */ factory Int8List(int length) { | 6 /* patch */ factory Int8List(int length) { |
7 return new _Int8Array(length); | 7 return new _Int8Array(length); |
8 } | 8 } |
9 | 9 |
10 /* patch */ factory Int8List.transferable(int length) { | 10 /* patch */ factory Int8List.transferable(int length) { |
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 return _length() * _BYTES_PER_ELEMENT; | 1324 return _length() * _BYTES_PER_ELEMENT; |
1325 } | 1325 } |
1326 | 1326 |
1327 static const int _BYTES_PER_ELEMENT = 1; | 1327 static const int _BYTES_PER_ELEMENT = 1; |
1328 | 1328 |
1329 int _getIndexed(int index) native "ExternalUint8Array_getIndexed"; | 1329 int _getIndexed(int index) native "ExternalUint8Array_getIndexed"; |
1330 int _setIndexed(int index, int value) native "ExternalUint8Array_setIndexed"; | 1330 int _setIndexed(int index, int value) native "ExternalUint8Array_setIndexed"; |
1331 } | 1331 } |
1332 | 1332 |
1333 | 1333 |
| 1334 class _ExternalUint8ClampedArray |
| 1335 extends _ByteArrayBase implements Uint8ClampedList { |
| 1336 |
| 1337 int operator[](int index) { |
| 1338 return _getIndexed(index); |
| 1339 } |
| 1340 |
| 1341 int operator[]=(int index, int value) { |
| 1342 _setIndexed(index, _toClampedUint8(value)); |
| 1343 } |
| 1344 |
| 1345 Iterator<int> get iterator { |
| 1346 return new _ByteArrayIterator<int>(this); |
| 1347 } |
| 1348 |
| 1349 List<int> getRange(int start, int length) { |
| 1350 _rangeCheck(this.length, start, length); |
| 1351 List<int> result = new Uint8ClampedList(length); |
| 1352 result.setRange(0, length, this, start); |
| 1353 return result; |
| 1354 } |
| 1355 |
| 1356 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { |
| 1357 if (from is _ExternalUint8ClampedArray || from is _Uint8ClampedArray) { |
| 1358 _setRange(start * _BYTES_PER_ELEMENT, |
| 1359 length * _BYTES_PER_ELEMENT, |
| 1360 from, |
| 1361 startFrom * _BYTES_PER_ELEMENT); |
| 1362 } else { |
| 1363 Arrays.copy(from, startFrom, this, start, length); |
| 1364 } |
| 1365 } |
| 1366 |
| 1367 String toString() { |
| 1368 return Collections.collectionToString(this); |
| 1369 } |
| 1370 |
| 1371 int bytesPerElement() { |
| 1372 return _BYTES_PER_ELEMENT; |
| 1373 } |
| 1374 |
| 1375 int lengthInBytes() { |
| 1376 return _length() * _BYTES_PER_ELEMENT; |
| 1377 } |
| 1378 |
| 1379 static const int _BYTES_PER_ELEMENT = 1; |
| 1380 |
| 1381 int _getIndexed(int index) native "ExternalUint8ClampedArray_getIndexed"; |
| 1382 int _setIndexed(int index, int value) native "ExternalUint8ClampedArray_setInd
exed"; |
| 1383 } |
| 1384 |
| 1385 |
1334 class _ExternalInt16Array extends _ByteArrayBase implements Int16List { | 1386 class _ExternalInt16Array extends _ByteArrayBase implements Int16List { |
1335 int operator[](int index) { | 1387 int operator[](int index) { |
1336 return _getIndexed(index); | 1388 return _getIndexed(index); |
1337 } | 1389 } |
1338 | 1390 |
1339 int operator[]=(int index, int value) { | 1391 int operator[]=(int index, int value) { |
1340 _setIndexed(index, _toInt16(value)); | 1392 _setIndexed(index, _toInt16(value)); |
1341 } | 1393 } |
1342 | 1394 |
1343 Iterator<int> get iterator { | 1395 Iterator<int> get iterator { |
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2597 ByteArray asByteArray([int start = 0, int length]) { | 2649 ByteArray asByteArray([int start = 0, int length]) { |
2598 if (length == null) { | 2650 if (length == null) { |
2599 length = this.lengthInBytes(); | 2651 length = this.lengthInBytes(); |
2600 } | 2652 } |
2601 _rangeCheck(this.length, start, length); | 2653 _rangeCheck(this.length, start, length); |
2602 return _array.subByteArray(_offset + start, length); | 2654 return _array.subByteArray(_offset + start, length); |
2603 } | 2655 } |
2604 | 2656 |
2605 static const int _BYTES_PER_ELEMENT = 8; | 2657 static const int _BYTES_PER_ELEMENT = 8; |
2606 } | 2658 } |
OLD | NEW |