Index: lib/dom/templates/html/frog/html_frog.darttemplate |
diff --git a/lib/dom/templates/html/frog/html_frog.darttemplate b/lib/dom/templates/html/frog/html_frog.darttemplate |
index d364246feea018b82450705114ca2849c89e394d..392f7576f2f035acaf777cf94dfdd354208fba0e 100644 |
--- a/lib/dom/templates/html/frog/html_frog.darttemplate |
+++ b/lib/dom/templates/html/frog/html_frog.darttemplate |
@@ -5,7 +5,10 @@ |
// DO NOT EDIT |
// Auto-generated dart:html library. |
-#library("html"); |
+#library('html'); |
+ |
+#import('dart:isolate'); |
+#import('dart:json'); |
$!GENERATED_DART_FILES |
@@ -28,6 +31,7 @@ $!GENERATED_DART_FILES |
#source('../../html/src/Device.dart'); |
#source('../../dom/src/_ListIterators.dart'); |
#source('../../dom/src/_Lists.dart'); |
+#source('../../isolate/serialization.dart'); |
Window get window() native "return window;"; |
@@ -44,3 +48,41 @@ ElementList queryAll(String selector) => _document.queryAll(selector); |
// Dart issue 1990. |
class _HTMLElementImpl extends _ElementImpl native "*HTMLElement" { |
} |
+ |
+// TODO(vsm): Move this to a separate Isolates.dart file. |
+_serialize(var message) { |
+ // TODO(kasperl): Specialize the serializer. |
+ return new _Serializer().traverse(message); |
+} |
+ |
+_deserialize(var message) { |
+ return new _JsDeserializer().deserialize(message); |
+} |
+ |
+class _JsDeserializer extends _Deserializer { |
+ |
+ deserializeSendPort(List x) { |
+ num id = x[1]; |
+ return new _JsSendPortSync(id); |
+ } |
+ |
+} |
+ |
+class _JsSendPortSync implements SendPortSync { |
+ |
+ num _id; |
+ _JsSendPortSync(this._id); |
+ |
+ callSync(var message) { |
+ var serialized = _serialize(message); |
+ var result = _call(_id, serialized); |
+ return _deserialize(result); |
+ } |
+ |
+ static _call(num id, var message) native @""" |
+ var deserialized = _deserialize(message); |
+ var result = ReceivePortSync.map[id].callback(deserialized); |
+ return _serialize(result); |
+ """; |
+ |
+} |