Index: client/dart.js |
diff --git a/client/dart.js b/client/dart.js |
index 30b0883c644165b04529082cb0fd1f083f92b928..d1d9122488c6e01dd35b0333268bce82cb0979a3 100644 |
--- a/client/dart.js |
+++ b/client/dart.js |
@@ -89,6 +89,7 @@ function ReceivePortSync() { |
case 'map': return deserializeMap(x); |
case 'sendport': return deserializeSendPort(x); |
case 'list': return deserializeList(x); |
+ case 'funcref': return deserializeFunction(x); |
vsm
2012/08/10 00:18:50
How about a more descriptive name? E.g., 'functio
Anton Muhin
2012/08/14 16:42:38
I can definitely do it, but I wished to minimize t
vsm
2012/08/15 15:35:38
It's fine for now.
On 2012/08/14 16:42:38, Anton
|
default: throw 'unimplemented'; |
} |
} |
@@ -131,6 +132,14 @@ function ReceivePortSync() { |
return result; |
} |
+ function deserializeFunction(x) { |
+ var ref = x[1]; |
+ var sendPort = deserializeSendPort(x[2]); |
+ // Number of arguments is not used as as of now |
vsm
2012/08/10 00:18:50
"as as" -> as
Anton Muhin
2012/08/14 16:42:38
Done.
|
+ // 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; |
@@ -214,4 +223,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)]); |
vsm
2012/08/10 00:18:50
Don't the arguments and return value need to be se
Anton Muhin
2012/08/14 16:42:38
I don't remember all the details, but won't callSy
vsm
2012/08/15 15:35:38
Yes, I think you're correct.
On 2012/08/14 16:42:
|
+ } |
+ } |
})(); |