| 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)]);
|
| + }
|
| + }
|
| })();
|
|
|