| Index: sdk/lib/typed_data/dart2js/native_typed_data_dart2js.dart
|
| diff --git a/sdk/lib/typed_data/dart2js/typed_data_dart2js.dart b/sdk/lib/typed_data/dart2js/native_typed_data_dart2js.dart
|
| similarity index 76%
|
| copy from sdk/lib/typed_data/dart2js/typed_data_dart2js.dart
|
| copy to sdk/lib/typed_data/dart2js/native_typed_data_dart2js.dart
|
| index c237962a66abed340cea09ac9cbf129331836c34..a69c406ba8b7409f90c6eedd10a44597708ce42d 100644
|
| --- a/sdk/lib/typed_data/dart2js/typed_data_dart2js.dart
|
| +++ b/sdk/lib/typed_data/dart2js/native_typed_data_dart2js.dart
|
| @@ -6,7 +6,7 @@
|
| * Specialized integers and floating point numbers,
|
| * with SIMD support and efficient lists.
|
| */
|
| -library dart.typed_data;
|
| +library dart.typed_data.implementation;
|
|
|
| import 'dart:collection';
|
| import 'dart:_collection-dev';
|
| @@ -37,20 +37,50 @@ class Endianness {
|
| * Used to process large quantities of binary or numerical data
|
| * more efficiently using a typed view.
|
| */
|
| -class ByteBuffer native "ArrayBuffer" {
|
| +abstract class ByteBuffer {
|
| + int get lengthInBytes;
|
| +}
|
| +
|
| +class NativeByteBuffer implements ByteBuffer native "ArrayBuffer" {
|
| @JSName('byteLength')
|
| final int lengthInBytes;
|
| +
|
| + Type get runtimeType => ByteBuffer;
|
| }
|
|
|
| /**
|
| * A typed view of a sequence of bytes.
|
| */
|
| -class TypedData native "ArrayBufferView" {
|
| +abstract class TypedData {
|
| /**
|
| * Returns the byte buffer associated with this object.
|
| */
|
| - @Creates('ByteBuffer')
|
| - @Returns('ByteBuffer|Null')
|
| + ByteBuffer get buffer;
|
| +
|
| + /**
|
| + * Returns the length of this view, in bytes.
|
| + */
|
| + int get lengthInBytes;
|
| +
|
| + /**
|
| + * Returns the offset in bytes into the underlying byte buffer of this view.
|
| + */
|
| + int get offsetInBytes;
|
| +
|
| + /**
|
| + * Returns the number of bytes in the representation of each element in this
|
| + * list.
|
| + */
|
| + int get elementSizeInBytes;
|
| +}
|
| +
|
| +class NativeTypedData implements TypedData native "ArrayBufferView" {
|
| + /**
|
| + * Returns the byte buffer associated with this object.
|
| + */
|
| + @Creates('NativeByteBuffer')
|
| + // May be Null for IE's CanvasPixelArray.
|
| + @Returns('NativeByteBuffer|Null')
|
| final ByteBuffer buffer;
|
|
|
| /**
|
| @@ -113,7 +143,7 @@ int _checkLength(length) {
|
| // (e.g. String arguments) or create typed data objects that are not actually
|
| // views of the input.
|
| void _checkViewArguments(buffer, offsetInBytes, length) {
|
| - if (buffer is! ByteBuffer) {
|
| + if (buffer is! NativeByteBuffer) {
|
| throw new ArgumentError('Invalid view buffer');
|
| }
|
| if (offsetInBytes is! int) {
|
| @@ -155,12 +185,12 @@ List _ensureNativeList(List list) {
|
| * bdata.setFloat32(0, 3.04);
|
| * int huh = bdata.getInt32(0);
|
| */
|
| -class ByteData extends TypedData native "DataView" {
|
| +abstract class ByteData extends TypedData {
|
| /**
|
| * Creates a [ByteData] of the specified length (in elements), all of
|
| * whose elements are initially zero.
|
| */
|
| - factory ByteData(int length) => _create1(_checkLength(length));
|
| + factory ByteData(int length) => new NativeByteData(length);
|
|
|
| /**
|
| * Creates an [ByteData] _view_ of the specified region in the specified
|
| @@ -175,13 +205,279 @@ class ByteData extends TypedData native "DataView" {
|
| * the length of [buffer].
|
| */
|
| factory ByteData.view(ByteBuffer buffer,
|
| - [int offsetInBytes = 0, int length]) {
|
| + [int offsetInBytes = 0, int length]) =>
|
| + new NativeByteData.view(buffer, offsetInBytes, length);
|
| +
|
| + int get elementSizeInBytes => 1;
|
| +
|
| + /**
|
| + * Returns the floating point number represented by the four bytes at
|
| + * the specified [byteOffset] in this object, in IEEE 754
|
| + * single-precision binary floating-point format (binary32).
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 4` is greater than the length of this object.
|
| + */
|
| + num getFloat32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Returns the floating point number represented by the eight bytes at
|
| + * the specified [byteOffset] in this object, in IEEE 754
|
| + * double-precision binary floating-point format (binary64).
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 8` is greater than the length of this object.
|
| + */
|
| + num getFloat64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Returns the (possibly negative) integer represented by the two bytes at
|
| + * the specified [byteOffset] in this object, in two's complement binary
|
| + * form.
|
| + * The return value will be between 2<sup>15</sup> and 2<sup>15</sup> - 1,
|
| + * inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 2` is greater than the length of this object.
|
| + */
|
| + int getInt16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Returns the (possibly negative) integer represented by the four bytes at
|
| + * the specified [byteOffset] in this object, in two's complement binary
|
| + * form.
|
| + * The return value will be between 2<sup>31</sup> and 2<sup>31</sup> - 1,
|
| + * inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 4` is greater than the length of this object.
|
| + */
|
| + int getInt32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Returns the (possibly negative) integer represented by the eight bytes at
|
| + * the specified [byteOffset] in this object, in two's complement binary
|
| + * form.
|
| + * The return value will be between 2<sup>63</sup> and 2<sup>63</sup> - 1,
|
| + * inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 8` is greater than the length of this object.
|
| + */
|
| + int getInt64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Returns the (possibly negative) integer represented by the byte at the
|
| + * specified [byteOffset] in this object, in two's complement binary
|
| + * representation. The return value will be between -128 and 127, inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * greater than or equal to the length of this object.
|
| + */
|
| + int getInt8(int byteOffset) ;
|
| +
|
| + /**
|
| + * Returns the positive integer represented by the two bytes starting
|
| + * at the specified [byteOffset] in this object, in unsigned binary
|
| + * form.
|
| + * The return value will be between 0 and 2<sup>16</sup> - 1, inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 2` is greater than the length of this object.
|
| + */
|
| + int getUint16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Returns the positive integer represented by the four bytes starting
|
| + * at the specified [byteOffset] in this object, in unsigned binary
|
| + * form.
|
| + * The return value will be between 0 and 2<sup>32</sup> - 1, inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 4` is greater than the length of this object.
|
| + */
|
| + int getUint32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Returns the positive integer represented by the eight bytes starting
|
| + * at the specified [byteOffset] in this object, in unsigned binary
|
| + * form.
|
| + * The return value will be between 0 and 2<sup>64</sup> - 1, inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 8` is greater than the length of this object.
|
| + */
|
| + int getUint64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Returns the positive integer represented by the byte at the specified
|
| + * [byteOffset] in this object, in unsigned binary form. The
|
| + * return value will be between 0 and 255, inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * greater than or equal to the length of this object.
|
| + */
|
| + int getUint8(int byteOffset);
|
| +
|
| + /**
|
| + * Sets the four bytes starting at the specified [byteOffset] in this
|
| + * object to the IEEE 754 single-precision binary floating-point
|
| + * (binary32) representation of the specified [value].
|
| + *
|
| + * **Note that this method can lose precision.** The input [value] is
|
| + * a 64-bit floating point value, which will be converted to 32-bit
|
| + * floating point value by IEEE 754 rounding rules before it is stored.
|
| + * If [value] cannot be represented exactly as a binary32, it will be
|
| + * converted to the nearest binary32 value. If two binary32 values are
|
| + * equally close, the one whose least significant bit is zero will be used.
|
| + * Note that finite (but large) values can be converted to infinity, and
|
| + * small non-zero values can be converted to zero.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 4` is greater than the length of this object.
|
| + */
|
| + void setFloat32(int byteOffset, num value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Sets the eight bytes starting at the specified [byteOffset] in this
|
| + * object to the IEEE 754 double-precision binary floating-point
|
| + * (binary64) representation of the specified [value].
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 8` is greater than the length of this object.
|
| + */
|
| + void setFloat64(int byteOffset, num value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Sets the two bytes starting at the specified [byteOffset] in this
|
| + * object to the two's complement binary representation of the specified
|
| + * [value], which must fit in two bytes. In other words, [value] must lie
|
| + * between 2<sup>15</sup> and 2<sup>15</sup> - 1, inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 2` is greater than the length of this object.
|
| + */
|
| + void setInt16(int byteOffset, int value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Sets the four bytes starting at the specified [byteOffset] in this
|
| + * object to the two's complement binary representation of the specified
|
| + * [value], which must fit in four bytes. In other words, [value] must lie
|
| + * between 2<sup>31</sup> and 2<sup>31</sup> - 1, inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 4` is greater than the length of this object.
|
| + */
|
| + void setInt32(int byteOffset, int value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Sets the eight bytes starting at the specified [byteOffset] in this
|
| + * object to the two's complement binary representation of the specified
|
| + * [value], which must fit in eight bytes. In other words, [value] must lie
|
| + * between 2<sup>63</sup> and 2<sup>63</sup> - 1, inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 8` is greater than the length of this object.
|
| + */
|
| + void setInt64(int byteOffset, int value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Sets the byte at the specified [byteOffset] in this object to the
|
| + * two's complement binary representation of the specified [value], which
|
| + * must fit in a single byte. In other words, [value] must be between
|
| + * -128 and 127, inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * greater than or equal to the length of this object.
|
| + */
|
| + void setInt8(int byteOffset, int value);
|
| +
|
| + /**
|
| + * Sets the two bytes starting at the specified [byteOffset] in this object
|
| + * to the unsigned binary representation of the specified [value],
|
| + * which must fit in two bytes. in other words, [value] must be between
|
| + * 0 and 2<sup>16</sup> - 1, inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 2` is greater than the length of this object.
|
| + */
|
| + void setUint16(int byteOffset, int value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Sets the four bytes starting at the specified [byteOffset] in this object
|
| + * to the unsigned binary representation of the specified [value],
|
| + * which must fit in four bytes. in other words, [value] must be between
|
| + * 0 and 2<sup>32</sup> - 1, inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 4` is greater than the length of this object.
|
| + */
|
| + void setUint32(int byteOffset, int value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Sets the eight bytes starting at the specified [byteOffset] in this object
|
| + * to the unsigned binary representation of the specified [value],
|
| + * which must fit in eight bytes. in other words, [value] must be between
|
| + * 0 and 2<sup>64</sup> - 1, inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative, or
|
| + * `byteOffset + 8` is greater than the length of this object.
|
| + */
|
| + void setUint64(int byteOffset, int value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]);
|
| +
|
| + /**
|
| + * Sets the byte at the specified [byteOffset] in this object to the
|
| + * unsigned binary representation of the specified [value], which must fit
|
| + * in a single byte. in other words, [value] must be between 0 and 255,
|
| + * inclusive.
|
| + *
|
| + * Throws [RangeError] if [byteOffset] is negative,
|
| + * or greater than or equal to the length of this object.
|
| + */
|
| + void setUint8(int byteOffset, int value);
|
| +}
|
| +
|
| +
|
| +class NativeByteData extends NativeTypedData implements ByteData
|
| + native "DataView" {
|
| + /**
|
| + * Creates a [ByteData] of the specified length (in elements), all of
|
| + * whose elements are initially zero.
|
| + */
|
| + factory NativeByteData(int length) => _create1(_checkLength(length));
|
| +
|
| + /**
|
| + * Creates an [ByteData] _view_ of the specified region in the specified
|
| + * byte buffer. Changes in the [ByteData] will be visible in the byte
|
| + * buffer and vice versa. If the [offsetInBytes] index of the region is not
|
| + * specified, it defaults to zero (the first byte in the byte buffer).
|
| + * If the length is not specified, it defaults to null, which indicates
|
| + * that the view extends to the end of the byte buffer.
|
| + *
|
| + * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
|
| + * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
|
| + * the length of [buffer].
|
| + */
|
| + factory NativeByteData.view(ByteBuffer buffer,
|
| + [int offsetInBytes = 0, int length]) {
|
| _checkViewArguments(buffer, offsetInBytes, length);
|
| return length == null
|
| ? _create2(buffer, offsetInBytes)
|
| : _create3(buffer, offsetInBytes, length);
|
| }
|
|
|
| + Type get runtimeType => ByteData;
|
| +
|
| + int get elementSizeInBytes => 1;
|
| +
|
| /**
|
| * Returns the floating point number represented by the four bytes at
|
| * the specified [byteOffset] in this object, in IEEE 754
|
| @@ -193,8 +489,6 @@ class ByteData extends TypedData native "DataView" {
|
| num getFloat32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| _getFloat32(byteOffset, endian._littleEndian);
|
|
|
| - int get elementSizeInBytes => 1;
|
| -
|
| @JSName('getFloat32')
|
| @Returns('num')
|
| num _getFloat32(int byteOffset, [bool littleEndian]) native;
|
| @@ -344,7 +638,8 @@ class ByteData extends TypedData native "DataView" {
|
| * Throws [RangeError] if [byteOffset] is negative, or
|
| * `byteOffset + 4` is greater than the length of this object.
|
| */
|
| - void setFloat32(int byteOffset, num value, [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| + void setFloat32(int byteOffset, num value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| _setFloat32(byteOffset, value, endian._littleEndian);
|
|
|
| @JSName('setFloat32')
|
| @@ -358,7 +653,8 @@ class ByteData extends TypedData native "DataView" {
|
| * Throws [RangeError] if [byteOffset] is negative, or
|
| * `byteOffset + 8` is greater than the length of this object.
|
| */
|
| - void setFloat64(int byteOffset, num value, [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| + void setFloat64(int byteOffset, num value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| _setFloat64(byteOffset, value, endian._littleEndian);
|
|
|
| @JSName('setFloat64')
|
| @@ -373,7 +669,8 @@ class ByteData extends TypedData native "DataView" {
|
| * Throws [RangeError] if [byteOffset] is negative, or
|
| * `byteOffset + 2` is greater than the length of this object.
|
| */
|
| - void setInt16(int byteOffset, int value, [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| + void setInt16(int byteOffset, int value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| _setInt16(byteOffset, value, endian._littleEndian);
|
|
|
| @JSName('setInt16')
|
| @@ -388,7 +685,8 @@ class ByteData extends TypedData native "DataView" {
|
| * Throws [RangeError] if [byteOffset] is negative, or
|
| * `byteOffset + 4` is greater than the length of this object.
|
| */
|
| - void setInt32(int byteOffset, int value, [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| + void setInt32(int byteOffset, int value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| _setInt32(byteOffset, value, endian._littleEndian);
|
|
|
| @JSName('setInt32')
|
| @@ -403,7 +701,8 @@ class ByteData extends TypedData native "DataView" {
|
| * Throws [RangeError] if [byteOffset] is negative, or
|
| * `byteOffset + 8` is greater than the length of this object.
|
| */
|
| - void setInt64(int byteOffset, int value, [Endianness endian=Endianness.BIG_ENDIAN]) {
|
| + void setInt64(int byteOffset, int value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]) {
|
| throw new UnsupportedError("Int64 accessor not supported by dart2js.");
|
| }
|
|
|
| @@ -427,7 +726,8 @@ class ByteData extends TypedData native "DataView" {
|
| * Throws [RangeError] if [byteOffset] is negative, or
|
| * `byteOffset + 2` is greater than the length of this object.
|
| */
|
| - void setUint16(int byteOffset, int value, [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| + void setUint16(int byteOffset, int value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| _setUint16(byteOffset, value, endian._littleEndian);
|
|
|
| @JSName('setUint16')
|
| @@ -442,7 +742,8 @@ class ByteData extends TypedData native "DataView" {
|
| * Throws [RangeError] if [byteOffset] is negative, or
|
| * `byteOffset + 4` is greater than the length of this object.
|
| */
|
| - void setUint32(int byteOffset, int value, [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| + void setUint32(int byteOffset, int value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]) =>
|
| _setUint32(byteOffset, value, endian._littleEndian);
|
|
|
| @JSName('setUint32')
|
| @@ -457,7 +758,8 @@ class ByteData extends TypedData native "DataView" {
|
| * Throws [RangeError] if [byteOffset] is negative, or
|
| * `byteOffset + 8` is greater than the length of this object.
|
| */
|
| - void setUint64(int byteOffset, int value, [Endianness endian=Endianness.BIG_ENDIAN]) {
|
| + void setUint64(int byteOffset, int value,
|
| + [Endianness endian=Endianness.BIG_ENDIAN]) {
|
| throw new UnsupportedError("Uint64 accessor not supported by dart2js.");
|
| }
|
|
|
| @@ -472,26 +774,26 @@ class ByteData extends TypedData native "DataView" {
|
| */
|
| void setUint8(int byteOffset, int value) native;
|
|
|
| - static ByteData _create1(arg) =>
|
| - JS('ByteData', 'new DataView(new ArrayBuffer(#))', arg);
|
| + static NativeByteData _create1(arg) =>
|
| + JS('NativeByteData', 'new DataView(new ArrayBuffer(#))', arg);
|
|
|
| - static ByteData _create2(arg1, arg2) =>
|
| - JS('ByteData', 'new DataView(#, #)', arg1, arg2);
|
| + static NativeByteData _create2(arg1, arg2) =>
|
| + JS('NativeByteData', 'new DataView(#, #)', arg1, arg2);
|
|
|
| - static ByteData _create3(arg1, arg2, arg3) =>
|
| - JS('ByteData', 'new DataView(#, #, #)', arg1, arg2, arg3);
|
| + static NativeByteData _create3(arg1, arg2, arg3) =>
|
| + JS('NativeByteData', 'new DataView(#, #, #)', arg1, arg2, arg3);
|
| }
|
|
|
|
|
| // TODO(sra): Move this type to a public name in a private library so that other
|
| // platform libraries like dart:html and dart:webaudio can tell a native array
|
| // from a list that implements the implicit interface.
|
| -abstract class _NativeTypedArray extends TypedData
|
| +abstract class NativeTypedArray extends NativeTypedData
|
| implements JavaScriptIndexingBehavior {
|
| int get length => JS("JSUInt32", '#.length', this);
|
|
|
| bool _setRangeFast(int start, int end,
|
| - _NativeTypedArray source, int skipCount) {
|
| + NativeTypedArray source, int skipCount) {
|
| int targetLength = this.length;
|
| _checkIndex(start, targetLength + 1);
|
| _checkIndex(end, targetLength + 1);
|
| @@ -514,15 +816,15 @@ abstract class _NativeTypedArray extends TypedData
|
| }
|
| }
|
|
|
| -// TODO(sra): Move to private library, like [_NativeTypedArray].
|
| -abstract class _NativeTypedArrayOfDouble
|
| - extends _NativeTypedArray
|
| +// TODO(sra): Move to private library, like [NativeTypedArray].
|
| +abstract class NativeTypedArrayOfDouble
|
| + extends NativeTypedArray
|
| with ListMixin<double>, FixedLengthListMixin<double>
|
| implements List<double> {
|
|
|
| void setRange(int start, int end, Iterable<double> iterable,
|
| [int skipCount = 0]) {
|
| - if (iterable is _NativeTypedArrayOfDouble) {
|
| + if (iterable is NativeTypedArrayOfDouble) {
|
| _setRangeFast(start, end, iterable, skipCount);
|
| return;
|
| }
|
| @@ -530,15 +832,15 @@ abstract class _NativeTypedArrayOfDouble
|
| }
|
| }
|
|
|
| -// TODO(sra): Move to private library, like [_NativeTypedArray].
|
| -abstract class _NativeTypedArrayOfInt
|
| - extends _NativeTypedArray
|
| +// TODO(sra): Move to private library, like [NativeTypedArray].
|
| +abstract class NativeTypedArrayOfInt
|
| + extends NativeTypedArray
|
| with ListMixin<int>, FixedLengthListMixin<int>
|
| implements List<int> {
|
|
|
| void setRange(int start, int end, Iterable<int> iterable,
|
| [int skipCount = 0]) {
|
| - if (iterable is _NativeTypedArrayOfInt) {
|
| + if (iterable is NativeTypedArrayOfInt) {
|
| _setRangeFast(start, end, iterable, skipCount);
|
| return;
|
| }
|
| @@ -553,19 +855,19 @@ abstract class _NativeTypedArrayOfInt
|
| * implementation can be considerably more space- and time-efficient than
|
| * the default [List] implementation.
|
| */
|
| -class Float32List extends _NativeTypedArrayOfDouble native "Float32Array" {
|
| +abstract class Float32List implements TypedData, List<double> {
|
| /**
|
| * Creates a [Float32List] of the specified length (in elements), all of
|
| * whose elements are initially zero.
|
| */
|
| - factory Float32List(int length) => _create1(_checkLength(length));
|
| + factory Float32List(int length) = NativeFloat32List;
|
|
|
| /**
|
| * Creates a [Float32List] with the same size as the [elements] list
|
| * and copies over the elements.
|
| */
|
| - factory Float32List.fromList(List<double> list) =>
|
| - _create1(_ensureNativeList(list));
|
| + factory Float32List.fromList(List<double> elements) =>
|
| + new NativeFloat32List.fromList(elements);
|
|
|
| /**
|
| * Creates a [Float32List] _view_ of the specified region in the specified
|
| @@ -583,14 +885,31 @@ class Float32List extends _NativeTypedArrayOfDouble native "Float32Array" {
|
| * BYTES_PER_ELEMENT.
|
| */
|
| factory Float32List.view(ByteBuffer buffer,
|
| - [int offsetInBytes = 0, int length]) {
|
| + [int offsetInBytes = 0, int length]) =>
|
| + new NativeFloat32List.view(buffer, offsetInBytes, length);
|
| +
|
| + static const int BYTES_PER_ELEMENT = 4;
|
| +}
|
| +
|
| +class NativeFloat32List
|
| + extends NativeTypedArrayOfDouble
|
| + implements Float32List
|
| + native "Float32Array" {
|
| +
|
| + factory NativeFloat32List(int length) => _create1(_checkLength(length));
|
| +
|
| + factory NativeFloat32List.fromList(List<double> elements) =>
|
| + _create1(_ensureNativeList(elements));
|
| +
|
| + factory NativeFloat32List.view(ByteBuffer buffer,
|
| + int offsetInBytes, int length) {
|
| _checkViewArguments(buffer, offsetInBytes, length);
|
| return length == null
|
| ? _create2(buffer, offsetInBytes)
|
| : _create3(buffer, offsetInBytes, length);
|
| }
|
|
|
| - static const int BYTES_PER_ELEMENT = 4;
|
| + Type get runtimeType => Float32List;
|
|
|
| num operator[](int index) {
|
| _checkIndex(index, length);
|
| @@ -604,18 +923,18 @@ class Float32List extends _NativeTypedArrayOfDouble native "Float32Array" {
|
|
|
| List<double> sublist(int start, [int end]) {
|
| end = _checkSublistArguments(start, end, length);
|
| - var source = JS('Float32List', '#.subarray(#, #)', this, start, end);
|
| + var source = JS('NativeFloat32List', '#.subarray(#, #)', this, start, end);
|
| return _create1(source);
|
| }
|
|
|
| - static Float32List _create1(arg) =>
|
| - JS('Float32List', 'new Float32Array(#)', arg);
|
| + static NativeFloat32List _create1(arg) =>
|
| + JS('NativeFloat32List', 'new Float32Array(#)', arg);
|
|
|
| - static Float32List _create2(arg1, arg2) =>
|
| - JS('Float32List', 'new Float32Array(#, #)', arg1, arg2);
|
| + static NativeFloat32List _create2(arg1, arg2) =>
|
| + JS('NativeFloat32List', 'new Float32Array(#, #)', arg1, arg2);
|
|
|
| - static Float32List _create3(arg1, arg2, arg3) =>
|
| - JS('Float32List', 'new Float32Array(#, #, #)', arg1, arg2, arg3);
|
| + static NativeFloat32List _create3(arg1, arg2, arg3) =>
|
| + JS('NativeFloat32List', 'new Float32Array(#, #, #)', arg1, arg2, arg3);
|
| }
|
|
|
|
|
| @@ -625,19 +944,19 @@ class Float32List extends _NativeTypedArrayOfDouble native "Float32Array" {
|
| * implementation can be considerably more space- and time-efficient than
|
| * the default [List] implementation.
|
| */
|
| -class Float64List extends _NativeTypedArrayOfDouble native "Float64Array" {
|
| +abstract class Float64List implements TypedData, List<double> {
|
| /**
|
| * Creates a [Float64List] of the specified length (in elements), all of
|
| * whose elements are initially zero.
|
| */
|
| - factory Float64List(int length) => _create1(_checkLength(length));
|
| + factory Float64List(int length) = NativeFloat64List;
|
|
|
| /**
|
| * Creates a [Float64List] with the same size as the [elements] list
|
| * and copies over the elements.
|
| */
|
| - factory Float64List.fromList(List<double> list) =>
|
| - _create1(_ensureNativeList(list));
|
| + factory Float64List.fromList(List<double> elements) =>
|
| + new NativeFloat64List.fromList(elements);
|
|
|
| /**
|
| * Creates a [Float64List] _view_ of the specified region in the specified
|
| @@ -655,14 +974,31 @@ class Float64List extends _NativeTypedArrayOfDouble native "Float64Array" {
|
| * BYTES_PER_ELEMENT.
|
| */
|
| factory Float64List.view(ByteBuffer buffer,
|
| - [int offsetInBytes = 0, int length]) {
|
| + [int offsetInBytes = 0, int length]) =>
|
| + new NativeFloat64List.view(buffer, offsetInBytes, length);
|
| +
|
| + static const int BYTES_PER_ELEMENT = 8;
|
| +}
|
| +
|
| +class NativeFloat64List
|
| + extends NativeTypedArrayOfDouble
|
| + implements Float64List
|
| + native "Float64Array" {
|
| +
|
| + factory NativeFloat64List(int length) => _create1(_checkLength(length));
|
| +
|
| + factory NativeFloat64List.fromList(List<double> elements) =>
|
| + _create1(_ensureNativeList(elements));
|
| +
|
| + factory NativeFloat64List.view(ByteBuffer buffer,
|
| + int offsetInBytes, int length) {
|
| _checkViewArguments(buffer, offsetInBytes, length);
|
| return length == null
|
| ? _create2(buffer, offsetInBytes)
|
| : _create3(buffer, offsetInBytes, length);
|
| }
|
|
|
| - static const int BYTES_PER_ELEMENT = 8;
|
| + Type get runtimeType => Float64List;
|
|
|
| num operator[](int index) {
|
| _checkIndex(index, length);
|
| @@ -676,21 +1012,18 @@ class Float64List extends _NativeTypedArrayOfDouble native "Float64Array" {
|
|
|
| List<double> sublist(int start, [int end]) {
|
| end = _checkSublistArguments(start, end, length);
|
| - var source = JS('Float64List', '#.subarray(#, #)', this, start, end);
|
| + var source = JS('NativeFloat64List', '#.subarray(#, #)', this, start, end);
|
| return _create1(source);
|
| }
|
|
|
| - static Float64List _create1(arg) {
|
| - return JS('Float64List', 'new Float64Array(#)', arg);
|
| - }
|
| + static NativeFloat64List _create1(arg) =>
|
| + JS('NativeFloat64List', 'new Float64Array(#)', arg);
|
|
|
| - static Float64List _create2(arg1, arg2) {
|
| - return JS('Float64List', 'new Float64Array(#, #)', arg1, arg2);
|
| - }
|
| + static NativeFloat64List _create2(arg1, arg2) =>
|
| + JS('NativeFloat64List', 'new Float64Array(#, #)', arg1, arg2);
|
|
|
| - static Float64List _create3(arg1, arg2, arg3) {
|
| - return JS('Float64List', 'new Float64Array(#, #, #)', arg1, arg2, arg3);
|
| - }
|
| + static NativeFloat64List _create3(arg1, arg2, arg3) =>
|
| + JS('NativeFloat64List', 'new Float64Array(#, #, #)', arg1, arg2, arg3);
|
| }
|
|
|
|
|
| @@ -699,19 +1032,19 @@ class Float64List extends _NativeTypedArrayOfDouble native "Float64Array" {
|
| * [TypedData]. For long lists, this implementation can be considerably
|
| * more space- and time-efficient than the default [List] implementation.
|
| */
|
| -class Int16List extends _NativeTypedArrayOfInt native "Int16Array" {
|
| +abstract class Int16List extends TypedData implements List<int> {
|
| /**
|
| * Creates an [Int16List] of the specified length (in elements), all of
|
| * whose elements are initially zero.
|
| */
|
| - factory Int16List(int length) => _create1(_checkLength(length));
|
| + factory Int16List(int length) = NativeInt16List;
|
|
|
| /**
|
| * Creates a [Int16List] with the same size as the [elements] list
|
| * and copies over the elements.
|
| */
|
| - factory Int16List.fromList(List<int> list) =>
|
| - _create1(_ensureNativeList(list));
|
| + factory Int16List.fromList(List<int> elements) =>
|
| + new NativeInt16List.fromList(elements);
|
|
|
| /**
|
| * Creates an [Int16List] _view_ of the specified region in the specified
|
| @@ -729,14 +1062,31 @@ class Int16List extends _NativeTypedArrayOfInt native "Int16Array" {
|
| * BYTES_PER_ELEMENT.
|
| */
|
| factory Int16List.view(ByteBuffer buffer,
|
| - [int offsetInBytes = 0, int length]) {
|
| + [int offsetInBytes = 0, int length]) =>
|
| + new NativeInt16List.view(buffer, offsetInBytes, length);
|
| +
|
| + static const int BYTES_PER_ELEMENT = 2;
|
| +}
|
| +
|
| +class NativeInt16List
|
| + extends NativeTypedArrayOfInt
|
| + implements Int16List
|
| + native "Int16Array" {
|
| +
|
| + factory NativeInt16List(int length) => _create1(_checkLength(length));
|
| +
|
| + factory NativeInt16List.fromList(List<int> elements) =>
|
| + _create1(_ensureNativeList(elements));
|
| +
|
| + factory NativeInt16List.view(ByteBuffer buffer,
|
| + [int offsetInBytes = 0, int length]) {
|
| _checkViewArguments(buffer, offsetInBytes, length);
|
| return length == null
|
| ? _create2(buffer, offsetInBytes)
|
| : _create3(buffer, offsetInBytes, length);
|
| }
|
|
|
| - static const int BYTES_PER_ELEMENT = 2;
|
| + Type get runtimeType => Int16List;
|
|
|
| int operator[](int index) {
|
| _checkIndex(index, length);
|
| @@ -750,18 +1100,18 @@ class Int16List extends _NativeTypedArrayOfInt native "Int16Array" {
|
|
|
| List<int> sublist(int start, [int end]) {
|
| end = _checkSublistArguments(start, end, length);
|
| - var source = JS('Int16List', '#.subarray(#, #)', this, start, end);
|
| + var source = JS('NativeInt16List', '#.subarray(#, #)', this, start, end);
|
| return _create1(source);
|
| }
|
|
|
| - static Int16List _create1(arg) =>
|
| - JS('Int16List', 'new Int16Array(#)', arg);
|
| + static NativeInt16List _create1(arg) =>
|
| + JS('NativeInt16List', 'new Int16Array(#)', arg);
|
|
|
| - static Int16List _create2(arg1, arg2) =>
|
| - JS('Int16List', 'new Int16Array(#, #)', arg1, arg2);
|
| + static NativeInt16List _create2(arg1, arg2) =>
|
| + JS('NativeInt16List', 'new Int16Array(#, #)', arg1, arg2);
|
|
|
| - static Int16List _create3(arg1, arg2, arg3) =>
|
| - JS('Int16List', 'new Int16Array(#, #, #)', arg1, arg2, arg3);
|
| + static NativeInt16List _create3(arg1, arg2, arg3) =>
|
| + JS('NativeInt16List', 'new Int16Array(#, #, #)', arg1, arg2, arg3);
|
| }
|
|
|
|
|
| @@ -770,19 +1120,19 @@ class Int16List extends _NativeTypedArrayOfInt native "Int16Array" {
|
| * [TypedData]. For long lists, this implementation can be considerably
|
| * more space- and time-efficient than the default [List] implementation.
|
| */
|
| -class Int32List extends _NativeTypedArrayOfInt native "Int32Array" {
|
| +abstract class Int32List implements TypedData, List<int> {
|
| /**
|
| * Creates an [Int32List] of the specified length (in elements), all of
|
| * whose elements are initially zero.
|
| */
|
| - factory Int32List(int length) => _create1(_checkLength(length));
|
| + factory Int32List(int length) = NativeInt32List;
|
|
|
| /**
|
| * Creates a [Int32List] with the same size as the [elements] list
|
| * and copies over the elements.
|
| */
|
| - factory Int32List.fromList(List<int> list) =>
|
| - _create1(_ensureNativeList(list));
|
| + factory Int32List.fromList(List<int> elements) =>
|
| + new NativeInt32List.fromList(elements);
|
|
|
| /**
|
| * Creates an [Int32List] _view_ of the specified region in the specified
|
| @@ -800,14 +1150,31 @@ class Int32List extends _NativeTypedArrayOfInt native "Int32Array" {
|
| * BYTES_PER_ELEMENT.
|
| */
|
| factory Int32List.view(ByteBuffer buffer,
|
| - [int offsetInBytes = 0, int length]) {
|
| + [int offsetInBytes = 0, int length]) =>
|
| + new NativeInt32List.view(buffer, offsetInBytes, length);
|
| +
|
| + static const int BYTES_PER_ELEMENT = 4;
|
| +}
|
| +
|
| +class NativeInt32List
|
| + extends NativeTypedArrayOfInt
|
| + implements Int32List
|
| + native "Int32Array" {
|
| +
|
| + factory NativeInt32List(int length) => _create1(_checkLength(length));
|
| +
|
| + factory NativeInt32List.fromList(List<int> elements) =>
|
| + _create1(_ensureNativeList(elements));
|
| +
|
| + factory NativeInt32List.view(ByteBuffer buffer,
|
| + int offsetInBytes, int length) {
|
| _checkViewArguments(buffer, offsetInBytes, length);
|
| return length == null
|
| ? _create2(buffer, offsetInBytes)
|
| : _create3(buffer, offsetInBytes, length);
|
| }
|
|
|
| - static const int BYTES_PER_ELEMENT = 4;
|
| + Type get runtimeType => Int32List;
|
|
|
| int operator[](int index) {
|
| _checkIndex(index, length);
|
| @@ -821,18 +1188,18 @@ class Int32List extends _NativeTypedArrayOfInt native "Int32Array" {
|
|
|
| List<int> sublist(int start, [int end]) {
|
| end = _checkSublistArguments(start, end, length);
|
| - var source = JS('Int32List', '#.subarray(#, #)', this, start, end);
|
| + var source = JS('NativeInt32List', '#.subarray(#, #)', this, start, end);
|
| return _create1(source);
|
| }
|
|
|
| - static Int32List _create1(arg) =>
|
| - JS('Int32List', 'new Int32Array(#)', arg);
|
| + static NativeInt32List _create1(arg) =>
|
| + JS('NativeInt32List', 'new Int32Array(#)', arg);
|
|
|
| - static Int32List _create2(arg1, arg2) =>
|
| - JS('Int32List', 'new Int32Array(#, #)', arg1, arg2);
|
| + static NativeInt32List _create2(arg1, arg2) =>
|
| + JS('NativeInt32List', 'new Int32Array(#, #)', arg1, arg2);
|
|
|
| - static Int32List _create3(arg1, arg2, arg3) =>
|
| - JS('Int32List', 'new Int32Array(#, #, #)', arg1, arg2, arg3);
|
| + static NativeInt32List _create3(arg1, arg2, arg3) =>
|
| + JS('NativeInt32List', 'new Int32Array(#, #, #)', arg1, arg2, arg3);
|
| }
|
|
|
|
|
| @@ -841,19 +1208,19 @@ class Int32List extends _NativeTypedArrayOfInt native "Int32Array" {
|
| * For long lists, this implementation can be considerably
|
| * more space- and time-efficient than the default [List] implementation.
|
| */
|
| -class Int8List extends _NativeTypedArrayOfInt native "Int8Array" {
|
| +abstract class Int8List implements TypedData, List<int> {
|
| /**
|
| * Creates an [Int8List] of the specified length (in elements), all of
|
| * whose elements are initially zero.
|
| */
|
| - factory Int8List(int length) => _create1(_checkLength(length));
|
| + factory Int8List(int length) = NativeInt8List;
|
|
|
| /**
|
| * Creates a [Int8List] with the same size as the [elements] list
|
| * and copies over the elements.
|
| */
|
| - factory Int8List.fromList(List<int> list) =>
|
| - _create1(_ensureNativeList(list));
|
| + factory Int8List.fromList(List<int> elements) =>
|
| + new NativeInt8List.fromList(elements);
|
|
|
| /**
|
| * Creates an [Int8List] _view_ of the specified region in the specified
|
| @@ -868,14 +1235,31 @@ class Int8List extends _NativeTypedArrayOfInt native "Int8Array" {
|
| * the length of [buffer].
|
| */
|
| factory Int8List.view(ByteBuffer buffer,
|
| - [int offsetInBytes = 0, int length]) {
|
| + [int offsetInBytes = 0, int length])
|
| + => new NativeInt8List.view(buffer, offsetInBytes, length);
|
| +
|
| + static const int BYTES_PER_ELEMENT = 1;
|
| +}
|
| +
|
| +class NativeInt8List
|
| + extends NativeTypedArrayOfInt
|
| + implements Int8List
|
| + native "Int8Array" {
|
| +
|
| + factory NativeInt8List(int length) => _create1(_checkLength(length));
|
| +
|
| + factory NativeInt8List.fromList(List<int> elements) =>
|
| + _create1(_ensureNativeList(elements));
|
| +
|
| + factory NativeInt8List.view(ByteBuffer buffer,
|
| + int offsetInBytes, int length) {
|
| _checkViewArguments(buffer, offsetInBytes, length);
|
| return length == null
|
| ? _create2(buffer, offsetInBytes)
|
| : _create3(buffer, offsetInBytes, length);
|
| }
|
|
|
| - static const int BYTES_PER_ELEMENT = 1;
|
| + Type get runtimeType => Int8List;
|
|
|
| int operator[](int index) {
|
| _checkIndex(index, length);
|
| @@ -889,18 +1273,18 @@ class Int8List extends _NativeTypedArrayOfInt native "Int8Array" {
|
|
|
| List<int> sublist(int start, [int end]) {
|
| end = _checkSublistArguments(start, end, length);
|
| - var source = JS('Int8List', '#.subarray(#, #)', this, start, end);
|
| + var source = JS('NativeInt8List', '#.subarray(#, #)', this, start, end);
|
| return _create1(source);
|
| }
|
|
|
| - static Int8List _create1(arg) =>
|
| - JS('Int8List', 'new Int8Array(#)', arg);
|
| + static NativeInt8List _create1(arg) =>
|
| + JS('NativeInt8List', 'new Int8Array(#)', arg);
|
|
|
| - static Int8List _create2(arg1, arg2) =>
|
| - JS('Int8List', 'new Int8Array(#, #)', arg1, arg2);
|
| + static NativeInt8List _create2(arg1, arg2) =>
|
| + JS('NativeInt8List', 'new Int8Array(#, #)', arg1, arg2);
|
|
|
| static Int8List _create3(arg1, arg2, arg3) =>
|
| - JS('Int8List', 'new Int8Array(#, #, #)', arg1, arg2, arg3);
|
| + JS('NativeInt8List', 'new Int8Array(#, #, #)', arg1, arg2, arg3);
|
| }
|
|
|
|
|
| @@ -909,19 +1293,19 @@ class Int8List extends _NativeTypedArrayOfInt native "Int8Array" {
|
| * [TypedData]. For long lists, this implementation can be considerably
|
| * more space- and time-efficient than the default [List] implementation.
|
| */
|
| -class Uint16List extends _NativeTypedArrayOfInt native "Uint16Array" {
|
| +abstract class Uint16List implements TypedData, List<int> {
|
| /**
|
| * Creates a [Uint16List] of the specified length (in elements), all
|
| * of whose elements are initially zero.
|
| */
|
| - factory Uint16List(int length) => _create1(_checkLength(length));
|
| + factory Uint16List(int length) = NativeUint16List;
|
|
|
| /**
|
| * Creates a [Uint16List] with the same size as the [elements] list
|
| * and copies over the elements.
|
| */
|
| - factory Uint16List.fromList(List<int> list) =>
|
| - _create1(_ensureNativeList(list));
|
| + factory Uint16List.fromList(List<int> elements) =>
|
| + new NativeUint16List.fromList(elements);
|
|
|
| /**
|
| * Creates a [Uint16List] _view_ of the specified region in
|
| @@ -939,14 +1323,31 @@ class Uint16List extends _NativeTypedArrayOfInt native "Uint16Array" {
|
| * BYTES_PER_ELEMENT.
|
| */
|
| factory Uint16List.view(ByteBuffer buffer,
|
| - [int offsetInBytes = 0, int length]) {
|
| + [int offsetInBytes = 0, int length]) =>
|
| + new NativeUint16List.view(buffer, offsetInBytes, length);
|
| +
|
| + static const int BYTES_PER_ELEMENT = 2;
|
| +}
|
| +
|
| +class NativeUint16List
|
| + extends NativeTypedArrayOfInt
|
| + implements Uint16List
|
| + native "Uint16Array" {
|
| +
|
| + factory NativeUint16List(int length) => _create1(_checkLength(length));
|
| +
|
| + factory NativeUint16List.fromList(List<int> list) =>
|
| + _create1(_ensureNativeList(list));
|
| +
|
| + factory NativeUint16List.view(ByteBuffer buffer,
|
| + int offsetInBytes, int length) {
|
| _checkViewArguments(buffer, offsetInBytes, length);
|
| return length == null
|
| ? _create2(buffer, offsetInBytes)
|
| : _create3(buffer, offsetInBytes, length);
|
| }
|
|
|
| - static const int BYTES_PER_ELEMENT = 2;
|
| + Type get runtimeType => Uint16List;
|
|
|
| int operator[](int index) {
|
| _checkIndex(index, length);
|
| @@ -960,18 +1361,18 @@ class Uint16List extends _NativeTypedArrayOfInt native "Uint16Array" {
|
|
|
| List<int> sublist(int start, [int end]) {
|
| end = _checkSublistArguments(start, end, length);
|
| - var source = JS('Uint16List', '#.subarray(#, #)', this, start, end);
|
| + var source = JS('NativeUint16List', '#.subarray(#, #)', this, start, end);
|
| return _create1(source);
|
| }
|
|
|
| - static Uint16List _create1(arg) =>
|
| - JS('Uint16List', 'new Uint16Array(#)', arg);
|
| + static NativeUint16List _create1(arg) =>
|
| + JS('NativeUint16List', 'new Uint16Array(#)', arg);
|
|
|
| - static Uint16List _create2(arg1, arg2) =>
|
| - JS('Uint16List', 'new Uint16Array(#, #)', arg1, arg2);
|
| + static NativeUint16List _create2(arg1, arg2) =>
|
| + JS('NativeUint16List', 'new Uint16Array(#, #)', arg1, arg2);
|
|
|
| - static Uint16List _create3(arg1, arg2, arg3) =>
|
| - JS('Uint16List', 'new Uint16Array(#, #, #)', arg1, arg2, arg3);
|
| + static NativeUint16List _create3(arg1, arg2, arg3) =>
|
| + JS('NativeUint16List', 'new Uint16Array(#, #, #)', arg1, arg2, arg3);
|
| }
|
|
|
|
|
| @@ -980,19 +1381,19 @@ class Uint16List extends _NativeTypedArrayOfInt native "Uint16Array" {
|
| * [TypedData]. For long lists, this implementation can be considerably
|
| * more space- and time-efficient than the default [List] implementation.
|
| */
|
| -class Uint32List extends _NativeTypedArrayOfInt native "Uint32Array" {
|
| +abstract class Uint32List implements TypedData, List<int> {
|
| /**
|
| * Creates a [Uint32List] of the specified length (in elements), all
|
| * of whose elements are initially zero.
|
| */
|
| - factory Uint32List(int length) => _create1(_checkLength(length));
|
| + factory Uint32List(int length) = NativeUint32List;
|
|
|
| /**
|
| * Creates a [Uint32List] with the same size as the [elements] list
|
| * and copies over the elements.
|
| */
|
| - factory Uint32List.fromList(List<int> list) =>
|
| - _create1(_ensureNativeList(list));
|
| + factory Uint32List.fromList(List<int> elements) =>
|
| + new NativeUint32List.fromList(elements);
|
|
|
| /**
|
| * Creates a [Uint32List] _view_ of the specified region in
|
| @@ -1010,14 +1411,31 @@ class Uint32List extends _NativeTypedArrayOfInt native "Uint32Array" {
|
| * BYTES_PER_ELEMENT.
|
| */
|
| factory Uint32List.view(ByteBuffer buffer,
|
| - [int offsetInBytes = 0, int length]) {
|
| + [int offsetInBytes = 0, int length]) =>
|
| + new NativeUint32List.view(buffer, offsetInBytes, length);
|
| +
|
| + static const int BYTES_PER_ELEMENT = 4;
|
| +}
|
| +
|
| +class NativeUint32List
|
| + extends NativeTypedArrayOfInt
|
| + implements Uint32List
|
| + native "Uint32Array" {
|
| +
|
| + factory NativeUint32List(int length) => _create1(_checkLength(length));
|
| +
|
| + factory NativeUint32List.fromList(List<int> elements) =>
|
| + _create1(_ensureNativeList(elements));
|
| +
|
| + factory NativeUint32List.view(ByteBuffer buffer,
|
| + int offsetInBytes, int length) {
|
| _checkViewArguments(buffer, offsetInBytes, length);
|
| return length == null
|
| ? _create2(buffer, offsetInBytes)
|
| : _create3(buffer, offsetInBytes, length);
|
| }
|
|
|
| - static const int BYTES_PER_ELEMENT = 4;
|
| + Type get runtimeType => Uint32List;
|
|
|
| int operator[](int index) {
|
| _checkIndex(index, length);
|
| @@ -1031,18 +1449,18 @@ class Uint32List extends _NativeTypedArrayOfInt native "Uint32Array" {
|
|
|
| List<int> sublist(int start, [int end]) {
|
| end = _checkSublistArguments(start, end, length);
|
| - var source = JS('Uint32List', '#.subarray(#, #)', this, start, end);
|
| + var source = JS('NativeUint32List', '#.subarray(#, #)', this, start, end);
|
| return _create1(source);
|
| }
|
|
|
| - static Uint32List _create1(arg) =>
|
| - JS('Uint32List', 'new Uint32Array(#)', arg);
|
| + static NativeUint32List _create1(arg) =>
|
| + JS('NativeUint32List', 'new Uint32Array(#)', arg);
|
|
|
| - static Uint32List _create2(arg1, arg2) =>
|
| - JS('Uint32List', 'new Uint32Array(#, #)', arg1, arg2);
|
| + static NativeUint32List _create2(arg1, arg2) =>
|
| + JS('NativeUint32List', 'new Uint32Array(#, #)', arg1, arg2);
|
|
|
| - static Uint32List _create3(arg1, arg2, arg3) =>
|
| - JS('Uint32List', 'new Uint32Array(#, #, #)', arg1, arg2, arg3);
|
| + static NativeUint32List _create3(arg1, arg2, arg3) =>
|
| + JS('NativeUint32List', 'new Uint32Array(#, #, #)', arg1, arg2, arg3);
|
| }
|
|
|
|
|
| @@ -1052,20 +1470,19 @@ class Uint32List extends _NativeTypedArrayOfInt native "Uint32Array" {
|
| * more space- and time-efficient than the default [List] implementation.
|
| * Indexed store clamps the value to range 0..0xFF.
|
| */
|
| -class Uint8ClampedList extends _NativeTypedArrayOfInt
|
| - native "Uint8ClampedArray,CanvasPixelArray" {
|
| +abstract class Uint8ClampedList implements TypedData, List<int> {
|
| /**
|
| * Creates a [Uint8ClampedList] of the specified length (in elements), all of
|
| * whose elements are initially zero.
|
| */
|
| - factory Uint8ClampedList(int length) => _create1(_checkLength(length));
|
| + factory Uint8ClampedList(int length) = NativeUint8ClampedList;
|
|
|
| /**
|
| * Creates a [Uint8ClampedList] of the same size as the [elements]
|
| * list and copies over the values clamping when needed.
|
| */
|
| - factory Uint8ClampedList.fromList(List<int> list) =>
|
| - _create1(_ensureNativeList(list));
|
| + factory Uint8ClampedList.fromList(List<int> elements) =>
|
| + new NativeUint8ClampedList.fromList(_ensureNativeList(elements));
|
|
|
| /**
|
| * Creates a [Uint8ClampedList] _view_ of the specified region in the
|
| @@ -1080,14 +1497,31 @@ class Uint8ClampedList extends _NativeTypedArrayOfInt
|
| * the length of [buffer].
|
| */
|
| factory Uint8ClampedList.view(ByteBuffer buffer,
|
| - [int offsetInBytes = 0, int length]) {
|
| + [int offsetInBytes = 0, int length]) =>
|
| + new NativeUint8ClampedList.view(buffer, offsetInBytes, length);
|
| +
|
| + static const int BYTES_PER_ELEMENT = 1;
|
| +}
|
| +
|
| +class NativeUint8ClampedList
|
| + extends NativeTypedArrayOfInt
|
| + implements Uint8ClampedList
|
| + native "Uint8ClampedArray,CanvasPixelArray" {
|
| +
|
| + factory NativeUint8ClampedList(int length) => _create1(_checkLength(length));
|
| +
|
| + factory NativeUint8ClampedList.fromList(List<int> elements) =>
|
| + _create1(_ensureNativeList(elements));
|
| +
|
| + factory NativeUint8ClampedList.view(ByteBuffer buffer,
|
| + int offsetInBytes, int length) {
|
| _checkViewArguments(buffer, offsetInBytes, length);
|
| return length == null
|
| ? _create2(buffer, offsetInBytes)
|
| : _create3(buffer, offsetInBytes, length);
|
| }
|
|
|
| - static const int BYTES_PER_ELEMENT = 1;
|
| + Type get runtimeType => Uint8ClampedList;
|
|
|
| int get length => JS("JSUInt32", '#.length', this);
|
|
|
| @@ -1103,18 +1537,19 @@ class Uint8ClampedList extends _NativeTypedArrayOfInt
|
|
|
| List<int> sublist(int start, [int end]) {
|
| end = _checkSublistArguments(start, end, length);
|
| - var source = JS('Uint8ClampedList', '#.subarray(#, #)', this, start, end);
|
| + var source = JS('NativeUint8ClampedList', '#.subarray(#, #)',
|
| + this, start, end);
|
| return _create1(source);
|
| }
|
|
|
| - static Uint8ClampedList _create1(arg) =>
|
| - JS('Uint8ClampedList', 'new Uint8ClampedArray(#)', arg);
|
| + static NativeUint8ClampedList _create1(arg) =>
|
| + JS('NativeUint8ClampedList', 'new Uint8ClampedArray(#)', arg);
|
|
|
| - static Uint8ClampedList _create2(arg1, arg2) =>
|
| - JS('Uint8ClampedList', 'new Uint8ClampedArray(#, #)', arg1, arg2);
|
| + static NativeUint8ClampedList _create2(arg1, arg2) =>
|
| + JS('NativeUint8ClampedList', 'new Uint8ClampedArray(#, #)', arg1, arg2);
|
|
|
| - static Uint8ClampedList _create3(arg1, arg2, arg3) =>
|
| - JS('Uint8ClampedList', 'new Uint8ClampedArray(#, #, #)',
|
| + static NativeUint8ClampedList _create3(arg1, arg2, arg3) =>
|
| + JS('NativeUint8ClampedList', 'new Uint8ClampedArray(#, #, #)',
|
| arg1, arg2, arg3);
|
| }
|
|
|
| @@ -1124,24 +1559,19 @@ class Uint8ClampedList extends _NativeTypedArrayOfInt
|
| * For long lists, this implementation can be considerably
|
| * more space- and time-efficient than the default [List] implementation.
|
| */
|
| -class Uint8List extends _NativeTypedArrayOfInt
|
| - // On some browsers Uint8ClampedArray is a subtype of Uint8Array. Marking
|
| - // Uint8List as !nonleaf ensures that the native dispatch correctly handles
|
| - // the potential for Uint8ClampedArray to 'accidentally' pick up the
|
| - // dispatch record for Uint8List.
|
| - native "Uint8Array,!nonleaf" {
|
| +abstract class Uint8List implements TypedData, List<int> {
|
| /**
|
| * Creates a [Uint8List] of the specified length (in elements), all of
|
| * whose elements are initially zero.
|
| */
|
| - factory Uint8List(int length) => _create1(_checkLength(length));
|
| + factory Uint8List(int length) = NativeUint8List;
|
|
|
| /**
|
| * Creates a [Uint8List] with the same size as the [elements] list
|
| * and copies over the elements.
|
| */
|
| - factory Uint8List.fromList(List<int> list) =>
|
| - _create1(_ensureNativeList(list));
|
| + factory Uint8List.fromList(List<int> elements) =>
|
| + new NativeUint8List.fromList(elements);
|
|
|
| /**
|
| * Creates a [Uint8List] _view_ of the specified region in the specified
|
| @@ -1156,14 +1586,35 @@ class Uint8List extends _NativeTypedArrayOfInt
|
| * the length of [buffer].
|
| */
|
| factory Uint8List.view(ByteBuffer buffer,
|
| - [int offsetInBytes = 0, int length]) {
|
| + [int offsetInBytes = 0, int length]) =>
|
| + new NativeUint8List.view(buffer, offsetInBytes, length);
|
| +
|
| + static const int BYTES_PER_ELEMENT = 1;
|
| +}
|
| +
|
| +class NativeUint8List
|
| + extends NativeTypedArrayOfInt
|
| + implements Uint8List
|
| + // On some browsers Uint8ClampedArray is a subtype of Uint8Array. Marking
|
| + // Uint8List as !nonleaf ensures that the native dispatch correctly handles
|
| + // the potential for Uint8ClampedArray to 'accidentally' pick up the
|
| + // dispatch record for Uint8List.
|
| + native "Uint8Array,!nonleaf" {
|
| +
|
| + factory NativeUint8List(int length) => _create1(_checkLength(length));
|
| +
|
| + factory NativeUint8List.fromList(List<int> elements) =>
|
| + _create1(_ensureNativeList(elements));
|
| +
|
| + factory NativeUint8List.view(ByteBuffer buffer,
|
| + int offsetInBytes, int length) {
|
| _checkViewArguments(buffer, offsetInBytes, length);
|
| return length == null
|
| ? _create2(buffer, offsetInBytes)
|
| : _create3(buffer, offsetInBytes, length);
|
| }
|
|
|
| - static const int BYTES_PER_ELEMENT = 1;
|
| + Type get runtimeType => Uint8List;
|
|
|
| int get length => JS("JSUInt32", '#.length', this);
|
|
|
| @@ -1179,18 +1630,18 @@ class Uint8List extends _NativeTypedArrayOfInt
|
|
|
| List<int> sublist(int start, [int end]) {
|
| end = _checkSublistArguments(start, end, length);
|
| - var source = JS('Uint8List', '#.subarray(#, #)', this, start, end);
|
| + var source = JS('NativeUint8List', '#.subarray(#, #)', this, start, end);
|
| return _create1(source);
|
| }
|
|
|
| - static Uint8List _create1(arg) =>
|
| - JS('Uint8List', 'new Uint8Array(#)', arg);
|
| + static NativeUint8List _create1(arg) =>
|
| + JS('NativeUint8List', 'new Uint8Array(#)', arg);
|
|
|
| - static Uint8List _create2(arg1, arg2) =>
|
| - JS('Uint8List', 'new Uint8Array(#, #)', arg1, arg2);
|
| + static NativeUint8List _create2(arg1, arg2) =>
|
| + JS('NativeUint8List', 'new Uint8Array(#, #)', arg1, arg2);
|
|
|
| - static Uint8List _create3(arg1, arg2, arg3) =>
|
| - JS('Uint8List', 'new Uint8Array(#, #, #)', arg1, arg2, arg3);
|
| + static NativeUint8List _create3(arg1, arg2, arg3) =>
|
| + JS('NativeUint8List', 'new Uint8Array(#, #, #)', arg1, arg2, arg3);
|
| }
|
|
|
|
|
| @@ -1199,8 +1650,7 @@ class Uint8List extends _NativeTypedArrayOfInt
|
| * [TypedData]. For long lists, this implementation can be considerably
|
| * more space- and time-efficient than the default [List] implementation.
|
| */
|
| -abstract class Int64List extends TypedData
|
| - implements JavaScriptIndexingBehavior, List<int> {
|
| +abstract class Int64List extends TypedData implements List<int> {
|
| /**
|
| * Creates an [Int64List] of the specified length (in elements), all of
|
| * whose elements are initially zero.
|
| @@ -1245,8 +1695,7 @@ abstract class Int64List extends TypedData
|
| * [TypedData]. For long lists, this implementation can be considerably
|
| * more space- and time-efficient than the default [List] implementation.
|
| */
|
| -abstract class Uint64List extends TypedData
|
| - implements JavaScriptIndexingBehavior, List<int> {
|
| +abstract class Uint64List extends TypedData implements List<int> {
|
| /**
|
| * Creates a [Uint64List] of the specified length (in elements), all
|
| * of whose elements are initially zero.
|
| @@ -1344,10 +1793,10 @@ class Float32x4List
|
| : _storage = new Float32List(list.length * 4) {
|
| for (int i = 0; i < list.length; i++) {
|
| var e = list[i];
|
| - _storage[(i*4)+0] = e.x;
|
| - _storage[(i*4)+1] = e.y;
|
| - _storage[(i*4)+2] = e.z;
|
| - _storage[(i*4)+3] = e.w;
|
| + _storage[(i * 4) + 0] = e.x;
|
| + _storage[(i * 4) + 1] = e.y;
|
| + _storage[(i * 4) + 2] = e.z;
|
| + _storage[(i * 4) + 3] = e.w;
|
| }
|
| }
|
|
|
| @@ -1390,24 +1839,25 @@ class Float32x4List
|
|
|
| Float32x4 operator[](int index) {
|
| _checkIndex(index, length);
|
| - double _x = _storage[(index*4)+0];
|
| - double _y = _storage[(index*4)+1];
|
| - double _z = _storage[(index*4)+2];
|
| - double _w = _storage[(index*4)+3];
|
| + double _x = _storage[(index * 4) + 0];
|
| + double _y = _storage[(index * 4) + 1];
|
| + double _z = _storage[(index * 4) + 2];
|
| + double _w = _storage[(index * 4) + 3];
|
| return new Float32x4(_x, _y, _z, _w);
|
| }
|
|
|
| void operator[]=(int index, Float32x4 value) {
|
| _checkIndex(index, length);
|
| - _storage[(index*4)+0] = value._storage[0];
|
| - _storage[(index*4)+1] = value._storage[1];
|
| - _storage[(index*4)+2] = value._storage[2];
|
| - _storage[(index*4)+3] = value._storage[3];
|
| + _storage[(index * 4) + 0] = value._storage[0];
|
| + _storage[(index * 4) + 1] = value._storage[1];
|
| + _storage[(index * 4) + 2] = value._storage[2];
|
| + _storage[(index * 4) + 3] = value._storage[3];
|
| }
|
|
|
| List<Float32x4> sublist(int start, [int end]) {
|
| end = _checkSublistArguments(start, end, length);
|
| - return new Float32x4List._externalStorage(_storage.sublist(start*4, end*4));
|
| + return new Float32x4List._externalStorage(
|
| + _storage.sublist(start * 4, end * 4));
|
| }
|
| }
|
|
|
| @@ -1462,7 +1912,7 @@ class Int32x4List
|
| * Creates a [Int32x4List] of the specified length (in elements),
|
| * all of whose elements are initially zero.
|
| */
|
| - Int32x4List(int length) : _storage = new Uint32List(length*4);
|
| + Int32x4List(int length) : _storage = new Uint32List(length * 4);
|
|
|
| Int32x4List._externalStorage(Uint32List storage) : _storage = storage;
|
|
|
| @@ -1470,10 +1920,10 @@ class Int32x4List
|
| : _storage = new Uint32List(list.length * 4) {
|
| for (int i = 0; i < list.length; i++) {
|
| var e = list[i];
|
| - _storage[(i*4)+0] = e.x;
|
| - _storage[(i*4)+1] = e.y;
|
| - _storage[(i*4)+2] = e.z;
|
| - _storage[(i*4)+3] = e.w;
|
| + _storage[(i * 4) + 0] = e.x;
|
| + _storage[(i * 4) + 1] = e.y;
|
| + _storage[(i * 4) + 2] = e.z;
|
| + _storage[(i * 4) + 3] = e.w;
|
| }
|
| }
|
|
|
| @@ -1516,19 +1966,19 @@ class Int32x4List
|
|
|
| Int32x4 operator[](int index) {
|
| _checkIndex(index, length);
|
| - int _x = _storage[(index*4)+0];
|
| - int _y = _storage[(index*4)+1];
|
| - int _z = _storage[(index*4)+2];
|
| - int _w = _storage[(index*4)+3];
|
| + int _x = _storage[(index * 4) + 0];
|
| + int _y = _storage[(index * 4) + 1];
|
| + int _z = _storage[(index * 4) + 2];
|
| + int _w = _storage[(index * 4) + 3];
|
| return new Int32x4(_x, _y, _z, _w);
|
| }
|
|
|
| void operator[]=(int index, Int32x4 value) {
|
| _checkIndex(index, length);
|
| - _storage[(index*4)+0] = value._storage[0];
|
| - _storage[(index*4)+1] = value._storage[1];
|
| - _storage[(index*4)+2] = value._storage[2];
|
| - _storage[(index*4)+3] = value._storage[3];
|
| + _storage[(index * 4) + 0] = value._storage[0];
|
| + _storage[(index * 4) + 1] = value._storage[1];
|
| + _storage[(index * 4) + 2] = value._storage[2];
|
| + _storage[(index * 4) + 3] = value._storage[3];
|
| }
|
|
|
| List<Int32x4> sublist(int start, [int end]) {
|
|
|