OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 class _TypedArrayFactoryProvider { |
| 6 |
| 7 factory Float32Array(int length) => _F32(length); |
| 8 factory Float32Array.fromList(List<num> list) => _F32(ensureNative(list)); |
| 9 factory Float32Array.fromBuffer(ArrayBuffer buffer, |
| 10 [int byteOffset = 0, int length]) { |
| 11 if (length == null) return _F32_2(buffer, byteOffset); |
| 12 return _F32_3(buffer, byteOffset, length); |
| 13 } |
| 14 |
| 15 factory Float64Array(int length) => _F64(length); |
| 16 factory Float64Array.fromList(List<num> list) => _F64(ensureNative(list)); |
| 17 factory Float64Array.fromBuffer(ArrayBuffer buffer, |
| 18 [int byteOffset = 0, int length]) { |
| 19 if (length == null) return _F64_2(buffer, byteOffset); |
| 20 return _F64_3(buffer, byteOffset, length); |
| 21 } |
| 22 |
| 23 factory Int8Array(int length) => _I8(length); |
| 24 factory Int8Array.fromList(List<num> list) => _I8(ensureNative(list)); |
| 25 factory Int8Array.fromBuffer(ArrayBuffer buffer, |
| 26 [int byteOffset = 0, int length]) { |
| 27 if (length == null) return _I8_2(buffer, byteOffset); |
| 28 return _I8_3(buffer, byteOffset, length); |
| 29 } |
| 30 |
| 31 factory Int16Array(int length) => _I16(length); |
| 32 factory Int16Array.fromList(List<num> list) => _I16(ensureNative(list)); |
| 33 factory Int16Array.fromBuffer(ArrayBuffer buffer, |
| 34 [int byteOffset = 0, int length]) { |
| 35 if (length == null) return _I16_2(buffer, byteOffset); |
| 36 return _I16_3(buffer, byteOffset, length); |
| 37 } |
| 38 |
| 39 factory Int32Array(int length) => _I32(length); |
| 40 factory Int32Array.fromList(List<num> list) => _I32(ensureNative(list)); |
| 41 factory Int32Array.fromBuffer(ArrayBuffer buffer, |
| 42 [int byteOffset = 0, int length]) { |
| 43 if (length == null) return _I32_2(buffer, byteOffset); |
| 44 return _I32_3(buffer, byteOffset, length); |
| 45 } |
| 46 |
| 47 factory Uint8Array(int length) => _U8(length); |
| 48 factory Uint8Array.fromList(List<num> list) => _U8(ensureNative(list)); |
| 49 factory Uint8Array.fromBuffer(ArrayBuffer buffer, |
| 50 [int byteOffset = 0, int length]) { |
| 51 if (length == null) return _U8_2(buffer, byteOffset); |
| 52 return _U8_3(buffer, byteOffset, length); |
| 53 } |
| 54 |
| 55 factory Uint16Array(int length) => _U16(length); |
| 56 factory Uint16Array.fromList(List<num> list) => _U16(ensureNative(list)); |
| 57 factory Uint16Array.fromBuffer(ArrayBuffer buffer, |
| 58 [int byteOffset = 0, int length]) { |
| 59 if (length == null) return _U16_2(buffer, byteOffset); |
| 60 return _U16_3(buffer, byteOffset, length); |
| 61 } |
| 62 |
| 63 factory Uint32Array(int length) => _U32(length); |
| 64 factory Uint32Array.fromList(List<num> list) => _U32(ensureNative(list)); |
| 65 factory Uint32Array.fromBuffer(ArrayBuffer buffer, |
| 66 [int byteOffset = 0, int length]) { |
| 67 if (length == null) return _U32_2(buffer, byteOffset); |
| 68 return _U32_3(buffer, byteOffset, length); |
| 69 } |
| 70 |
| 71 factory Uint8ClampedArray(int length) => _U8C(length); |
| 72 factory Uint8ClampedArray.fromList(List<num> list) => _U8C(ensureNative(list))
; |
| 73 factory Uint8ClampedArray.fromBuffer(ArrayBuffer buffer, |
| 74 [int byteOffset = 0, int length]) { |
| 75 if (length == null) return _U8C_2(buffer, byteOffset); |
| 76 return _U8C_3(buffer, byteOffset, length); |
| 77 } |
| 78 |
| 79 static Float32Array _F32(arg) native 'return new Float32Array(arg);'; |
| 80 static Float64Array _F64(arg) native 'return new Float64Array(arg);'; |
| 81 static Int8Array _I8(arg) native 'return new Int8Array(arg);'; |
| 82 static Int16Array _I16(arg) native 'return new Int16Array(arg);'; |
| 83 static Int32Array _I32(arg) native 'return new Int32Array(arg);'; |
| 84 static Uint8Array _U8(arg) native 'return new Uint8Array(arg);'; |
| 85 static Uint16Array _U16(arg) native 'return new Uint16Array(arg);'; |
| 86 static Uint32Array _U32(arg) native 'return new Uint32Array(arg);'; |
| 87 static Uint8ClampedArray _U8C(arg) native 'return new Uint8ClampedArray(arg);'
; |
| 88 |
| 89 static Float32Array _F32_2(arg1, arg2) native 'return new Float32Array(arg1, a
rg2);'; |
| 90 static Float64Array _F64_2(arg1, arg2) native 'return new Float64Array(arg1, a
rg2);'; |
| 91 static Int8Array _I8_2(arg1, arg2) native 'return new Int8Array(arg1, arg2);'; |
| 92 static Int16Array _I16_2(arg1, arg2) native 'return new Int16Array(arg1, arg2)
;'; |
| 93 static Int32Array _I32_2(arg1, arg2) native 'return new Int32Array(arg1, arg2)
;'; |
| 94 static Uint8Array _U8_2(arg1, arg2) native 'return new Uint8Array(arg1, arg2);
'; |
| 95 static Uint16Array _U16_2(arg1, arg2) native 'return new Uint16Array(arg1, arg
2);'; |
| 96 static Uint32Array _U32_2(arg1, arg2) native 'return new Uint32Array(arg1, arg
2);'; |
| 97 static Uint8ClampedArray _U8C_2(arg1, arg2) native 'return new Uint8ClampedArr
ay(arg1, arg2);'; |
| 98 |
| 99 static Float32Array _F32_3(arg1, arg2, arg3) native 'return new Float32Array(a
rg1, arg2, arg3);'; |
| 100 static Float64Array _F64_3(arg1, arg2, arg3) native 'return new Float64Array(a
rg1, arg2, arg3);'; |
| 101 static Int8Array _I8_3(arg1, arg2, arg3) native 'return new Int8Array(arg1, ar
g2, arg3);'; |
| 102 static Int16Array _I16_3(arg1, arg2, arg3) native 'return new Int16Array(arg1,
arg2, arg3);'; |
| 103 static Int32Array _I32_3(arg1, arg2, arg3) native 'return new Int32Array(arg1,
arg2, arg3);'; |
| 104 static Uint8Array _U8_3(arg1, arg2, arg3) native 'return new Uint8Array(arg1,
arg2, arg3);'; |
| 105 static Uint16Array _U16_3(arg1, arg2, arg3) native 'return new Uint16Array(arg
1, arg2, arg3);'; |
| 106 static Uint32Array _U32_3(arg1, arg2, arg3) native 'return new Uint32Array(arg
1, arg2, arg3);'; |
| 107 static Uint8ClampedArray _U8C_3(arg1, arg2, arg3) native 'return new Uint8Clam
pedArray(arg1, arg2, arg3);'; |
| 108 |
| 109 |
| 110 // Ensures that [list] is a JavaScript Array or a typed array. If necessary, |
| 111 // copies the list. |
| 112 static ensureNative(List list) => list; // TODO: make sure. |
| 113 } |
OLD | NEW |