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 | 6 |
7 factory AudioContext() native ''' | 7 factory AudioContext() native ''' |
8 var constructor = window.AudioContext || window.webkitAudioContext; | 8 var constructor = window.AudioContext || window.webkitAudioContext; |
9 return new constructor(); | 9 return new constructor(); |
10 '''; | 10 '''; |
11 } | 11 } |
12 | 12 |
13 class _TypedArrayFactoryProvider { | |
14 | |
15 factory Float32Array(int length) => _F32(length); | |
16 factory Float32Array.fromList(List<num> list) => _F32(ensureNative(list)); | |
17 factory Float32Array.fromBuffer(ArrayBuffer buffer) => _F32(buffer); | |
18 | |
19 factory Float64Array(int length) => _F64(length); | |
20 factory Float64Array.fromList(List<num> list) => _F64(ensureNative(list)); | |
21 factory Float64Array.fromBuffer(ArrayBuffer buffer) => _F64(buffer); | |
22 | |
23 factory Int8Array(int length) => _I8(length); | |
24 factory Int8Array.fromList(List<num> list) => _I8(ensureNative(list)); | |
25 factory Int8Array.fromBuffer(ArrayBuffer buffer) => _I8(buffer); | |
26 | |
27 factory Int16Array(int length) => _I16(length); | |
28 factory Int16Array.fromList(List<num> list) => _I16(ensureNative(list)); | |
29 factory Int16Array.fromBuffer(ArrayBuffer buffer) => _I16(buffer); | |
30 | |
31 factory Int32Array(int length) => _I32(length); | |
32 factory Int32Array.fromList(List<num> list) => _I32(ensureNative(list)); | |
33 factory Int32Array.fromBuffer(ArrayBuffer buffer) => _I32(buffer); | |
34 | |
35 factory Uint8Array(int length) => _U8(length); | |
36 factory Uint8Array.fromList(List<num> list) => _U8(ensureNative(list)); | |
37 factory Uint8Array.fromBuffer(ArrayBuffer buffer) => _U8(buffer); | |
38 | |
39 factory Uint16Array(int length) => _U16(length); | |
40 factory Uint16Array.fromList(List<num> list) => _U16(ensureNative(list)); | |
41 factory Uint16Array.fromBuffer(ArrayBuffer buffer) => _U16(buffer); | |
42 | |
43 factory Uint32Array(int length) => _U32(length); | |
44 factory Uint32Array.fromList(List<num> list) => _U32(ensureNative(list)); | |
45 factory Uint32Array.fromBuffer(ArrayBuffer buffer) => _U32(buffer); | |
46 | |
47 factory Uint8ClampedArray(int length) => _U8C(length); | |
48 factory Uint8ClampedArray.fromList(List<num> list) => _U8C(ensureNative(list))
; | |
49 factory Uint8ClampedArray.fromBuffer(ArrayBuffer buffer) => _U8C(buffer); | |
50 | |
51 static Float32Array _F32(arg) native 'return new Float32Array(arg);'; | |
52 static Float64Array _F64(arg) native 'return new Float64Array(arg);'; | |
53 static Int8Array _I8(arg) native 'return new Int8Array(arg);'; | |
54 static Int16Array _I16(arg) native 'return new Int16Array(arg);'; | |
55 static Int32Array _I32(arg) native 'return new Int32Array(arg);'; | |
56 static Uint8Array _U8(arg) native 'return new Uint8Array(arg);'; | |
57 static Uint16Array _U16(arg) native 'return new Uint16Array(arg);'; | |
58 static Uint32Array _U32(arg) native 'return new Uint32Array(arg);'; | |
59 static Uint8ClampedArray _U8C(arg) native 'return new Uint8ClampedArray(arg);'
; | |
60 | |
61 static ensureNative(List list) => list; // TODO: make sure. | |
62 } | |
63 | |
64 class _PointFactoryProvider { | 13 class _PointFactoryProvider { |
65 | 14 |
66 factory Point(num x, num y) native 'return new WebKitPoint(x, y);'; | 15 factory Point(num x, num y) native 'return new WebKitPoint(x, y);'; |
67 } | 16 } |
68 | 17 |
69 class _WebSocketFactoryProvider { | 18 class _WebSocketFactoryProvider { |
70 | 19 |
71 factory WebSocket(String url) native '''return new WebSocket(url);'''; | 20 factory WebSocket(String url) native '''return new WebSocket(url);'''; |
72 } | 21 } |
73 | 22 |
74 class _TextFactoryProvider { | 23 class _TextFactoryProvider { |
75 factory Text(String data) native "return document.createTextNode(data);"; | 24 factory Text(String data) native "return document.createTextNode(data);"; |
76 } | 25 } |
OLD | NEW |