mirror of
https://github.com/dart-lang/sdk
synced 2024-10-02 23:24:42 +00:00
Declare return types of Uint8List.
These methods all were returning Uint8List, yet they were only declared to return List<int>. This forced callers to either defensively wrap the return values in Uint8List, or to assume the contravariant return value: * Utf8Codec.encode() * BytesBuilder.takeBytes() * BytesBuilder.toBytes() * File.readAsBytes() * File.readAsBytesSync() * RandomAccessFile.read() * RandomAccessFile.readSync() * Uint8List.sublist() Since it's related, this change also updates the following sublist() methods to declare that they return the a sublist of the same type as the source list: * Int8List * Uint8ClampedList * Int16List * Uint16List * Int32List * Uint32List * Int64List * Uint64List * Float32List * Float64List * Float32x4List * Int32x4List * Float64x2List Bug: https://github.com/dart-lang/sdk/issues/36900 Bug: https://github.com/dart-lang/sdk/issues/31547 Bug: https://github.com/dart-lang/sdk/issues/27818 Bug: https://github.com/dart-lang/sdk/issues/35521 Change-Id: Ic3bc1db0d64de36fb68b1d8d98037eed1464f978 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101742 Commit-Queue: Todd Volkert <tvolkert@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
This commit is contained in:
parent
25b40a0291
commit
9173aed1ba
34
CHANGELOG.md
34
CHANGELOG.md
|
@ -6,6 +6,40 @@
|
|||
|
||||
### Core libraries
|
||||
|
||||
* As part of (Issue [36900][]), the following methods and properties across
|
||||
various core libraries, which used to declare a return type of `List<int>`,
|
||||
were updated to declare a return type of `Uint8List`:
|
||||
|
||||
* `Utf8Codec.encode()` (and `Utf8Encoder.convert()`)
|
||||
* `BytesBuilder.takeBytes()`
|
||||
* `BytesBuilder.toBytes()`
|
||||
* `File.readAsBytes()` (`Future<Uint8List>`)
|
||||
* `File.readAsBytesSync()`
|
||||
* `RandomAccessFile.read()` (`Future<Uint8List>`)
|
||||
* `RandomAccessFile.readSync()`
|
||||
* `InternetAddress.rawAddress`
|
||||
* `RawSocket.read()`
|
||||
|
||||
In addition, the following typed lists were updated to have their `sublist()`
|
||||
methods declare a return type that is the same as the source list:
|
||||
|
||||
* `Uint8List.sublist()` → `Uint8List`
|
||||
* `Int8List.sublist()` → `Int8List`
|
||||
* `Uint8ClampedList.sublist()` → `Uint8ClampedList`
|
||||
* `Int16List.sublist()` → `Int16List`
|
||||
* `Uint16List.sublist()` → `Uint16List`
|
||||
* `Int32List.sublist()` → `Int32List`
|
||||
* `Uint32List.sublist()` → `Uint32List`
|
||||
* `Int64List.sublist()` → `Int64List`
|
||||
* `Uint64List.sublist()` → `Uint64List`
|
||||
* `Float32List.sublist()` → `Float32List`
|
||||
* `Float64List.sublist()` → `Float64List`
|
||||
* `Float32x4List.sublist()` → `Float32x4List`
|
||||
* `Int32x4List.sublist()` → `Int32x4List`
|
||||
* `Float64x2List.sublist()` → `Float64x2List`
|
||||
|
||||
[36900]: https://github.com/dart-lang/sdk/issues/36900
|
||||
|
||||
#### `dart:core`
|
||||
|
||||
* Update `Uri` class to support [RFC6874](https://tools.ietf.org/html/rfc6874):
|
||||
|
|
2
DEPS
2
DEPS
|
@ -85,7 +85,7 @@ vars = {
|
|||
"fixnum_tag": "0.10.9",
|
||||
"glob_tag": "1.1.7",
|
||||
"html_tag" : "0.14.0+1",
|
||||
"http_io_rev": "57da05a66f5bf7df3dd7aebe7b7efe0dfc477baa",
|
||||
"http_io_rev": "773f4bc73ef572e2c37e879b065c3b406d75e8fd",
|
||||
"http_multi_server_tag" : "2.0.5",
|
||||
"http_parser_tag" : "3.1.3",
|
||||
"http_retry_tag": "0.1.1",
|
||||
|
|
|
@ -111,12 +111,13 @@ abstract class _TypedListBase {
|
|||
int startFromInBytes, int toCid, int fromCid) native "TypedData_setRange";
|
||||
}
|
||||
|
||||
abstract class _IntListMixin implements List<int> {
|
||||
abstract class _IntListMixin<SpawnedType extends List<int>>
|
||||
implements List<int> {
|
||||
int get elementSizeInBytes;
|
||||
int get offsetInBytes;
|
||||
_ByteBuffer get buffer;
|
||||
|
||||
List<int> _createList(int length);
|
||||
SpawnedType _createList(int length);
|
||||
|
||||
Iterable<T> whereType<T>() => new WhereTypeIterable<T>(this);
|
||||
|
||||
|
@ -441,10 +442,10 @@ abstract class _IntListMixin implements List<int> {
|
|||
throw IterableElementError.tooMany();
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
SpawnedType sublist(int start, [int end]) {
|
||||
end = RangeError.checkValidRange(start, end, this.length);
|
||||
var length = end - start;
|
||||
List<int> result = _createList(length);
|
||||
SpawnedType result = _createList(length);
|
||||
result.setRange(0, length, this, start);
|
||||
return result;
|
||||
}
|
||||
|
@ -462,12 +463,13 @@ abstract class _IntListMixin implements List<int> {
|
|||
}
|
||||
}
|
||||
|
||||
abstract class _DoubleListMixin implements List<double> {
|
||||
abstract class _DoubleListMixin<SpawnedType extends List<double>>
|
||||
implements List<double> {
|
||||
int get elementSizeInBytes;
|
||||
int get offsetInBytes;
|
||||
_ByteBuffer get buffer;
|
||||
|
||||
List<double> _createList(int length);
|
||||
SpawnedType _createList(int length);
|
||||
|
||||
Iterable<T> whereType<T>() => new WhereTypeIterable<T>(this);
|
||||
|
||||
|
@ -795,10 +797,10 @@ abstract class _DoubleListMixin implements List<double> {
|
|||
throw IterableElementError.tooMany();
|
||||
}
|
||||
|
||||
List<double> sublist(int start, [int end]) {
|
||||
SpawnedType sublist(int start, [int end]) {
|
||||
end = RangeError.checkValidRange(start, end, this.length);
|
||||
var length = end - start;
|
||||
List<double> result = _createList(length);
|
||||
SpawnedType result = _createList(length);
|
||||
result.setRange(0, length, this, start);
|
||||
return result;
|
||||
}
|
||||
|
@ -821,7 +823,7 @@ abstract class _Float32x4ListMixin implements List<Float32x4> {
|
|||
int get offsetInBytes;
|
||||
_ByteBuffer get buffer;
|
||||
|
||||
List<Float32x4> _createList(int length);
|
||||
Float32x4List _createList(int length);
|
||||
|
||||
Iterable<T> whereType<T>() => new WhereTypeIterable<T>(this);
|
||||
|
||||
|
@ -1153,10 +1155,10 @@ abstract class _Float32x4ListMixin implements List<Float32x4> {
|
|||
throw IterableElementError.tooMany();
|
||||
}
|
||||
|
||||
List<Float32x4> sublist(int start, [int end]) {
|
||||
Float32x4List sublist(int start, [int end]) {
|
||||
end = RangeError.checkValidRange(start, end, this.length);
|
||||
var length = end - start;
|
||||
List<Float32x4> result = _createList(length);
|
||||
Float32x4List result = _createList(length);
|
||||
result.setRange(0, length, this, start);
|
||||
return result;
|
||||
}
|
||||
|
@ -1179,7 +1181,7 @@ abstract class _Int32x4ListMixin implements List<Int32x4> {
|
|||
int get offsetInBytes;
|
||||
_ByteBuffer get buffer;
|
||||
|
||||
List<Int32x4> _createList(int length);
|
||||
Int32x4List _createList(int length);
|
||||
|
||||
Iterable<T> whereType<T>() => new WhereTypeIterable<T>(this);
|
||||
|
||||
|
@ -1510,10 +1512,10 @@ abstract class _Int32x4ListMixin implements List<Int32x4> {
|
|||
throw IterableElementError.tooMany();
|
||||
}
|
||||
|
||||
List<Int32x4> sublist(int start, [int end]) {
|
||||
Int32x4List sublist(int start, [int end]) {
|
||||
end = RangeError.checkValidRange(start, end, this.length);
|
||||
var length = end - start;
|
||||
List<Int32x4> result = _createList(length);
|
||||
Int32x4List result = _createList(length);
|
||||
result.setRange(0, length, this, start);
|
||||
return result;
|
||||
}
|
||||
|
@ -1536,7 +1538,7 @@ abstract class _Float64x2ListMixin implements List<Float64x2> {
|
|||
int get offsetInBytes;
|
||||
_ByteBuffer get buffer;
|
||||
|
||||
List<Float64x2> _createList(int length);
|
||||
Float64x2List _createList(int length);
|
||||
|
||||
Iterable<T> whereType<T>() => new WhereTypeIterable<T>(this);
|
||||
|
||||
|
@ -1868,10 +1870,10 @@ abstract class _Float64x2ListMixin implements List<Float64x2> {
|
|||
throw IterableElementError.tooMany();
|
||||
}
|
||||
|
||||
List<Float64x2> sublist(int start, [int end]) {
|
||||
Float64x2List sublist(int start, [int end]) {
|
||||
end = RangeError.checkValidRange(start, end, this.length);
|
||||
var length = end - start;
|
||||
List<Float64x2> result = _createList(length);
|
||||
Float64x2List result = _createList(length);
|
||||
result.setRange(0, length, this, start);
|
||||
return result;
|
||||
}
|
||||
|
@ -2138,7 +2140,9 @@ class Int8List {
|
|||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
class _Int8List extends _TypedList with _IntListMixin implements Int8List {
|
||||
class _Int8List extends _TypedList
|
||||
with _IntListMixin<Int8List>
|
||||
implements Int8List {
|
||||
factory _Int8List._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
}
|
||||
|
@ -2184,7 +2188,9 @@ class Uint8List {
|
|||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
class _Uint8List extends _TypedList with _IntListMixin implements Uint8List {
|
||||
class _Uint8List extends _TypedList
|
||||
with _IntListMixin<Uint8List>
|
||||
implements Uint8List {
|
||||
factory _Uint8List._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
}
|
||||
|
@ -2231,7 +2237,7 @@ class Uint8ClampedList {
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Uint8ClampedList extends _TypedList
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Uint8ClampedList>
|
||||
implements Uint8ClampedList {
|
||||
factory _Uint8ClampedList._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -2278,7 +2284,9 @@ class Int16List {
|
|||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
class _Int16List extends _TypedList with _IntListMixin implements Int16List {
|
||||
class _Int16List extends _TypedList
|
||||
with _IntListMixin<Int16List>
|
||||
implements Int16List {
|
||||
factory _Int16List._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
}
|
||||
|
@ -2343,7 +2351,9 @@ class Uint16List {
|
|||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
class _Uint16List extends _TypedList with _IntListMixin implements Uint16List {
|
||||
class _Uint16List extends _TypedList
|
||||
with _IntListMixin<Uint16List>
|
||||
implements Uint16List {
|
||||
factory _Uint16List._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
}
|
||||
|
@ -2408,7 +2418,9 @@ class Int32List {
|
|||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
class _Int32List extends _TypedList with _IntListMixin implements Int32List {
|
||||
class _Int32List extends _TypedList
|
||||
with _IntListMixin<Int32List>
|
||||
implements Int32List {
|
||||
factory _Int32List._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
}
|
||||
|
@ -2461,7 +2473,9 @@ class Uint32List {
|
|||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
class _Uint32List extends _TypedList with _IntListMixin implements Uint32List {
|
||||
class _Uint32List extends _TypedList
|
||||
with _IntListMixin<Uint32List>
|
||||
implements Uint32List {
|
||||
factory _Uint32List._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
}
|
||||
|
@ -2514,7 +2528,9 @@ class Int64List {
|
|||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
class _Int64List extends _TypedList with _IntListMixin implements Int64List {
|
||||
class _Int64List extends _TypedList
|
||||
with _IntListMixin<Int64List>
|
||||
implements Int64List {
|
||||
factory _Int64List._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
}
|
||||
|
@ -2567,7 +2583,9 @@ class Uint64List {
|
|||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
class _Uint64List extends _TypedList with _IntListMixin implements Uint64List {
|
||||
class _Uint64List extends _TypedList
|
||||
with _IntListMixin<Uint64List>
|
||||
implements Uint64List {
|
||||
factory _Uint64List._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
}
|
||||
|
@ -2621,7 +2639,7 @@ class Float32List {
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Float32List extends _TypedList
|
||||
with _DoubleListMixin
|
||||
with _DoubleListMixin<Float32List>
|
||||
implements Float32List {
|
||||
factory _Float32List._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -2677,7 +2695,7 @@ class Float64List {
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Float64List extends _TypedList
|
||||
with _DoubleListMixin
|
||||
with _DoubleListMixin<Float64List>
|
||||
implements Float64List {
|
||||
factory _Float64List._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -2885,7 +2903,7 @@ class _Float64x2List extends _TypedList
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _ExternalInt8Array extends _TypedList
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Int8List>
|
||||
implements Int8List {
|
||||
factory _ExternalInt8Array._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -2919,7 +2937,7 @@ class _ExternalInt8Array extends _TypedList
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _ExternalUint8Array extends _TypedList
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Uint8List>
|
||||
implements Uint8List {
|
||||
factory _ExternalUint8Array._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -2954,7 +2972,7 @@ class _ExternalUint8Array extends _TypedList
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _ExternalUint8ClampedArray extends _TypedList
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Uint8ClampedList>
|
||||
implements Uint8ClampedList {
|
||||
factory _ExternalUint8ClampedArray._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -2989,7 +3007,7 @@ class _ExternalUint8ClampedArray extends _TypedList
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _ExternalInt16Array extends _TypedList
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Int16List>
|
||||
implements Int16List {
|
||||
factory _ExternalInt16Array._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -3031,7 +3049,7 @@ class _ExternalInt16Array extends _TypedList
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _ExternalUint16Array extends _TypedList
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Uint16List>
|
||||
implements Uint16List {
|
||||
factory _ExternalUint16Array._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -3073,7 +3091,7 @@ class _ExternalUint16Array extends _TypedList
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _ExternalInt32Array extends _TypedList
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Int32List>
|
||||
implements Int32List {
|
||||
factory _ExternalInt32Array._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -3115,7 +3133,7 @@ class _ExternalInt32Array extends _TypedList
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _ExternalUint32Array extends _TypedList
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Uint32List>
|
||||
implements Uint32List {
|
||||
factory _ExternalUint32Array._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -3157,7 +3175,7 @@ class _ExternalUint32Array extends _TypedList
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _ExternalInt64Array extends _TypedList
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Int64List>
|
||||
implements Int64List {
|
||||
factory _ExternalInt64Array._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -3199,7 +3217,7 @@ class _ExternalInt64Array extends _TypedList
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _ExternalUint64Array extends _TypedList
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Uint64List>
|
||||
implements Uint64List {
|
||||
factory _ExternalUint64Array._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -3241,7 +3259,7 @@ class _ExternalUint64Array extends _TypedList
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _ExternalFloat32Array extends _TypedList
|
||||
with _DoubleListMixin
|
||||
with _DoubleListMixin<Float32List>
|
||||
implements Float32List {
|
||||
factory _ExternalFloat32Array._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -3283,7 +3301,7 @@ class _ExternalFloat32Array extends _TypedList
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _ExternalFloat64Array extends _TypedList
|
||||
with _DoubleListMixin
|
||||
with _DoubleListMixin<Float64List>
|
||||
implements Float64List {
|
||||
factory _ExternalFloat64Array._uninstantiable() {
|
||||
throw "Unreachable";
|
||||
|
@ -3698,7 +3716,7 @@ abstract class _TypedListView extends _TypedListBase implements TypedData {
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Int8ArrayView extends _TypedListView
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Int8List>
|
||||
implements Int8List {
|
||||
// Constructor.
|
||||
@pragma("vm:exact-result-type", _Int8ArrayView)
|
||||
|
@ -3735,7 +3753,7 @@ class _Int8ArrayView extends _TypedListView
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Uint8ArrayView extends _TypedListView
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Uint8List>
|
||||
implements Uint8List {
|
||||
// Constructor.
|
||||
@pragma("vm:exact-result-type", _Uint8ArrayView)
|
||||
|
@ -3772,7 +3790,7 @@ class _Uint8ArrayView extends _TypedListView
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Uint8ClampedArrayView extends _TypedListView
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Uint8ClampedList>
|
||||
implements Uint8ClampedList {
|
||||
// Constructor.
|
||||
@pragma("vm:exact-result-type", _Uint8ClampedArrayView)
|
||||
|
@ -3809,7 +3827,7 @@ class _Uint8ClampedArrayView extends _TypedListView
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Int16ArrayView extends _TypedListView
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Int16List>
|
||||
implements Int16List {
|
||||
// Constructor.
|
||||
@pragma("vm:exact-result-type", _Int16ArrayView)
|
||||
|
@ -3858,7 +3876,7 @@ class _Int16ArrayView extends _TypedListView
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Uint16ArrayView extends _TypedListView
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Uint16List>
|
||||
implements Uint16List {
|
||||
// Constructor.
|
||||
@pragma("vm:exact-result-type", _Uint16ArrayView)
|
||||
|
@ -3908,7 +3926,7 @@ class _Uint16ArrayView extends _TypedListView
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Int32ArrayView extends _TypedListView
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Int32List>
|
||||
implements Int32List {
|
||||
// Constructor.
|
||||
@pragma("vm:exact-result-type", _Int32ArrayView)
|
||||
|
@ -3945,7 +3963,7 @@ class _Int32ArrayView extends _TypedListView
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Uint32ArrayView extends _TypedListView
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Uint32List>
|
||||
implements Uint32List {
|
||||
// Constructor.
|
||||
@pragma("vm:exact-result-type", _Uint32ArrayView)
|
||||
|
@ -3982,7 +4000,7 @@ class _Uint32ArrayView extends _TypedListView
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Int64ArrayView extends _TypedListView
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Int64List>
|
||||
implements Int64List {
|
||||
// Constructor.
|
||||
@pragma("vm:exact-result-type", _Int64ArrayView)
|
||||
|
@ -4019,7 +4037,7 @@ class _Int64ArrayView extends _TypedListView
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Uint64ArrayView extends _TypedListView
|
||||
with _IntListMixin
|
||||
with _IntListMixin<Uint64List>
|
||||
implements Uint64List {
|
||||
// Constructor.
|
||||
@pragma("vm:exact-result-type", _Uint64ArrayView)
|
||||
|
@ -4056,7 +4074,7 @@ class _Uint64ArrayView extends _TypedListView
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Float32ArrayView extends _TypedListView
|
||||
with _DoubleListMixin
|
||||
with _DoubleListMixin<Float32List>
|
||||
implements Float32List {
|
||||
// Constructor.
|
||||
@pragma("vm:exact-result-type", _Float32ArrayView)
|
||||
|
@ -4093,7 +4111,7 @@ class _Float32ArrayView extends _TypedListView
|
|||
|
||||
@pragma("vm:entry-point")
|
||||
class _Float64ArrayView extends _TypedListView
|
||||
with _DoubleListMixin
|
||||
with _DoubleListMixin<Float64List>
|
||||
implements Float64List {
|
||||
// Constructor.
|
||||
@pragma("vm:exact-result-type", _Float64ArrayView)
|
||||
|
|
|
@ -85,14 +85,14 @@ class _CopyingBytesBuilder implements BytesBuilder {
|
|||
_buffer = newBuffer;
|
||||
}
|
||||
|
||||
List<int> takeBytes() {
|
||||
Uint8List takeBytes() {
|
||||
if (_length == 0) return _emptyList;
|
||||
var buffer = new Uint8List.view(_buffer.buffer, 0, _length);
|
||||
clear();
|
||||
return buffer;
|
||||
}
|
||||
|
||||
List<int> toBytes() {
|
||||
Uint8List toBytes() {
|
||||
if (_length == 0) return _emptyList;
|
||||
return new Uint8List.fromList(
|
||||
new Uint8List.view(_buffer.buffer, 0, _length));
|
||||
|
|
|
@ -171,7 +171,7 @@ class NativeFloat32x4List extends Object
|
|||
_storage[(index * 4) + 3] = value.w;
|
||||
}
|
||||
|
||||
List<Float32x4> sublist(int start, [int end]) {
|
||||
Float32x4List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
return NativeFloat32x4List._externalStorage(
|
||||
_storage.sublist(start * 4, end * 4));
|
||||
|
@ -249,7 +249,7 @@ class NativeInt32x4List extends Object
|
|||
_storage[(index * 4) + 3] = value.w;
|
||||
}
|
||||
|
||||
List<Int32x4> sublist(int start, [int end]) {
|
||||
Int32x4List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
return NativeInt32x4List._externalStorage(
|
||||
_storage.sublist(start * 4, end * 4));
|
||||
|
@ -321,7 +321,7 @@ class NativeFloat64x2List extends Object
|
|||
_storage[(index * 2) + 1] = value.y;
|
||||
}
|
||||
|
||||
List<Float64x2> sublist(int start, [int end]) {
|
||||
Float64x2List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
return NativeFloat64x2List._externalStorage(
|
||||
_storage.sublist(start * 2, end * 2));
|
||||
|
@ -831,7 +831,7 @@ class NativeFloat32List extends NativeTypedArrayOfDouble
|
|||
|
||||
Type get runtimeType => Float32List;
|
||||
|
||||
List<double> sublist(int start, [int end]) {
|
||||
Float32List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeFloat32List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -865,7 +865,7 @@ class NativeFloat64List extends NativeTypedArrayOfDouble
|
|||
|
||||
Type get runtimeType => Float64List;
|
||||
|
||||
List<double> sublist(int start, [int end]) {
|
||||
Float64List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeFloat64List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -903,7 +903,7 @@ class NativeInt16List extends NativeTypedArrayOfInt implements Int16List {
|
|||
return JS('int', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Int16List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeInt16List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -941,7 +941,7 @@ class NativeInt32List extends NativeTypedArrayOfInt implements Int32List {
|
|||
return JS('int', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Int32List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeInt32List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -979,7 +979,7 @@ class NativeInt8List extends NativeTypedArrayOfInt implements Int8List {
|
|||
return JS('int', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Int8List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeInt8List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -1017,7 +1017,7 @@ class NativeUint16List extends NativeTypedArrayOfInt implements Uint16List {
|
|||
return JS('int', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Uint16List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeUint16List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -1055,7 +1055,7 @@ class NativeUint32List extends NativeTypedArrayOfInt implements Uint32List {
|
|||
return JS('int', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Uint32List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeUint32List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -1096,7 +1096,7 @@ class NativeUint8ClampedList extends NativeTypedArrayOfInt
|
|||
return JS('int', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Uint8ClampedList sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source =
|
||||
JS('NativeUint8ClampedList', '#.subarray(#, #)', this, start, end);
|
||||
|
@ -1145,7 +1145,7 @@ class NativeUint8List extends NativeTypedArrayOfInt implements Uint8List {
|
|||
return JS('int', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Uint8List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeUint8List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
|
|
@ -163,7 +163,7 @@ class NativeFloat32x4List extends Object
|
|||
_storage[(index * 4) + 3] = value.w;
|
||||
}
|
||||
|
||||
List<Float32x4> sublist(int start, [int end]) {
|
||||
Float32x4List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
return new NativeFloat32x4List._externalStorage(
|
||||
_storage.sublist(start * 4, end * 4));
|
||||
|
@ -235,7 +235,7 @@ class NativeInt32x4List extends Object
|
|||
_storage[(index * 4) + 3] = value.w;
|
||||
}
|
||||
|
||||
List<Int32x4> sublist(int start, [int end]) {
|
||||
Int32x4List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
return new NativeInt32x4List._externalStorage(
|
||||
_storage.sublist(start * 4, end * 4));
|
||||
|
@ -302,7 +302,7 @@ class NativeFloat64x2List extends Object
|
|||
_storage[(index * 2) + 1] = value.y;
|
||||
}
|
||||
|
||||
List<Float64x2> sublist(int start, [int end]) {
|
||||
Float64x2List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
return new NativeFloat64x2List._externalStorage(
|
||||
_storage.sublist(start * 2, end * 2));
|
||||
|
@ -757,7 +757,7 @@ class NativeFloat32List extends NativeTypedArrayOfDouble
|
|||
|
||||
Type get runtimeType => Float32List;
|
||||
|
||||
List<double> sublist(int start, [int end]) {
|
||||
Float32List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeFloat32List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -791,7 +791,7 @@ class NativeFloat64List extends NativeTypedArrayOfDouble
|
|||
|
||||
Type get runtimeType => Float64List;
|
||||
|
||||
List<double> sublist(int start, [int end]) {
|
||||
Float64List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeFloat64List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -829,7 +829,7 @@ class NativeInt16List extends NativeTypedArrayOfInt implements Int16List {
|
|||
return JS('int', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Int16List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeInt16List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -867,7 +867,7 @@ class NativeInt32List extends NativeTypedArrayOfInt implements Int32List {
|
|||
return JS('int', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Int32List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeInt32List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -905,7 +905,7 @@ class NativeInt8List extends NativeTypedArrayOfInt implements Int8List {
|
|||
return JS('int', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Int8List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeInt8List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -943,7 +943,7 @@ class NativeUint16List extends NativeTypedArrayOfInt implements Uint16List {
|
|||
return JS('JSUInt31', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Uint16List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeUint16List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -981,7 +981,7 @@ class NativeUint32List extends NativeTypedArrayOfInt implements Uint32List {
|
|||
return JS('JSUInt32', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Uint32List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeUint32List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
@ -1022,7 +1022,7 @@ class NativeUint8ClampedList extends NativeTypedArrayOfInt
|
|||
return JS('JSUInt31', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Uint8ClampedList sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source =
|
||||
JS('NativeUint8ClampedList', '#.subarray(#, #)', this, start, end);
|
||||
|
@ -1071,7 +1071,7 @@ class NativeUint8List extends NativeTypedArrayOfInt implements Uint8List {
|
|||
return JS('JSUInt31', '#[#]', this, index);
|
||||
}
|
||||
|
||||
List<int> sublist(int start, [int end]) {
|
||||
Uint8List sublist(int start, [int end]) {
|
||||
end = _checkValidRange(start, end, this.length);
|
||||
var source = JS('NativeUint8List', '#.subarray(#, #)', this, start, end);
|
||||
return _create1(source);
|
||||
|
|
|
@ -75,7 +75,7 @@ class Utf8Encoder extends Converter<String, List<int>> {
|
|||
///
|
||||
/// If [start] and [end] are provided, only the substring
|
||||
/// `string.substring(start, end)` is converted.
|
||||
List<int> convert(String string, [int start = 0, int end]) {
|
||||
Uint8List convert(String string, [int start = 0, int end]) {
|
||||
var stringLength = string.length;
|
||||
end = RangeError.checkValidRange(start, end, stringLength);
|
||||
var length = end - start;
|
||||
|
@ -117,7 +117,7 @@ class Utf8Encoder extends Converter<String, List<int>> {
|
|||
class _Utf8Encoder {
|
||||
int _carry = 0;
|
||||
int _bufferIndex = 0;
|
||||
final List<int> _buffer;
|
||||
final Uint8List _buffer;
|
||||
|
||||
static const _DEFAULT_BYTE_BUFFER_SIZE = 1024;
|
||||
|
||||
|
@ -127,7 +127,7 @@ class _Utf8Encoder {
|
|||
: _buffer = _createBuffer(bufferSize);
|
||||
|
||||
/// Allow an implementation to pick the most efficient way of storing bytes.
|
||||
static List<int> _createBuffer(int size) => Uint8List(size);
|
||||
static Uint8List _createBuffer(int size) => Uint8List(size);
|
||||
|
||||
/// Tries to combine the given [leadingSurrogate] with the [nextCodeUnit] and
|
||||
/// writes it to [_buffer].
|
||||
|
|
|
@ -48,14 +48,14 @@ abstract class BytesBuilder {
|
|||
* The list returned is a view of the internal buffer, limited to the
|
||||
* [length].
|
||||
*/
|
||||
List<int> takeBytes();
|
||||
Uint8List takeBytes();
|
||||
|
||||
/**
|
||||
* Returns a copy of the current contents of the builder.
|
||||
*
|
||||
* Leaves the contents of the builder intact.
|
||||
*/
|
||||
List<int> toBytes();
|
||||
Uint8List toBytes();
|
||||
|
||||
/**
|
||||
* The number of bytes in the builder.
|
||||
|
@ -82,6 +82,7 @@ class _CopyingBytesBuilder implements BytesBuilder {
|
|||
// Start with 1024 bytes.
|
||||
static const int _initSize = 1024;
|
||||
|
||||
// Safe for reuse because a fixed-length empty list is immutable.
|
||||
static final _emptyList = new Uint8List(0);
|
||||
|
||||
int _length = 0;
|
||||
|
@ -135,14 +136,14 @@ class _CopyingBytesBuilder implements BytesBuilder {
|
|||
_buffer = newBuffer;
|
||||
}
|
||||
|
||||
List<int> takeBytes() {
|
||||
Uint8List takeBytes() {
|
||||
if (_length == 0) return _emptyList;
|
||||
var buffer = new Uint8List.view(_buffer.buffer, 0, _length);
|
||||
clear();
|
||||
return buffer;
|
||||
}
|
||||
|
||||
List<int> toBytes() {
|
||||
Uint8List toBytes() {
|
||||
if (_length == 0) return _emptyList;
|
||||
return new Uint8List.fromList(
|
||||
new Uint8List.view(_buffer.buffer, 0, _length));
|
||||
|
@ -191,7 +192,7 @@ class _BytesBuilder implements BytesBuilder {
|
|||
_length++;
|
||||
}
|
||||
|
||||
List<int> takeBytes() {
|
||||
Uint8List takeBytes() {
|
||||
if (_length == 0) return _CopyingBytesBuilder._emptyList;
|
||||
if (_chunks.length == 1) {
|
||||
var buffer = _chunks[0];
|
||||
|
@ -208,7 +209,7 @@ class _BytesBuilder implements BytesBuilder {
|
|||
return buffer;
|
||||
}
|
||||
|
||||
List<int> toBytes() {
|
||||
Uint8List toBytes() {
|
||||
if (_length == 0) return _CopyingBytesBuilder._emptyList;
|
||||
var buffer = new Uint8List(_length);
|
||||
int offset = 0;
|
||||
|
|
|
@ -505,17 +505,17 @@ abstract class File implements FileSystemEntity {
|
|||
|
||||
/**
|
||||
* Read the entire file contents as a list of bytes. Returns a
|
||||
* `Future<List<int>>` that completes with the list of bytes that
|
||||
* `Future<Uint8List>` that completes with the list of bytes that
|
||||
* is the contents of the file.
|
||||
*/
|
||||
Future<List<int>> readAsBytes();
|
||||
Future<Uint8List> readAsBytes();
|
||||
|
||||
/**
|
||||
* Synchronously read the entire file contents as a list of bytes.
|
||||
*
|
||||
* Throws a [FileSystemException] if the operation fails.
|
||||
*/
|
||||
List<int> readAsBytesSync();
|
||||
Uint8List readAsBytesSync();
|
||||
|
||||
/**
|
||||
* Read the entire file contents as a string using the given
|
||||
|
@ -682,7 +682,7 @@ abstract class RandomAccessFile {
|
|||
/**
|
||||
* Reads [bytes] bytes from a file and returns the result as a list of bytes.
|
||||
*/
|
||||
Future<List<int>> read(int bytes);
|
||||
Future<Uint8List> read(int bytes);
|
||||
|
||||
/**
|
||||
* Synchronously reads a maximum of [bytes] bytes from a file and
|
||||
|
@ -690,7 +690,7 @@ abstract class RandomAccessFile {
|
|||
*
|
||||
* Throws a [FileSystemException] if the operation fails.
|
||||
*/
|
||||
List<int> readSync(int bytes);
|
||||
Uint8List readSync(int bytes);
|
||||
|
||||
/**
|
||||
* Reads into an existing [List<int>] from the file. If [start] is present,
|
||||
|
|
|
@ -513,10 +513,10 @@ class _File extends FileSystemEntity implements File {
|
|||
return new IOSink(consumer, encoding: encoding);
|
||||
}
|
||||
|
||||
Future<List<int>> readAsBytes() {
|
||||
Future<List<int>> readDataChunked(RandomAccessFile file) {
|
||||
Future<Uint8List> readAsBytes() {
|
||||
Future<Uint8List> readDataChunked(RandomAccessFile file) {
|
||||
var builder = new BytesBuilder(copy: false);
|
||||
var completer = new Completer<List<int>>();
|
||||
var completer = new Completer<Uint8List>();
|
||||
void read() {
|
||||
file.read(_blockSize).then((data) {
|
||||
if (data.length > 0) {
|
||||
|
@ -543,10 +543,10 @@ class _File extends FileSystemEntity implements File {
|
|||
});
|
||||
}
|
||||
|
||||
List<int> readAsBytesSync() {
|
||||
Uint8List readAsBytesSync() {
|
||||
var opened = openSync();
|
||||
try {
|
||||
List<int> data;
|
||||
Uint8List data;
|
||||
var length = opened.lengthSync();
|
||||
if (length == 0) {
|
||||
// May be character device, try to read it in chunks.
|
||||
|
@ -741,19 +741,19 @@ class _RandomAccessFile implements RandomAccessFile {
|
|||
return result;
|
||||
}
|
||||
|
||||
Future<List<int>> read(int bytes) {
|
||||
Future<Uint8List> read(int bytes) {
|
||||
ArgumentError.checkNotNull(bytes, 'bytes');
|
||||
return _dispatch(_IOService.fileRead, [null, bytes]).then((response) {
|
||||
if (_isErrorResponse(response)) {
|
||||
throw _exceptionFromResponse(response, "read failed", path);
|
||||
}
|
||||
_resourceInfo.addRead(response[1].length);
|
||||
List<int> result = response[1];
|
||||
Uint8List result = response[1];
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
List<int> readSync(int bytes) {
|
||||
Uint8List readSync(int bytes) {
|
||||
_checkAvailable();
|
||||
ArgumentError.checkNotNull(bytes, 'bytes');
|
||||
var result = _ops.read(bytes);
|
||||
|
|
|
@ -772,6 +772,31 @@ abstract class Int8List implements List<int>, _TypedIntList {
|
|||
return buffer.asInt8List(offsetInBytes, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is an `Int8List` containing the elements of this list at
|
||||
* positions greater than or equal to [start] and less than [end] in the same
|
||||
* order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Int8List.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Int8List
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Int8List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 1;
|
||||
}
|
||||
|
||||
|
@ -829,6 +854,31 @@ abstract class Uint8List implements List<int>, _TypedIntList {
|
|||
*/
|
||||
List<int> operator +(List<int> other);
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is a `Uint8List` containing the elements of this list at
|
||||
* positions greater than or equal to [start] and less than [end] in the same
|
||||
* order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Uint8List.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Uint8List
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Uint8List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 1;
|
||||
}
|
||||
|
||||
|
@ -878,6 +928,31 @@ abstract class Uint8ClampedList implements List<int>, _TypedIntList {
|
|||
return buffer.asUint8ClampedList(offsetInBytes, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is a `Uint8ClampedList` containing the elements of this
|
||||
* list at positions greater than or equal to [start] and less than [end] in
|
||||
* the same order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Uint8ClampedList.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Uint8ClampedList
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Uint8ClampedList sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 1;
|
||||
}
|
||||
|
||||
|
@ -930,6 +1005,31 @@ abstract class Int16List implements List<int>, _TypedIntList {
|
|||
return buffer.asInt16List(offsetInBytes, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is an `Int16List` containing the elements of this
|
||||
* list at positions greater than or equal to [start] and less than [end] in
|
||||
* the same order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Int16List.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Int16List
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Int16List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 2;
|
||||
}
|
||||
|
||||
|
@ -983,6 +1083,31 @@ abstract class Uint16List implements List<int>, _TypedIntList {
|
|||
return buffer.asUint16List(offsetInBytes, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is a `Uint16List` containing the elements of this
|
||||
* list at positions greater than or equal to [start] and less than [end] in
|
||||
* the same order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Uint16List.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Uint16List
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Uint16List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 2;
|
||||
}
|
||||
|
||||
|
@ -1035,6 +1160,31 @@ abstract class Int32List implements List<int>, _TypedIntList {
|
|||
return buffer.asInt32List(offsetInBytes, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is an `Int32List` containing the elements of this
|
||||
* list at positions greater than or equal to [start] and less than [end] in
|
||||
* the same order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Int32List.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Int32List
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Int32List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 4;
|
||||
}
|
||||
|
||||
|
@ -1088,6 +1238,31 @@ abstract class Uint32List implements List<int>, _TypedIntList {
|
|||
return buffer.asUint32List(offsetInBytes, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is a `Uint32List` containing the elements of this
|
||||
* list at positions greater than or equal to [start] and less than [end] in
|
||||
* the same order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Uint32List.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Uint32List
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Uint32List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 4;
|
||||
}
|
||||
|
||||
|
@ -1140,6 +1315,31 @@ abstract class Int64List implements List<int>, _TypedIntList {
|
|||
return buffer.asInt64List(offsetInBytes, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is an `Int64List` containing the elements of this
|
||||
* list at positions greater than or equal to [start] and less than [end] in
|
||||
* the same order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Int64List.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Int64List
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Int64List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 8;
|
||||
}
|
||||
|
||||
|
@ -1193,6 +1393,31 @@ abstract class Uint64List implements List<int>, _TypedIntList {
|
|||
return buffer.asUint64List(offsetInBytes, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is a `Uint64List` containing the elements of this
|
||||
* list at positions greater than or equal to [start] and less than [end] in
|
||||
* the same order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Uint64List.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Uint64List
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Uint64List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 8;
|
||||
}
|
||||
|
||||
|
@ -1246,6 +1471,31 @@ abstract class Float32List implements List<double>, _TypedFloatList {
|
|||
return buffer.asFloat32List(offsetInBytes, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is a `Float32List` containing the elements of this
|
||||
* list at positions greater than or equal to [start] and less than [end] in
|
||||
* the same order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Float32List.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Float32List
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Float32List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 4;
|
||||
}
|
||||
|
||||
|
@ -1292,6 +1542,31 @@ abstract class Float64List implements List<double>, _TypedFloatList {
|
|||
return buffer.asFloat64List(offsetInBytes, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is a `Float64List` containing the elements of this
|
||||
* list at positions greater than or equal to [start] and less than [end] in
|
||||
* the same order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Float64List.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Float64List
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Float64List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 8;
|
||||
}
|
||||
|
||||
|
@ -1345,6 +1620,31 @@ abstract class Float32x4List implements List<Float32x4>, TypedData {
|
|||
*/
|
||||
List<Float32x4> operator +(List<Float32x4> other);
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is a `Float32x4List` containing the elements of this
|
||||
* list at positions greater than or equal to [start] and less than [end] in
|
||||
* the same order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Float32x4List.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Float32x4List
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Float32x4List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 16;
|
||||
}
|
||||
|
||||
|
@ -1398,6 +1698,31 @@ abstract class Int32x4List implements List<Int32x4>, TypedData {
|
|||
*/
|
||||
List<Int32x4> operator +(List<Int32x4> other);
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is an `Int32x4list` containing the elements of this
|
||||
* list at positions greater than or equal to [start] and less than [end] in
|
||||
* the same order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Int32x4list.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Int32x4list
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Int32x4List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 16;
|
||||
}
|
||||
|
||||
|
@ -1451,6 +1776,31 @@ abstract class Float64x2List implements List<Float64x2>, TypedData {
|
|||
return buffer.asFloat64x2List(offsetInBytes, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new list containing the elements between [start] and [end].
|
||||
*
|
||||
* The new list is a `Float64x2List` containing the elements of this
|
||||
* list at positions greater than or equal to [start] and less than [end] in
|
||||
* the same order as they occur in this list.
|
||||
*
|
||||
* ```dart
|
||||
* var numbers = Float64x2List.fromList([0, 1, 2, 3, 4]);
|
||||
* print(numbers.sublist(1, 3)); // [1, 2]
|
||||
* print(numbers.sublist(1, 3).runtimeType); // Float64x2List
|
||||
* ```
|
||||
*
|
||||
* If [end] is omitted, it defaults to the [length] of this list.
|
||||
*
|
||||
* ```dart
|
||||
* print(numbers.sublist(1)); // [1, 2, 3, 4]
|
||||
* ```
|
||||
*
|
||||
* The `start` and `end` positions must satisfy the relations
|
||||
* 0 ≤ `start` ≤ `end` ≤ `this.length`
|
||||
* If `end` is equal to `start`, then the returned list is empty.
|
||||
*/
|
||||
Float64x2List sublist(int start, [int end]);
|
||||
|
||||
static const int bytesPerElement = 16;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,6 +160,16 @@ abstract class _UnmodifiableListMixin<N, L extends List<N>,
|
|||
int get lengthInBytes => _data.lengthInBytes;
|
||||
|
||||
ByteBuffer get buffer => new UnmodifiableByteBufferView(_data.buffer);
|
||||
|
||||
L _createList(int length);
|
||||
|
||||
L sublist(int start, [int end]) {
|
||||
end = RangeError.checkValidRange(start, end, length);
|
||||
int sublistLength = end - start;
|
||||
L result = _createList(sublistLength);
|
||||
result.setRange(0, sublistLength, _list, start);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,6 +180,8 @@ class UnmodifiableUint8ListView extends UnmodifiableListBase<int>
|
|||
implements Uint8List {
|
||||
final Uint8List _list;
|
||||
UnmodifiableUint8ListView(Uint8List list) : _list = list;
|
||||
|
||||
Uint8List _createList(int length) => Uint8List(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -180,6 +192,8 @@ class UnmodifiableInt8ListView extends UnmodifiableListBase<int>
|
|||
implements Int8List {
|
||||
final Int8List _list;
|
||||
UnmodifiableInt8ListView(Int8List list) : _list = list;
|
||||
|
||||
Int8List _createList(int length) => Int8List(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,6 +204,8 @@ class UnmodifiableUint8ClampedListView extends UnmodifiableListBase<int>
|
|||
implements Uint8ClampedList {
|
||||
final Uint8ClampedList _list;
|
||||
UnmodifiableUint8ClampedListView(Uint8ClampedList list) : _list = list;
|
||||
|
||||
Uint8ClampedList _createList(int length) => Uint8ClampedList(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,6 +216,8 @@ class UnmodifiableUint16ListView extends UnmodifiableListBase<int>
|
|||
implements Uint16List {
|
||||
final Uint16List _list;
|
||||
UnmodifiableUint16ListView(Uint16List list) : _list = list;
|
||||
|
||||
Uint16List _createList(int length) => Uint16List(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -210,6 +228,8 @@ class UnmodifiableInt16ListView extends UnmodifiableListBase<int>
|
|||
implements Int16List {
|
||||
final Int16List _list;
|
||||
UnmodifiableInt16ListView(Int16List list) : _list = list;
|
||||
|
||||
Int16List _createList(int length) => Int16List(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -220,6 +240,8 @@ class UnmodifiableUint32ListView extends UnmodifiableListBase<int>
|
|||
implements Uint32List {
|
||||
final Uint32List _list;
|
||||
UnmodifiableUint32ListView(Uint32List list) : _list = list;
|
||||
|
||||
Uint32List _createList(int length) => Uint32List(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -230,6 +252,8 @@ class UnmodifiableInt32ListView extends UnmodifiableListBase<int>
|
|||
implements Int32List {
|
||||
final Int32List _list;
|
||||
UnmodifiableInt32ListView(Int32List list) : _list = list;
|
||||
|
||||
Int32List _createList(int length) => Int32List(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -240,6 +264,8 @@ class UnmodifiableUint64ListView extends UnmodifiableListBase<int>
|
|||
implements Uint64List {
|
||||
final Uint64List _list;
|
||||
UnmodifiableUint64ListView(Uint64List list) : _list = list;
|
||||
|
||||
Uint64List _createList(int length) => Uint64List(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,6 +276,8 @@ class UnmodifiableInt64ListView extends UnmodifiableListBase<int>
|
|||
implements Int64List {
|
||||
final Int64List _list;
|
||||
UnmodifiableInt64ListView(Int64List list) : _list = list;
|
||||
|
||||
Int64List _createList(int length) => Int64List(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -260,6 +288,8 @@ class UnmodifiableInt32x4ListView extends UnmodifiableListBase<Int32x4>
|
|||
implements Int32x4List {
|
||||
final Int32x4List _list;
|
||||
UnmodifiableInt32x4ListView(Int32x4List list) : _list = list;
|
||||
|
||||
Int32x4List _createList(int length) => Int32x4List(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -270,6 +300,8 @@ class UnmodifiableFloat32x4ListView extends UnmodifiableListBase<Float32x4>
|
|||
implements Float32x4List {
|
||||
final Float32x4List _list;
|
||||
UnmodifiableFloat32x4ListView(Float32x4List list) : _list = list;
|
||||
|
||||
Float32x4List _createList(int length) => Float32x4List(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -280,6 +312,8 @@ class UnmodifiableFloat64x2ListView extends UnmodifiableListBase<Float64x2>
|
|||
implements Float64x2List {
|
||||
final Float64x2List _list;
|
||||
UnmodifiableFloat64x2ListView(Float64x2List list) : _list = list;
|
||||
|
||||
Float64x2List _createList(int length) => Float64x2List(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -290,6 +324,8 @@ class UnmodifiableFloat32ListView extends UnmodifiableListBase<double>
|
|||
implements Float32List {
|
||||
final Float32List _list;
|
||||
UnmodifiableFloat32ListView(Float32List list) : _list = list;
|
||||
|
||||
Float32List _createList(int length) => Float32List(length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,4 +336,6 @@ class UnmodifiableFloat64ListView extends UnmodifiableListBase<double>
|
|||
implements Float64List {
|
||||
final Float64List _list;
|
||||
UnmodifiableFloat64ListView(Float64List list) : _list = list;
|
||||
|
||||
Float64List _createList(int length) => Float64List(length);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue