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

Unified Diff: client/dart.js

Issue 10702113: Serialize/deserialize lists in JS ports (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dart.js
===================================================================
--- client/dart.js (revision 9437)
+++ client/dart.js (working copy)
@@ -53,6 +53,12 @@
typeof(message) == 'number' ||
typeof(message) == 'boolean') {
return message;
+ } else if (message instanceof Array) {
+ var values = new Array(message.length);
+ for (var i = 0; i < message.length; i++) {
+ values[i] = serialize(message[i]);
+ }
+ return [ 'list', message.length, values ];
} else if (message instanceof LocalSendPortSync) {
return [ 'sendport', 'nativejs', message.receivePort.id ];
} else if (message instanceof DartSendPortSync) {
@@ -63,7 +69,7 @@
var keys = Object.getOwnPropertyNames(message);
var values = new Array(keys.length);
for (var i = 0; i < keys.length; i++) {
- values[i] = message[keys[i]];
+ values[i] = serialize(message[keys[i]]);
}
return [ 'map', id, keys, values ];
}
@@ -83,6 +89,7 @@
switch (x[0]) {
case 'map': return deserializeMap(x);
case 'sendport': return deserializeSendPort(x);
+ case 'list': return deserializeList(x);
default: throw 'unimplemented';
}
}
@@ -105,7 +112,7 @@
switch (tag) {
case 'nativejs':
var id = x[2];
- return new LocalSendPortSync(id);
+ return new LocalSendPortSync(ReceivePortSync.map[id]);
sammccall 2012/07/06 16:01:41 I think this was just an oversight before?
case 'dart':
var isolateId = x[2];
var portId = x[3];
@@ -115,6 +122,16 @@
}
}
+ function deserializeList(x) {
+ var length = x[1];
+ var values = x[2];
+ var result = new Array(length);
+ for (var i = 0; i < length; i++) {
+ result[i] = values[i];
+ }
+ return result;
+ }
+
window.registerPort = function(name, port) {
var stringified = JSON.stringify(serialize(port));
window.localStorage['dart-port:' + name] = stringified;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698