Conversions between JavaScript objects and Maps.

Review URL: https://chromiumcodereview.appspot.com//10870030

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11208 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
sra@google.com
2012-08-23 03:50:16 +00:00
parent 9efad2644b
commit 5e134e6b8b
2 changed files with 24 additions and 8 deletions
+12 -4
View File
@@ -38573,15 +38573,23 @@ _convertDartToNative_ImageData(ImageData imageData) {
/// Converts a JavaScript object with properties into a Dart Map.
/// Not suitable for nested objects.
Map _convertNativeToDart_Dictionary(object) {
// TODO: Implement.
return object;
var dict = {};
for (final key in JS('List', 'Object.getOwnPropertyNames(#)', object)) {
dict[key] = JS('var', '#[#]', object, key);
}
return dict;
}
/// Converts a Dart map into a JavaScript object with properties.
/// Converts a flat Dart map into a JavaScript object with properties.
_convertDartToNative_Dictionary(Map dict) {
// TODO: Implement.
return dict;
var object = JS('var', '{}');
dict.forEach((String key, value) {
JS('void', '#[#] = #', object, key, value);
});
return object;
}
+12 -4
View File
@@ -84,15 +84,23 @@ _convertDartToNative_ImageData(ImageData imageData) {
/// Converts a JavaScript object with properties into a Dart Map.
/// Not suitable for nested objects.
Map _convertNativeToDart_Dictionary(object) {
// TODO: Implement.
return object;
var dict = {};
for (final key in JS('List', 'Object.getOwnPropertyNames(#)', object)) {
dict[key] = JS('var', '#[#]', object, key);
}
return dict;
}
/// Converts a Dart map into a JavaScript object with properties.
/// Converts a flat Dart map into a JavaScript object with properties.
_convertDartToNative_Dictionary(Map dict) {
// TODO: Implement.
return dict;
var object = JS('var', '{}');
dict.forEach((String key, value) {
JS('void', '#[#] = #', object, key, value);
});
return object;
}