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

Side by Side Diff: dart/sdk/lib/typed_data/dart2js/typed_data_dart2js.dart

Issue 66253002: Version 0.8.10.9 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « dart/sdk/lib/math/point.dart ('k') | dart/tests/co19/co19-analyzer.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Specialized integers and floating point numbers, 6 * Specialized integers and floating point numbers,
7 * with SIMD support and efficient lists. 7 * with SIMD support and efficient lists.
8 */ 8 */
9 library dart.typed_data; 9 library dart.typed_data;
10 10
(...skipping 12 matching lines...) Expand all
23 static const Endianness BIG_ENDIAN = const Endianness(false); 23 static const Endianness BIG_ENDIAN = const Endianness(false);
24 static const Endianness LITTLE_ENDIAN = const Endianness(true); 24 static const Endianness LITTLE_ENDIAN = const Endianness(true);
25 static final Endianness HOST_ENDIAN = 25 static final Endianness HOST_ENDIAN =
26 (new ByteData.view(new Int16List.fromList([1]).buffer)).getInt8(0) == 1 ? 26 (new ByteData.view(new Int16List.fromList([1]).buffer)).getInt8(0) == 1 ?
27 LITTLE_ENDIAN : BIG_ENDIAN; 27 LITTLE_ENDIAN : BIG_ENDIAN;
28 28
29 final bool _littleEndian; 29 final bool _littleEndian;
30 } 30 }
31 31
32 32
33 /**
34 * A sequence of bytes underlying a typed data object.
35 * Used to process large quantities of binary or numerical data
36 * more efficiently using a typed view.
37 */
33 class ByteBuffer native "ArrayBuffer" { 38 class ByteBuffer native "ArrayBuffer" {
34 @JSName('byteLength') 39 @JSName('byteLength')
35 final int lengthInBytes; 40 final int lengthInBytes;
36 } 41 }
37 42
38 // TODO(12929): Remove this constant once V8 optimizes length access of 43 // TODO(12929): Remove this constant once V8 optimizes length access of
39 // typed arrays. Firefox does not like accessing a named property of a 44 // typed arrays. Firefox does not like accessing a named property of a
40 // typed array, so we only use the new [:$dartCachedLength:] property in V8 and 45 // typed array, so we only use the new [:$dartCachedLength:] property in V8 and
41 // Chrome. 46 // Chrome.
42 const fetchLength = const JS_CONST(r''' 47 const fetchLength = const JS_CONST(r'''
43 ((typeof version == "function" && typeof os == "object" && "system" in os) 48 ((typeof version == "function" && typeof os == "object" && "system" in os)
44 || (typeof navigator == "object" 49 || (typeof navigator == "object"
45 && navigator.userAgent.indexOf('Chrome') != -1)) 50 && navigator.userAgent.indexOf('Chrome') != -1))
46 ? function(x) { return x.$dartCachedLength || x.length; } 51 ? function(x) { return x.$dartCachedLength || x.length; }
47 : function(x) { return x.length; }; 52 : function(x) { return x.length; };
48 '''); 53 ''');
49 54
55 /**
56 * A typed view of a sequence of bytes.
57 */
50 class TypedData native "ArrayBufferView" { 58 class TypedData native "ArrayBufferView" {
59 /**
60 * Returns the byte buffer associated with this object.
61 */
51 @Creates('ByteBuffer') 62 @Creates('ByteBuffer')
52 @Returns('ByteBuffer|Null') 63 @Returns('ByteBuffer|Null')
53 final ByteBuffer buffer; 64 final ByteBuffer buffer;
54 65
66 /**
67 * Returns the length of this view, in bytes.
68 */
55 @JSName('byteLength') 69 @JSName('byteLength')
56 final int lengthInBytes; 70 final int lengthInBytes;
57 71
72 /**
73 * Returns the offset in bytes into the underlying byte buffer of this view.
74 */
58 @JSName('byteOffset') 75 @JSName('byteOffset')
59 final int offsetInBytes; 76 final int offsetInBytes;
60 77
78 /**
79 * Returns the number of bytes in the representation of each element in this
80 * list.
81 */
61 @JSName('BYTES_PER_ELEMENT') 82 @JSName('BYTES_PER_ELEMENT')
62 final int elementSizeInBytes; 83 final int elementSizeInBytes;
63 84
64 void _invalidIndex(int index, int length) { 85 void _invalidIndex(int index, int length) {
65 if (index < 0 || index >= length) { 86 if (index < 0 || index >= length) {
66 throw new RangeError.range(index, 0, length); 87 throw new RangeError.range(index, 0, length);
67 } else { 88 } else {
68 throw new ArgumentError('Invalid list index $index'); 89 throw new ArgumentError('Invalid list index $index');
69 } 90 }
70 } 91 }
(...skipping 24 matching lines...) Expand all
95 } 116 }
96 117
97 118
98 // Ensures that [list] is a JavaScript Array or a typed array. If necessary, 119 // Ensures that [list] is a JavaScript Array or a typed array. If necessary,
99 // returns a copy of the list. 120 // returns a copy of the list.
100 List _ensureNativeList(List list) { 121 List _ensureNativeList(List list) {
101 return list; // TODO: make sure. 122 return list; // TODO: make sure.
102 } 123 }
103 124
104 125
126 /**
127 * A fixed-length, random-access sequence of bytes that also provides random
128 * and unaligned access to the fixed-width integers and floating point
129 * numbers represented by those bytes.
130 * ByteData may be used to pack and unpack data from external sources
131 * (such as networks or files systems), and to process large quantities
132 * of numerical data more efficiently than would be possible
133 * with ordinary [List] implementations. ByteData can save space, by
134 * eliminating the need for object headers, and time, by eliminating the
135 * need for data copies. Finally, ByteData may be used to intentionally
136 * reinterpret the bytes representing one arithmetic type as another.
137 * For example this code fragment determine what 32-bit signed integer
138 * is represented by the bytes of a 32-bit floating point number:
139 *
140 * var buffer = new Uint8List(8).buffer;
141 * var bdata = new ByteData.view(buffer);
142 * bdata.setFloat32(0, 3.04);
143 * int huh = bdata.getInt32(0);
144 */
105 class ByteData extends TypedData native "DataView" { 145 class ByteData extends TypedData native "DataView" {
146 /**
147 * Creates a [ByteData] of the specified length (in elements), all of
148 * whose elements are initially zero.
149 */
106 factory ByteData(int length) => _create1(length); 150 factory ByteData(int length) => _create1(length);
107 151
152 /**
153 * Creates an [ByteData] _view_ of the specified region in the specified
154 * byte buffer. Changes in the [ByteData] will be visible in the byte
155 * buffer and vice versa. If the [offsetInBytes] index of the region is not
156 * specified, it defaults to zero (the first byte in the byte buffer).
157 * If the length is not specified, it defaults to null, which indicates
158 * that the view extends to the end of the byte buffer.
159 *
160 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
161 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
162 * the length of [buffer].
163 */
108 factory ByteData.view(ByteBuffer buffer, 164 factory ByteData.view(ByteBuffer buffer,
109 [int byteOffset = 0, int byteLength]) => 165 [int byteOffset = 0, int byteLength]) =>
110 byteLength == null 166 byteLength == null
111 ? _create2(buffer, byteOffset) 167 ? _create2(buffer, byteOffset)
112 : _create3(buffer, byteOffset, byteLength); 168 : _create3(buffer, byteOffset, byteLength);
113 169
170 /**
171 * Returns the floating point number represented by the four bytes at
172 * the specified [byteOffset] in this object, in IEEE 754
173 * single-precision binary floating-point format (binary32).
174 *
175 * Throws [RangeError] if [byteOffset] is negative, or
176 * `byteOffset + 4` is greater than the length of this object.
177 */
114 num getFloat32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => 178 num getFloat32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) =>
115 _getFloat32(byteOffset, endian._littleEndian); 179 _getFloat32(byteOffset, endian._littleEndian);
116 180
117 @JSName('getFloat32') 181 @JSName('getFloat32')
118 @Returns('num') 182 @Returns('num')
119 num _getFloat32(int byteOffset, [bool littleEndian]) native; 183 num _getFloat32(int byteOffset, [bool littleEndian]) native;
120 184
185 /**
186 * Returns the floating point number represented by the eight bytes at
187 * the specified [byteOffset] in this object, in IEEE 754
188 * double-precision binary floating-point format (binary64).
189 *
190 * Throws [RangeError] if [byteOffset] is negative, or
191 * `byteOffset + 8` is greater than the length of this object.
192 */
121 num getFloat64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => 193 num getFloat64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) =>
122 _getFloat64(byteOffset, endian._littleEndian); 194 _getFloat64(byteOffset, endian._littleEndian);
123 195
124 @JSName('getFloat64') 196 @JSName('getFloat64')
125 @Returns('num') 197 @Returns('num')
126 num _getFloat64(int byteOffset, [bool littleEndian]) native; 198 num _getFloat64(int byteOffset, [bool littleEndian]) native;
127 199
200 /**
201 * Returns the (possibly negative) integer represented by the two bytes at
202 * the specified [byteOffset] in this object, in two's complement binary
203 * form.
204 * The return value will be between 2<sup>15</sup> and 2<sup>15</sup> - 1,
205 * inclusive.
206 *
207 * Throws [RangeError] if [byteOffset] is negative, or
208 * `byteOffset + 2` is greater than the length of this object.
209 */
128 int getInt16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => 210 int getInt16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) =>
129 _getInt16(byteOffset, endian._littleEndian); 211 _getInt16(byteOffset, endian._littleEndian);
130 212
131 @JSName('getInt16') 213 @JSName('getInt16')
132 @Returns('int') 214 @Returns('int')
133 int _getInt16(int byteOffset, [bool littleEndian]) native; 215 int _getInt16(int byteOffset, [bool littleEndian]) native;
134 216
217 /**
218 * Returns the (possibly negative) integer represented by the four bytes at
219 * the specified [byteOffset] in this object, in two's complement binary
220 * form.
221 * The return value will be between 2<sup>31</sup> and 2<sup>31</sup> - 1,
222 * inclusive.
223 *
224 * Throws [RangeError] if [byteOffset] is negative, or
225 * `byteOffset + 4` is greater than the length of this object.
226 */
135 int getInt32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => 227 int getInt32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) =>
136 _getInt32(byteOffset, endian._littleEndian); 228 _getInt32(byteOffset, endian._littleEndian);
137 229
138 @JSName('getInt32') 230 @JSName('getInt32')
139 @Returns('int') 231 @Returns('int')
140 int _getInt32(int byteOffset, [bool littleEndian]) native; 232 int _getInt32(int byteOffset, [bool littleEndian]) native;
141 233
234 /**
235 * Returns the (possibly negative) integer represented by the eight bytes at
236 * the specified [byteOffset] in this object, in two's complement binary
237 * form.
238 * The return value will be between 2<sup>63</sup> and 2<sup>63</sup> - 1,
239 * inclusive.
240 *
241 * Throws [RangeError] if [byteOffset] is negative, or
242 * `byteOffset + 8` is greater than the length of this object.
243 */
142 int getInt64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) { 244 int getInt64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) {
143 throw new UnsupportedError("Int64 accessor not supported by dart2js."); 245 throw new UnsupportedError("Int64 accessor not supported by dart2js.");
144 } 246 }
145 247
248 /**
249 * Returns the (possibly negative) integer represented by the byte at the
250 * specified [byteOffset] in this object, in two's complement binary
251 * representation. The return value will be between -128 and 127, inclusive.
252 *
253 * Throws [RangeError] if [byteOffset] is negative, or
254 * greater than or equal to the length of this object.
255 */
146 int getInt8(int byteOffset) native; 256 int getInt8(int byteOffset) native;
147 257
258 /**
259 * Returns the positive integer represented by the two bytes starting
260 * at the specified [byteOffset] in this object, in unsigned binary
261 * form.
262 * The return value will be between 0 and 2<sup>16</sup> - 1, inclusive.
263 *
264 * Throws [RangeError] if [byteOffset] is negative, or
265 * `byteOffset + 2` is greater than the length of this object.
266 */
148 int getUint16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => 267 int getUint16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) =>
149 _getUint16(byteOffset, endian._littleEndian); 268 _getUint16(byteOffset, endian._littleEndian);
150 269
151 @JSName('getUint16') 270 @JSName('getUint16')
152 @Returns('int') 271 @Returns('int')
153 int _getUint16(int byteOffset, [bool littleEndian]) native; 272 int _getUint16(int byteOffset, [bool littleEndian]) native;
154 273
274 /**
275 * Returns the positive integer represented by the four bytes starting
276 * at the specified [byteOffset] in this object, in unsigned binary
277 * form.
278 * The return value will be between 0 and 2<sup>32</sup> - 1, inclusive.
279 *
280 */
155 int getUint32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => 281 int getUint32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) =>
156 _getUint32(byteOffset, endian._littleEndian); 282 _getUint32(byteOffset, endian._littleEndian);
157 283
158 @JSName('getUint32') 284 @JSName('getUint32')
159 @Returns('int') 285 @Returns('int')
160 int _getUint32(int byteOffset, [bool littleEndian]) native; 286 int _getUint32(int byteOffset, [bool littleEndian]) native;
161 287
288 /**
289 * Returns the positive integer represented by the eight bytes starting
290 * at the specified [byteOffset] in this object, in unsigned binary
291 * form.
292 * The return value will be between 0 and 2<sup>64</sup> - 1, inclusive.
293 *
294 * Throws [RangeError] if [byteOffset] is negative, or
295 * `byteOffset + 8` is greater than the length of this object.
296 */
162 int getUint64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) { 297 int getUint64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) {
163 throw new UnsupportedError("Uint64 accessor not supported by dart2js."); 298 throw new UnsupportedError("Uint64 accessor not supported by dart2js.");
164 } 299 }
165 300
301 /**
302 * Returns the positive integer represented by the byte at the specified
303 * [byteOffset] in this object, in unsigned binary form. The
304 * return value will be between 0 and 255, inclusive.
305 *
306 * Throws [RangeError] if [byteOffset] is negative, or
307 * greater than or equal to the length of this object.
308 */
166 int getUint8(int byteOffset) native; 309 int getUint8(int byteOffset) native;
167 310
311 /**
312 * Sets the four bytes starting at the specified [byteOffset] in this
313 * object to the IEEE 754 single-precision binary floating-point
314 * (binary32) representation of the specified [value].
315 *
316 * **Note that this method can lose precision.** The input [value] is
317 * a 64-bit floating point value, which will be converted to 32-bit
318 * floating point value by IEEE 754 rounding rules before it is stored.
319 * If [value] cannot be represented exactly as a binary32, it will be
320 * converted to the nearest binary32 value. If two binary32 values are
321 * equally close, the one whose least significant bit is zero will be used.
322 * Note that finite (but large) values can be converted to infinity, and
323 * small non-zero values can be converted to zero.
324 *
325 * Throws [RangeError] if [byteOffset] is negative, or
326 * `byteOffset + 4` is greater than the length of this object.
327 */
168 void setFloat32(int byteOffset, num value, [Endianness endian=Endianness.BIG_E NDIAN]) => 328 void setFloat32(int byteOffset, num value, [Endianness endian=Endianness.BIG_E NDIAN]) =>
169 _setFloat32(byteOffset, value, endian._littleEndian); 329 _setFloat32(byteOffset, value, endian._littleEndian);
170 330
171 @JSName('setFloat32') 331 @JSName('setFloat32')
172 void _setFloat32(int byteOffset, num value, [bool littleEndian]) native; 332 void _setFloat32(int byteOffset, num value, [bool littleEndian]) native;
173 333
334 /**
335 * Sets the eight bytes starting at the specified [byteOffset] in this
336 * object to the IEEE 754 double-precision binary floating-point
337 * (binary64) representation of the specified [value].
338 *
339 * Throws [RangeError] if [byteOffset] is negative, or
340 * `byteOffset + 8` is greater than the length of this object.
341 */
174 void setFloat64(int byteOffset, num value, [Endianness endian=Endianness.BIG_E NDIAN]) => 342 void setFloat64(int byteOffset, num value, [Endianness endian=Endianness.BIG_E NDIAN]) =>
175 _setFloat64(byteOffset, value, endian._littleEndian); 343 _setFloat64(byteOffset, value, endian._littleEndian);
176 344
177 @JSName('setFloat64') 345 @JSName('setFloat64')
178 void _setFloat64(int byteOffset, num value, [bool littleEndian]) native; 346 void _setFloat64(int byteOffset, num value, [bool littleEndian]) native;
179 347
348 /**
349 * Sets the two bytes starting at the specified [byteOffset] in this
350 * object to the two's complement binary representation of the specified
351 * [value], which must fit in two bytes. In other words, [value] must lie
352 * between 2<sup>15</sup> and 2<sup>15</sup> - 1, inclusive.
353 *
354 * Throws [RangeError] if [byteOffset] is negative, or
355 * `byteOffset + 2` is greater than the length of this object.
356 */
180 void setInt16(int byteOffset, int value, [Endianness endian=Endianness.BIG_END IAN]) => 357 void setInt16(int byteOffset, int value, [Endianness endian=Endianness.BIG_END IAN]) =>
181 _setInt16(byteOffset, value, endian._littleEndian); 358 _setInt16(byteOffset, value, endian._littleEndian);
182 359
183 @JSName('setInt16') 360 @JSName('setInt16')
184 void _setInt16(int byteOffset, int value, [bool littleEndian]) native; 361 void _setInt16(int byteOffset, int value, [bool littleEndian]) native;
185 362
363 /**
364 * Sets the four bytes starting at the specified [byteOffset] in this
365 * object to the two's complement binary representation of the specified
366 * [value], which must fit in four bytes. In other words, [value] must lie
367 * between 2<sup>31</sup> and 2<sup>31</sup> - 1, inclusive.
368 *
369 * Throws [RangeError] if [byteOffset] is negative, or
370 * `byteOffset + 4` is greater than the length of this object.
371 */
186 void setInt32(int byteOffset, int value, [Endianness endian=Endianness.BIG_END IAN]) => 372 void setInt32(int byteOffset, int value, [Endianness endian=Endianness.BIG_END IAN]) =>
187 _setInt32(byteOffset, value, endian._littleEndian); 373 _setInt32(byteOffset, value, endian._littleEndian);
188 374
189 @JSName('setInt32') 375 @JSName('setInt32')
190 void _setInt32(int byteOffset, int value, [bool littleEndian]) native; 376 void _setInt32(int byteOffset, int value, [bool littleEndian]) native;
191 377
378 /**
379 * Sets the eight bytes starting at the specified [byteOffset] in this
380 * object to the two's complement binary representation of the specified
381 * [value], which must fit in eight bytes. In other words, [value] must lie
382 * between 2<sup>63</sup> and 2<sup>63</sup> - 1, inclusive.
383 *
384 * Throws [RangeError] if [byteOffset] is negative, or
385 * `byteOffset + 8` is greater than the length of this object.
386 */
192 void setInt64(int byteOffset, int value, [Endianness endian=Endianness.BIG_END IAN]) { 387 void setInt64(int byteOffset, int value, [Endianness endian=Endianness.BIG_END IAN]) {
193 throw new UnsupportedError("Int64 accessor not supported by dart2js."); 388 throw new UnsupportedError("Int64 accessor not supported by dart2js.");
194 } 389 }
195 390
391 /**
392 * Sets the byte at the specified [byteOffset] in this object to the
393 * two's complement binary representation of the specified [value], which
394 * must fit in a single byte. In other words, [value] must be between
395 * -128 and 127, inclusive.
396 *
397 * Throws [RangeError] if [byteOffset] is negative, or
398 * greater than or equal to the length of this object.
399 */
196 void setInt8(int byteOffset, int value) native; 400 void setInt8(int byteOffset, int value) native;
197 401
402 /**
403 * Sets the two bytes starting at the specified [byteOffset] in this object
404 * to the unsigned binary representation of the specified [value],
405 * which must fit in two bytes. in other words, [value] must be between
406 * 0 and 2<sup>16</sup> - 1, inclusive.
407 *
408 * Throws [RangeError] if [byteOffset] is negative, or
409 * `byteOffset + 2` is greater than the length of this object.
410 */
198 void setUint16(int byteOffset, int value, [Endianness endian=Endianness.BIG_EN DIAN]) => 411 void setUint16(int byteOffset, int value, [Endianness endian=Endianness.BIG_EN DIAN]) =>
199 _setUint16(byteOffset, value, endian._littleEndian); 412 _setUint16(byteOffset, value, endian._littleEndian);
200 413
201 @JSName('setUint16') 414 @JSName('setUint16')
202 void _setUint16(int byteOffset, int value, [bool littleEndian]) native; 415 void _setUint16(int byteOffset, int value, [bool littleEndian]) native;
203 416
417 /**
418 * Sets the four bytes starting at the specified [byteOffset] in this object
419 * to the unsigned binary representation of the specified [value],
420 * which must fit in four bytes. in other words, [value] must be between
421 * 0 and 2<sup>32</sup> - 1, inclusive.
422 *
423 * Throws [RangeError] if [byteOffset] is negative, or
424 * `byteOffset + 4` is greater than the length of this object.
425 */
204 void setUint32(int byteOffset, int value, [Endianness endian=Endianness.BIG_EN DIAN]) => 426 void setUint32(int byteOffset, int value, [Endianness endian=Endianness.BIG_EN DIAN]) =>
205 _setUint32(byteOffset, value, endian._littleEndian); 427 _setUint32(byteOffset, value, endian._littleEndian);
206 428
207 @JSName('setUint32') 429 @JSName('setUint32')
208 void _setUint32(int byteOffset, int value, [bool littleEndian]) native; 430 void _setUint32(int byteOffset, int value, [bool littleEndian]) native;
209 431
432 /**
433 * Sets the eight bytes starting at the specified [byteOffset] in this object
434 * to the unsigned binary representation of the specified [value],
435 * which must fit in eight bytes. in other words, [value] must be between
436 * 0 and 2<sup>64</sup> - 1, inclusive.
437 *
438 * Throws [RangeError] if [byteOffset] is negative, or
439 * `byteOffset + 8` is greater than the length of this object.
440 */
210 void setUint64(int byteOffset, int value, [Endianness endian=Endianness.BIG_EN DIAN]) { 441 void setUint64(int byteOffset, int value, [Endianness endian=Endianness.BIG_EN DIAN]) {
211 throw new UnsupportedError("Uint64 accessor not supported by dart2js."); 442 throw new UnsupportedError("Uint64 accessor not supported by dart2js.");
212 } 443 }
213 444
445 /**
446 * Sets the byte at the specified [byteOffset] in this object to the
447 * unsigned binary representation of the specified [value], which must fit
448 * in a single byte. in other words, [value] must be between 0 and 255,
449 * inclusive.
450 *
451 * Throws [RangeError] if [byteOffset] is negative,
452 * or greater than or equal to the length of this object.
453 */
214 void setUint8(int byteOffset, int value) native; 454 void setUint8(int byteOffset, int value) native;
215 455
216 static ByteData _create1(arg) => 456 static ByteData _create1(arg) =>
217 JS('ByteData', 'new DataView(new ArrayBuffer(#))', arg).._setCachedLength( ); 457 JS('ByteData', 'new DataView(new ArrayBuffer(#))', arg).._setCachedLength( );
218 458
219 static ByteData _create2(arg1, arg2) => 459 static ByteData _create2(arg1, arg2) =>
220 JS('ByteData', 'new DataView(#, #)', arg1, arg2).._setCachedLength(); 460 JS('ByteData', 'new DataView(#, #)', arg1, arg2).._setCachedLength();
221 461
222 static ByteData _create3(arg1, arg2, arg3) => 462 static ByteData _create3(arg1, arg2, arg3) =>
223 JS('ByteData', 'new DataView(#, #, #)', arg1, arg2, arg3) 463 JS('ByteData', 'new DataView(#, #, #)', arg1, arg2, arg3)
224 .._setCachedLength(); 464 .._setCachedLength();
225 } 465 }
226 466
227 467 /**
468 * A fixed-length list of IEEE 754 single-precision binary floating-point
469 * numbers that is viewable as a [TypedData]. For long lists, this
470 * implementation can be considerably more space- and time-efficient than
471 * the default [List] implementation.
472 */
228 class Float32List 473 class Float32List
229 extends TypedData with ListMixin<double>, FixedLengthListMixin<double> 474 extends TypedData with ListMixin<double>, FixedLengthListMixin<double>
230 implements JavaScriptIndexingBehavior, List<double> 475 implements JavaScriptIndexingBehavior, List<double>
231 native "Float32Array" { 476 native "Float32Array" {
477 /**
478 * Creates a [Float32List] of the specified length (in elements), all of
479 * whose elements are initially zero.
480 */
232 factory Float32List(int length) => _create1(length); 481 factory Float32List(int length) => _create1(length);
233 482
483 /**
484 * Creates a [Float32List] with the same size as the [elements] list
485 * and copies over the elements.
486 */
234 factory Float32List.fromList(List<num> list) => 487 factory Float32List.fromList(List<num> list) =>
235 _create1(_ensureNativeList(list)); 488 _create1(_ensureNativeList(list));
236 489
490 /**
491 * Creates a [Float32List] _view_ of the specified region in the specified
492 * byte buffer. Changes in the [Float32List] will be visible in the byte
493 * buffer and vice versa. If the [offsetInBytes] index of the region is not
494 * specified, it defaults to zero (the first byte in the byte buffer).
495 * If the length is not specified, it defaults to null, which indicates
496 * that the view extends to the end of the byte buffer.
497 *
498 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
499 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
500 * the length of [buffer].
501 *
502 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
503 * BYTES_PER_ELEMENT.
504 */
237 factory Float32List.view(ByteBuffer buffer, 505 factory Float32List.view(ByteBuffer buffer,
238 [int byteOffset = 0, int length]) => 506 [int byteOffset = 0, int length]) =>
239 length == null 507 length == null
240 ? _create2(buffer, byteOffset) 508 ? _create2(buffer, byteOffset)
241 : _create3(buffer, byteOffset, length); 509 : _create3(buffer, byteOffset, length);
242 510
243 static const int BYTES_PER_ELEMENT = 4; 511 static const int BYTES_PER_ELEMENT = 4;
244 512
245 int get length => JS("int", '#(#)', fetchLength, this); 513 int get length => JS("int", '#(#)', fetchLength, this);
246 514
(...skipping 20 matching lines...) Expand all
267 static Float32List _create2(arg1, arg2) => 535 static Float32List _create2(arg1, arg2) =>
268 JS('Float32List', 'new Float32Array(#, #)', arg1, arg2) 536 JS('Float32List', 'new Float32Array(#, #)', arg1, arg2)
269 .._setCachedLength(); 537 .._setCachedLength();
270 538
271 static Float32List _create3(arg1, arg2, arg3) => 539 static Float32List _create3(arg1, arg2, arg3) =>
272 JS('Float32List', 'new Float32Array(#, #, #)', arg1, arg2, arg3) 540 JS('Float32List', 'new Float32Array(#, #, #)', arg1, arg2, arg3)
273 .._setCachedLength(); 541 .._setCachedLength();
274 } 542 }
275 543
276 544
545 /**
546 * A fixed-length list of IEEE 754 double-precision binary floating-point
547 * numbers that is viewable as a [TypedData]. For long lists, this
548 * implementation can be considerably more space- and time-efficient than
549 * the default [List] implementation.
550 */
277 class Float64List 551 class Float64List
278 extends TypedData with ListMixin<double>, FixedLengthListMixin<double> 552 extends TypedData with ListMixin<double>, FixedLengthListMixin<double>
279 implements JavaScriptIndexingBehavior, List<double> 553 implements JavaScriptIndexingBehavior, List<double>
280 native "Float64Array" { 554 native "Float64Array" {
555 /**
556 * Creates a [Float64List] of the specified length (in elements), all of
557 * whose elements are initially zero.
558 */
281 factory Float64List(int length) => _create1(length); 559 factory Float64List(int length) => _create1(length);
282 560
561 /**
562 * Creates a [Float64List] with the same size as the [elements] list
563 * and copies over the elements.
564 */
283 factory Float64List.fromList(List<num> list) => 565 factory Float64List.fromList(List<num> list) =>
284 _create1(_ensureNativeList(list)); 566 _create1(_ensureNativeList(list));
285 567
568 /**
569 * Creates a [Float64List] _view_ of the specified region in the specified
570 * byte buffer. Changes in the [Float64List] will be visible in the byte
571 * buffer and vice versa. If the [offsetInBytes] index of the region is not
572 * specified, it defaults to zero (the first byte in the byte buffer).
573 * If the length is not specified, it defaults to null, which indicates
574 * 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 [buffer].
579 *
580 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
581 * BYTES_PER_ELEMENT.
582 */
286 factory Float64List.view(ByteBuffer buffer, 583 factory Float64List.view(ByteBuffer buffer,
287 [int byteOffset = 0, int length]) => 584 [int byteOffset = 0, int length]) =>
288 length == null 585 length == null
289 ? _create2(buffer, byteOffset) 586 ? _create2(buffer, byteOffset)
290 : _create3(buffer, byteOffset, length); 587 : _create3(buffer, byteOffset, length);
291 588
292 static const int BYTES_PER_ELEMENT = 8; 589 static const int BYTES_PER_ELEMENT = 8;
293 590
294 int get length => JS("int", '#(#)', fetchLength, this); 591 int get length => JS("int", '#(#)', fetchLength, this);
295 592
(...skipping 23 matching lines...) Expand all
319 .._setCachedLength(); 616 .._setCachedLength();
320 } 617 }
321 618
322 static Float64List _create3(arg1, arg2, arg3) { 619 static Float64List _create3(arg1, arg2, arg3) {
323 return JS('Float64List', 'new Float64Array(#, #, #)', arg1, arg2, arg3) 620 return JS('Float64List', 'new Float64Array(#, #, #)', arg1, arg2, arg3)
324 .._setCachedLength(); 621 .._setCachedLength();
325 } 622 }
326 } 623 }
327 624
328 625
626 /**
627 * A fixed-length list of 16-bit signed integers that is viewable as a
628 * [TypedData]. For long lists, this implementation can be considerably
629 * more space- and time-efficient than the default [List] implementation.
630 */
329 class Int16List 631 class Int16List
330 extends TypedData with ListMixin<int>, FixedLengthListMixin<int> 632 extends TypedData with ListMixin<int>, FixedLengthListMixin<int>
331 implements JavaScriptIndexingBehavior, List<int> 633 implements JavaScriptIndexingBehavior, List<int>
332 native "Int16Array" { 634 native "Int16Array" {
635 /**
636 * Creates an [Int16List] of the specified length (in elements), all of
637 * whose elements are initially zero.
638 */
333 factory Int16List(int length) => _create1(length); 639 factory Int16List(int length) => _create1(length);
334 640
641 /**
642 * Creates a [Int16List] with the same size as the [elements] list
643 * and copies over the elements.
644 */
335 factory Int16List.fromList(List<num> list) => 645 factory Int16List.fromList(List<num> list) =>
336 _create1(_ensureNativeList(list)); 646 _create1(_ensureNativeList(list));
337 647
648 /**
649 * Creates an [Int16List] _view_ of the specified region in the specified
650 * byte buffer. Changes in the [Int16List] will be visible in the byte
651 * buffer and vice versa. If the [offsetInBytes] index of the region is not
652 * specified, it defaults to zero (the first byte in the byte buffer).
653 * If the length is not specified, it defaults to null, which indicates
654 * that the view extends to the end of the byte buffer.
655 *
656 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
657 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
658 * the length of [buffer].
659 *
660 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
661 * BYTES_PER_ELEMENT.
662 */
338 factory Int16List.view(ByteBuffer buffer, [int byteOffset = 0, int length]) => 663 factory Int16List.view(ByteBuffer buffer, [int byteOffset = 0, int length]) =>
339 length == null 664 length == null
340 ? _create2(buffer, byteOffset) 665 ? _create2(buffer, byteOffset)
341 : _create3(buffer, byteOffset, length); 666 : _create3(buffer, byteOffset, length);
342 667
343 static const int BYTES_PER_ELEMENT = 2; 668 static const int BYTES_PER_ELEMENT = 2;
344 669
345 int get length => JS("int", '#(#)', fetchLength, this); 670 int get length => JS("int", '#(#)', fetchLength, this);
346 671
347 int operator[](int index) { 672 int operator[](int index) {
(...skipping 18 matching lines...) Expand all
366 691
367 static Int16List _create2(arg1, arg2) => 692 static Int16List _create2(arg1, arg2) =>
368 JS('Int16List', 'new Int16Array(#, #)', arg1, arg2).._setCachedLength(); 693 JS('Int16List', 'new Int16Array(#, #)', arg1, arg2).._setCachedLength();
369 694
370 static Int16List _create3(arg1, arg2, arg3) => 695 static Int16List _create3(arg1, arg2, arg3) =>
371 JS('Int16List', 'new Int16Array(#, #, #)', arg1, arg2, arg3) 696 JS('Int16List', 'new Int16Array(#, #, #)', arg1, arg2, arg3)
372 .._setCachedLength(); 697 .._setCachedLength();
373 } 698 }
374 699
375 700
701 /**
702 * A fixed-length list of 32-bit signed integers that is viewable as a
703 * [TypedData]. For long lists, this implementation can be considerably
704 * more space- and time-efficient than the default [List] implementation.
705 */
376 class Int32List 706 class Int32List
377 extends TypedData with ListMixin<int>, FixedLengthListMixin<int> 707 extends TypedData with ListMixin<int>, FixedLengthListMixin<int>
378 implements JavaScriptIndexingBehavior, List<int> 708 implements JavaScriptIndexingBehavior, List<int>
379 native "Int32Array" { 709 native "Int32Array" {
710 /**
711 * Creates an [Int32List] of the specified length (in elements), all of
712 * whose elements are initially zero.
713 */
380 factory Int32List(int length) => _create1(length); 714 factory Int32List(int length) => _create1(length);
381 715
716 /**
717 * Creates a [Int32List] with the same size as the [elements] list
718 * and copies over the elements.
719 */
382 factory Int32List.fromList(List<num> list) => 720 factory Int32List.fromList(List<num> list) =>
383 _create1(_ensureNativeList(list)); 721 _create1(_ensureNativeList(list));
384 722
723 /**
724 * Creates an [Int32List] _view_ of the specified region in the specified
725 * byte buffer. Changes in the [Int32List] will be visible in the byte
726 * buffer and vice versa. If the [offsetInBytes] index of the region is not
727 * specified, it defaults to zero (the first byte in the byte buffer).
728 * If the length is not specified, it defaults to null, which indicates
729 * that the view extends to the end of the byte buffer.
730 *
731 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
732 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
733 * the length of [buffer].
734 *
735 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
736 * BYTES_PER_ELEMENT.
737 */
385 factory Int32List.view(ByteBuffer buffer, [int byteOffset = 0, int length]) => 738 factory Int32List.view(ByteBuffer buffer, [int byteOffset = 0, int length]) =>
386 length == null 739 length == null
387 ? _create2(buffer, byteOffset) 740 ? _create2(buffer, byteOffset)
388 : _create3(buffer, byteOffset, length); 741 : _create3(buffer, byteOffset, length);
389 742
390 static const int BYTES_PER_ELEMENT = 4; 743 static const int BYTES_PER_ELEMENT = 4;
391 744
392 int get length => JS("int", '#(#)', fetchLength, this); 745 int get length => JS("int", '#(#)', fetchLength, this);
393 746
394 int operator[](int index) { 747 int operator[](int index) {
(...skipping 18 matching lines...) Expand all
413 766
414 static Int32List _create2(arg1, arg2) => 767 static Int32List _create2(arg1, arg2) =>
415 JS('Int32List', 'new Int32Array(#, #)', arg1, arg2).._setCachedLength(); 768 JS('Int32List', 'new Int32Array(#, #)', arg1, arg2).._setCachedLength();
416 769
417 static Int32List _create3(arg1, arg2, arg3) => 770 static Int32List _create3(arg1, arg2, arg3) =>
418 JS('Int32List', 'new Int32Array(#, #, #)', arg1, arg2, arg3) 771 JS('Int32List', 'new Int32Array(#, #, #)', arg1, arg2, arg3)
419 .._setCachedLength(); 772 .._setCachedLength();
420 } 773 }
421 774
422 775
776 /**
777 * A fixed-length list of 8-bit signed integers.
778 * For long lists, this implementation can be considerably
779 * more space- and time-efficient than the default [List] implementation.
780 */
423 class Int8List 781 class Int8List
424 extends TypedData with ListMixin<int>, FixedLengthListMixin<int> 782 extends TypedData with ListMixin<int>, FixedLengthListMixin<int>
425 implements JavaScriptIndexingBehavior, List<int> 783 implements JavaScriptIndexingBehavior, List<int>
426 native "Int8Array" { 784 native "Int8Array" {
785 /**
786 * Creates an [Int8List] of the specified length (in elements), all of
787 * whose elements are initially zero.
788 */
427 factory Int8List(int length) => _create1(length); 789 factory Int8List(int length) => _create1(length);
428 790
791 /**
792 * Creates a [Int8List] with the same size as the [elements] list
793 * and copies over the elements.
794 */
429 factory Int8List.fromList(List<num> list) => 795 factory Int8List.fromList(List<num> list) =>
430 _create1(_ensureNativeList(list)); 796 _create1(_ensureNativeList(list));
431 797
798 /**
799 * Creates an [Int8List] _view_ of the specified region in the specified
800 * byte buffer. Changes in the [Int8List] will be visible in the byte
801 * buffer and vice versa. If the [offsetInBytes] index of the region is not
802 * specified, it defaults to zero (the first byte in the byte buffer).
803 * If the length is not specified, it defaults to null, which indicates
804 * that the view extends to the end of the byte buffer.
805 *
806 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
807 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
808 * the length of [buffer].
809 */
432 factory Int8List.view(ByteBuffer buffer, [int byteOffset = 0, int length]) => 810 factory Int8List.view(ByteBuffer buffer, [int byteOffset = 0, int length]) =>
433 length == null 811 length == null
434 ? _create2(buffer, byteOffset) 812 ? _create2(buffer, byteOffset)
435 : _create3(buffer, byteOffset, length); 813 : _create3(buffer, byteOffset, length);
436 814
437 static const int BYTES_PER_ELEMENT = 1; 815 static const int BYTES_PER_ELEMENT = 1;
438 816
439 int get length => JS("int", '#(#)', fetchLength, this); 817 int get length => JS("int", '#(#)', fetchLength, this);
440 818
441 int operator[](int index) { 819 int operator[](int index) {
(...skipping 18 matching lines...) Expand all
460 838
461 static Int8List _create2(arg1, arg2) => 839 static Int8List _create2(arg1, arg2) =>
462 JS('Int8List', 'new Int8Array(#, #)', arg1, arg2).._setCachedLength(); 840 JS('Int8List', 'new Int8Array(#, #)', arg1, arg2).._setCachedLength();
463 841
464 static Int8List _create3(arg1, arg2, arg3) => 842 static Int8List _create3(arg1, arg2, arg3) =>
465 JS('Int8List', 'new Int8Array(#, #, #)', arg1, arg2, arg3) 843 JS('Int8List', 'new Int8Array(#, #, #)', arg1, arg2, arg3)
466 .._setCachedLength(); 844 .._setCachedLength();
467 } 845 }
468 846
469 847
848 /**
849 * A fixed-length list of 16-bit unsigned integers that is viewable as a
850 * [TypedData]. For long lists, this implementation can be considerably
851 * more space- and time-efficient than the default [List] implementation.
852 */
470 class Uint16List 853 class Uint16List
471 extends TypedData with ListMixin<int>, FixedLengthListMixin<int> 854 extends TypedData with ListMixin<int>, FixedLengthListMixin<int>
472 implements JavaScriptIndexingBehavior, List<int> 855 implements JavaScriptIndexingBehavior, List<int>
473 native "Uint16Array" { 856 native "Uint16Array" {
857 /**
858 * Creates a [Uint16List] of the specified length (in elements), all
859 * of whose elements are initially zero.
860 */
474 factory Uint16List(int length) => _create1(length); 861 factory Uint16List(int length) => _create1(length);
475 862
863 /**
864 * Creates a [Uint16List] with the same size as the [elements] list
865 * and copies over the elements.
866 */
476 factory Uint16List.fromList(List<num> list) => 867 factory Uint16List.fromList(List<num> list) =>
477 _create1(_ensureNativeList(list)); 868 _create1(_ensureNativeList(list));
478 869
870 /**
871 * Creates a [Uint16List] _view_ of the specified region in
872 * the specified byte buffer. Changes in the [Uint16List] will be
873 * visible in the byte buffer and vice versa. If the [offsetInBytes] index
874 * of the region is not specified, it defaults to zero (the first byte in
875 * the byte buffer). If the length is not specified, it defaults to null,
876 * which indicates that the view extends to the end of the byte buffer.
877 *
878 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
879 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
880 * the length of [buffer].
881 *
882 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
883 * BYTES_PER_ELEMENT.
884 */
479 factory Uint16List.view(ByteBuffer buffer, 885 factory Uint16List.view(ByteBuffer buffer,
480 [int byteOffset = 0, int length]) => 886 [int byteOffset = 0, int length]) =>
481 length == null 887 length == null
482 ? _create2(buffer, byteOffset) 888 ? _create2(buffer, byteOffset)
483 : _create3(buffer, byteOffset, length); 889 : _create3(buffer, byteOffset, length);
484 890
485 static const int BYTES_PER_ELEMENT = 2; 891 static const int BYTES_PER_ELEMENT = 2;
486 892
487 int get length => JS("int", '#(#)', fetchLength, this); 893 int get length => JS("int", '#(#)', fetchLength, this);
488 894
(...skipping 19 matching lines...) Expand all
508 914
509 static Uint16List _create2(arg1, arg2) => 915 static Uint16List _create2(arg1, arg2) =>
510 JS('Uint16List', 'new Uint16Array(#, #)', arg1, arg2).._setCachedLength(); 916 JS('Uint16List', 'new Uint16Array(#, #)', arg1, arg2).._setCachedLength();
511 917
512 static Uint16List _create3(arg1, arg2, arg3) => 918 static Uint16List _create3(arg1, arg2, arg3) =>
513 JS('Uint16List', 'new Uint16Array(#, #, #)', arg1, arg2, arg3) 919 JS('Uint16List', 'new Uint16Array(#, #, #)', arg1, arg2, arg3)
514 .._setCachedLength(); 920 .._setCachedLength();
515 } 921 }
516 922
517 923
924 /**
925 * A fixed-length list of 32-bit unsigned integers that is viewable as a
926 * [TypedData]. For long lists, this implementation can be considerably
927 * more space- and time-efficient than the default [List] implementation.
928 */
518 class Uint32List 929 class Uint32List
519 extends TypedData with ListMixin<int>, FixedLengthListMixin<int> 930 extends TypedData with ListMixin<int>, FixedLengthListMixin<int>
520 implements JavaScriptIndexingBehavior, List<int> 931 implements JavaScriptIndexingBehavior, List<int>
521 native "Uint32Array" { 932 native "Uint32Array" {
933 /**
934 * Creates a [Uint32List] of the specified length (in elements), all
935 * of whose elements are initially zero.
936 */
522 factory Uint32List(int length) => _create1(length); 937 factory Uint32List(int length) => _create1(length);
523 938
939 /**
940 * Creates a [Uint32List] with the same size as the [elements] list
941 * and copies over the elements.
942 */
524 factory Uint32List.fromList(List<num> list) => 943 factory Uint32List.fromList(List<num> list) =>
525 _create1(_ensureNativeList(list)); 944 _create1(_ensureNativeList(list));
526 945
946 /**
947 * Creates a [Uint32List] _view_ of the specified region in
948 * the specified byte buffer. Changes in the [Uint32] will be
949 * visible in the byte buffer and vice versa. If the [offsetInBytes] index
950 * of the region is not specified, it defaults to zero (the first byte in
951 * the byte buffer). If the length is not specified, it defaults to null,
952 * which indicates that the view extends to the end of the byte buffer.
953 *
954 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
955 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
956 * the length of [buffer].
957 *
958 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
959 * BYTES_PER_ELEMENT.
960 */
527 factory Uint32List.view(ByteBuffer buffer, 961 factory Uint32List.view(ByteBuffer buffer,
528 [int byteOffset = 0, int length]) => 962 [int byteOffset = 0, int length]) =>
529 length == null 963 length == null
530 ? _create2(buffer, byteOffset) 964 ? _create2(buffer, byteOffset)
531 : _create3(buffer, byteOffset, length); 965 : _create3(buffer, byteOffset, length);
532 966
533 static const int BYTES_PER_ELEMENT = 4; 967 static const int BYTES_PER_ELEMENT = 4;
534 968
535 int get length => JS("int", '#(#)', fetchLength, this); 969 int get length => JS("int", '#(#)', fetchLength, this);
536 970
(...skipping 19 matching lines...) Expand all
556 990
557 static Uint32List _create2(arg1, arg2) => 991 static Uint32List _create2(arg1, arg2) =>
558 JS('Uint32List', 'new Uint32Array(#, #)', arg1, arg2).._setCachedLength(); 992 JS('Uint32List', 'new Uint32Array(#, #)', arg1, arg2).._setCachedLength();
559 993
560 static Uint32List _create3(arg1, arg2, arg3) => 994 static Uint32List _create3(arg1, arg2, arg3) =>
561 JS('Uint32List', 'new Uint32Array(#, #, #)', arg1, arg2, arg3) 995 JS('Uint32List', 'new Uint32Array(#, #, #)', arg1, arg2, arg3)
562 .._setCachedLength(); 996 .._setCachedLength();
563 } 997 }
564 998
565 999
1000 /**
1001 * A fixed-length list of 8-bit unsigned integers.
1002 * For long lists, this implementation can be considerably
1003 * more space- and time-efficient than the default [List] implementation.
1004 * Indexed store clamps the value to range 0..0xFF.
1005 */
566 class Uint8ClampedList extends TypedData with ListMixin<int>, 1006 class Uint8ClampedList extends TypedData with ListMixin<int>,
567 FixedLengthListMixin<int> implements JavaScriptIndexingBehavior, List<int> 1007 FixedLengthListMixin<int> implements JavaScriptIndexingBehavior, List<int>
568 native "Uint8ClampedArray,CanvasPixelArray" { 1008 native "Uint8ClampedArray,CanvasPixelArray" {
1009 /**
1010 * Creates a [Uint8ClampedList] of the specified length (in elements), all of
1011 * whose elements are initially zero.
1012 */
569 factory Uint8ClampedList(int length) => _create1(length); 1013 factory Uint8ClampedList(int length) => _create1(length);
570 1014
1015 /**
1016 * Creates a [Uint8ClampedList] of the same size as the [elements]
1017 * list and copies over the values clamping when needed.
1018 */
571 factory Uint8ClampedList.fromList(List<num> list) => 1019 factory Uint8ClampedList.fromList(List<num> list) =>
572 _create1(_ensureNativeList(list)); 1020 _create1(_ensureNativeList(list));
573 1021
1022 /**
1023 * Creates a [Uint8ClampedList] _view_ of the specified region in the
1024 * specified byte [buffer]. Changes in the [Uint8List] will be visible in the
1025 * byte buffer and vice versa. If the [offsetInBytes] index of the region is
1026 * not specified, it defaults to zero (the first byte in the byte buffer).
1027 * If the length is not specified, it defaults to null, which indicates that
1028 * the view extends to the end of the byte buffer.
1029 *
1030 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
1031 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
1032 * the length of [buffer].
1033 */
574 factory Uint8ClampedList.view(ByteBuffer buffer, 1034 factory Uint8ClampedList.view(ByteBuffer buffer,
575 [int byteOffset = 0, int length]) => 1035 [int byteOffset = 0, int length]) =>
576 length == null 1036 length == null
577 ? _create2(buffer, byteOffset) 1037 ? _create2(buffer, byteOffset)
578 : _create3(buffer, byteOffset, length); 1038 : _create3(buffer, byteOffset, length);
579 1039
580 static const int BYTES_PER_ELEMENT = 1; 1040 static const int BYTES_PER_ELEMENT = 1;
581 1041
582 int get length => JS("int", '#(#)', fetchLength, this); 1042 int get length => JS("int", '#(#)', fetchLength, this);
583 1043
(...skipping 21 matching lines...) Expand all
605 static Uint8ClampedList _create2(arg1, arg2) => 1065 static Uint8ClampedList _create2(arg1, arg2) =>
606 JS('Uint8ClampedList', 'new Uint8ClampedArray(#, #)', arg1, arg2) 1066 JS('Uint8ClampedList', 'new Uint8ClampedArray(#, #)', arg1, arg2)
607 .._setCachedLength(); 1067 .._setCachedLength();
608 1068
609 static Uint8ClampedList _create3(arg1, arg2, arg3) => 1069 static Uint8ClampedList _create3(arg1, arg2, arg3) =>
610 JS('Uint8ClampedList', 'new Uint8ClampedArray(#, #, #)', arg1, arg2, arg3) 1070 JS('Uint8ClampedList', 'new Uint8ClampedArray(#, #, #)', arg1, arg2, arg3)
611 .._setCachedLength(); 1071 .._setCachedLength();
612 } 1072 }
613 1073
614 1074
1075 /**
1076 * A fixed-length list of 8-bit unsigned integers.
1077 * For long lists, this implementation can be considerably
1078 * more space- and time-efficient than the default [List] implementation.
1079 */
615 class Uint8List 1080 class Uint8List
616 extends TypedData with ListMixin<int>, FixedLengthListMixin<int> 1081 extends TypedData with ListMixin<int>, FixedLengthListMixin<int>
617 implements JavaScriptIndexingBehavior, List<int> 1082 implements JavaScriptIndexingBehavior, List<int>
618 // On some browsers Uint8ClampedArray is a subtype of Uint8Array. Marking 1083 // On some browsers Uint8ClampedArray is a subtype of Uint8Array. Marking
619 // Uint8List as !nonleaf ensures that the native dispatch correctly handles 1084 // Uint8List as !nonleaf ensures that the native dispatch correctly handles
620 // the potential for Uint8ClampedArray to 'accidentally' pick up the 1085 // the potential for Uint8ClampedArray to 'accidentally' pick up the
621 // dispatch record for Uint8List. 1086 // dispatch record for Uint8List.
622 native "Uint8Array,!nonleaf" { 1087 native "Uint8Array,!nonleaf" {
1088 /**
1089 * Creates a [Uint8List] of the specified length (in elements), all of
1090 * whose elements are initially zero.
1091 */
623 factory Uint8List(int length) => _create1(length); 1092 factory Uint8List(int length) => _create1(length);
624 1093
1094 /**
1095 * Creates a [Uint8List] with the same size as the [elements] list
1096 * and copies over the elements.
1097 */
625 factory Uint8List.fromList(List<num> list) => 1098 factory Uint8List.fromList(List<num> list) =>
626 _create1(_ensureNativeList(list)); 1099 _create1(_ensureNativeList(list));
627 1100
1101 /**
1102 * Creates a [Uint8List] _view_ of the specified region in the specified
1103 * byte buffer. Changes in the [Uint8List] will be visible in the byte
1104 * buffer and vice versa. If the [offsetInBytes] index of the region is not
1105 * specified, it defaults to zero (the first byte in the byte buffer).
1106 * If the length is not specified, it defaults to null, which indicates
1107 * that the view extends to the end of the byte buffer.
1108 *
1109 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
1110 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
1111 * the length of [buffer].
1112 */
628 factory Uint8List.view(ByteBuffer buffer, 1113 factory Uint8List.view(ByteBuffer buffer,
629 [int byteOffset = 0, int length]) => 1114 [int byteOffset = 0, int length]) =>
630 length == null 1115 length == null
631 ? _create2(buffer, byteOffset) 1116 ? _create2(buffer, byteOffset)
632 : _create3(buffer, byteOffset, length); 1117 : _create3(buffer, byteOffset, length);
633 1118
634 static const int BYTES_PER_ELEMENT = 1; 1119 static const int BYTES_PER_ELEMENT = 1;
635 1120
636 int get length => JS("int", '#(#)', fetchLength, this); 1121 int get length => JS("int", '#(#)', fetchLength, this);
637 1122
(...skipping 19 matching lines...) Expand all
657 1142
658 static Uint8List _create2(arg1, arg2) => 1143 static Uint8List _create2(arg1, arg2) =>
659 JS('Uint8List', 'new Uint8Array(#, #)', arg1, arg2).._setCachedLength(); 1144 JS('Uint8List', 'new Uint8Array(#, #)', arg1, arg2).._setCachedLength();
660 1145
661 static Uint8List _create3(arg1, arg2, arg3) => 1146 static Uint8List _create3(arg1, arg2, arg3) =>
662 JS('Uint8List', 'new Uint8Array(#, #, #)', arg1, arg2, arg3) 1147 JS('Uint8List', 'new Uint8Array(#, #, #)', arg1, arg2, arg3)
663 .._setCachedLength(); 1148 .._setCachedLength();
664 } 1149 }
665 1150
666 1151
1152 /**
1153 * A fixed-length list of 64-bit signed integers that is viewable as a
1154 * [TypedData]. For long lists, this implementation can be considerably
1155 * more space- and time-efficient than the default [List] implementation.
1156 */
667 class Int64List extends TypedData implements JavaScriptIndexingBehavior, List<in t> { 1157 class Int64List extends TypedData implements JavaScriptIndexingBehavior, List<in t> {
1158 /**
1159 * Creates an [Int64List] of the specified length (in elements), all of
1160 * whose elements are initially zero.
1161 */
668 factory Int64List(int length) { 1162 factory Int64List(int length) {
669 throw new UnsupportedError("Int64List not supported by dart2js."); 1163 throw new UnsupportedError("Int64List not supported by dart2js.");
670 } 1164 }
671 1165
1166 /**
1167 * Creates a [Int64List] with the same size as the [elements] list
1168 * and copies over the elements.
1169 */
672 factory Int64List.fromList(List<int> list) { 1170 factory Int64List.fromList(List<int> list) {
673 throw new UnsupportedError("Int64List not supported by dart2js."); 1171 throw new UnsupportedError("Int64List not supported by dart2js.");
674 } 1172 }
675 1173
1174 /**
1175 * Creates an [Int64List] _view_ of the specified region in the specified
1176 * byte buffer. Changes in the [Int64List] will be visible in the byte buffer
1177 * and vice versa. If the [offsetInBytes] index of the region is not
1178 * specified, it defaults to zero (the first byte in the byte buffer).
1179 * If the length is not specified, it defaults to null, which indicates that
1180 * the view extends to the end of the byte buffer.
1181 *
1182 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
1183 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
1184 * the length of [buffer].
1185 *
1186 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
1187 * BYTES_PER_ELEMENT.
1188 */
676 factory Int64List.view(ByteBuffer buffer, [int byteOffset, int length]) { 1189 factory Int64List.view(ByteBuffer buffer, [int byteOffset, int length]) {
677 throw new UnsupportedError("Int64List not supported by dart2js."); 1190 throw new UnsupportedError("Int64List not supported by dart2js.");
678 } 1191 }
679 1192
680 static const int BYTES_PER_ELEMENT = 8; 1193 static const int BYTES_PER_ELEMENT = 8;
681 } 1194 }
682 1195
683 1196
1197 /**
1198 * A fixed-length list of 64-bit unsigned integers that is viewable as a
1199 * [TypedData]. For long lists, this implementation can be considerably
1200 * more space- and time-efficient than the default [List] implementation.
1201 */
684 class Uint64List extends TypedData implements JavaScriptIndexingBehavior, List<i nt> { 1202 class Uint64List extends TypedData implements JavaScriptIndexingBehavior, List<i nt> {
1203 /**
1204 * Creates a [Uint64List] of the specified length (in elements), all
1205 * of whose elements are initially zero.
1206 */
685 factory Uint64List(int length) { 1207 factory Uint64List(int length) {
686 throw new UnsupportedError("Uint64List not supported by dart2js."); 1208 throw new UnsupportedError("Uint64List not supported by dart2js.");
687 } 1209 }
688 1210
1211 /**
1212 * Creates a [Uint64List] with the same size as the [elements] list
1213 * and copies over the elements.
1214 */
689 factory Uint64List.fromList(List<int> list) { 1215 factory Uint64List.fromList(List<int> list) {
690 throw new UnsupportedError("Uint64List not supported by dart2js."); 1216 throw new UnsupportedError("Uint64List not supported by dart2js.");
691 } 1217 }
692 1218
1219 /**
1220 * Creates an [Uint64List] _view_ of the specified region in
1221 * the specified byte buffer. Changes in the [Uint64List] will be
1222 * visible in the byte buffer and vice versa. If the [offsetInBytes]
1223 * index of the region is not specified, it defaults to zero (the first
1224 * byte in the byte buffer). If the length is not specified, it defaults
1225 * to null, which indicates that the view extends to the end of the byte
1226 * buffer.
1227 *
1228 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
1229 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
1230 * the length of [buffer].
1231 *
1232 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
1233 * BYTES_PER_ELEMENT.
1234 */
693 factory Uint64List.view(ByteBuffer buffer, [int byteOffset, int length]) { 1235 factory Uint64List.view(ByteBuffer buffer, [int byteOffset, int length]) {
694 throw new UnsupportedError("Uint64List not supported by dart2js."); 1236 throw new UnsupportedError("Uint64List not supported by dart2js.");
695 } 1237 }
696 1238
697 static const int BYTES_PER_ELEMENT = 8; 1239 static const int BYTES_PER_ELEMENT = 8;
698 } 1240 }
699 1241
700 1242
1243 /**
1244 * A fixed-length list of Float32x4 numbers that is viewable as a
1245 * [TypedData]. For long lists, this implementation will be considerably more
1246 * space- and time-efficient than the default [List] implementation.
1247 */
701 class Float32x4List 1248 class Float32x4List
702 extends Object with ListMixin<Float32x4>, FixedLengthListMixin<Float32x4> 1249 extends Object with ListMixin<Float32x4>, FixedLengthListMixin<Float32x4>
703 implements List<Float32x4>, TypedData { 1250 implements List<Float32x4>, TypedData {
704 1251
705 final Float32List _storage; 1252 final Float32List _storage;
706 1253
707 ByteBuffer get buffer => _storage.buffer; 1254 ByteBuffer get buffer => _storage.buffer;
708 1255
709 int get lengthInBytes => _storage.lengthInBytes; 1256 int get lengthInBytes => _storage.lengthInBytes;
710 1257
(...skipping 20 matching lines...) Expand all
731 // [length]. However, [_checkIndex] only allows indices in the range 1278 // [length]. However, [_checkIndex] only allows indices in the range
732 // 0 .. length - 1. We therefore increment the [length] argument by one 1279 // 0 .. length - 1. We therefore increment the [length] argument by one
733 // for the [_checkIndex] checks. 1280 // for the [_checkIndex] checks.
734 _checkIndex(start, length + 1); 1281 _checkIndex(start, length + 1);
735 if (end == null) return length; 1282 if (end == null) return length;
736 _checkIndex(end, length + 1); 1283 _checkIndex(end, length + 1);
737 if (start > end) throw new RangeError.range(start, 0, end); 1284 if (start > end) throw new RangeError.range(start, 0, end);
738 return end; 1285 return end;
739 } 1286 }
740 1287
1288 /**
1289 * Creates a [Float32x4List] of the specified length (in elements),
1290 * all of whose elements are initially zero.
1291 */
741 Float32x4List(int length) : _storage = new Float32List(length*4); 1292 Float32x4List(int length) : _storage = new Float32List(length*4);
742 1293
743 Float32x4List._externalStorage(Float32List storage) : _storage = storage; 1294 Float32x4List._externalStorage(Float32List storage) : _storage = storage;
744 1295
745 Float32x4List._slowFromList(List<Float32x4> list) 1296 Float32x4List._slowFromList(List<Float32x4> list)
746 : _storage = new Float32List(list.length * 4) { 1297 : _storage = new Float32List(list.length * 4) {
747 for (int i = 0; i < list.length; i++) { 1298 for (int i = 0; i < list.length; i++) {
748 var e = list[i]; 1299 var e = list[i];
749 _storage[(i*4)+0] = e.x; 1300 _storage[(i*4)+0] = e.x;
750 _storage[(i*4)+1] = e.y; 1301 _storage[(i*4)+1] = e.y;
751 _storage[(i*4)+2] = e.z; 1302 _storage[(i*4)+2] = e.z;
752 _storage[(i*4)+3] = e.w; 1303 _storage[(i*4)+3] = e.w;
753 } 1304 }
754 } 1305 }
755 1306
1307 /**
1308 * Creates a [Float32x4List] with the same size as the [elements] list
1309 * and copies over the elements.
1310 */
756 factory Float32x4List.fromList(List<Float32x4> list) { 1311 factory Float32x4List.fromList(List<Float32x4> list) {
757 if (list is Float32x4List) { 1312 if (list is Float32x4List) {
758 Float32x4List nativeList = list as Float32x4List; 1313 Float32x4List nativeList = list as Float32x4List;
759 return new Float32x4List._externalStorage( 1314 return new Float32x4List._externalStorage(
760 new Float32List.fromList(nativeList._storage)); 1315 new Float32List.fromList(nativeList._storage));
761 } else { 1316 } else {
762 return new Float32x4List._slowFromList(list); 1317 return new Float32x4List._slowFromList(list);
763 } 1318 }
764 } 1319 }
765 1320
1321 /**
1322 * Creates a [Float32x4List] _view_ of the specified region in the specified
1323 * byte buffer. Changes in the [Float32x4List] will be visible in the byte
1324 * buffer and vice versa. If the [offsetInBytes] index of the region is not
1325 * specified, it defaults to zero (the first byte in the byte buffer).
1326 * If the length is not specified, it defaults to null, which indicates
1327 * that the view extends to the end of the byte buffer.
1328 *
1329 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
1330 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
1331 * the length of [buffer].
1332 *
1333 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
1334 * BYTES_PER_ELEMENT.
1335 */
766 Float32x4List.view(ByteBuffer buffer, 1336 Float32x4List.view(ByteBuffer buffer,
767 [int byteOffset = 0, int length]) 1337 [int byteOffset = 0, int length])
768 : _storage = new Float32List.view(buffer, byteOffset, length); 1338 : _storage = new Float32List.view(buffer, byteOffset, length);
769 1339
770 static const int BYTES_PER_ELEMENT = 16; 1340 static const int BYTES_PER_ELEMENT = 16;
771 1341
772 int get length => _storage.length ~/ 4; 1342 int get length => _storage.length ~/ 4;
773 1343
774 Float32x4 operator[](int index) { 1344 Float32x4 operator[](int index) {
775 _checkIndex(index, length); 1345 _checkIndex(index, length);
(...skipping 12 matching lines...) Expand all
788 _storage[(index*4)+3] = value._storage[3]; 1358 _storage[(index*4)+3] = value._storage[3];
789 } 1359 }
790 1360
791 List<Float32x4> sublist(int start, [int end]) { 1361 List<Float32x4> sublist(int start, [int end]) {
792 end = _checkSublistArguments(start, end, length); 1362 end = _checkSublistArguments(start, end, length);
793 return new Float32x4List._externalStorage(_storage.sublist(start*4, end*4)); 1363 return new Float32x4List._externalStorage(_storage.sublist(start*4, end*4));
794 } 1364 }
795 } 1365 }
796 1366
797 1367
1368 /**
1369 * A fixed-length list of Int32x4 numbers that is viewable as a
1370 * [TypedData]. For long lists, this implementation will be considerably more
1371 * space- and time-efficient than the default [List] implementation.
1372 */
798 class Int32x4List 1373 class Int32x4List
799 extends Object with ListMixin<Int32x4>, FixedLengthListMixin<Int32x4> 1374 extends Object with ListMixin<Int32x4>, FixedLengthListMixin<Int32x4>
800 implements List<Int32x4>, TypedData { 1375 implements List<Int32x4>, TypedData {
801 1376
802 final Uint32List _storage; 1377 final Uint32List _storage;
803 1378
804 ByteBuffer get buffer => _storage.buffer; 1379 ByteBuffer get buffer => _storage.buffer;
805 1380
806 int get lengthInBytes => _storage.lengthInBytes; 1381 int get lengthInBytes => _storage.lengthInBytes;
807 1382
(...skipping 20 matching lines...) Expand all
828 // [length]. However, [_checkIndex] only allows indices in the range 1403 // [length]. However, [_checkIndex] only allows indices in the range
829 // 0 .. length - 1. We therefore increment the [length] argument by one 1404 // 0 .. length - 1. We therefore increment the [length] argument by one
830 // for the [_checkIndex] checks. 1405 // for the [_checkIndex] checks.
831 _checkIndex(start, length + 1); 1406 _checkIndex(start, length + 1);
832 if (end == null) return length; 1407 if (end == null) return length;
833 _checkIndex(end, length + 1); 1408 _checkIndex(end, length + 1);
834 if (start > end) throw new RangeError.range(start, 0, end); 1409 if (start > end) throw new RangeError.range(start, 0, end);
835 return end; 1410 return end;
836 } 1411 }
837 1412
1413 /**
1414 * Creates a [Int32x4List] of the specified length (in elements),
1415 * all of whose elements are initially zero.
1416 */
838 Int32x4List(int length) : _storage = new Uint32List(length*4); 1417 Int32x4List(int length) : _storage = new Uint32List(length*4);
839 1418
840 Int32x4List._externalStorage(Uint32List storage) : _storage = storage; 1419 Int32x4List._externalStorage(Uint32List storage) : _storage = storage;
841 1420
842 Int32x4List._slowFromList(List<Int32x4> list) 1421 Int32x4List._slowFromList(List<Int32x4> list)
843 : _storage = new Uint32List(list.length * 4) { 1422 : _storage = new Uint32List(list.length * 4) {
844 for (int i = 0; i < list.length; i++) { 1423 for (int i = 0; i < list.length; i++) {
845 var e = list[i]; 1424 var e = list[i];
846 _storage[(i*4)+0] = e.x; 1425 _storage[(i*4)+0] = e.x;
847 _storage[(i*4)+1] = e.y; 1426 _storage[(i*4)+1] = e.y;
848 _storage[(i*4)+2] = e.z; 1427 _storage[(i*4)+2] = e.z;
849 _storage[(i*4)+3] = e.w; 1428 _storage[(i*4)+3] = e.w;
850 } 1429 }
851 } 1430 }
852 1431
1432 /**
1433 * Creates a [Int32x4List] with the same size as the [elements] list
1434 * and copies over the elements.
1435 */
853 factory Int32x4List.fromList(List<Int32x4> list) { 1436 factory Int32x4List.fromList(List<Int32x4> list) {
854 if (list is Int32x4List) { 1437 if (list is Int32x4List) {
855 Int32x4List nativeList = list as Int32x4List; 1438 Int32x4List nativeList = list as Int32x4List;
856 return new Int32x4List._externalStorage( 1439 return new Int32x4List._externalStorage(
857 new Uint32List.fromList(nativeList._storage)); 1440 new Uint32List.fromList(nativeList._storage));
858 } else { 1441 } else {
859 return new Int32x4List._slowFromList(list); 1442 return new Int32x4List._slowFromList(list);
860 } 1443 }
861 } 1444 }
862 1445
1446 /**
1447 * Creates a [Int32x4List] _view_ of the specified region in the specified
1448 * byte buffer. Changes in the [Int32x4List] will be visible in the byte
1449 * buffer and vice versa. If the [offsetInBytes] index of the region is not
1450 * specified, it defaults to zero (the first byte in the byte buffer).
1451 * If the length is not specified, it defaults to null, which indicates
1452 * that the view extends to the end of the byte buffer.
1453 *
1454 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
1455 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
1456 * the length of [buffer].
1457 *
1458 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
1459 * BYTES_PER_ELEMENT.
1460 */
863 Int32x4List.view(ByteBuffer buffer, 1461 Int32x4List.view(ByteBuffer buffer,
864 [int byteOffset = 0, int length]) 1462 [int byteOffset = 0, int length])
865 : _storage = new Uint32List.view(buffer, byteOffset, length); 1463 : _storage = new Uint32List.view(buffer, byteOffset, length);
866 1464
867 static const int BYTES_PER_ELEMENT = 16; 1465 static const int BYTES_PER_ELEMENT = 16;
868 1466
869 int get length => _storage.length ~/ 4; 1467 int get length => _storage.length ~/ 4;
870 1468
871 Int32x4 operator[](int index) { 1469 Int32x4 operator[](int index) {
872 _checkIndex(index, length); 1470 _checkIndex(index, length);
(...skipping 12 matching lines...) Expand all
885 _storage[(index*4)+3] = value._storage[3]; 1483 _storage[(index*4)+3] = value._storage[3];
886 } 1484 }
887 1485
888 List<Int32x4> sublist(int start, [int end]) { 1486 List<Int32x4> sublist(int start, [int end]) {
889 end = _checkSublistArguments(start, end, length); 1487 end = _checkSublistArguments(start, end, length);
890 return new Int32x4List._externalStorage(_storage.sublist(start*4, end*4)); 1488 return new Int32x4List._externalStorage(_storage.sublist(start*4, end*4));
891 } 1489 }
892 } 1490 }
893 1491
894 1492
1493 /**
1494 * Interface of Dart Float32x4 immutable value type and operations.
1495 * Float32x4 stores 4 32-bit floating point values in "lanes".
1496 * The lanes are "x", "y", "z", and "w" respectively.
1497 */
895 class Float32x4 { 1498 class Float32x4 {
896 final _storage = new Float32List(4); 1499 final _storage = new Float32List(4);
897 1500
898 Float32x4(double x, double y, double z, double w) { 1501 Float32x4(double x, double y, double z, double w) {
899 _storage[0] = x; 1502 _storage[0] = x;
900 _storage[1] = y; 1503 _storage[1] = y;
901 _storage[2] = z; 1504 _storage[2] = z;
902 _storage[3] = w; 1505 _storage[3] = w;
903 } 1506 }
904 Float32x4.splat(double v) { 1507 Float32x4.splat(double v) {
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 Float32x4 reciprocalSqrt() { 2068 Float32x4 reciprocalSqrt() {
1466 double _x = Math.sqrt(1.0 / _storage[0]); 2069 double _x = Math.sqrt(1.0 / _storage[0]);
1467 double _y = Math.sqrt(1.0 / _storage[1]); 2070 double _y = Math.sqrt(1.0 / _storage[1]);
1468 double _z = Math.sqrt(1.0 / _storage[2]); 2071 double _z = Math.sqrt(1.0 / _storage[2]);
1469 double _w = Math.sqrt(1.0 / _storage[3]); 2072 double _w = Math.sqrt(1.0 / _storage[3]);
1470 return new Float32x4(_x, _y, _z, _w); 2073 return new Float32x4(_x, _y, _z, _w);
1471 } 2074 }
1472 } 2075 }
1473 2076
1474 2077
2078 /**
2079 * Interface of Dart Int32x4 and operations.
2080 * Int32x4 stores 4 32-bit bit-masks in "lanes".
2081 * The lanes are "x", "y", "z", and "w" respectively.
2082 */
1475 class Int32x4 { 2083 class Int32x4 {
1476 final _storage = new Int32List(4); 2084 final _storage = new Int32List(4);
1477 2085
1478 Int32x4(int x, int y, int z, int w) { 2086 Int32x4(int x, int y, int z, int w) {
1479 _storage[0] = x; 2087 _storage[0] = x;
1480 _storage[1] = y; 2088 _storage[1] = y;
1481 _storage[2] = z; 2089 _storage[2] = z;
1482 _storage[3] = w; 2090 _storage[3] = w;
1483 } 2091 }
1484 2092
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 int _w = (cmw & stw) | (~cmw & sfw); 2558 int _w = (cmw & stw) | (~cmw & sfw);
1951 var r = new Float32x4(0.0, 0.0, 0.0, 0.0); 2559 var r = new Float32x4(0.0, 0.0, 0.0, 0.0);
1952 var rView = new Int32List.view(r._storage.buffer); 2560 var rView = new Int32List.view(r._storage.buffer);
1953 rView[0] = _x; 2561 rView[0] = _x;
1954 rView[1] = _y; 2562 rView[1] = _y;
1955 rView[2] = _z; 2563 rView[2] = _z;
1956 rView[3] = _w; 2564 rView[3] = _w;
1957 return r; 2565 return r;
1958 } 2566 }
1959 } 2567 }
OLDNEW
« no previous file with comments | « dart/sdk/lib/math/point.dart ('k') | dart/tests/co19/co19-analyzer.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698