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

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

Powered by Google App Engine
This is Rietveld 408576698