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

Unified Diff: client/dart.js

Issue 10690142: Move function serialization to sync ports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « no previous file | lib/html/src/Isolates.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dart.js
diff --git a/client/dart.js b/client/dart.js
index c070ef1a68a6a2b33e92e7a8c3bdce55008e9104..dae0d2b61482a36eab12c9112a360af5b25a45c9 100644
--- a/client/dart.js
+++ b/client/dart.js
@@ -108,6 +108,7 @@ function ReceivePortSync() {
case 'map': return deserializeMap(x);
case 'sendport': return deserializeSendPort(x);
case 'list': return deserializeList(x);
+ case 'funcref': return deserializeFunction(x);
default: throw 'unimplemented';
}
}
@@ -150,6 +151,14 @@ function ReceivePortSync() {
return result;
}
+ function deserializeFunction(x) {
+ var ref = x[1];
+ var sendPort = deserializeSendPort(x[2]);
+ // Number of arguments is not used as of now
+ // we cannot find it out for Dart function in pure Dart.
+ return _makeFunctionFromRef(ref, sendPort);
+ }
+
window.registerPort = function(name, port) {
var stringified = JSON.stringify(serialize(port));
window.localStorage['dart-port:' + name] = stringified;
@@ -233,4 +242,12 @@ function ReceivePortSync() {
window.removeEventListener(source, listener, false);
return deserialize(result);
}
+
+ // Leaking implementation.
+ // TODO: provide proper, backend-specific implementation.
+ function _makeFunctionFromRef(ref, sendPort) {
+ return function() {
+ return sendPort.callSync([ref, Array.prototype.slice.call(arguments)]);
+ }
+ }
})();
« no previous file with comments | « no previous file | lib/html/src/Isolates.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698