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

Unified Diff: lib/isolate/serialization.dart

Issue 10834426: Support general serializing of functions between JS and Dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 8 years, 4 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 | « lib/html/src/Isolates.dart ('k') | tests/html/js_interop_func_passing_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/isolate/serialization.dart
diff --git a/lib/isolate/serialization.dart b/lib/isolate/serialization.dart
index b3cb136eafa562f9702efc417bc01966d5bc5d3a..cd90d92405c4a3ef1d4cfc26cb8756efbc47007f 100644
--- a/lib/isolate/serialization.dart
+++ b/lib/isolate/serialization.dart
@@ -37,10 +37,9 @@ class _MessageTraverser {
if (x is Map) return visitMap(x);
if (x is SendPort) return visitSendPort(x);
if (x is SendPortSync) return visitSendPortSync(x);
- if (x is Function) return visitFunction(x);
- // TODO(floitsch): make this a real exception. (which one)?
- throw "Message serialization: Illegal value $x passed";
+ // Overridable fallback.
+ return visitObject(x);
}
abstract visitPrimitive(x);
@@ -49,8 +48,9 @@ class _MessageTraverser {
abstract visitSendPort(SendPort x);
abstract visitSendPortSync(SendPortSync x);
- visitFunction(Function func) {
- throw "Serialization of functions is not allowed.";
+ visitObject(Object x) {
+ // TODO(floitsch): make this a real exception. (which one)?
+ throw "Message serialization: Illegal value $x passed";
}
static bool isPrimitive(x) {
@@ -158,8 +158,7 @@ class _Deserializer {
case 'list': return _deserializeList(x);
case 'map': return _deserializeMap(x);
case 'sendport': return deserializeSendPort(x);
- // TODO(floitsch): Use real exception (which one?).
- default: throw "Unexpected serialized object";
+ default: return deserializeObject(x);
}
}
@@ -200,4 +199,8 @@ class _Deserializer {
abstract deserializeSendPort(List x);
+ deserializeObject(List x) {
+ // TODO(floitsch): Use real exception (which one?).
+ throw "Unexpected serialized object";
+ }
}
« no previous file with comments | « lib/html/src/Isolates.dart ('k') | tests/html/js_interop_func_passing_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698