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

Unified Diff: sdk/lib/typeddata/typeddata_base.dart

Issue 12313088: First step towards implementing dart:typeddata library. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/typeddata/typeddata_base.dart
===================================================================
--- sdk/lib/typeddata/typeddata_base.dart (revision 0)
+++ sdk/lib/typeddata/typeddata_base.dart (revision 0)
@@ -0,0 +1,689 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of dart.typeddata;
+
+/**
+ * A sequence of bytes that can be used to process large quantities of
+ * numerical data more efficiently using a typed view.
sra1 2013/02/26 07:25:30 I don't really think of bitmaps and textures a 'nu
siva 2013/02/27 19:51:51 Reworded the comment. On 2013/02/26 07:25:30, sra
+ */
sra1 2013/02/26 07:25:30 I would say that this is the sequence of bytes und
siva 2013/02/27 19:51:51 Reworded the comment. On 2013/02/26 07:25:30, sra
+abstract class ByteBuffer {
+ /**
+ * Returns the length of this byte buffer, in bytes.
+ */
+ int lengthInBytes();
Lasse Reichstein Nielsen 2013/02/25 12:02:51 Should be a getter.
sra1 2013/02/26 07:25:30 'byteLength' would be more familiar to users of DO
siva 2013/02/27 19:51:51 I seem to prefer more verbose names as it clearly
siva 2013/02/27 19:51:51 Done.
+
+}
+
+
+/**
+ * A typed view of a sequence of bytes.
+ */
+abstract class TypedData {
sra1 2013/02/26 07:25:30 'TypedData' is a bit of a strange name. In Dart, a
siva 2013/02/27 19:51:51 I think in the g+ discussion there was a lot of ba
Lasse Reichstein Nielsen 2013/02/28 09:05:13 Do you have a link to this g+ discussion?
+ /**
+ * Returns the number of bytes in the representation of each element in
+ * this list, or the number bytes in the representation of the entire
+ * object if it is not a list.
sra1 2013/02/26 07:25:30 So elementSizeInBytes for a ByteData is not 1?
siva 2013/02/27 19:51:51 Removed that line in the comment regarding the ent
+ */
+ int elementSizeInBytes();
Lasse Reichstein Nielsen 2013/02/25 12:02:51 Also getter, and same for the ones below.
sra1 2013/02/26 07:25:30 'bytesPerElement' is shorter and would be more fam
siva 2013/02/27 19:51:51 Ditto comment regarding more verbose names. If the
siva 2013/02/27 19:51:51 Done.
+
+ /**
+ * Returns the offset in bytes into the underlying byte buffer of this view.
+ */
+ int offsetInBytes();
+
+ /**
+ * Returns the length of this view, in bytes.
+ */
+ int lengthInBytes();
+
+ /**
+ * Returns the byte buffer associated with this object.
+ */
+ ByteBuffer get buffer;
+}
+
+
+/**
+ * A fixed-length, random-access sequence of bytes that also provides random
+ * access to the fixed-width integers and floating point numbers represented
+ * by those bytes.
+ * ByteData may be used to pack and unpack data from external sources
+ * (such as networks or files systems), and to process large quantities
+ * of numerical data more efficiently than would be possible
+ * with ordinary [List] implementations. ByteData can save space, by
+ * eliminating the need for object headers, and time, by eliminating the
+ * need for data copies. Finally, ByteData may be used to intentionally
+ * reinterpret the bytes representing one arithmetic type as another.
+ * For example this code fragment determine what 64-bit signed integer
+ * is represented by the bytes of a 64-bit floating point number:
+ *
+ * var buffer = new Uint8List(8).buffer;
+ * var bdata = new ByteData.view(buffer);
+ * ba.setFloat64(0, 3.14159265358979323846);
sra1 2013/02/26 07:25:30 ba -> bdata
siva 2013/02/27 19:51:51 Done.
+ * int huh = ba.getInt64(0);
Lasse Reichstein Nielsen 2013/02/25 12:02:51 Should it be mentioned here that the code doesn't
sra1 2013/02/26 07:25:30 I would suggest (1) change the example to a 32-bi
siva 2013/02/27 19:51:51 Changed the example to a 32 bit example to avoid t
siva 2013/02/27 19:51:51 I have changed the example to use 32 bit values. W
+ */
+abstract class ByteData implements TypedData {
+ /**
+ * Creates a [ByteData] of the specified length (in elements), all of
+ * whose elements are initially zero.
+ */
+ external factory ByteData(int 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 [start] 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.
+ */
+ external factory ByteData.view(ByteBuffer buffer,
+ [int start = 0, int length]);
+
+ /**
+ * Returns a [ByteData] _view_ of a portion of this ByteData object
+ * in the given range.
+ * [startIndex] is inclusive and [endIndex] is exclusive.
+ * The returned object is backed by the same byte buffer as this object.
+ * In other words, changes to the returned object are visible in this object
+ * and vice-versa.
+ *
+ * Throws [RangeError] if [startIndex] or [endIndex] are negative, or
+ * if `endIndex - startIndex` is greater than the length of this object.
Lasse Reichstein Nielsen 2013/02/25 12:02:51 or if startIndex or endIndex are greater than the
siva 2013/02/27 19:51:51 Added conditions endIndex is less than startIndex,
+ */
+ ByteData subByteData(int startIndex, [int endIndex]);
+
+ /**
+ * 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);
+
+ /**
+ * 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.
+ *
+ * Returns `byteOffset + 1`, which is the offset of the first byte in the
+ * buffer after the byte that was set by this call. This return value can
+ * be passed as the [byteOffset] parameter to a subsequent `setXxx` call.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * greater than or equal to the length of this object.
+ *
+ * Throws [ArgumentError] if [value] is less than -128 or
+ * greater than 127.
+ */
+ int setInt8(int byteOffset, int value);
+
+ /**
+ * 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 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.
+ *
+ * Returns `byteOffset + 1`, which is the offset of the first byte in the
+ * buffer after the byte that was set by this call. This return value can
+ * be passed as the [byteOffset] parameter to a subsequent `setXxx` call.
+ *
+ * Throws [RangeError] if [byteOffset] is negative,
+ * or greater than or equal to the length of this object.
+ *
+ * Throws [ArgumentError] if [value] is negative or
+ * greater than 255.
sra1 2013/02/26 07:25:30 This check is not done by DataView, so it will be
Ivan Posva 2013/02/26 23:26:20 We had a agreed on silently truncating for all ope
siva 2013/02/27 19:51:51 Removed comment. On 2013/02/26 07:25:30, sra1 wro
siva 2013/02/27 19:51:51 Done.
+ */
+ int setUint8(int byteOffset, int value);
+
+ /**
+ * 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 - 1,
sra1 2013/02/26 07:25:30 Missing </sup>, also more below.
siva 2013/02/27 19:51:51 Done.
+ * inclusive.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 2` is greater than the length of this object.
sra1 2013/02/26 07:25:30 Endianness needs to be specified. I assume that t
Ivan Posva 2013/02/26 23:26:20 In this first cut we left out endian-specific API
siva 2013/02/27 19:51:51 I have left out the endianness stuff in the first
+ */
+ int getInt16(int byteOffset);
+
+ /**
+ * 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 - 1, inclusive.
+ *
+ * Returns `byteOffset + 2`, which is the offset of the first byte in this
+ * object after the last byte that was set by this call. This return value
+ * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 2` is greater than the length of this object.
+ *
+ * Throws [ArgumentError] if [value] is less than 2<sup>15</sup>
+ * or greater than 2<sup>15 - 1.
+ */
+ int setInt16(int byteOffset, int value);
+
+ /**
+ * 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 - 1, inclusive.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 2` is greater than the length of this object.
+ */
+ int getUint16(int byteOffset);
+
+ /**
+ * 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 - 1, inclusive.
+ *
+ * Returns `byteOffset + 2`, which is the offset of the first byte in this
+ * object after the last byte that was set by this call. This return value
+ * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 2` is greater than the length of this object.
+ *
+ * Throws [ArgumentError] if [value] is negative or
+ * greater than 2<sup>16 - 1.
+ */
+ int setUint16(int byteOffset, int value);
+
+ /**
+ * 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 - 1,
+ * inclusive.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 4` is greater than the length of this object.
+ */
+ int getInt32(int byteOffset);
+
+ /**
+ * 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 - 1, inclusive.
+ *
+ * Returns `byteOffset + 4`, which is the offset of the first byte in this
+ * object after the last byte that was set by this call. This return value
+ * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 4` is greater than the length of this object.
+ *
+ * Throws [ArgumentError] if [value] is less than 2<sup>31</sup>
+ * or greater than 2<sup>31 - 1.
+ */
+ int setInt32(int byteOffset, int value);
+
+ /**
+ * 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 - 1, inclusive.
+ *
+ */
+ int getUint32(int byteOffset);
+
+ /**
+ * 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 - 1, inclusive.
+ *
+ * Returns `byteOffset + 4`, which is the offset of the first byte in this
+ * object after the last byte that was set by this call. This return value
+ * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 4` is greater than the length of this object.
+ *
+ * Throws [ArgumentError] if [value] is negative or
+ * greater than 2<sup>32 - 1.
+ */
+ int setUint32(int byteOffset, int value);
+
+ /**
+ * 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 - 1,
+ * inclusive.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 8` is greater than the length of this object.
+ */
+ int getInt64(int byteOffset);
+
+ /**
+ * 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 - 1, inclusive.
+ *
+ * Returns `byteOffset + 8`, which is the offset of the first byte in this
+ * object after the last byte that was set by this call. This return value
+ * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 8` is greater than the length of this object.
+ *
+ * Throws [ArgumentError] if [value] is less than 2<sup>63</sup>
+ * or greater than 2<sup>63 - 1.
+ */
+ int setInt64(int byteOffset, int value);
+
+ /**
+ * 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 - 1, inclusive.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 8` is greater than the length of this object.
+ */
+ int getUint64(int byteOffset);
+
+ /**
+ * 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 - 1, inclusive.
+ *
+ * Returns `byteOffset + 8`, which is the offset of the first byte in this
+ * object after the last byte that was set by this call. This return value
+ * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 8` is greater than the length of this object.
+ *
+ * Throws [ArgumentError] if [value] is negative or
+ * greater than 2<sup>64 - 1.
+ */
+ int setUint64(int byteOffset, int value);
+
+ /**
+ * 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.
+ */
+ double getFloat32(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.
+ *
+ * Returns `byteOffset + 4`, which is the offset of the first byte in this
+ * object after the last byte that was set by this call. This return value
+ * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 4` is greater than the length of this object.
+ */
+ int setFloat32(int byteOffset, double value);
+
+ /**
+ * 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.
+ */
+ double getFloat64(int byteOffset);
+
+ /**
+ * 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].
+ *
+ * Returns `byteOffset + 8`, which is the offset of the first byte in this
+ * object after the last byte that was set by this call. This return value
+ * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call.
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 8` is greater than the length of this object.
+ */
+ int setFloat64(int byteOffset, double value);
+}
+
+
+/**
+ * A fixed-length list of 8-bit signed integers.
+ * For long lists, this implementation will be considerably
+ * more space- and time-efficient than the default [List] implementation.
+ */
+abstract class Int8List implements List<int>, TypedData {
+ /**
+ * Creates an [Int8List] of the specified length (in elements), all of
+ * whose elements are initially zero.
+ */
+ external factory Int8List(int length);
+
+ /**
+ * Creates an [Int8List] _view_ of the specified region in the specified
+ * byte buffer. Changes in the [Int8List] will be visible in the byte
+ * buffer and vice versa. If the [start] 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.
+ */
+ external factory Int8List.view(ByteBuffer buffer,
+ [int start = 0, int length]);
+}
+
+
+/**
+ * A fixed-length list of 8-bit unsigned integers.
+ * For long lists, this implementation will be considerably
+ * more space- and time-efficient than the default [List] implementation.
+ */
+abstract class Uint8List implements List<int>, TypedData {
+ /**
+ * Creates a [Uint8List] of the specified length (in elements), all of
+ * whose elements are initially zero.
+ */
+ external factory Uint8List(int length);
+
+ /**
+ * Creates a [Uint8List] _view_ of the specified region in the specified
+ * byte buffer. Changes in the [Uint8List] will be visible in the byte
+ * buffer and vice versa. If the [start] 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.
+ */
+ external factory Uint8List.view(ByteBuffer buffer,
+ [int start = 0, int length]);
+}
+
+
+/**
+ * A fixed-length list of 8-bit unsigned integers.
+ * For long lists, this implementation will be considerably
+ * more space- and time-efficient than the default [List] implementation.
+ * Indexed store clamps the value to range 0..0xFF.
+ */
+abstract class Uint8ClampedList implements List<int>, TypedData {
+ /**
+ * Creates a [Uint8ClampedList] of the specified length (in elements), all of
+ * whose elements are initially zero.
+ */
+ external factory Uint8ClampedList(int length);
+
+ /**
+ * Creates a [Uint8ClampedList] _view_ of the specified region in the
+ * specified byte [buffer]. Changes in the [Uint8List] will be visible in the
+ * byte buffer and vice versa. If the [start] 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.
+ */
+ external factory Uint8ClampedList.view(ByteBuffer buffer,
+ [int start = 0, int length]);
+}
+
+
+/**
+ * A fixed-length list of 16-bit signed integers that is viewable as a
+ * [ByteArray]. For long lists, this implementation will be considerably
+ * more space- and time-efficient than the default [List] implementation.
+ */
+abstract class Int16List implements List<int>, TypedData {
+ /**
+ * Creates an [Int16List] of the specified length (in elements), all of
+ * whose elements are initially zero.
+ */
+ external factory Int16List(int length);
+
+ /**
+ * Creates an [Int16List] _view_ of the specified region in the specified
+ * byte buffer. Changes in the [Int16List] will be visible in the byte
+ * buffer and vice versa. If the [start] 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 [ArgumentError] if the length of the specified region
Ivan Posva 2013/02/26 23:26:20 As discussed length is length in elements like in
siva 2013/02/27 19:51:51 Removed comment and changed the name 'start' to 'o
+ * is not divisible by 2 (the size of an "int16" in bytes), or if the
+ * [start] of the region is not divisible by 2.
sra1 2013/02/26 07:25:30 It took me a long time to see that [start] was ali
siva 2013/02/27 19:51:51 [start] is not aligned renamed [start] to [offsetI
+ */
sra1 2013/02/26 07:25:30 This 'length' is different to the other constructo
siva 2013/02/27 19:51:51 'length' is length counted in elements. On 2013/0
+ external factory Int16List.view(ByteBuffer buffer,
+ [int start = 0, int length]);
sra1 2013/02/26 07:25:30 Other things being equal, a constructor for an obj
siva 2013/02/27 19:51:51 renamed start to offsetInBytes. length is not leng
+}
sra1 2013/02/26 07:25:30 The JS class/constructor, Int16Array, has a static
siva 2013/02/27 19:51:51 I have added a BYTES_PER_ELEMENT constant in each
+
+
+/**
+ * A fixed-length list of 16-bit unsigned integers that is viewable as a
+ * [ByteArray]. For long lists, this implementation will be considerably
+ * more space- and time-efficient than the default [List] implementation.
+ */
+abstract class Uint16List implements List<int>, TypedData {
+ /**
+ * Creates a [Uint16List] of the specified length (in elements), all
+ * of whose elements are initially zero.
+ */
+ external factory Uint16List(int length);
+
+ /**
+ * Creates a [Uint16List] _view_ of the specified region in
+ * the specified byte buffer. Changes in the [Uint16List] will be
+ * visible in the byte buffer and vice versa. If the [start] 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 [ArgumentError] if the length of the specified region
+ * is not divisible by 2 (the size of a "uint16" in bytes), or if the
+ * [start] of the region is not divisible by 2.
+ */
+ external factory Uint16List.view(ByteBuffer buffer,
+ [int start = 0, int length]);
+}
+
+
+/**
+ * A fixed-length list of 32-bit signed integers that is viewable as a
+ * [ByteArray]. For long lists, this implementation will be considerably
+ * more space- and time-efficient than the default [List] implementation.
+ */
+abstract class Int32List implements List<int>, TypedData {
+ /**
+ * Creates an [Int32List] of the specified length (in elements), all of
+ * whose elements are initially zero.
+ */
+ external factory Int32List(int length);
+
+ /**
+ * Creates an [Int32List] _view_ of the specified region in the specified
+ * byte buffer. Changes in the [Int32List] will be visible in the byte
+ * buffer and vice versa. If the [start] 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 [ArgumentError] if the length of the specified region
+ * is not divisible by 4 (the size of an "int32" in bytes), or if the
+ * [start] of the region is not divisible by 4.
+ */
+ external factory Int32List.view(ByteBuffer buffer,
+ [int start = 0, int length]);
+}
+
+
+/**
+ * A fixed-length list of 32-bit unsigned integers that is viewable as a
+ * [ByteArray]. For long lists, this implementation will be considerably
+ * more space- and time-efficient than the default [List] implementation.
+ */
+abstract class Uint32List implements List<int>, TypedData {
+ /**
+ * Creates a [Uint32List] of the specified length (in elements), all
+ * of whose elements are initially zero.
+ */
+ external factory Uint32List(int length);
+
+ /**
+ * Creates a [Uint32List] _view_ of the specified region in
+ * the specified byte buffer. Changes in the [Uint32] will be
+ * visible in the byte buffer and vice versa. If the [start] 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 [ArgumentError] if the length of the specified region
+ * is not divisible by 4 (the size of a "uint32" in bytes), or if the
+ * [start] of the region is not divisible by 4.
+ */
+ external factory Uint32List.view(ByteBuffer buffer,
Anton Muhin 2013/02/25 20:11:20 there are no .transferable constructors, is it by
siva 2013/02/27 19:51:51 In this first cut I have left out the transferable
+ [int start = 0, int length]);
+}
+
+
+/**
+ * A fixed-length list of 64-bit signed integers that is viewable as a
+ * [ByteArray]. For long lists, this implementation will be considerably
+ * more space- and time-efficient than the default [List] implementation.
+ */
+abstract class Int64List implements List<int>, TypedData {
+ /**
+ * Creates an [Int64List] of the specified length (in elements), all of
+ * whose elements are initially zero.
+ */
+ external factory Int64List(int length);
+
+ /**
+ * Creates an [Int64List] _view_ of the specified region in the specified
+ * byte buffer. Changes in the [Int64List] will be visible in the byte buffer
+ * and vice versa. If the [start] 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 [ArgumentError] if the length of the specified region
+ * is not divisible by 8 (the size of an "int64" in bytes), or if the
+ * [start] of the region is not divisible by 8.
+ */
+ external factory Int64List.view(ByteBuffer buffer,
+ [int start = 0, int length]);
+}
+
+
+/**
+ * A fixed-length list of 64-bit unsigned integers that is viewable as a
+ * [ByteArray]. For long lists, this implementation will be considerably
+ * more space- and time-efficient than the default [List] implementation.
+ */
+abstract class Uint64List implements List<int>, TypedData {
+ /**
+ * Creates a [Uint64List] of the specified length (in elements), all
+ * of whose elements are initially zero.
+ */
+ external factory Uint64List(int length);
+
+ /**
+ * Creates an [Uint64List] _view_ of the specified region in
+ * the specified byte buffer. Changes in the [Uint64List] will be
+ * visible in the byte buffer and vice versa. If the [start] 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 [ArgumentError] if the length of the specified region
+ * is not divisible by 8 (the size of a "uint64" in bytes), or if the
+ * [start] of the region is not divisible by 8.
+ */
+ external factory Uint64List.view(ByteBuffer buffer,
+ [int start = 0, int length]);
+}
+
+
+/**
+ * A fixed-length list of IEEE 754 single-precision binary floating-point
+ * numbers that is viewable as a [ByteArray]. For long lists, this
+ * implementation will be considerably more space- and time-efficient than
+ * the default [List] implementation.
+ */
+abstract class Float32List implements List<double>, TypedData {
+ /**
+ * Creates a [Float32List] of the specified length (in elements), all of
+ * whose elements are initially zero.
+ */
+ external factory Float32List(int length);
+
+ /**
+ * Creates a [Float32List] _view_ of the specified region in the specified
+ * byte buffer. Changes in the [Float32List] will be visible in the byte
+ * buffer and vice versa. If the [start] 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 [ArgumentError] if the length of the specified region
+ * is not divisible by 4 (the size of a "float32" in bytes), or if the
+ * [start] of the region is not divisible by 4.
+ */
+ external factory Float32List.view(ByteBuffer buffer,
+ [int start = 0, int length]);
+}
+
+
+/**
+ * A fixed-length list of IEEE 754 double-precision binary floating-point
+ * numbers that is viewable as a [ByteArray]. For long lists, this
+ * implementation will be considerably more space- and time-efficient than
+ * the default [List] implementation.
+ */
+abstract class Float64List implements List<double>, TypedData {
+ /**
+ * Creates a [Float64List] of the specified length (in elements), all of
+ * whose elements are initially zero.
+ */
+ external factory Float64List(int length);
+
+ /**
+ * Creates a [Float64List] _view_ of the specified region in the specified
+ * byte buffer. Changes in the [Float64List] will be visible in the byte
+ * buffer and vice versa. If the [start] 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 [ArgumentError] if the length of the specified region
+ * is not divisible by 8 (the size of a "float64" in bytes), or if the
+ * [start] of the region is not divisible by 8.
+ */
+ external factory Float64List.view(ByteBuffer buffer,
+ [int start = 0, int length]);
+}

Powered by Google App Engine
This is Rietveld 408576698