Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: client/html/src/frog_FactoryProviders.dart

Issue 9403004: Wrapperless dart:html generator (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final version to check in. changes generator script but doesn't check in an active version of the … Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/dom/templates/interface.darttemplate ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/html/src/frog_FactoryProviders.dart
diff --git a/client/html/src/frog_FactoryProviders.dart b/client/html/src/frog_FactoryProviders.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3a701890d1b378df31b8238f0e3a58a5b0360651
--- /dev/null
+++ b/client/html/src/frog_FactoryProviders.dart
@@ -0,0 +1,125 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class _AudioContextFactoryProvider {
+
+ factory AudioContext() native '''
+ var constructor = window.AudioContext || window.webkitAudioContext;
+ return new constructor();
+''';
+}
+
+class _DOMParserFactoryProvider {
+
+ factory DOMParser() native 'return new DOMParser();';
+}
+
+class _FileReaderFactoryProvider {
+
+ factory FileReader() native 'return new FileReader();';
+}
+
+class _TypedArrayFactoryProvider {
+
+ factory Float32Array(int length) => _F32(length);
+ factory Float32Array.fromList(List<num> list) => _F32(ensureNative(list));
+ factory Float32Array.fromBuffer(ArrayBuffer buffer) => _F32(buffer);
+
+ factory Float64Array(int length) => _F64(length);
+ factory Float64Array.fromList(List<num> list) => _F64(ensureNative(list));
+ factory Float64Array.fromBuffer(ArrayBuffer buffer) => _F64(buffer);
+
+ factory Int8Array(int length) => _I8(length);
+ factory Int8Array.fromList(List<num> list) => _I8(ensureNative(list));
+ factory Int8Array.fromBuffer(ArrayBuffer buffer) => _I8(buffer);
+
+ factory Int16Array(int length) => _I16(length);
+ factory Int16Array.fromList(List<num> list) => _I16(ensureNative(list));
+ factory Int16Array.fromBuffer(ArrayBuffer buffer) => _I16(buffer);
+
+ factory Int32Array(int length) => _I32(length);
+ factory Int32Array.fromList(List<num> list) => _I32(ensureNative(list));
+ factory Int32Array.fromBuffer(ArrayBuffer buffer) => _I32(buffer);
+
+ factory Uint8Array(int length) => _U8(length);
+ factory Uint8Array.fromList(List<num> list) => _U8(ensureNative(list));
+ factory Uint8Array.fromBuffer(ArrayBuffer buffer) => _U8(buffer);
+
+ factory Uint16Array(int length) => _U16(length);
+ factory Uint16Array.fromList(List<num> list) => _U16(ensureNative(list));
+ factory Uint16Array.fromBuffer(ArrayBuffer buffer) => _U16(buffer);
+
+ factory Uint32Array(int length) => _U32(length);
+ factory Uint32Array.fromList(List<num> list) => _U32(ensureNative(list));
+ factory Uint32Array.fromBuffer(ArrayBuffer buffer) => _U32(buffer);
+
+ factory Uint8ClampedArray(int length) => _U8C(length);
+ factory Uint8ClampedArray.fromList(List<num> list) => _U8C(ensureNative(list));
+ factory Uint8ClampedArray.fromBuffer(ArrayBuffer buffer) => _U8C(buffer);
+
+ static Float32Array _F32(arg) native 'return new Float32Array(arg);';
+ static Float64Array _F64(arg) native 'return new Float64Array(arg);';
+ static Int8Array _I8(arg) native 'return new Int8Array(arg);';
+ static Int16Array _I16(arg) native 'return new Int16Array(arg);';
+ static Int32Array _I32(arg) native 'return new Int32Array(arg);';
+ static Uint8Array _U8(arg) native 'return new Uint8Array(arg);';
+ static Uint16Array _U16(arg) native 'return new Uint16Array(arg);';
+ static Uint32Array _U32(arg) native 'return new Uint32Array(arg);';
+ static Uint8ClampedArray _U8C(arg) native 'return new Uint8ClampedArray(arg);';
+
+ static ensureNative(List list) => list; // TODO: make sure.
+}
+
+class _CSSMatrixFactoryProvider {
+
+ factory CSSMatrix([String spec = '']) native
+ 'return new WebKitCSSMatrix(spec);';
+}
+
+// TODO(jacobr): this factory does not require any native code so move to a
+// separate file so it can be shared between wrapper and wrapperless versions.
+class _EventFactoryProvider {
+ factory Event(String type, [bool canBubble = true,
+ bool cancelable = true]) {
+ _EventJs e = _document._createEvent("Event");
+ e._initEvent(type, canBubble, cancelable);
+ return e;
+ }
+}
+
+class _PointFactoryProvider {
+
+ factory Point(num x, num y) native 'return new WebKitPoint(x, y);';
+}
+
+class _WebSocketFactoryProvider {
+
+ factory WebSocket(String url) native 'return new WebSocket(url);';
+}
+
+class _XMLHttpRequestFactoryProvider {
+ factory XMLHttpRequest() native 'return new XMLHttpRequest();';
+
+ factory XMLHttpRequest.getTEMPNAME(String url,
+ onSuccess(XMLHttpRequest request)) {
+ final request = new XMLHttpRequest();
+ request.open('GET', url, true);
+
+ // TODO(terry): Validate after client login added if necessary to forward
+ // cookies to server.
+ request.withCredentials = true;
+
+ // Status 0 is for local XHR request.
+ request.on.readyStateChange.add((e) {
+ if (request.readyState == XMLHttpRequest.DONE &&
+ (request.status == 200 || request.status == 0)) {
+ onSuccess(request);
+ }
+ });
+
+ request.send();
+
+ return request;
+ }
+}
« no previous file with comments | « client/dom/templates/interface.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698