Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 part of dart.typeddata; | |
| 6 | |
| 7 /** | |
| 8 * A sequence of bytes underlying a typed data object. | |
| 9 * Used to process large quantities of binary or numerical data | |
| 10 * more efficiently using a typed view. | |
| 11 */ | |
| 12 abstract class ByteBuffer { | |
| 13 /** | |
| 14 * Returns the length of this byte buffer, in bytes. | |
| 15 */ | |
| 16 int get lengthInBytes; | |
| 17 | |
| 18 } | |
| 19 | |
| 20 | |
| 21 /** | |
| 22 * A typed view of a sequence of bytes. | |
| 23 */ | |
| 24 abstract class TypedData { | |
| 25 /** | |
| 26 * Returns the number of bytes in the representation of each element in this l ist. | |
|
sra1
2013/02/28 02:41:58
Line length?
siva
2013/03/01 01:15:56
Fixed.
On 2013/02/28 02:41:58, sra1 wrote:
| |
| 27 */ | |
| 28 int get elementSizeInBytes; | |
| 29 | |
| 30 /** | |
| 31 * Returns the offset in bytes into the underlying byte buffer of this view. | |
| 32 */ | |
| 33 int get offsetInBytes; | |
| 34 | |
| 35 /** | |
| 36 * Returns the length of this view, in bytes. | |
| 37 */ | |
| 38 int get lengthInBytes; | |
| 39 | |
| 40 /** | |
| 41 * Returns the byte buffer associated with this object. | |
| 42 */ | |
| 43 ByteBuffer get buffer; | |
| 44 } | |
| 45 | |
| 46 | |
| 47 /** | |
| 48 * A fixed-length, random-access sequence of bytes that also provides random | |
| 49 * access to the fixed-width integers and floating point numbers represented | |
| 50 * by those bytes. | |
| 51 * ByteData may be used to pack and unpack data from external sources | |
| 52 * (such as networks or files systems), and to process large quantities | |
| 53 * of numerical data more efficiently than would be possible | |
| 54 * with ordinary [List] implementations. ByteData can save space, by | |
| 55 * eliminating the need for object headers, and time, by eliminating the | |
| 56 * need for data copies. Finally, ByteData may be used to intentionally | |
| 57 * reinterpret the bytes representing one arithmetic type as another. | |
| 58 * For example this code fragment determine what 32-bit signed integer | |
| 59 * is represented by the bytes of a 32-bit floating point number: | |
|
Ivan Posva
2013/02/28 05:00:02
As far as I remember the plan was to allow ByteDat
siva
2013/03/01 01:15:56
I thought random-access also meant unaligned acces
| |
| 60 * | |
| 61 * var buffer = new Uint8List(8).buffer; | |
| 62 * var bdata = new ByteData.view(buffer); | |
| 63 * bdata.setFloat32(0, 3.04); | |
| 64 * int huh = bdata.getInt32(0); | |
| 65 */ | |
| 66 abstract class ByteData implements TypedData { | |
| 67 /** | |
| 68 * Creates a [ByteData] of the specified length (in elements), all of | |
| 69 * whose elements are initially zero. | |
| 70 */ | |
| 71 external factory ByteData(int length); | |
| 72 | |
| 73 /** | |
| 74 * Creates an [ByteData] _view_ of the specified region in the specified | |
| 75 * byte buffer. Changes in the [ByteData] will be visible in the byte | |
| 76 * buffer and vice versa. If the [offsetInBytes] index of the region is not | |
| 77 * specified, it defaults to zero (the first byte in the byte buffer). | |
| 78 * If the length is not specified, it defaults to null, which indicates | |
| 79 * that the view extends to the end of the byte buffer. | |
| 80 * | |
| 81 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | |
| 82 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | |
| 83 * the length of this object. | |
| 84 */ | |
| 85 external factory ByteData.view(ByteBuffer buffer, | |
| 86 [int offsetInBytes = 0, int length]); | |
| 87 | |
| 88 /** | |
| 89 * Returns a [ByteData] _view_ of a portion of this ByteData object | |
| 90 * in the given range. | |
| 91 * [startIndex] is inclusive and [endIndex] is exclusive. | |
| 92 * The returned object is backed by the same byte buffer as this object. | |
| 93 * In other words, changes to the returned object are visible in this object | |
| 94 * and vice-versa. | |
| 95 * | |
| 96 * Throws [RangeError] if [startIndex] or [endIndex] are negative, or | |
| 97 * if [endIndex] is less than [startIndex], or | |
| 98 * if [startIndex] is greater than the length of this object, or | |
| 99 * if `endIndex - startIndex` is greater than the length of this object. | |
| 100 */ | |
| 101 ByteData subByteData(int startIndex, [int endIndex]); | |
|
Ivan Posva
2013/02/28 05:00:02
Basically this is a sugar for:
var sb = new ByteDa
siva
2013/03/01 01:15:56
Yes. It is basically sugar for that with the addit
| |
| 102 | |
| 103 /** | |
| 104 * Returns the (possibly negative) integer represented by the byte at the | |
| 105 * specified [byteOffset] in this object, in two's complement binary | |
| 106 * representation. The return value will be between -128 and 127, inclusive. | |
| 107 * | |
| 108 * Throws [RangeError] if [byteOffset] is negative, or | |
| 109 * greater than or equal to the length of this object. | |
| 110 */ | |
| 111 int getInt8(int byteOffset); | |
| 112 | |
| 113 /** | |
| 114 * Sets the byte at the specified [byteOffset] in this object to the | |
| 115 * two's complement binary representation of the specified [value], which | |
| 116 * must fit in a single byte. In other words, [value] must be between | |
| 117 * -128 and 127, inclusive. | |
| 118 * | |
| 119 * Returns `byteOffset + 1`, which is the offset of the first byte in the | |
|
Ivan Posva
2013/02/28 05:00:02
I am not sure I understand the purpose of the retu
siva
2013/03/01 01:15:56
I don't remember why this returns setInt8 (Carl at
| |
| 120 * buffer after the byte that was set by this call. This return value can | |
| 121 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | |
| 122 * | |
| 123 * Throws [RangeError] if [byteOffset] is negative, or | |
| 124 * greater than or equal to the length of this object. | |
| 125 */ | |
| 126 int setInt8(int byteOffset, int value); | |
| 127 | |
| 128 /** | |
| 129 * Returns the positive integer represented by the byte at the specified | |
| 130 * [byteOffset] in this object, in unsigned binary form. The | |
| 131 * return value will be between 0 and 255, inclusive. | |
| 132 * | |
| 133 * Throws [RangeError] if [byteOffset] is negative, or | |
| 134 * greater than or equal to the length of this object. | |
| 135 */ | |
| 136 int getUint8(int byteOffset); | |
| 137 | |
| 138 /** | |
| 139 * Sets the byte at the specified [byteOffset] in this object to the | |
| 140 * unsigned binary representation of the specified [value], which must fit | |
| 141 * in a single byte. in other words, [value] must be between 0 and 255, | |
| 142 * inclusive. | |
| 143 * | |
| 144 * Returns `byteOffset + 1`, which is the offset of the first byte in the | |
| 145 * buffer after the byte that was set by this call. This return value can | |
| 146 * be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | |
| 147 * | |
| 148 * Throws [RangeError] if [byteOffset] is negative, | |
| 149 * or greater than or equal to the length of this object. | |
| 150 */ | |
| 151 int setUint8(int byteOffset, int value); | |
| 152 | |
| 153 /** | |
| 154 * Returns the (possibly negative) integer represented by the two bytes at | |
| 155 * the specified [byteOffset] in this object, in two's complement binary | |
| 156 * form. | |
| 157 * The return value will be between 2<sup>15</sup> and 2<sup>15</sup> - 1, | |
| 158 * inclusive. | |
| 159 * | |
| 160 * Throws [RangeError] if [byteOffset] is negative, or | |
| 161 * `byteOffset + 2` is greater than the length of this object. | |
| 162 */ | |
| 163 int getInt16(int byteOffset); | |
| 164 | |
| 165 /** | |
| 166 * Sets the two bytes starting at the specified [byteOffset] in this | |
| 167 * object to the two's complement binary representation of the specified | |
| 168 * [value], which must fit in two bytes. In other words, [value] must lie | |
| 169 * between 2<sup>15</sup> and 2<sup>15</sup> - 1, inclusive. | |
| 170 * | |
| 171 * Returns `byteOffset + 2`, which is the offset of the first byte in this | |
| 172 * object after the last byte that was set by this call. This return value | |
| 173 * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | |
| 174 * | |
| 175 * Throws [RangeError] if [byteOffset] is negative, or | |
| 176 * `byteOffset + 2` is greater than the length of this object. | |
| 177 */ | |
| 178 int setInt16(int byteOffset, int value); | |
| 179 | |
| 180 /** | |
| 181 * Returns the positive integer represented by the two bytes starting | |
| 182 * at the specified [byteOffset] in this object, in unsigned binary | |
| 183 * form. | |
| 184 * The return value will be between 0 and 2<sup>16</sup> - 1, inclusive. | |
| 185 * | |
| 186 * Throws [RangeError] if [byteOffset] is negative, or | |
| 187 * `byteOffset + 2` is greater than the length of this object. | |
| 188 */ | |
| 189 int getUint16(int byteOffset); | |
| 190 | |
| 191 /** | |
| 192 * Sets the two bytes starting at the specified [byteOffset] in this object | |
| 193 * to the unsigned binary representation of the specified [value], | |
| 194 * which must fit in two bytes. in other words, [value] must be between | |
| 195 * 0 and 2<sup>16</sup> - 1, inclusive. | |
| 196 * | |
| 197 * Returns `byteOffset + 2`, which is the offset of the first byte in this | |
| 198 * object after the last byte that was set by this call. This return value | |
| 199 * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | |
| 200 * | |
| 201 * Throws [RangeError] if [byteOffset] is negative, or | |
| 202 * `byteOffset + 2` is greater than the length of this object. | |
| 203 */ | |
| 204 int setUint16(int byteOffset, int value); | |
| 205 | |
| 206 /** | |
| 207 * Returns the (possibly negative) integer represented by the four bytes at | |
| 208 * the specified [byteOffset] in this object, in two's complement binary | |
| 209 * form. | |
| 210 * The return value will be between 2<sup>31</sup> and 2<sup>31</sup> - 1, | |
| 211 * inclusive. | |
| 212 * | |
| 213 * Throws [RangeError] if [byteOffset] is negative, or | |
| 214 * `byteOffset + 4` is greater than the length of this object. | |
| 215 */ | |
| 216 int getInt32(int byteOffset); | |
| 217 | |
| 218 /** | |
| 219 * Sets the four bytes starting at the specified [byteOffset] in this | |
| 220 * object to the two's complement binary representation of the specified | |
| 221 * [value], which must fit in four bytes. In other words, [value] must lie | |
| 222 * between 2<sup>31</sup> and 2<sup>31</sup> - 1, inclusive. | |
| 223 * | |
| 224 * Returns `byteOffset + 4`, which is the offset of the first byte in this | |
| 225 * object after the last byte that was set by this call. This return value | |
| 226 * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | |
| 227 * | |
| 228 * Throws [RangeError] if [byteOffset] is negative, or | |
| 229 * `byteOffset + 4` is greater than the length of this object. | |
| 230 */ | |
| 231 int setInt32(int byteOffset, int value); | |
| 232 | |
| 233 /** | |
| 234 * Returns the positive integer represented by the four bytes starting | |
| 235 * at the specified [byteOffset] in this object, in unsigned binary | |
| 236 * form. | |
| 237 * The return value will be between 0 and 2<sup>32</sup> - 1, inclusive. | |
| 238 * | |
| 239 */ | |
| 240 int getUint32(int byteOffset); | |
| 241 | |
| 242 /** | |
| 243 * Sets the four bytes starting at the specified [byteOffset] in this object | |
| 244 * to the unsigned binary representation of the specified [value], | |
| 245 * which must fit in four bytes. in other words, [value] must be between | |
| 246 * 0 and 2<sup>32</sup> - 1, inclusive. | |
| 247 * | |
| 248 * Returns `byteOffset + 4`, which is the offset of the first byte in this | |
| 249 * object after the last byte that was set by this call. This return value | |
| 250 * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | |
| 251 * | |
| 252 * Throws [RangeError] if [byteOffset] is negative, or | |
| 253 * `byteOffset + 4` is greater than the length of this object. | |
| 254 */ | |
| 255 int setUint32(int byteOffset, int value); | |
| 256 | |
| 257 /** | |
| 258 * Returns the (possibly negative) integer represented by the eight bytes at | |
| 259 * the specified [byteOffset] in this object, in two's complement binary | |
| 260 * form. | |
| 261 * The return value will be between 2<sup>63</sup> and 2<sup>63</sup> - 1, | |
| 262 * inclusive. | |
| 263 * | |
| 264 * Throws [RangeError] if [byteOffset] is negative, or | |
| 265 * `byteOffset + 8` is greater than the length of this object. | |
| 266 */ | |
| 267 int getInt64(int byteOffset); | |
| 268 | |
| 269 /** | |
| 270 * Sets the eight bytes starting at the specified [byteOffset] in this | |
| 271 * object to the two's complement binary representation of the specified | |
| 272 * [value], which must fit in eight bytes. In other words, [value] must lie | |
| 273 * between 2<sup>63</sup> and 2<sup>63</sup> - 1, inclusive. | |
| 274 * | |
| 275 * Returns `byteOffset + 8`, which is the offset of the first byte in this | |
| 276 * object after the last byte that was set by this call. This return value | |
| 277 * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | |
| 278 * | |
| 279 * Throws [RangeError] if [byteOffset] is negative, or | |
| 280 * `byteOffset + 8` is greater than the length of this object. | |
| 281 */ | |
| 282 int setInt64(int byteOffset, int value); | |
| 283 | |
| 284 /** | |
| 285 * Returns the positive integer represented by the eight bytes starting | |
| 286 * at the specified [byteOffset] in this object, in unsigned binary | |
| 287 * form. | |
| 288 * The return value will be between 0 and 2<sup>64</sup> - 1, inclusive. | |
| 289 * | |
| 290 * Throws [RangeError] if [byteOffset] is negative, or | |
| 291 * `byteOffset + 8` is greater than the length of this object. | |
| 292 */ | |
| 293 int getUint64(int byteOffset); | |
| 294 | |
| 295 /** | |
| 296 * Sets the eight bytes starting at the specified [byteOffset] in this object | |
| 297 * to the unsigned binary representation of the specified [value], | |
| 298 * which must fit in eight bytes. in other words, [value] must be between | |
| 299 * 0 and 2<sup>64</sup> - 1, inclusive. | |
| 300 * | |
| 301 * Returns `byteOffset + 8`, which is the offset of the first byte in this | |
| 302 * object after the last byte that was set by this call. This return value | |
| 303 * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | |
| 304 * | |
| 305 * Throws [RangeError] if [byteOffset] is negative, or | |
| 306 * `byteOffset + 8` is greater than the length of this object. | |
| 307 */ | |
| 308 int setUint64(int byteOffset, int value); | |
| 309 | |
| 310 /** | |
| 311 * Returns the floating point number represented by the four bytes at | |
| 312 * the specified [byteOffset] in this object, in IEEE 754 | |
| 313 * single-precision binary floating-point format (binary32). | |
| 314 * | |
| 315 * Throws [RangeError] if [byteOffset] is negative, or | |
| 316 * `byteOffset + 4` is greater than the length of this object. | |
| 317 */ | |
| 318 double getFloat32(int byteOffset); | |
| 319 | |
| 320 /** | |
| 321 * Sets the four bytes starting at the specified [byteOffset] in this | |
| 322 * object to the IEEE 754 single-precision binary floating-point | |
| 323 * (binary32) representation of the specified [value]. | |
| 324 * | |
| 325 * **Note that this method can lose precision.** The input [value] is | |
| 326 * a 64-bit floating point value, which will be converted to 32-bit | |
| 327 * floating point value by IEEE 754 rounding rules before it is stored. | |
| 328 * If [value] cannot be represented exactly as a binary32, it will be | |
| 329 * converted to the nearest binary32 value. If two binary32 values are | |
| 330 * equally close, the one whose least significant bit is zero will be used. | |
| 331 * Note that finite (but large) values can be converted to infinity, and | |
| 332 * small non-zero values can be converted to zero. | |
| 333 * | |
| 334 * Returns `byteOffset + 4`, which is the offset of the first byte in this | |
| 335 * object after the last byte that was set by this call. This return value | |
| 336 * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | |
| 337 * | |
| 338 * Throws [RangeError] if [byteOffset] is negative, or | |
| 339 * `byteOffset + 4` is greater than the length of this object. | |
| 340 */ | |
| 341 int setFloat32(int byteOffset, double value); | |
| 342 | |
| 343 /** | |
| 344 * Returns the floating point number represented by the eight bytes at | |
| 345 * the specified [byteOffset] in this object, in IEEE 754 | |
| 346 * double-precision binary floating-point format (binary64). | |
| 347 * | |
| 348 * Throws [RangeError] if [byteOffset] is negative, or | |
| 349 * `byteOffset + 8` is greater than the length of this object. | |
| 350 */ | |
| 351 double getFloat64(int byteOffset); | |
| 352 | |
| 353 /** | |
| 354 * Sets the eight bytes starting at the specified [byteOffset] in this | |
| 355 * object to the IEEE 754 double-precision binary floating-point | |
| 356 * (binary64) representation of the specified [value]. | |
| 357 * | |
| 358 * Returns `byteOffset + 8`, which is the offset of the first byte in this | |
| 359 * object after the last byte that was set by this call. This return value | |
| 360 * can be passed as the [byteOffset] parameter to a subsequent `setXxx` call. | |
| 361 * | |
| 362 * Throws [RangeError] if [byteOffset] is negative, or | |
| 363 * `byteOffset + 8` is greater than the length of this object. | |
| 364 */ | |
| 365 int setFloat64(int byteOffset, double value); | |
| 366 } | |
| 367 | |
| 368 | |
| 369 /** | |
| 370 * A fixed-length list of 8-bit signed integers. | |
| 371 * For long lists, this implementation will be considerably | |
|
Ivan Posva
2013/02/28 05:00:02
will -> can
siva
2013/03/01 01:15:56
Done.
| |
| 372 * more space- and time-efficient than the default [List] implementation. | |
| 373 */ | |
| 374 abstract class Int8List implements List<int>, TypedData { | |
| 375 /** | |
| 376 * Creates an [Int8List] of the specified length (in elements), all of | |
| 377 * whose elements are initially zero. | |
| 378 */ | |
| 379 external factory Int8List(int length); | |
| 380 | |
| 381 /** | |
| 382 * Creates an [Int8List] _view_ of the specified region in the specified | |
| 383 * byte buffer. Changes in the [Int8List] will be visible in the byte | |
| 384 * buffer and vice versa. If the [offsetInBytes] index of the region is not | |
| 385 * specified, it defaults to zero (the first byte in the byte buffer). | |
| 386 * If the length is not specified, it defaults to null, which indicates | |
| 387 * that the view extends to the end of the byte buffer. | |
| 388 * | |
| 389 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | |
| 390 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | |
| 391 * the length of this object. | |
| 392 */ | |
| 393 external factory Int8List.view(ByteBuffer buffer, | |
| 394 [int offsetInBytes = 0, int length]); | |
| 395 | |
| 396 static const int BYTES_PER_ELEMENT = 1; | |
| 397 } | |
| 398 | |
| 399 | |
| 400 /** | |
| 401 * A fixed-length list of 8-bit unsigned integers. | |
| 402 * For long lists, this implementation will be considerably | |
| 403 * more space- and time-efficient than the default [List] implementation. | |
| 404 */ | |
| 405 abstract class Uint8List implements List<int>, TypedData { | |
| 406 /** | |
| 407 * Creates a [Uint8List] of the specified length (in elements), all of | |
| 408 * whose elements are initially zero. | |
| 409 */ | |
| 410 external factory Uint8List(int length); | |
| 411 | |
| 412 /** | |
| 413 * Creates a [Uint8List] _view_ of the specified region in the specified | |
| 414 * byte buffer. Changes in the [Uint8List] will be visible in the byte | |
| 415 * buffer and vice versa. If the [offsetInBytes] index of the region is not | |
| 416 * specified, it defaults to zero (the first byte in the byte buffer). | |
| 417 * If the length is not specified, it defaults to null, which indicates | |
| 418 * that the view extends to the end of the byte buffer. | |
| 419 * | |
| 420 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | |
| 421 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | |
| 422 * the length of this object. | |
| 423 */ | |
| 424 external factory Uint8List.view(ByteBuffer buffer, | |
| 425 [int offsetInBytes = 0, int length]); | |
| 426 | |
| 427 static const int BYTES_PER_ELEMENT = 1; | |
| 428 } | |
| 429 | |
| 430 | |
| 431 /** | |
| 432 * A fixed-length list of 8-bit unsigned integers. | |
| 433 * For long lists, this implementation will be considerably | |
| 434 * more space- and time-efficient than the default [List] implementation. | |
| 435 * Indexed store clamps the value to range 0..0xFF. | |
| 436 */ | |
| 437 abstract class Uint8ClampedList implements List<int>, TypedData { | |
| 438 /** | |
| 439 * Creates a [Uint8ClampedList] of the specified length (in elements), all of | |
| 440 * whose elements are initially zero. | |
| 441 */ | |
| 442 external factory Uint8ClampedList(int length); | |
| 443 | |
| 444 /** | |
| 445 * Creates a [Uint8ClampedList] _view_ of the specified region in the | |
| 446 * specified byte [buffer]. Changes in the [Uint8List] will be visible in the | |
| 447 * byte buffer and vice versa. If the [offsetInBytes] index of the region is n ot | |
| 448 * specified, it defaults to zero (the first byte in the byte buffer). If the | |
| 449 * length is not specified, it defaults to null, which indicates that the | |
| 450 * view extends to the end of the byte buffer. | |
| 451 * | |
| 452 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | |
| 453 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | |
| 454 * the length of this object. | |
| 455 */ | |
| 456 external factory Uint8ClampedList.view(ByteBuffer buffer, | |
| 457 [int offsetInBytes = 0, int length]); | |
| 458 | |
| 459 static const int BYTES_PER_ELEMENT = 1; | |
| 460 } | |
| 461 | |
| 462 | |
| 463 /** | |
| 464 * A fixed-length list of 16-bit signed integers that is viewable as a | |
| 465 * [ByteArray]. For long lists, this implementation will be considerably | |
| 466 * more space- and time-efficient than the default [List] implementation. | |
| 467 */ | |
| 468 abstract class Int16List implements List<int>, TypedData { | |
| 469 /** | |
| 470 * Creates an [Int16List] of the specified length (in elements), all of | |
| 471 * whose elements are initially zero. | |
| 472 */ | |
| 473 external factory Int16List(int length); | |
| 474 | |
| 475 /** | |
| 476 * Creates an [Int16List] _view_ of the specified region in the specified | |
| 477 * byte buffer. Changes in the [Int16List] will be visible in the byte | |
| 478 * buffer and vice versa. If the [offsetInBytes] index of the region is not | |
| 479 * specified, it defaults to zero (the first byte in the byte buffer). | |
| 480 * If the length is not specified, it defaults to null, which indicates | |
| 481 * that the view extends to the end of the byte buffer. | |
| 482 * | |
| 483 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | |
| 484 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | |
| 485 * the length of this object. | |
|
sra1
2013/02/28 02:41:58
this object -> [buffer]
siva
2013/03/01 01:15:56
Done.
| |
| 486 */ | |
| 487 external factory Int16List.view(ByteBuffer buffer, | |
| 488 [int offsetInBytes = 0, int length]); | |
|
Ivan Posva
2013/02/28 05:00:02
Isn't the expectation that offsetInBytes is aligne
siva
2013/03/01 01:15:56
The current scalarlist implementation doesn't seem
| |
| 489 | |
| 490 static const int BYTES_PER_ELEMENT = 2; | |
| 491 } | |
| 492 | |
| 493 | |
| 494 /** | |
| 495 * A fixed-length list of 16-bit unsigned integers that is viewable as a | |
| 496 * [ByteArray]. For long lists, this implementation will be considerably | |
| 497 * more space- and time-efficient than the default [List] implementation. | |
| 498 */ | |
| 499 abstract class Uint16List implements List<int>, TypedData { | |
| 500 /** | |
| 501 * Creates a [Uint16List] of the specified length (in elements), all | |
| 502 * of whose elements are initially zero. | |
| 503 */ | |
| 504 external factory Uint16List(int length); | |
| 505 | |
| 506 /** | |
| 507 * Creates a [Uint16List] _view_ of the specified region in | |
| 508 * the specified byte buffer. Changes in the [Uint16List] will be | |
| 509 * visible in the byte buffer and vice versa. If the [offsetInBytes] index | |
| 510 * of the region is not specified, it defaults to zero (the first byte in | |
| 511 * the byte buffer). If the length is not specified, it defaults to null, | |
| 512 * which indicates that the view extends to the end of the byte buffer. | |
| 513 * | |
| 514 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | |
| 515 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | |
| 516 * the length of this object. | |
| 517 */ | |
| 518 external factory Uint16List.view(ByteBuffer buffer, | |
| 519 [int offsetInBytes = 0, int length]); | |
| 520 | |
| 521 static const int BYTES_PER_ELEMENT = 2; | |
| 522 } | |
| 523 | |
| 524 | |
| 525 /** | |
| 526 * A fixed-length list of 32-bit signed integers that is viewable as a | |
| 527 * [ByteArray]. For long lists, this implementation will be considerably | |
| 528 * more space- and time-efficient than the default [List] implementation. | |
| 529 */ | |
| 530 abstract class Int32List implements List<int>, TypedData { | |
| 531 /** | |
| 532 * Creates an [Int32List] of the specified length (in elements), all of | |
| 533 * whose elements are initially zero. | |
| 534 */ | |
| 535 external factory Int32List(int length); | |
| 536 | |
| 537 /** | |
| 538 * Creates an [Int32List] _view_ of the specified region in the specified | |
| 539 * byte buffer. Changes in the [Int32List] will be visible in the byte | |
| 540 * buffer and vice versa. If the [offsetInBytes] index of the region is not | |
| 541 * specified, it defaults to zero (the first byte in the byte buffer). | |
| 542 * If the length is not specified, it defaults to null, which indicates | |
| 543 * that the view extends to the end of the byte buffer. | |
| 544 * | |
| 545 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | |
| 546 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | |
| 547 * the length of this object. | |
| 548 */ | |
| 549 external factory Int32List.view(ByteBuffer buffer, | |
| 550 [int offsetInBytes = 0, int length]); | |
| 551 | |
| 552 static const int BYTES_PER_ELEMENT = 4; | |
| 553 } | |
| 554 | |
| 555 | |
| 556 /** | |
| 557 * A fixed-length list of 32-bit unsigned integers that is viewable as a | |
| 558 * [ByteArray]. For long lists, this implementation will be considerably | |
| 559 * more space- and time-efficient than the default [List] implementation. | |
| 560 */ | |
| 561 abstract class Uint32List implements List<int>, TypedData { | |
| 562 /** | |
| 563 * Creates a [Uint32List] of the specified length (in elements), all | |
| 564 * of whose elements are initially zero. | |
| 565 */ | |
| 566 external factory Uint32List(int length); | |
| 567 | |
| 568 /** | |
| 569 * Creates a [Uint32List] _view_ of the specified region in | |
| 570 * the specified byte buffer. Changes in the [Uint32] will be | |
| 571 * visible in the byte buffer and vice versa. If the [offsetInBytes] index | |
| 572 * of the region is not specified, it defaults to zero (the first byte in | |
| 573 * the byte buffer). If the length is not specified, it defaults to null, | |
| 574 * which indicates that the view extends to the end of the byte buffer. | |
| 575 * | |
| 576 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | |
| 577 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | |
| 578 * the length of this object. | |
| 579 */ | |
| 580 external factory Uint32List.view(ByteBuffer buffer, | |
| 581 [int offsetInBytes = 0, int length]); | |
| 582 | |
| 583 static const int BYTES_PER_ELEMENT = 4; | |
| 584 } | |
| 585 | |
| 586 | |
| 587 /** | |
| 588 * A fixed-length list of 64-bit signed integers that is viewable as a | |
| 589 * [ByteArray]. For long lists, this implementation will be considerably | |
| 590 * more space- and time-efficient than the default [List] implementation. | |
| 591 */ | |
| 592 abstract class Int64List implements List<int>, TypedData { | |
| 593 /** | |
| 594 * Creates an [Int64List] of the specified length (in elements), all of | |
| 595 * whose elements are initially zero. | |
| 596 */ | |
| 597 external factory Int64List(int length); | |
| 598 | |
| 599 /** | |
| 600 * Creates an [Int64List] _view_ of the specified region in the specified | |
| 601 * byte buffer. Changes in the [Int64List] will be visible in the byte buffer | |
| 602 * and vice versa. If the [offsetInBytes] index of the region is not specified , | |
| 603 * it defaults to zero (the first byte in the byte buffer). If the length is | |
| 604 * not specified, it defaults to null, which indicates that the view extends | |
| 605 * to the end of the byte buffer. | |
| 606 * | |
| 607 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | |
| 608 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | |
| 609 * the length of this object. | |
| 610 */ | |
| 611 external factory Int64List.view(ByteBuffer buffer, | |
| 612 [int offsetInBytes = 0, int length]); | |
| 613 | |
| 614 static const int BYTES_PER_ELEMENT = 8; | |
| 615 } | |
| 616 | |
| 617 | |
| 618 /** | |
| 619 * A fixed-length list of 64-bit unsigned integers that is viewable as a | |
| 620 * [ByteArray]. For long lists, this implementation will be considerably | |
| 621 * more space- and time-efficient than the default [List] implementation. | |
|
sra1
2013/02/28 02:41:58
I agree that this boilerplate comment is true for
siva
2013/03/01 01:15:56
The comment was changed to 'can be'.
Your point a
| |
| 622 */ | |
| 623 abstract class Uint64List implements List<int>, TypedData { | |
| 624 /** | |
| 625 * Creates a [Uint64List] of the specified length (in elements), all | |
| 626 * of whose elements are initially zero. | |
| 627 */ | |
| 628 external factory Uint64List(int length); | |
| 629 | |
| 630 /** | |
| 631 * Creates an [Uint64List] _view_ of the specified region in | |
| 632 * the specified byte buffer. Changes in the [Uint64List] will be | |
| 633 * visible in the byte buffer and vice versa. If the [offsetInBytes] | |
| 634 * index of the region is not specified, it defaults to zero (the first | |
| 635 * byte in the byte buffer). If the length is not specified, it defaults | |
| 636 * to null, which indicates that the view extends to the end of the byte | |
| 637 * buffer. | |
| 638 * | |
| 639 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | |
| 640 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | |
| 641 * the length of this object. | |
| 642 */ | |
| 643 external factory Uint64List.view(ByteBuffer buffer, | |
| 644 [int offsetInBytes = 0, int length]); | |
| 645 | |
| 646 static const int BYTES_PER_ELEMENT = 8; | |
| 647 } | |
| 648 | |
| 649 | |
| 650 /** | |
| 651 * A fixed-length list of IEEE 754 single-precision binary floating-point | |
| 652 * numbers that is viewable as a [ByteArray]. For long lists, this | |
|
Ivan Posva
2013/02/28 05:00:02
ByteArray?
siva
2013/03/01 01:15:56
Done.
| |
| 653 * implementation will be considerably more space- and time-efficient than | |
| 654 * the default [List] implementation. | |
| 655 */ | |
| 656 abstract class Float32List implements List<double>, TypedData { | |
| 657 /** | |
| 658 * Creates a [Float32List] of the specified length (in elements), all of | |
| 659 * whose elements are initially zero. | |
| 660 */ | |
| 661 external factory Float32List(int length); | |
| 662 | |
| 663 /** | |
| 664 * Creates a [Float32List] _view_ of the specified region in the specified | |
| 665 * byte buffer. Changes in the [Float32List] will be visible in the byte | |
| 666 * buffer and vice versa. If the [offsetInBytes] index of the region is not | |
| 667 * specified, it defaults to zero (the first byte in the byte buffer). | |
| 668 * If the length is not specified, it defaults to null, which indicates | |
| 669 * that the view extends to the end of the byte buffer. | |
| 670 * | |
| 671 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | |
| 672 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | |
| 673 * the length of this object. | |
| 674 */ | |
| 675 external factory Float32List.view(ByteBuffer buffer, | |
| 676 [int offsetInBytes = 0, int length]); | |
| 677 | |
| 678 static const int BYTES_PER_ELEMENT = 4; | |
| 679 } | |
| 680 | |
| 681 | |
| 682 /** | |
| 683 * A fixed-length list of IEEE 754 double-precision binary floating-point | |
| 684 * numbers that is viewable as a [ByteArray]. For long lists, this | |
|
Ivan Posva
2013/02/28 05:00:02
ditto
siva
2013/03/01 01:15:56
Done.
| |
| 685 * implementation will be considerably more space- and time-efficient than | |
| 686 * the default [List] implementation. | |
| 687 */ | |
| 688 abstract class Float64List implements List<double>, TypedData { | |
| 689 /** | |
| 690 * Creates a [Float64List] of the specified length (in elements), all of | |
| 691 * whose elements are initially zero. | |
| 692 */ | |
| 693 external factory Float64List(int length); | |
| 694 | |
| 695 /** | |
| 696 * Creates a [Float64List] _view_ of the specified region in the specified | |
| 697 * byte buffer. Changes in the [Float64List] will be visible in the byte | |
| 698 * buffer and vice versa. If the [offsetInBytes] index of the region is not | |
| 699 * specified, it defaults to zero (the first byte in the byte buffer). | |
| 700 * If the length is not specified, it defaults to null, which indicates | |
| 701 * that the view extends to the end of the byte buffer. | |
| 702 * | |
| 703 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | |
| 704 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | |
| 705 * the length of this object. | |
| 706 */ | |
| 707 external factory Float64List.view(ByteBuffer buffer, | |
| 708 [int offsetInBytes = 0, int length]); | |
| 709 | |
| 710 static const int BYTES_PER_ELEMENT = 8; | |
| 711 } | |
| OLD | NEW |