OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 class _AudioContextFactoryProvider { | 5 class _AudioContextFactoryProvider { |
6 factory AudioContext() => _wrap(new dom.AudioContext()); | 6 factory AudioContext() => _wrap(new dom.AudioContext()); |
7 } | 7 } |
8 | 8 |
9 class _TypedArrayFactoryProvider { | 9 class _TypedArrayFactoryProvider { |
10 | 10 |
11 factory Float32Array(int length) => _F32(length); | 11 factory Float32Array(int length) => _F32(length); |
12 factory Float32Array.fromList(List<num> list) => _F32(ensureNative(list)); | 12 factory Float32Array.fromList(List<num> list) => _F32(ensureNative(list)); |
13 factory Float32Array.fromBuffer(ArrayBuffer buffer) => _F32(buffer); | 13 factory Float32Array.fromBuffer(ArrayBuffer buffer, |
| 14 [int byteOffset = 0, int length]) { |
| 15 if (length == null) return _F32_2(buffer, byteOffset); |
| 16 return _F32_3(buffer, byteOffset, length); |
| 17 } |
14 | 18 |
15 factory Float64Array(int length) => _F64(length); | 19 factory Float64Array(int length) => _F64(length); |
16 factory Float64Array.fromList(List<num> list) => _F64(ensureNative(list)); | 20 factory Float64Array.fromList(List<num> list) => _F64(ensureNative(list)); |
17 factory Float64Array.fromBuffer(ArrayBuffer buffer) => _F64(buffer); | 21 factory Float64Array.fromBuffer(ArrayBuffer buffer, |
| 22 [int byteOffset = 0, int length]) { |
| 23 if (length == null) return _F64_2(buffer, byteOffset); |
| 24 return _F64_3(buffer, byteOffset, length); |
| 25 } |
18 | 26 |
19 factory Int8Array(int length) => _I8(length); | 27 factory Int8Array(int length) => _I8(length); |
20 factory Int8Array.fromList(List<num> list) => _I8(ensureNative(list)); | 28 factory Int8Array.fromList(List<num> list) => _I8(ensureNative(list)); |
21 factory Int8Array.fromBuffer(ArrayBuffer buffer) => _I8(buffer); | 29 factory Int8Array.fromBuffer(ArrayBuffer buffer, |
| 30 [int byteOffset = 0, int length]) { |
| 31 if (length == null) return _I8_2(buffer, byteOffset); |
| 32 return _I8_3(buffer, byteOffset, length); |
| 33 } |
22 | 34 |
23 factory Int16Array(int length) => _I16(length); | 35 factory Int16Array(int length) => _I16(length); |
24 factory Int16Array.fromList(List<num> list) => _I16(ensureNative(list)); | 36 factory Int16Array.fromList(List<num> list) => _I16(ensureNative(list)); |
25 factory Int16Array.fromBuffer(ArrayBuffer buffer) => _I16(buffer); | 37 factory Int16Array.fromBuffer(ArrayBuffer buffer, |
| 38 [int byteOffset = 0, int length]) { |
| 39 if (length == null) return _I16_2(buffer, byteOffset); |
| 40 return _I16_3(buffer, byteOffset, length); |
| 41 } |
26 | 42 |
27 factory Int32Array(int length) => _I32(length); | 43 factory Int32Array(int length) => _I32(length); |
28 factory Int32Array.fromList(List<num> list) => _I32(ensureNative(list)); | 44 factory Int32Array.fromList(List<num> list) => _I32(ensureNative(list)); |
29 factory Int32Array.fromBuffer(ArrayBuffer buffer) => _I32(buffer); | 45 factory Int32Array.fromBuffer(ArrayBuffer buffer, |
| 46 [int byteOffset = 0, int length]) { |
| 47 if (length == null) return _I32_2(buffer, byteOffset); |
| 48 return _I32_3(buffer, byteOffset, length); |
| 49 } |
30 | 50 |
31 factory Uint8Array(int length) => _U8(length); | 51 factory Uint8Array(int length) => _U8(length); |
32 factory Uint8Array.fromList(List<num> list) => _U8(ensureNative(list)); | 52 factory Uint8Array.fromList(List<num> list) => _U8(ensureNative(list)); |
33 factory Uint8Array.fromBuffer(ArrayBuffer buffer) => _U8(buffer); | 53 factory Uint8Array.fromBuffer(ArrayBuffer buffer, |
| 54 [int byteOffset = 0, int length]) { |
| 55 if (length == null) return _U8_2(buffer, byteOffset); |
| 56 return _U8_3(buffer, byteOffset, length); |
| 57 } |
34 | 58 |
35 factory Uint16Array(int length) => _U16(length); | 59 factory Uint16Array(int length) => _U16(length); |
36 factory Uint16Array.fromList(List<num> list) => _U16(ensureNative(list)); | 60 factory Uint16Array.fromList(List<num> list) => _U16(ensureNative(list)); |
37 factory Uint16Array.fromBuffer(ArrayBuffer buffer) => _U16(buffer); | 61 factory Uint16Array.fromBuffer(ArrayBuffer buffer, |
| 62 [int byteOffset = 0, int length]) { |
| 63 if (length == null) return _U16_2(buffer, byteOffset); |
| 64 return _U16_3(buffer, byteOffset, length); |
| 65 } |
38 | 66 |
39 factory Uint32Array(int length) => _U32(length); | 67 factory Uint32Array(int length) => _U32(length); |
40 factory Uint32Array.fromList(List<num> list) => _U32(ensureNative(list)); | 68 factory Uint32Array.fromList(List<num> list) => _U32(ensureNative(list)); |
41 factory Uint32Array.fromBuffer(ArrayBuffer buffer) => _U32(buffer); | 69 factory Uint32Array.fromBuffer(ArrayBuffer buffer, |
| 70 [int byteOffset = 0, int length]) { |
| 71 if (length == null) return _U32_2(buffer, byteOffset); |
| 72 return _U32_3(buffer, byteOffset, length); |
| 73 } |
42 | 74 |
43 factory Uint8ClampedArray(int length) => _U8C(length); | 75 factory Uint8ClampedArray(int length) => _U8C(length); |
44 factory Uint8ClampedArray.fromList(List<num> list) => _U8C(ensureNative(list))
; | 76 factory Uint8ClampedArray.fromList(List<num> list) => _U8C(ensureNative(list))
; |
45 factory Uint8ClampedArray.fromBuffer(ArrayBuffer buffer) => _U8C(buffer); | 77 factory Uint8ClampedArray.fromBuffer(ArrayBuffer buffer, |
| 78 [int byteOffset = 0, int length]) { |
| 79 if (length == null) return _U8C_2(buffer, byteOffset); |
| 80 return _U8C_3(buffer, byteOffset, length); |
| 81 } |
46 | 82 |
47 static Float32Array _F32(arg) => _wrap(new dom.Float32Array(arg)); | 83 static Float32Array _F32(arg) => _wrap(new dom.Float32Array(arg)); |
48 static Float64Array _F64(arg) => _wrap(new dom.Float64Array(arg)); | 84 static Float64Array _F64(arg) => _wrap(new dom.Float64Array(arg)); |
49 static Int8Array _I8(arg) => _wrap(new dom.Int8Array(arg)); | 85 static Int8Array _I8(arg) => _wrap(new dom.Int8Array(arg)); |
50 static Int16Array _I16(arg) => _wrap(new dom.Int16Array(arg)); | 86 static Int16Array _I16(arg) => _wrap(new dom.Int16Array(arg)); |
51 static Int32Array _I32(arg) => _wrap(new dom.Int32Array(arg)); | 87 static Int32Array _I32(arg) => _wrap(new dom.Int32Array(arg)); |
52 static Uint8Array _U8(arg) => _wrap(new dom.Uint8Array(arg)); | 88 static Uint8Array _U8(arg) => _wrap(new dom.Uint8Array(arg)); |
53 static Uint16Array _U16(arg) => _wrap(new dom.Uint16Array(arg)); | 89 static Uint16Array _U16(arg) => _wrap(new dom.Uint16Array(arg)); |
54 static Uint32Array _U32(arg) => _wrap(new dom.Uint32Array(arg)); | 90 static Uint32Array _U32(arg) => _wrap(new dom.Uint32Array(arg)); |
55 static Uint8ClampedArray _U8C(arg) => _wrap(new dom.Uint8ClampedArray(arg)); | 91 static Uint8ClampedArray _U8C(arg) => _wrap(new dom.Uint8ClampedArray(arg)); |
56 | 92 |
| 93 static Float32Array _F32_2(arg1, arg2) => _wrap(new dom.Float32Array(arg1, arg
2)); |
| 94 static Float64Array _F64_2(arg1, arg2) => _wrap(new dom.Float64Array(arg1, arg
2)); |
| 95 static Int8Array _I8_2(arg1, arg2) => _wrap(new dom.Int8Array(arg1, arg2)); |
| 96 static Int16Array _I16_2(arg1, arg2) => _wrap(new dom.Int16Array(arg1, arg2)); |
| 97 static Int32Array _I32_2(arg1, arg2) => _wrap(new dom.Int32Array(arg1, arg2)); |
| 98 static Uint8Array _U8_2(arg1, arg2) => _wrap(new dom.Uint8Array(arg1, arg2)); |
| 99 static Uint16Array _U16_2(arg1, arg2) => _wrap(new dom.Uint16Array(arg1, arg2)
); |
| 100 static Uint32Array _U32_2(arg1, arg2) => _wrap(new dom.Uint32Array(arg1, arg2)
); |
| 101 static Uint8ClampedArray _U8C_2(arg1, arg2) => _wrap(new dom.Uint8ClampedArray
(arg1, arg2)); |
| 102 |
| 103 static Float32Array _F32_3(arg1, arg2, arg3) => _wrap(new dom.Float32Array(arg
1, arg2, arg3)); |
| 104 static Float64Array _F64_3(arg1, arg2, arg3) => _wrap(new dom.Float64Array(arg
1, arg2, arg3)); |
| 105 static Int8Array _I8_3(arg1, arg2, arg3) => _wrap(new dom.Int8Array(arg1, arg2
, arg3)); |
| 106 static Int16Array _I16_3(arg1, arg2, arg3) => _wrap(new dom.Int16Array(arg1, a
rg2, arg3)); |
| 107 static Int32Array _I32_3(arg1, arg2, arg3) => _wrap(new dom.Int32Array(arg1, a
rg2, arg3)); |
| 108 static Uint8Array _U8_3(arg1, arg2, arg3) => _wrap(new dom.Uint8Array(arg1, ar
g2, arg3)); |
| 109 static Uint16Array _U16_3(arg1, arg2, arg3) => _wrap(new dom.Uint16Array(arg1,
arg2, arg3)); |
| 110 static Uint32Array _U32_3(arg1, arg2, arg3) => _wrap(new dom.Uint32Array(arg1,
arg2, arg3)); |
| 111 static Uint8ClampedArray _U8C_3(arg1, arg2, arg3) => _wrap(new dom.Uint8Clampe
dArray(arg1, arg2, arg3)); |
| 112 |
57 static ensureNative(List list) => list; // TODO: make sure. | 113 static ensureNative(List list) => list; // TODO: make sure. |
58 } | 114 } |
59 | 115 |
60 class _PointFactoryProvider { | 116 class _PointFactoryProvider { |
61 | 117 |
62 factory Point(num x, num y) => _wrap(new dom.WebKitPoint(x, y)); | 118 factory Point(num x, num y) => _wrap(new dom.WebKitPoint(x, y)); |
63 } | 119 } |
64 | 120 |
65 class _WebSocketFactoryProvider { | 121 class _WebSocketFactoryProvider { |
66 | 122 |
67 factory WebSocket(String url) => _wrap(new dom.WebSocket(url)); | 123 factory WebSocket(String url) => _wrap(new dom.WebSocket(url)); |
68 } | 124 } |
69 | 125 |
70 class _TextFactoryProvider { | 126 class _TextFactoryProvider { |
71 factory Text(String data) => _document.$dom_createTextNode(data); | 127 factory Text(String data) => _document.$dom_createTextNode(data); |
72 } | 128 } |
OLD | NEW |