| 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(_createAudioContext()); |
| 7 static _createAudioContext() native "AudioContext_constructor_Callback"; |
| 7 } | 8 } |
| 8 | 9 |
| 9 class _IDBKeyRangeFactoryProvider { | 10 class _IDBKeyRangeFactoryProvider { |
| 10 | 11 |
| 11 factory IDBKeyRange.only(/*IDBKey*/ value) => | 12 factory IDBKeyRange.only(/*IDBKey*/ value) => |
| 12 _wrap(new dom.IDBKeyRange.only(_unwrap(value))); | 13 _wrap(_IDBKeyRangeDOMImpl.only(_unwrap(value))); |
| 13 | 14 |
| 14 factory IDBKeyRange.lowerBound(/*IDBKey*/ bound, [bool open = false]) => | 15 factory IDBKeyRange.lowerBound(/*IDBKey*/ bound, [bool open = false]) => |
| 15 _wrap(new dom.IDBKeyRange.lowerBound(_unwrap(bound), open)); | 16 _wrap(_IDBKeyRangeDOMImpl.lowerBound(_unwrap(bound), open)); |
| 16 | 17 |
| 17 factory IDBKeyRange.upperBound(/*IDBKey*/ bound, [bool open = false]) => | 18 factory IDBKeyRange.upperBound(/*IDBKey*/ bound, [bool open = false]) => |
| 18 _wrap(new dom.IDBKeyRange.upperBound(_unwrap(bound), open)); | 19 _wrap(_IDBKeyRangeDOMImpl.upperBound(_unwrap(bound), open)); |
| 19 | 20 |
| 20 factory IDBKeyRange.bound(/*IDBKey*/ lower, /*IDBKey*/ upper, | 21 factory IDBKeyRange.bound(/*IDBKey*/ lower, /*IDBKey*/ upper, |
| 21 [bool lowerOpen = false, bool upperOpen = false]) => | 22 [bool lowerOpen = false, bool upperOpen = false]) => |
| 22 _wrap(new dom.IDBKeyRange.bound(_unwrap(lower), _unwrap(upper), | 23 _wrap(_IDBKeyRangeDOMImpl.bound(_unwrap(lower), _unwrap(upper), |
| 23 lowerOpen, upperOpen)); | 24 lowerOpen, upperOpen)); |
| 24 } | 25 } |
| 25 | 26 |
| 26 class _TypedArrayFactoryProvider { | 27 class _TypedArrayFactoryProvider { |
| 28 factory Float32Array(int length) => _wrap(_F32(length)); |
| 29 factory Float32Array.fromList(List<num> list) => _wrap(_F32(ensureNative(list)
)); |
| 30 factory Float32Array.fromBuffer(ArrayBuffer buffer, |
| 31 [int byteOffset = 0, int length]) => |
| 32 _wrap(_F32(_unwrap(buffer), byteOffset, length)); |
| 33 static _F32(_arg0, [_arg1, _arg2]) native "Float32Array_constructor_Callback"; |
| 27 | 34 |
| 28 factory Float32Array(int length) => _F32(length); | 35 factory Float64Array(int length) => _wrap(_F64(length)); |
| 29 factory Float32Array.fromList(List<num> list) => _F32_1(ensureNative(list)); | 36 factory Float64Array.fromList(List<num> list) => _wrap(_F64(ensureNative(list)
)); |
| 30 factory Float32Array.fromBuffer(ArrayBuffer buffer, | 37 factory Float64Array.fromBuffer(ArrayBuffer buffer, |
| 31 [int byteOffset = 0, int length]) { | 38 [int byteOffset = 0, int length]) => |
| 32 if (length == null) return _F32_2(buffer, byteOffset); | 39 _wrap(_F64(_unwrap(buffer), byteOffset, length)); |
| 33 return _F32_3(buffer, byteOffset, length); | 40 static _F64(_arg0, [_arg1, _arg2]) native "Float64Array_constructor_Callback"; |
| 34 } | |
| 35 | 41 |
| 36 factory Float64Array(int length) => _F64(length); | 42 factory Int8Array(int length) => _wrap(_I8(length)); |
| 37 factory Float64Array.fromList(List<num> list) => _F64_1(ensureNative(list)); | 43 factory Int8Array.fromList(List<num> list) => _wrap(_I8(ensureNative(list))); |
| 38 factory Float64Array.fromBuffer(ArrayBuffer buffer, | 44 factory Int8Array.fromBuffer(ArrayBuffer buffer, |
| 39 [int byteOffset = 0, int length]) { | 45 [int byteOffset = 0, int length]) => |
| 40 if (length == null) return _F64_2(buffer, byteOffset); | 46 _wrap(_I8(_unwrap(buffer), byteOffset, length)); |
| 41 return _F64_3(buffer, byteOffset, length); | 47 static _I8(_arg0, [_arg1, _arg2]) native "Int8Array_constructor_Callback"; |
| 42 } | |
| 43 | 48 |
| 44 factory Int8Array(int length) => _I8(length); | 49 factory Int16Array(int length) => _wrap(_I16(length)); |
| 45 factory Int8Array.fromList(List<num> list) => _I8_1(ensureNative(list)); | 50 factory Int16Array.fromList(List<num> list) => _wrap(_I16(ensureNative(list)))
; |
| 46 factory Int8Array.fromBuffer(ArrayBuffer buffer, | 51 factory Int16Array.fromBuffer(ArrayBuffer buffer, |
| 47 [int byteOffset = 0, int length]) { | 52 [int byteOffset = 0, int length]) => |
| 48 if (length == null) return _I8_2(buffer, byteOffset); | 53 _wrap(_I16(_unwrap(buffer), byteOffset, length)); |
| 49 return _I8_3(buffer, byteOffset, length); | 54 static _I16(_arg0, [_arg1, _arg2]) native "Int16Array_constructor_Callback"; |
| 50 } | |
| 51 | 55 |
| 52 factory Int16Array(int length) => _I16(length); | 56 factory Int32Array(int length) => _wrap(_I32(length)); |
| 53 factory Int16Array.fromList(List<num> list) => _I16_1(ensureNative(list)); | 57 factory Int32Array.fromList(List<num> list) => _wrap(_I32(ensureNative(list)))
; |
| 54 factory Int16Array.fromBuffer(ArrayBuffer buffer, | 58 factory Int32Array.fromBuffer(ArrayBuffer buffer, |
| 55 [int byteOffset = 0, int length]) { | 59 [int byteOffset = 0, int length]) => |
| 56 if (length == null) return _I16_2(buffer, byteOffset); | 60 _wrap(_I32(_unwrap(buffer), byteOffset, length)); |
| 57 return _I16_3(buffer, byteOffset, length); | 61 static _I32(_arg0, [_arg1, _arg2]) native "Int32Array_constructor_Callback"; |
| 58 } | |
| 59 | 62 |
| 60 factory Int32Array(int length) => _I32(length); | 63 factory Uint8Array(int length) => _wrap(_U8(length)); |
| 61 factory Int32Array.fromList(List<num> list) => _I32_1(ensureNative(list)); | 64 factory Uint8Array.fromList(List<num> list) => _wrap(_U8(ensureNative(list))); |
| 62 factory Int32Array.fromBuffer(ArrayBuffer buffer, | 65 factory Uint8Array.fromBuffer(ArrayBuffer buffer, |
| 63 [int byteOffset = 0, int length]) { | 66 [int byteOffset = 0, int length]) => |
| 64 if (length == null) return _I32_2(buffer, byteOffset); | 67 _wrap(_U8(_unwrap(buffer), byteOffset, length)); |
| 65 return _I32_3(buffer, byteOffset, length); | 68 static _U8(_arg0, [_arg1, _arg2]) native "Uint8Array_constructor_Callback"; |
| 66 } | |
| 67 | 69 |
| 68 factory Uint8Array(int length) => _U8(length); | 70 factory Uint16Array(int length) => _wrap(_U16(length)); |
| 69 factory Uint8Array.fromList(List<num> list) => _U8_1(ensureNative(list)); | 71 factory Uint16Array.fromList(List<num> list) => _wrap(_U16(ensureNative(list))
); |
| 70 factory Uint8Array.fromBuffer(ArrayBuffer buffer, | 72 factory Uint16Array.fromBuffer(ArrayBuffer buffer, |
| 71 [int byteOffset = 0, int length]) { | 73 [int byteOffset = 0, int length]) => |
| 72 if (length == null) return _U8_2(buffer, byteOffset); | 74 _wrap(_U16(_unwrap(buffer), byteOffset, length)); |
| 73 return _U8_3(buffer, byteOffset, length); | 75 static _U16(_arg0, [_arg1, _arg2]) native "Uint16Array_constructor_Callback"; |
| 74 } | |
| 75 | 76 |
| 76 factory Uint16Array(int length) => _U16(length); | 77 factory Uint32Array(int length) => _wrap(_U32(length)); |
| 77 factory Uint16Array.fromList(List<num> list) => _U16_1(ensureNative(list)); | 78 factory Uint32Array.fromList(List<num> list) => _wrap(_U32(ensureNative(list))
); |
| 78 factory Uint16Array.fromBuffer(ArrayBuffer buffer, | 79 factory Uint32Array.fromBuffer(ArrayBuffer buffer, |
| 79 [int byteOffset = 0, int length]) { | 80 [int byteOffset = 0, int length]) => |
| 80 if (length == null) return _U16_2(buffer, byteOffset); | 81 _wrap(_U32(_unwrap(buffer), byteOffset, length)); |
| 81 return _U16_3(buffer, byteOffset, length); | 82 static _U32(_arg0, [_arg1, _arg2]) native "Uint32Array_constructor_Callback"; |
| 82 } | |
| 83 | 83 |
| 84 factory Uint32Array(int length) => _U32(length); | 84 factory Uint8ClampedArray(int length) => _wrap(_U8C(length)); |
| 85 factory Uint32Array.fromList(List<num> list) => _U32_1(ensureNative(list)); | 85 factory Uint8ClampedArray.fromList(List<num> list) => _wrap(_U8C(ensureNative(
list))); |
| 86 factory Uint32Array.fromBuffer(ArrayBuffer buffer, | |
| 87 [int byteOffset = 0, int length]) { | |
| 88 if (length == null) return _U32_2(buffer, byteOffset); | |
| 89 return _U32_3(buffer, byteOffset, length); | |
| 90 } | |
| 91 | |
| 92 factory Uint8ClampedArray(int length) => _U8C(length); | |
| 93 factory Uint8ClampedArray.fromList(List<num> list) => _U8C_1(ensureNative(list
)); | |
| 94 factory Uint8ClampedArray.fromBuffer(ArrayBuffer buffer, | 86 factory Uint8ClampedArray.fromBuffer(ArrayBuffer buffer, |
| 95 [int byteOffset = 0, int length]) { | 87 [int byteOffset = 0, int length]) => |
| 96 if (length == null) return _U8C_2(buffer, byteOffset); | 88 _wrap(_U8C(_unwrap(buffer), byteOffset, length)); |
| 97 return _U8C_3(buffer, byteOffset, length); | 89 static _U8C(_arg0, [_arg1, _arg2]) native "Uint8ClampedArray_constructor_Callb
ack"; |
| 98 } | |
| 99 | |
| 100 static Float32Array _F32(arg) => _wrap(new dom.Float32Array(arg)); | |
| 101 static Float64Array _F64(arg) => _wrap(new dom.Float64Array(arg)); | |
| 102 static Int8Array _I8(arg) => _wrap(new dom.Int8Array(arg)); | |
| 103 static Int16Array _I16(arg) => _wrap(new dom.Int16Array(arg)); | |
| 104 static Int32Array _I32(arg) => _wrap(new dom.Int32Array(arg)); | |
| 105 static Uint8Array _U8(arg) => _wrap(new dom.Uint8Array(arg)); | |
| 106 static Uint16Array _U16(arg) => _wrap(new dom.Uint16Array(arg)); | |
| 107 static Uint32Array _U32(arg) => _wrap(new dom.Uint32Array(arg)); | |
| 108 static Uint8ClampedArray _U8C(arg) => _wrap(new dom.Uint8ClampedArray(arg)); | |
| 109 | |
| 110 static Float32Array _F32_1(arg) => _wrap(new dom.Float32Array.fromList(arg)); | |
| 111 static Float64Array _F64_1(arg) => _wrap(new dom.Float64Array.fromList(arg)); | |
| 112 static Int8Array _I8_1(arg) => _wrap(new dom.Int8Array.fromList(arg)); | |
| 113 static Int16Array _I16_1(arg) => _wrap(new dom.Int16Array.fromList(arg)); | |
| 114 static Int32Array _I32_1(arg) => _wrap(new dom.Int32Array.fromList(arg)); | |
| 115 static Uint8Array _U8_1(arg) => _wrap(new dom.Uint8Array.fromList(arg)); | |
| 116 static Uint16Array _U16_1(arg) => _wrap(new dom.Uint16Array.fromList(arg)); | |
| 117 static Uint32Array _U32_1(arg) => _wrap(new dom.Uint32Array.fromList(arg)); | |
| 118 static Uint8ClampedArray _U8C_1(arg) => _wrap(new dom.Uint8ClampedArray.fromLi
st(arg)); | |
| 119 | |
| 120 static Float32Array _F32_2(buffer, byteOffset) => _wrap(new dom.Float32Array.f
romBuffer(_unwrap(buffer), byteOffset)); | |
| 121 static Float64Array _F64_2(buffer, byteOffset) => _wrap(new dom.Float64Array.f
romBuffer(_unwrap(buffer), byteOffset)); | |
| 122 static Int8Array _I8_2(buffer, byteOffset) => _wrap(new dom.Int8Array.fromBuff
er(_unwrap(buffer), byteOffset)); | |
| 123 static Int16Array _I16_2(buffer, byteOffset) => _wrap(new dom.Int16Array.fromB
uffer(_unwrap(buffer), byteOffset)); | |
| 124 static Int32Array _I32_2(buffer, byteOffset) => _wrap(new dom.Int32Array.fromB
uffer(_unwrap(buffer), byteOffset)); | |
| 125 static Uint8Array _U8_2(buffer, byteOffset) => _wrap(new dom.Uint8Array.fromBu
ffer(_unwrap(buffer), byteOffset)); | |
| 126 static Uint16Array _U16_2(buffer, byteOffset) => _wrap(new dom.Uint16Array.fro
mBuffer(_unwrap(buffer), byteOffset)); | |
| 127 static Uint32Array _U32_2(buffer, byteOffset) => _wrap(new dom.Uint32Array.fro
mBuffer(_unwrap(buffer), byteOffset)); | |
| 128 static Uint8ClampedArray _U8C_2(buffer, byteOffset) => _wrap(new dom.Uint8Clam
pedArray.fromBuffer(_unwrap(buffer), byteOffset)); | |
| 129 | |
| 130 static Float32Array _F32_3(buffer, byteOffset, length) => _wrap(new dom.Float3
2Array.fromBuffer(_unwrap(buffer), byteOffset, length)); | |
| 131 static Float64Array _F64_3(buffer, byteOffset, length) => _wrap(new dom.Float6
4Array.fromBuffer(_unwrap(buffer), byteOffset, length)); | |
| 132 static Int8Array _I8_3(buffer, byteOffset, length) => _wrap(new dom.Int8Array.
fromBuffer(_unwrap(buffer), byteOffset, length)); | |
| 133 static Int16Array _I16_3(buffer, byteOffset, length) => _wrap(new dom.Int16Arr
ay.fromBuffer(_unwrap(buffer), byteOffset, length)); | |
| 134 static Int32Array _I32_3(buffer, byteOffset, length) => _wrap(new dom.Int32Arr
ay.fromBuffer(_unwrap(buffer), byteOffset, length)); | |
| 135 static Uint8Array _U8_3(buffer, byteOffset, length) => _wrap(new dom.Uint8Arra
y.fromBuffer(_unwrap(buffer), byteOffset, length)); | |
| 136 static Uint16Array _U16_3(buffer, byteOffset, length) => _wrap(new dom.Uint16A
rray.fromBuffer(_unwrap(buffer), byteOffset, length)); | |
| 137 static Uint32Array _U32_3(buffer, byteOffset, length) => _wrap(new dom.Uint32A
rray.fromBuffer(_unwrap(buffer), byteOffset, length)); | |
| 138 static Uint8ClampedArray _U8C_3(buffer, byteOffset, length) => _wrap(new dom.U
int8ClampedArray.fromBuffer(_unwrap(buffer), byteOffset, length)); | |
| 139 | 90 |
| 140 static ensureNative(List list) => list; // TODO: make sure. | 91 static ensureNative(List list) => list; // TODO: make sure. |
| 141 } | 92 } |
| 142 | 93 |
| 143 class _PointFactoryProvider { | 94 class _PointFactoryProvider { |
| 144 | 95 factory Point(num x, num y) => _wrap(_createWebKitPoint(x, y)); |
| 145 factory Point(num x, num y) => _wrap(new dom.WebKitPoint(x, y)); | 96 static _createWebKitPoint(num x, num y) native "WebKitPoint_constructor_Callba
ck"; |
| 146 } | 97 } |
| 147 | 98 |
| 148 class _WebSocketFactoryProvider { | 99 class _WebSocketFactoryProvider { |
| 149 | 100 factory WebSocket(String url) => _wrap(_createWebSocket(url)); |
| 150 factory WebSocket(String url) => _wrap(new dom.WebSocket(url)); | 101 static _createWebSocket(String url) native "WebSocket_constructor_Callback"; |
| 151 } | 102 } |
| 152 | 103 |
| 153 class _TextFactoryProvider { | 104 class _TextFactoryProvider { |
| 154 factory Text(String data) => _document.$dom_createTextNode(data); | 105 factory Text(String data) => _document.$dom_createTextNode(data); |
| 155 } | 106 } |
| OLD | NEW |