OLD | NEW |
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 // patch classes for Int8List ..... Float64List and ByteData implementations. | 5 // patch classes for Int8List ..... Float64List and ByteData implementations. |
6 | 6 |
7 patch class Int8List { | 7 patch class Int8List { |
8 /* patch */ factory Int8List(int length) { | 8 /* patch */ factory Int8List(int length) { |
9 return new _Int8Array(length); | 9 return new _Int8Array(length); |
10 } | 10 } |
(...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2184 _current = null; | 2184 _current = null; |
2185 return false; | 2185 return false; |
2186 } | 2186 } |
2187 | 2187 |
2188 E get current => _current; | 2188 E get current => _current; |
2189 } | 2189 } |
2190 | 2190 |
2191 | 2191 |
2192 class _TypedListView extends _TypedListBase implements TypedData { | 2192 class _TypedListView extends _TypedListBase implements TypedData { |
2193 _TypedListView(ByteBuffer _buffer, int _offset, int _length) | 2193 _TypedListView(ByteBuffer _buffer, int _offset, int _length) |
2194 : _typeddata = _buffer, // This assignment is type safe. | 2194 : _typedData = _buffer, // This assignment is type safe. |
2195 offsetInBytes = _offset, | 2195 offsetInBytes = _offset, |
2196 length = _length { | 2196 length = _length { |
2197 } | 2197 } |
2198 | 2198 |
2199 | 2199 |
2200 // Method(s) implementing the TypedData interface. | 2200 // Method(s) implementing the TypedData interface. |
2201 | 2201 |
2202 int get lengthInBytes { | 2202 int get lengthInBytes { |
2203 return length * elementSizeInBytes; | 2203 return length * elementSizeInBytes; |
2204 } | 2204 } |
2205 | 2205 |
2206 ByteBuffer get buffer { | 2206 ByteBuffer get buffer { |
2207 return _typeddata.buffer; | 2207 return _typedData.buffer; |
2208 } | 2208 } |
2209 | 2209 |
2210 final TypedData _typeddata; | 2210 final TypedData _typedData; |
2211 final int offsetInBytes; | 2211 final int offsetInBytes; |
2212 final int length; | 2212 final int length; |
2213 } | 2213 } |
2214 | 2214 |
2215 | 2215 |
2216 class _Int8ArrayView extends _TypedListView implements Int8List { | 2216 class _Int8ArrayView extends _TypedListView implements Int8List { |
2217 // Constructor. | 2217 // Constructor. |
2218 _Int8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | 2218 _Int8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) |
2219 : super(buffer, _offsetInBytes, | 2219 : super(buffer, _offsetInBytes, |
2220 _defaultIfNull(_length, | 2220 _defaultIfNull(_length, |
2221 ((buffer.lengthInBytes - _offsetInBytes) ~/ | 2221 ((buffer.lengthInBytes - _offsetInBytes) ~/ |
2222 Int8List.BYTES_PER_ELEMENT))) { | 2222 Int8List.BYTES_PER_ELEMENT))) { |
2223 _rangeCheck(buffer.lengthInBytes, | 2223 _rangeCheck(buffer.lengthInBytes, |
2224 _offsetInBytes, | 2224 _offsetInBytes, |
2225 length * Int8List.BYTES_PER_ELEMENT); | 2225 length * Int8List.BYTES_PER_ELEMENT); |
2226 } | 2226 } |
2227 | 2227 |
2228 | 2228 |
2229 // Method(s) implementing List interface. | 2229 // Method(s) implementing List interface. |
2230 | 2230 |
2231 int operator[](int index) { | 2231 int operator[](int index) { |
2232 if (index < 0 || index >= length) { | 2232 if (index < 0 || index >= length) { |
2233 _throwRangeError(index, length); | 2233 _throwRangeError(index, length); |
2234 } | 2234 } |
2235 return _typeddata._getInt8(offsetInBytes + | 2235 return _typedData._getInt8(offsetInBytes + |
2236 (index * Int8List.BYTES_PER_ELEMENT)); | 2236 (index * Int8List.BYTES_PER_ELEMENT)); |
2237 } | 2237 } |
2238 | 2238 |
2239 void operator[]=(int index, int value) { | 2239 void operator[]=(int index, int value) { |
2240 if (index < 0 || index >= length) { | 2240 if (index < 0 || index >= length) { |
2241 _throwRangeError(index, length); | 2241 _throwRangeError(index, length); |
2242 } | 2242 } |
2243 _typeddata._setInt8(offsetInBytes + (index * Int8List.BYTES_PER_ELEMENT), | 2243 _typedData._setInt8(offsetInBytes + (index * Int8List.BYTES_PER_ELEMENT), |
2244 _toInt8(value)); | 2244 _toInt8(value)); |
2245 } | 2245 } |
2246 | 2246 |
2247 Iterator<int> get iterator { | 2247 Iterator<int> get iterator { |
2248 return new _TypedListIterator<int>(this); | 2248 return new _TypedListIterator<int>(this); |
2249 } | 2249 } |
2250 | 2250 |
2251 | 2251 |
2252 // Method(s) implementing TypedData interface. | 2252 // Method(s) implementing TypedData interface. |
2253 | 2253 |
(...skipping 22 matching lines...) Expand all Loading... |
2276 length * Uint8List.BYTES_PER_ELEMENT); | 2276 length * Uint8List.BYTES_PER_ELEMENT); |
2277 } | 2277 } |
2278 | 2278 |
2279 | 2279 |
2280 // Method(s) implementing List interface. | 2280 // Method(s) implementing List interface. |
2281 | 2281 |
2282 int operator[](int index) { | 2282 int operator[](int index) { |
2283 if (index < 0 || index >= length) { | 2283 if (index < 0 || index >= length) { |
2284 _throwRangeError(index, length); | 2284 _throwRangeError(index, length); |
2285 } | 2285 } |
2286 return _typeddata._getUint8(offsetInBytes + | 2286 return _typedData._getUint8(offsetInBytes + |
2287 (index * Uint8List.BYTES_PER_ELEMENT)); | 2287 (index * Uint8List.BYTES_PER_ELEMENT)); |
2288 } | 2288 } |
2289 | 2289 |
2290 void operator[]=(int index, int value) { | 2290 void operator[]=(int index, int value) { |
2291 if (index < 0 || index >= length) { | 2291 if (index < 0 || index >= length) { |
2292 _throwRangeError(index, length); | 2292 _throwRangeError(index, length); |
2293 } | 2293 } |
2294 _typeddata._setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT), | 2294 _typedData._setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT), |
2295 _toUint8(value)); | 2295 _toUint8(value)); |
2296 } | 2296 } |
2297 | 2297 |
2298 Iterator<int> get iterator { | 2298 Iterator<int> get iterator { |
2299 return new _TypedListIterator<int>(this); | 2299 return new _TypedListIterator<int>(this); |
2300 } | 2300 } |
2301 | 2301 |
2302 | 2302 |
2303 // Method(s) implementing TypedData interface. | 2303 // Method(s) implementing TypedData interface. |
2304 | 2304 |
(...skipping 23 matching lines...) Expand all Loading... |
2328 length * Uint8List.BYTES_PER_ELEMENT); | 2328 length * Uint8List.BYTES_PER_ELEMENT); |
2329 } | 2329 } |
2330 | 2330 |
2331 | 2331 |
2332 // Method(s) implementing List interface. | 2332 // Method(s) implementing List interface. |
2333 | 2333 |
2334 int operator[](int index) { | 2334 int operator[](int index) { |
2335 if (index < 0 || index >= length) { | 2335 if (index < 0 || index >= length) { |
2336 _throwRangeError(index, length); | 2336 _throwRangeError(index, length); |
2337 } | 2337 } |
2338 return _typeddata._getUint8(offsetInBytes + | 2338 return _typedData._getUint8(offsetInBytes + |
2339 (index * Uint8List.BYTES_PER_ELEMENT)); | 2339 (index * Uint8List.BYTES_PER_ELEMENT)); |
2340 } | 2340 } |
2341 | 2341 |
2342 void operator[]=(int index, int value) { | 2342 void operator[]=(int index, int value) { |
2343 if (index < 0 || index >= length) { | 2343 if (index < 0 || index >= length) { |
2344 _throwRangeError(index, length); | 2344 _throwRangeError(index, length); |
2345 } | 2345 } |
2346 _typeddata._setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT), | 2346 _typedData._setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT), |
2347 _toClampedUint8(value)); | 2347 _toClampedUint8(value)); |
2348 } | 2348 } |
2349 | 2349 |
2350 Iterator<int> get iterator { | 2350 Iterator<int> get iterator { |
2351 return new _TypedListIterator<int>(this); | 2351 return new _TypedListIterator<int>(this); |
2352 } | 2352 } |
2353 | 2353 |
2354 | 2354 |
2355 // Method(s) implementing TypedData interface. | 2355 // Method(s) implementing TypedData interface. |
2356 | 2356 |
(...skipping 22 matching lines...) Expand all Loading... |
2379 length * Int16List.BYTES_PER_ELEMENT); | 2379 length * Int16List.BYTES_PER_ELEMENT); |
2380 } | 2380 } |
2381 | 2381 |
2382 | 2382 |
2383 // Method(s) implementing List interface. | 2383 // Method(s) implementing List interface. |
2384 | 2384 |
2385 int operator[](int index) { | 2385 int operator[](int index) { |
2386 if (index < 0 || index >= length) { | 2386 if (index < 0 || index >= length) { |
2387 _throwRangeError(index, length); | 2387 _throwRangeError(index, length); |
2388 } | 2388 } |
2389 return _typeddata._getInt16(offsetInBytes + | 2389 return _typedData._getInt16(offsetInBytes + |
2390 (index * Int16List.BYTES_PER_ELEMENT)); | 2390 (index * Int16List.BYTES_PER_ELEMENT)); |
2391 } | 2391 } |
2392 | 2392 |
2393 void operator[]=(int index, int value) { | 2393 void operator[]=(int index, int value) { |
2394 if (index < 0 || index >= length) { | 2394 if (index < 0 || index >= length) { |
2395 _throwRangeError(index, length); | 2395 _throwRangeError(index, length); |
2396 } | 2396 } |
2397 _typeddata._setInt16(offsetInBytes + (index * Int16List.BYTES_PER_ELEMENT), | 2397 _typedData._setInt16(offsetInBytes + (index * Int16List.BYTES_PER_ELEMENT), |
2398 _toInt16(value)); | 2398 _toInt16(value)); |
2399 } | 2399 } |
2400 | 2400 |
2401 Iterator<int> get iterator { | 2401 Iterator<int> get iterator { |
2402 return new _TypedListIterator<int>(this); | 2402 return new _TypedListIterator<int>(this); |
2403 } | 2403 } |
2404 | 2404 |
2405 | 2405 |
2406 // Method(s) implementing TypedData interface. | 2406 // Method(s) implementing TypedData interface. |
2407 | 2407 |
(...skipping 22 matching lines...) Expand all Loading... |
2430 length * Uint16List.BYTES_PER_ELEMENT); | 2430 length * Uint16List.BYTES_PER_ELEMENT); |
2431 } | 2431 } |
2432 | 2432 |
2433 | 2433 |
2434 // Method(s) implementing List interface. | 2434 // Method(s) implementing List interface. |
2435 | 2435 |
2436 int operator[](int index) { | 2436 int operator[](int index) { |
2437 if (index < 0 || index >= length) { | 2437 if (index < 0 || index >= length) { |
2438 _throwRangeError(index, length); | 2438 _throwRangeError(index, length); |
2439 } | 2439 } |
2440 return _typeddata._getUint16(offsetInBytes + | 2440 return _typedData._getUint16(offsetInBytes + |
2441 (index * Uint16List.BYTES_PER_ELEMENT)); | 2441 (index * Uint16List.BYTES_PER_ELEMENT)); |
2442 } | 2442 } |
2443 | 2443 |
2444 void operator[]=(int index, int value) { | 2444 void operator[]=(int index, int value) { |
2445 if (index < 0 || index >= length) { | 2445 if (index < 0 || index >= length) { |
2446 _throwRangeError(index, length); | 2446 _throwRangeError(index, length); |
2447 } | 2447 } |
2448 _typeddata._setUint16(offsetInBytes + (index * Uint16List.BYTES_PER_ELEMENT)
, | 2448 _typedData._setUint16(offsetInBytes + (index * Uint16List.BYTES_PER_ELEMENT)
, |
2449 _toUint16(value)); | 2449 _toUint16(value)); |
2450 } | 2450 } |
2451 | 2451 |
2452 Iterator<int> get iterator { | 2452 Iterator<int> get iterator { |
2453 return new _TypedListIterator<int>(this); | 2453 return new _TypedListIterator<int>(this); |
2454 } | 2454 } |
2455 | 2455 |
2456 | 2456 |
2457 // Method(s) implementing TypedData interface. | 2457 // Method(s) implementing TypedData interface. |
2458 | 2458 |
(...skipping 22 matching lines...) Expand all Loading... |
2481 length * Int32List.BYTES_PER_ELEMENT); | 2481 length * Int32List.BYTES_PER_ELEMENT); |
2482 } | 2482 } |
2483 | 2483 |
2484 | 2484 |
2485 // Method(s) implementing List interface. | 2485 // Method(s) implementing List interface. |
2486 | 2486 |
2487 int operator[](int index) { | 2487 int operator[](int index) { |
2488 if (index < 0 || index >= length) { | 2488 if (index < 0 || index >= length) { |
2489 _throwRangeError(index, length); | 2489 _throwRangeError(index, length); |
2490 } | 2490 } |
2491 return _typeddata._getInt32(offsetInBytes + | 2491 return _typedData._getInt32(offsetInBytes + |
2492 (index * Int32List.BYTES_PER_ELEMENT)); | 2492 (index * Int32List.BYTES_PER_ELEMENT)); |
2493 } | 2493 } |
2494 | 2494 |
2495 void operator[]=(int index, int value) { | 2495 void operator[]=(int index, int value) { |
2496 if (index < 0 || index >= length) { | 2496 if (index < 0 || index >= length) { |
2497 _throwRangeError(index, length); | 2497 _throwRangeError(index, length); |
2498 } | 2498 } |
2499 _typeddata._setInt32(offsetInBytes + (index * Int32List.BYTES_PER_ELEMENT), | 2499 _typedData._setInt32(offsetInBytes + (index * Int32List.BYTES_PER_ELEMENT), |
2500 _toInt32(value)); | 2500 _toInt32(value)); |
2501 } | 2501 } |
2502 | 2502 |
2503 Iterator<int> get iterator { | 2503 Iterator<int> get iterator { |
2504 return new _TypedListIterator<int>(this); | 2504 return new _TypedListIterator<int>(this); |
2505 } | 2505 } |
2506 | 2506 |
2507 | 2507 |
2508 // Method(s) implementing TypedData interface. | 2508 // Method(s) implementing TypedData interface. |
2509 | 2509 |
(...skipping 22 matching lines...) Expand all Loading... |
2532 length * Uint32List.BYTES_PER_ELEMENT); | 2532 length * Uint32List.BYTES_PER_ELEMENT); |
2533 } | 2533 } |
2534 | 2534 |
2535 | 2535 |
2536 // Method(s) implementing List interface. | 2536 // Method(s) implementing List interface. |
2537 | 2537 |
2538 int operator[](int index) { | 2538 int operator[](int index) { |
2539 if (index < 0 || index >= length) { | 2539 if (index < 0 || index >= length) { |
2540 _throwRangeError(index, length); | 2540 _throwRangeError(index, length); |
2541 } | 2541 } |
2542 return _typeddata._getUint32(offsetInBytes + | 2542 return _typedData._getUint32(offsetInBytes + |
2543 (index * Uint32List.BYTES_PER_ELEMENT)); | 2543 (index * Uint32List.BYTES_PER_ELEMENT)); |
2544 } | 2544 } |
2545 | 2545 |
2546 void operator[]=(int index, int value) { | 2546 void operator[]=(int index, int value) { |
2547 if (index < 0 || index >= length) { | 2547 if (index < 0 || index >= length) { |
2548 _throwRangeError(index, length); | 2548 _throwRangeError(index, length); |
2549 } | 2549 } |
2550 _typeddata._setUint32(offsetInBytes + (index * Uint32List.BYTES_PER_ELEMENT)
, | 2550 _typedData._setUint32(offsetInBytes + (index * Uint32List.BYTES_PER_ELEMENT)
, |
2551 _toUint32(value)); | 2551 _toUint32(value)); |
2552 } | 2552 } |
2553 | 2553 |
2554 Iterator<int> get iterator { | 2554 Iterator<int> get iterator { |
2555 return new _TypedListIterator<int>(this); | 2555 return new _TypedListIterator<int>(this); |
2556 } | 2556 } |
2557 | 2557 |
2558 | 2558 |
2559 // Method(s) implementing TypedData interface. | 2559 // Method(s) implementing TypedData interface. |
2560 | 2560 |
(...skipping 22 matching lines...) Expand all Loading... |
2583 length * Int64List.BYTES_PER_ELEMENT); | 2583 length * Int64List.BYTES_PER_ELEMENT); |
2584 } | 2584 } |
2585 | 2585 |
2586 | 2586 |
2587 // Method(s) implementing List interface. | 2587 // Method(s) implementing List interface. |
2588 | 2588 |
2589 int operator[](int index) { | 2589 int operator[](int index) { |
2590 if (index < 0 || index >= length) { | 2590 if (index < 0 || index >= length) { |
2591 _throwRangeError(index, length); | 2591 _throwRangeError(index, length); |
2592 } | 2592 } |
2593 return _typeddata._getInt64(offsetInBytes + | 2593 return _typedData._getInt64(offsetInBytes + |
2594 (index * Int64List.BYTES_PER_ELEMENT)); | 2594 (index * Int64List.BYTES_PER_ELEMENT)); |
2595 } | 2595 } |
2596 | 2596 |
2597 void operator[]=(int index, int value) { | 2597 void operator[]=(int index, int value) { |
2598 if (index < 0 || index >= length) { | 2598 if (index < 0 || index >= length) { |
2599 _throwRangeError(index, length); | 2599 _throwRangeError(index, length); |
2600 } | 2600 } |
2601 _typeddata._setInt64(offsetInBytes + (index * Int64List.BYTES_PER_ELEMENT), | 2601 _typedData._setInt64(offsetInBytes + (index * Int64List.BYTES_PER_ELEMENT), |
2602 _toInt64(value)); | 2602 _toInt64(value)); |
2603 } | 2603 } |
2604 | 2604 |
2605 Iterator<int> get iterator { | 2605 Iterator<int> get iterator { |
2606 return new _TypedListIterator<int>(this); | 2606 return new _TypedListIterator<int>(this); |
2607 } | 2607 } |
2608 | 2608 |
2609 | 2609 |
2610 // Method(s) implementing TypedData interface. | 2610 // Method(s) implementing TypedData interface. |
2611 | 2611 |
(...skipping 22 matching lines...) Expand all Loading... |
2634 length * Uint64List.BYTES_PER_ELEMENT); | 2634 length * Uint64List.BYTES_PER_ELEMENT); |
2635 } | 2635 } |
2636 | 2636 |
2637 | 2637 |
2638 // Method(s) implementing List interface. | 2638 // Method(s) implementing List interface. |
2639 | 2639 |
2640 int operator[](int index) { | 2640 int operator[](int index) { |
2641 if (index < 0 || index >= length) { | 2641 if (index < 0 || index >= length) { |
2642 _throwRangeError(index, length); | 2642 _throwRangeError(index, length); |
2643 } | 2643 } |
2644 return _typeddata._getUint64(offsetInBytes + | 2644 return _typedData._getUint64(offsetInBytes + |
2645 (index * Uint64List.BYTES_PER_ELEMENT)); | 2645 (index * Uint64List.BYTES_PER_ELEMENT)); |
2646 } | 2646 } |
2647 | 2647 |
2648 void operator[]=(int index, int value) { | 2648 void operator[]=(int index, int value) { |
2649 if (index < 0 || index >= length) { | 2649 if (index < 0 || index >= length) { |
2650 _throwRangeError(index, length); | 2650 _throwRangeError(index, length); |
2651 } | 2651 } |
2652 _typeddata._setUint64(offsetInBytes + (index * Uint64List.BYTES_PER_ELEMENT)
, | 2652 _typedData._setUint64(offsetInBytes + (index * Uint64List.BYTES_PER_ELEMENT)
, |
2653 _toUint64(value)); | 2653 _toUint64(value)); |
2654 } | 2654 } |
2655 | 2655 |
2656 Iterator<int> get iterator { | 2656 Iterator<int> get iterator { |
2657 return new _TypedListIterator<int>(this); | 2657 return new _TypedListIterator<int>(this); |
2658 } | 2658 } |
2659 | 2659 |
2660 | 2660 |
2661 // Method(s) implementing TypedData interface. | 2661 // Method(s) implementing TypedData interface. |
2662 | 2662 |
(...skipping 22 matching lines...) Expand all Loading... |
2685 length * Float32List.BYTES_PER_ELEMENT); | 2685 length * Float32List.BYTES_PER_ELEMENT); |
2686 } | 2686 } |
2687 | 2687 |
2688 | 2688 |
2689 // Method(s) implementing List interface. | 2689 // Method(s) implementing List interface. |
2690 | 2690 |
2691 double operator[](int index) { | 2691 double operator[](int index) { |
2692 if (index < 0 || index >= length) { | 2692 if (index < 0 || index >= length) { |
2693 _throwRangeError(index, length); | 2693 _throwRangeError(index, length); |
2694 } | 2694 } |
2695 return _typeddata._getFloat32(offsetInBytes + | 2695 return _typedData._getFloat32(offsetInBytes + |
2696 (index * Float32List.BYTES_PER_ELEMENT)); | 2696 (index * Float32List.BYTES_PER_ELEMENT)); |
2697 } | 2697 } |
2698 | 2698 |
2699 void operator[]=(int index, double value) { | 2699 void operator[]=(int index, double value) { |
2700 if (index < 0 || index >= length) { | 2700 if (index < 0 || index >= length) { |
2701 _throwRangeError(index, length); | 2701 _throwRangeError(index, length); |
2702 } | 2702 } |
2703 _typeddata._setFloat32(offsetInBytes + | 2703 _typedData._setFloat32(offsetInBytes + |
2704 (index * Float32List.BYTES_PER_ELEMENT), value); | 2704 (index * Float32List.BYTES_PER_ELEMENT), value); |
2705 } | 2705 } |
2706 | 2706 |
2707 Iterator<double> get iterator { | 2707 Iterator<double> get iterator { |
2708 return new _TypedListIterator<double>(this); | 2708 return new _TypedListIterator<double>(this); |
2709 } | 2709 } |
2710 | 2710 |
2711 | 2711 |
2712 // Method(s) implementing TypedData interface. | 2712 // Method(s) implementing TypedData interface. |
2713 | 2713 |
(...skipping 22 matching lines...) Expand all Loading... |
2736 length * Float64List.BYTES_PER_ELEMENT); | 2736 length * Float64List.BYTES_PER_ELEMENT); |
2737 } | 2737 } |
2738 | 2738 |
2739 | 2739 |
2740 // Method(s) implementing List interface. | 2740 // Method(s) implementing List interface. |
2741 | 2741 |
2742 double operator[](int index) { | 2742 double operator[](int index) { |
2743 if (index < 0 || index >= length) { | 2743 if (index < 0 || index >= length) { |
2744 _throwRangeError(index, length); | 2744 _throwRangeError(index, length); |
2745 } | 2745 } |
2746 return _typeddata._getFloat64(offsetInBytes + | 2746 return _typedData._getFloat64(offsetInBytes + |
2747 (index * Float64List.BYTES_PER_ELEMENT)); | 2747 (index * Float64List.BYTES_PER_ELEMENT)); |
2748 } | 2748 } |
2749 | 2749 |
2750 void operator[]=(int index, double value) { | 2750 void operator[]=(int index, double value) { |
2751 if (index < 0 || index >= length) { | 2751 if (index < 0 || index >= length) { |
2752 _throwRangeError(index, length); | 2752 _throwRangeError(index, length); |
2753 } | 2753 } |
2754 _typeddata._setFloat64(offsetInBytes + | 2754 _typedData._setFloat64(offsetInBytes + |
2755 (index * Float64List.BYTES_PER_ELEMENT), value); | 2755 (index * Float64List.BYTES_PER_ELEMENT), value); |
2756 } | 2756 } |
2757 | 2757 |
2758 Iterator<double> get iterator { | 2758 Iterator<double> get iterator { |
2759 return new _TypedListIterator<double>(this); | 2759 return new _TypedListIterator<double>(this); |
2760 } | 2760 } |
2761 | 2761 |
2762 | 2762 |
2763 // Method(s) implementing TypedData interface. | 2763 // Method(s) implementing TypedData interface. |
2764 | 2764 |
(...skipping 22 matching lines...) Expand all Loading... |
2787 length * Float32x4List.BYTES_PER_ELEMENT); | 2787 length * Float32x4List.BYTES_PER_ELEMENT); |
2788 } | 2788 } |
2789 | 2789 |
2790 | 2790 |
2791 // Method(s) implementing List interface. | 2791 // Method(s) implementing List interface. |
2792 | 2792 |
2793 Float32x4 operator[](int index) { | 2793 Float32x4 operator[](int index) { |
2794 if (index < 0 || index >= length) { | 2794 if (index < 0 || index >= length) { |
2795 _throwRangeError(index, length); | 2795 _throwRangeError(index, length); |
2796 } | 2796 } |
2797 return _typeddata._getFloat32x4(offsetInBytes + | 2797 return _typedData._getFloat32x4(offsetInBytes + |
2798 (index * Float32x4List.BYTES_PER_ELEMENT)); | 2798 (index * Float32x4List.BYTES_PER_ELEMENT)); |
2799 } | 2799 } |
2800 | 2800 |
2801 void operator[]=(int index, Float32x4 value) { | 2801 void operator[]=(int index, Float32x4 value) { |
2802 if (index < 0 || index >= length) { | 2802 if (index < 0 || index >= length) { |
2803 _throwRangeError(index, length); | 2803 _throwRangeError(index, length); |
2804 } | 2804 } |
2805 _typeddata._setFloat32x4(offsetInBytes + | 2805 _typedData._setFloat32x4(offsetInBytes + |
2806 (index * Float32x4List.BYTES_PER_ELEMENT), value); | 2806 (index * Float32x4List.BYTES_PER_ELEMENT), value); |
2807 } | 2807 } |
2808 | 2808 |
2809 Iterator<Float32x4> get iterator { | 2809 Iterator<Float32x4> get iterator { |
2810 return new _TypedListIterator<Float32x4>(this); | 2810 return new _TypedListIterator<Float32x4>(this); |
2811 } | 2811 } |
2812 | 2812 |
2813 | 2813 |
2814 // Method(s) implementing TypedData interface. | 2814 // Method(s) implementing TypedData interface. |
2815 | 2815 |
2816 int get elementSizeInBytes { | 2816 int get elementSizeInBytes { |
2817 return Float32x4List.BYTES_PER_ELEMENT; | 2817 return Float32x4List.BYTES_PER_ELEMENT; |
2818 } | 2818 } |
2819 | 2819 |
2820 | 2820 |
2821 // Internal utility methods. | 2821 // Internal utility methods. |
2822 | 2822 |
2823 Float32x4List _createList(int length) { | 2823 Float32x4List _createList(int length) { |
2824 return new Float32x4List(length); | 2824 return new Float32x4List(length); |
2825 } | 2825 } |
2826 } | 2826 } |
2827 | 2827 |
2828 | 2828 |
2829 class _ByteDataView implements ByteData { | 2829 class _ByteDataView implements ByteData { |
2830 _ByteDataView(ByteBuffer _buffer, int _offsetInBytes, int _lengthInBytes) | 2830 _ByteDataView(ByteBuffer _buffer, int _offsetInBytes, int _lengthInBytes) |
2831 : _typeddata = _buffer, // _buffer is guaranteed to be a TypedData here. | 2831 : _typedData = _buffer, // _buffer is guaranteed to be a TypedData here. |
2832 _offset = _offsetInBytes, | 2832 _offset = _offsetInBytes, |
2833 length = _lengthInBytes { | 2833 length = _lengthInBytes { |
2834 _rangeCheck(_buffer.lengthInBytes, _offset, length); | 2834 _rangeCheck(_buffer.lengthInBytes, _offset, length); |
2835 } | 2835 } |
2836 | 2836 |
2837 | 2837 |
2838 // Method(s) implementing TypedData interface. | 2838 // Method(s) implementing TypedData interface. |
2839 | 2839 |
2840 ByteBuffer get buffer { | 2840 ByteBuffer get buffer { |
2841 return _typeddata.buffer; | 2841 return _typedData.buffer; |
2842 } | 2842 } |
2843 | 2843 |
2844 int get lengthInBytes { | 2844 int get lengthInBytes { |
2845 return length; | 2845 return length; |
2846 } | 2846 } |
2847 | 2847 |
2848 int get offsetInBytes { | 2848 int get offsetInBytes { |
2849 return _offset; | 2849 return _offset; |
2850 } | 2850 } |
2851 | 2851 |
2852 // Method(s) implementing ByteData interface. | 2852 // Method(s) implementing ByteData interface. |
2853 | 2853 |
2854 int getInt8(int byteOffset) { | 2854 int getInt8(int byteOffset) { |
2855 if (byteOffset < 0 || byteOffset >= length) { | 2855 if (byteOffset < 0 || byteOffset >= length) { |
2856 _throwRangeError(byteOffset, length); | 2856 _throwRangeError(byteOffset, length); |
2857 } | 2857 } |
2858 return _typeddata._getInt8(_offset + byteOffset); | 2858 return _typedData._getInt8(_offset + byteOffset); |
2859 } | 2859 } |
2860 void setInt8(int byteOffset, int value) { | 2860 void setInt8(int byteOffset, int value) { |
2861 if (byteOffset < 0 || byteOffset >= length) { | 2861 if (byteOffset < 0 || byteOffset >= length) { |
2862 _throwRangeError(byteOffset, length); | 2862 _throwRangeError(byteOffset, length); |
2863 } | 2863 } |
2864 _typeddata._setInt8(_offset + byteOffset, _toInt8(value)); | 2864 _typedData._setInt8(_offset + byteOffset, _toInt8(value)); |
2865 } | 2865 } |
2866 | 2866 |
2867 int getUint8(int byteOffset) { | 2867 int getUint8(int byteOffset) { |
2868 if (byteOffset < 0 || byteOffset >= length) { | 2868 if (byteOffset < 0 || byteOffset >= length) { |
2869 _throwRangeError(byteOffset, length); | 2869 _throwRangeError(byteOffset, length); |
2870 } | 2870 } |
2871 return _typeddata._getUint8(_offset + byteOffset); | 2871 return _typedData._getUint8(_offset + byteOffset); |
2872 } | 2872 } |
2873 void setUint8(int byteOffset, int value) { | 2873 void setUint8(int byteOffset, int value) { |
2874 if (byteOffset < 0 || byteOffset >= length) { | 2874 if (byteOffset < 0 || byteOffset >= length) { |
2875 _throwRangeError(byteOffset, length); | 2875 _throwRangeError(byteOffset, length); |
2876 } | 2876 } |
2877 _typeddata._setUint8(_offset + byteOffset, _toUint8(value)); | 2877 _typedData._setUint8(_offset + byteOffset, _toUint8(value)); |
2878 } | 2878 } |
2879 | 2879 |
2880 int getInt16(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { | 2880 int getInt16(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { |
2881 if (byteOffset < 0 || byteOffset >= length) { | 2881 if (byteOffset < 0 || byteOffset >= length) { |
2882 _throwRangeError(byteOffset, length); | 2882 _throwRangeError(byteOffset, length); |
2883 } | 2883 } |
2884 var result = _typeddata._getInt16(_offset + byteOffset); | 2884 var result = _typedData._getInt16(_offset + byteOffset); |
2885 if (identical(endian, Endianness.HOST_ENDIAN)) { | 2885 if (identical(endian, Endianness.HOST_ENDIAN)) { |
2886 return result; | 2886 return result; |
2887 } | 2887 } |
2888 return _toEndianInt16(result, endian._littleEndian); | 2888 return _toEndianInt16(result, endian._littleEndian); |
2889 } | 2889 } |
2890 void setInt16(int byteOffset, | 2890 void setInt16(int byteOffset, |
2891 int value, | 2891 int value, |
2892 [Endianness endian = Endianness.BIG_ENDIAN]) { | 2892 [Endianness endian = Endianness.BIG_ENDIAN]) { |
2893 if (byteOffset < 0 || byteOffset >= length) { | 2893 if (byteOffset < 0 || byteOffset >= length) { |
2894 _throwRangeError(byteOffset, length); | 2894 _throwRangeError(byteOffset, length); |
2895 } | 2895 } |
2896 var set_value = _toInt16(value); | 2896 var set_value = _toInt16(value); |
2897 if (!identical(endian, Endianness.HOST_ENDIAN)) { | 2897 if (!identical(endian, Endianness.HOST_ENDIAN)) { |
2898 set_value = _toEndianInt16(set_value, endian._littleEndian); | 2898 set_value = _toEndianInt16(set_value, endian._littleEndian); |
2899 } | 2899 } |
2900 _typeddata._setInt16(_offset + byteOffset, set_value); | 2900 _typedData._setInt16(_offset + byteOffset, set_value); |
2901 } | 2901 } |
2902 | 2902 |
2903 int getUint16(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { | 2903 int getUint16(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { |
2904 if (byteOffset < 0 || byteOffset >= length) { | 2904 if (byteOffset < 0 || byteOffset >= length) { |
2905 _throwRangeError(byteOffset, length); | 2905 _throwRangeError(byteOffset, length); |
2906 } | 2906 } |
2907 var result = _typeddata._getUint16(_offset + byteOffset); | 2907 var result = _typedData._getUint16(_offset + byteOffset); |
2908 if (identical(endian, Endianness.HOST_ENDIAN)) { | 2908 if (identical(endian, Endianness.HOST_ENDIAN)) { |
2909 return result; | 2909 return result; |
2910 } | 2910 } |
2911 return _toEndianUint16(result, endian._littleEndian); | 2911 return _toEndianUint16(result, endian._littleEndian); |
2912 } | 2912 } |
2913 void setUint16(int byteOffset, | 2913 void setUint16(int byteOffset, |
2914 int value, | 2914 int value, |
2915 [Endianness endian = Endianness.BIG_ENDIAN]) { | 2915 [Endianness endian = Endianness.BIG_ENDIAN]) { |
2916 if (byteOffset < 0 || byteOffset >= length) { | 2916 if (byteOffset < 0 || byteOffset >= length) { |
2917 _throwRangeError(byteOffset, length); | 2917 _throwRangeError(byteOffset, length); |
2918 } | 2918 } |
2919 var set_value = _toUint16(value); | 2919 var set_value = _toUint16(value); |
2920 if (!identical(endian, Endianness.HOST_ENDIAN)) { | 2920 if (!identical(endian, Endianness.HOST_ENDIAN)) { |
2921 set_value = _toEndianUint16(set_value, endian._littleEndian); | 2921 set_value = _toEndianUint16(set_value, endian._littleEndian); |
2922 } | 2922 } |
2923 _typeddata._setUint16(_offset + byteOffset, set_value); | 2923 _typedData._setUint16(_offset + byteOffset, set_value); |
2924 } | 2924 } |
2925 | 2925 |
2926 int getInt32(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { | 2926 int getInt32(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { |
2927 if (byteOffset < 0 || byteOffset >= length) { | 2927 if (byteOffset < 0 || byteOffset >= length) { |
2928 _throwRangeError(byteOffset, length); | 2928 _throwRangeError(byteOffset, length); |
2929 } | 2929 } |
2930 var result = _typeddata._getInt32(_offset + byteOffset); | 2930 var result = _typedData._getInt32(_offset + byteOffset); |
2931 if (identical(endian, Endianness.HOST_ENDIAN)) { | 2931 if (identical(endian, Endianness.HOST_ENDIAN)) { |
2932 return result; | 2932 return result; |
2933 } | 2933 } |
2934 return _toEndianInt32(result, endian._littleEndian); | 2934 return _toEndianInt32(result, endian._littleEndian); |
2935 } | 2935 } |
2936 void setInt32(int byteOffset, | 2936 void setInt32(int byteOffset, |
2937 int value, | 2937 int value, |
2938 [Endianness endian = Endianness.BIG_ENDIAN]) { | 2938 [Endianness endian = Endianness.BIG_ENDIAN]) { |
2939 if (byteOffset < 0 || byteOffset >= length) { | 2939 if (byteOffset < 0 || byteOffset >= length) { |
2940 _throwRangeError(byteOffset, length); | 2940 _throwRangeError(byteOffset, length); |
2941 } | 2941 } |
2942 var set_value = _toInt32(value); | 2942 var set_value = _toInt32(value); |
2943 if (!identical(endian, Endianness.HOST_ENDIAN)) { | 2943 if (!identical(endian, Endianness.HOST_ENDIAN)) { |
2944 set_value = _toEndianInt32(set_value, endian._littleEndian); | 2944 set_value = _toEndianInt32(set_value, endian._littleEndian); |
2945 } | 2945 } |
2946 _typeddata._setInt32(_offset + byteOffset, set_value); | 2946 _typedData._setInt32(_offset + byteOffset, set_value); |
2947 } | 2947 } |
2948 | 2948 |
2949 int getUint32(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { | 2949 int getUint32(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { |
2950 if (byteOffset < 0 || byteOffset >= length) { | 2950 if (byteOffset < 0 || byteOffset >= length) { |
2951 _throwRangeError(byteOffset, length); | 2951 _throwRangeError(byteOffset, length); |
2952 } | 2952 } |
2953 var result = _typeddata._getUint32(_offset + byteOffset); | 2953 var result = _typedData._getUint32(_offset + byteOffset); |
2954 if (identical(endian, Endianness.HOST_ENDIAN)) { | 2954 if (identical(endian, Endianness.HOST_ENDIAN)) { |
2955 return result; | 2955 return result; |
2956 } | 2956 } |
2957 return _toEndianUint32(result, endian._littleEndian); | 2957 return _toEndianUint32(result, endian._littleEndian); |
2958 } | 2958 } |
2959 void setUint32(int byteOffset, | 2959 void setUint32(int byteOffset, |
2960 int value, | 2960 int value, |
2961 [Endianness endian = Endianness.BIG_ENDIAN]) { | 2961 [Endianness endian = Endianness.BIG_ENDIAN]) { |
2962 if (byteOffset < 0 || byteOffset >= length) { | 2962 if (byteOffset < 0 || byteOffset >= length) { |
2963 _throwRangeError(byteOffset, length); | 2963 _throwRangeError(byteOffset, length); |
2964 } | 2964 } |
2965 var set_value = _toUint32(value); | 2965 var set_value = _toUint32(value); |
2966 if (!identical(endian, Endianness.HOST_ENDIAN)) { | 2966 if (!identical(endian, Endianness.HOST_ENDIAN)) { |
2967 set_value = _toEndianUint32(set_value, endian._littleEndian); | 2967 set_value = _toEndianUint32(set_value, endian._littleEndian); |
2968 } | 2968 } |
2969 _typeddata._setUint32(_offset + byteOffset, set_value); | 2969 _typedData._setUint32(_offset + byteOffset, set_value); |
2970 } | 2970 } |
2971 | 2971 |
2972 int getInt64(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { | 2972 int getInt64(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { |
2973 if (byteOffset < 0 || byteOffset >= length) { | 2973 if (byteOffset < 0 || byteOffset >= length) { |
2974 _throwRangeError(byteOffset, length); | 2974 _throwRangeError(byteOffset, length); |
2975 } | 2975 } |
2976 var result = _typeddata._getInt64(_offset + byteOffset); | 2976 var result = _typedData._getInt64(_offset + byteOffset); |
2977 if (identical(endian, Endianness.HOST_ENDIAN)) { | 2977 if (identical(endian, Endianness.HOST_ENDIAN)) { |
2978 return result; | 2978 return result; |
2979 } | 2979 } |
2980 return _toEndianInt64(result, endian._littleEndian); | 2980 return _toEndianInt64(result, endian._littleEndian); |
2981 } | 2981 } |
2982 void setInt64(int byteOffset, | 2982 void setInt64(int byteOffset, |
2983 int value, | 2983 int value, |
2984 [Endianness endian = Endianness.BIG_ENDIAN]) { | 2984 [Endianness endian = Endianness.BIG_ENDIAN]) { |
2985 if (byteOffset < 0 || byteOffset >= length) { | 2985 if (byteOffset < 0 || byteOffset >= length) { |
2986 _throwRangeError(byteOffset, length); | 2986 _throwRangeError(byteOffset, length); |
2987 } | 2987 } |
2988 var set_value = _toInt64(value); | 2988 var set_value = _toInt64(value); |
2989 if (!identical(endian, Endianness.HOST_ENDIAN)) { | 2989 if (!identical(endian, Endianness.HOST_ENDIAN)) { |
2990 set_value = _toEndianInt64(set_value, endian._littleEndian); | 2990 set_value = _toEndianInt64(set_value, endian._littleEndian); |
2991 } | 2991 } |
2992 _typeddata._setInt64(_offset + byteOffset, set_value); | 2992 _typedData._setInt64(_offset + byteOffset, set_value); |
2993 } | 2993 } |
2994 | 2994 |
2995 int getUint64(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { | 2995 int getUint64(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { |
2996 if (byteOffset < 0 || byteOffset >= length) { | 2996 if (byteOffset < 0 || byteOffset >= length) { |
2997 _throwRangeError(byteOffset, length); | 2997 _throwRangeError(byteOffset, length); |
2998 } | 2998 } |
2999 var result = _typeddata._getUint64(_offset + byteOffset); | 2999 var result = _typedData._getUint64(_offset + byteOffset); |
3000 if (identical(endian, Endianness.HOST_ENDIAN)) { | 3000 if (identical(endian, Endianness.HOST_ENDIAN)) { |
3001 return result; | 3001 return result; |
3002 } | 3002 } |
3003 return _toEndianUint64(result, endian._littleEndian); | 3003 return _toEndianUint64(result, endian._littleEndian); |
3004 } | 3004 } |
3005 void setUint64(int byteOffset, | 3005 void setUint64(int byteOffset, |
3006 int value, | 3006 int value, |
3007 [Endianness endian = Endianness.BIG_ENDIAN]) { | 3007 [Endianness endian = Endianness.BIG_ENDIAN]) { |
3008 if (byteOffset < 0 || byteOffset >= length) { | 3008 if (byteOffset < 0 || byteOffset >= length) { |
3009 _throwRangeError(byteOffset, length); | 3009 _throwRangeError(byteOffset, length); |
3010 } | 3010 } |
3011 var set_value = _toUint64(value); | 3011 var set_value = _toUint64(value); |
3012 if (!identical(endian, Endianness.HOST_ENDIAN)) { | 3012 if (!identical(endian, Endianness.HOST_ENDIAN)) { |
3013 set_value = _toEndianUint64(set_value, endian._littleEndian); | 3013 set_value = _toEndianUint64(set_value, endian._littleEndian); |
3014 } | 3014 } |
3015 _typeddata._setUint64(_offset + byteOffset, set_value); | 3015 _typedData._setUint64(_offset + byteOffset, set_value); |
3016 } | 3016 } |
3017 | 3017 |
3018 double getFloat32(int byteOffset, | 3018 double getFloat32(int byteOffset, |
3019 [Endianness endian = Endianness.BIG_ENDIAN]) { | 3019 [Endianness endian = Endianness.BIG_ENDIAN]) { |
3020 if (byteOffset < 0 || byteOffset >= length) { | 3020 if (byteOffset < 0 || byteOffset >= length) { |
3021 _throwRangeError(byteOffset, length); | 3021 _throwRangeError(byteOffset, length); |
3022 } | 3022 } |
3023 var result = _typeddata._getFloat32(_offset + byteOffset); | 3023 var result = _typedData._getFloat32(_offset + byteOffset); |
3024 if (identical(endian, Endianness.HOST_ENDIAN)) { | 3024 if (identical(endian, Endianness.HOST_ENDIAN)) { |
3025 return result; | 3025 return result; |
3026 } | 3026 } |
3027 return _toEndianFloat32(result, endian._littleEndian); | 3027 return _toEndianFloat32(result, endian._littleEndian); |
3028 } | 3028 } |
3029 void setFloat32(int byteOffset, | 3029 void setFloat32(int byteOffset, |
3030 double value, | 3030 double value, |
3031 [Endianness endian = Endianness.BIG_ENDIAN]) { | 3031 [Endianness endian = Endianness.BIG_ENDIAN]) { |
3032 if (byteOffset < 0 || byteOffset >= length) { | 3032 if (byteOffset < 0 || byteOffset >= length) { |
3033 _throwRangeError(byteOffset, length); | 3033 _throwRangeError(byteOffset, length); |
3034 } | 3034 } |
3035 var set_value = value; | 3035 var set_value = value; |
3036 if (!identical(endian, Endianness.HOST_ENDIAN)) { | 3036 if (!identical(endian, Endianness.HOST_ENDIAN)) { |
3037 set_value = _toEndianFloat32(set_value, endian._littleEndian); | 3037 set_value = _toEndianFloat32(set_value, endian._littleEndian); |
3038 } | 3038 } |
3039 _typeddata._setFloat32(_offset + byteOffset, set_value); | 3039 _typedData._setFloat32(_offset + byteOffset, set_value); |
3040 } | 3040 } |
3041 | 3041 |
3042 double getFloat64(int byteOffset, | 3042 double getFloat64(int byteOffset, |
3043 [Endianness endian = Endianness.BIG_ENDIAN]) { | 3043 [Endianness endian = Endianness.BIG_ENDIAN]) { |
3044 if (byteOffset < 0 || byteOffset >= length) { | 3044 if (byteOffset < 0 || byteOffset >= length) { |
3045 _throwRangeError(byteOffset, length); | 3045 _throwRangeError(byteOffset, length); |
3046 } | 3046 } |
3047 var result = _typeddata._getFloat64(_offset + byteOffset); | 3047 var result = _typedData._getFloat64(_offset + byteOffset); |
3048 if (identical(endian, Endianness.HOST_ENDIAN)) { | 3048 if (identical(endian, Endianness.HOST_ENDIAN)) { |
3049 return result; | 3049 return result; |
3050 } | 3050 } |
3051 return _toEndianFloat64(result, endian._littleEndian); | 3051 return _toEndianFloat64(result, endian._littleEndian); |
3052 } | 3052 } |
3053 void setFloat64(int byteOffset, | 3053 void setFloat64(int byteOffset, |
3054 double value, | 3054 double value, |
3055 [Endianness endian = Endianness.BIG_ENDIAN]) { | 3055 [Endianness endian = Endianness.BIG_ENDIAN]) { |
3056 if (byteOffset < 0 || byteOffset >= length) { | 3056 if (byteOffset < 0 || byteOffset >= length) { |
3057 _throwRangeError(byteOffset, length); | 3057 _throwRangeError(byteOffset, length); |
3058 } | 3058 } |
3059 var set_value = value; | 3059 var set_value = value; |
3060 if (!identical(endian, Endianness.HOST_ENDIAN)) { | 3060 if (!identical(endian, Endianness.HOST_ENDIAN)) { |
3061 set_value = _toEndianFloat64(set_value, endian._littleEndian); | 3061 set_value = _toEndianFloat64(set_value, endian._littleEndian); |
3062 } | 3062 } |
3063 _typeddata._setFloat64(_offset + byteOffset, set_value); | 3063 _typedData._setFloat64(_offset + byteOffset, set_value); |
3064 } | 3064 } |
3065 | 3065 |
3066 Float32x4 getFloat32x4(int byteOffset, | 3066 Float32x4 getFloat32x4(int byteOffset, |
3067 [Endianness endian = Endianness.BIG_ENDIAN]) { | 3067 [Endianness endian = Endianness.BIG_ENDIAN]) { |
3068 if (byteOffset < 0 || byteOffset >= length) { | 3068 if (byteOffset < 0 || byteOffset >= length) { |
3069 _throwRangeError(byteOffset, length); | 3069 _throwRangeError(byteOffset, length); |
3070 } | 3070 } |
3071 // TODO(johnmccutchan) : Need to resolve this for endianity. | 3071 // TODO(johnmccutchan) : Need to resolve this for endianity. |
3072 return _typeddata._getFloat32x4(_offset + byteOffset); | 3072 return _typedData._getFloat32x4(_offset + byteOffset); |
3073 } | 3073 } |
3074 void setFloat32x4(int byteOffset, | 3074 void setFloat32x4(int byteOffset, |
3075 Float32x4 value, | 3075 Float32x4 value, |
3076 [Endianness endian = Endianness.BIG_ENDIAN]) { | 3076 [Endianness endian = Endianness.BIG_ENDIAN]) { |
3077 if (byteOffset < 0 || byteOffset >= length) { | 3077 if (byteOffset < 0 || byteOffset >= length) { |
3078 _throwRangeError(byteOffset, length); | 3078 _throwRangeError(byteOffset, length); |
3079 } | 3079 } |
3080 // TODO(johnmccutchan) : Need to resolve this for endianity. | 3080 // TODO(johnmccutchan) : Need to resolve this for endianity. |
3081 _typeddata._setFloat32x4(_offset + byteOffset, value); | 3081 _typedData._setFloat32x4(_offset + byteOffset, value); |
3082 | 3082 |
3083 } | 3083 } |
3084 | 3084 |
3085 | 3085 |
3086 // Internal utility methods. | 3086 // Internal utility methods. |
3087 | 3087 |
3088 static int _toEndianInt16(int host_value, bool little_endian) | 3088 static int _toEndianInt16(int host_value, bool little_endian) |
3089 native "ByteData_ToEndianInt16"; | 3089 native "ByteData_ToEndianInt16"; |
3090 static int _toEndianUint16(int host_value, bool little_endian) | 3090 static int _toEndianUint16(int host_value, bool little_endian) |
3091 native "ByteData_ToEndianUint16"; | 3091 native "ByteData_ToEndianUint16"; |
3092 static int _toEndianInt32(int host_value, bool little_endian) | 3092 static int _toEndianInt32(int host_value, bool little_endian) |
3093 native "ByteData_ToEndianInt32"; | 3093 native "ByteData_ToEndianInt32"; |
3094 static int _toEndianUint32(int host_value, bool little_endian) | 3094 static int _toEndianUint32(int host_value, bool little_endian) |
3095 native "ByteData_ToEndianUint32"; | 3095 native "ByteData_ToEndianUint32"; |
3096 static int _toEndianInt64(int host_value, bool little_endian) | 3096 static int _toEndianInt64(int host_value, bool little_endian) |
3097 native "ByteData_ToEndianInt64"; | 3097 native "ByteData_ToEndianInt64"; |
3098 static int _toEndianUint64(int host_value, bool little_endian) | 3098 static int _toEndianUint64(int host_value, bool little_endian) |
3099 native "ByteData_ToEndianUint64"; | 3099 native "ByteData_ToEndianUint64"; |
3100 static double _toEndianFloat32(double host_value, bool little_endian) | 3100 static double _toEndianFloat32(double host_value, bool little_endian) |
3101 native "ByteData_ToEndianFloat32"; | 3101 native "ByteData_ToEndianFloat32"; |
3102 static double _toEndianFloat64(double host_value, bool little_endian) | 3102 static double _toEndianFloat64(double host_value, bool little_endian) |
3103 native "ByteData_ToEndianFloat64"; | 3103 native "ByteData_ToEndianFloat64"; |
3104 | 3104 |
3105 | 3105 |
3106 final TypedData _typeddata; | 3106 final TypedData _typedData; |
3107 final int _offset; | 3107 final int _offset; |
3108 final int length; | 3108 final int length; |
3109 } | 3109 } |
3110 | 3110 |
3111 | 3111 |
3112 // Top level utility methods. | 3112 // Top level utility methods. |
3113 int _toInt(int value, int mask) { | 3113 int _toInt(int value, int mask) { |
3114 value &= mask; | 3114 value &= mask; |
3115 if (value > (mask >> 1)) value -= mask + 1; | 3115 if (value > (mask >> 1)) value -= mask + 1; |
3116 return value; | 3116 return value; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3182 return value; | 3182 return value; |
3183 } | 3183 } |
3184 return object; | 3184 return object; |
3185 } | 3185 } |
3186 | 3186 |
3187 | 3187 |
3188 void _throwRangeError(int index, int length) { | 3188 void _throwRangeError(int index, int length) { |
3189 String message = "$index must be in the range [0..$length)"; | 3189 String message = "$index must be in the range [0..$length)"; |
3190 throw new RangeError(message); | 3190 throw new RangeError(message); |
3191 } | 3191 } |
OLD | NEW |