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

Unified Diff: pkg/polymer/lib/deserialize.dart

Issue 173003006: Use smoke in polymer and polymer_expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
Index: pkg/polymer/lib/deserialize.dart
diff --git a/pkg/polymer/lib/deserialize.dart b/pkg/polymer/lib/deserialize.dart
index 60e63f7588ccfa43c502f45f0464544672d18dbc..32499ff32bea8020876e116bef3098003311812a 100644
--- a/pkg/polymer/lib/deserialize.dart
+++ b/pkg/polymer/lib/deserialize.dart
@@ -5,14 +5,11 @@
library polymer.deserialize;
import 'dart:convert' show JSON;
-import 'dart:mirrors' show TypeMirror;
-final _typeHandlers = () {
- // TODO(jmesserly): switch to map and symbol literal form when supported.
- var m = new Map();
- m[#dart.core.String] = (x, _) => x;
- m[#dart.core.Null] = (x, _) => x;
- m[#dart.core.DateTime] = (x, def) {
+final _typeHandlers = {
+ String: (x, _) => x,
+ Null: (x, _) => x,
+ DateTime: (x, def) {
// TODO(jmesserly): shouldn't need to try-catch here
// See: https://code.google.com/p/dart/issues/detail?id=1878
try {
@@ -20,20 +17,15 @@ final _typeHandlers = () {
} catch (e) {
return def;
}
- };
- m[#dart.core.bool] = (x, _) => x != 'false';
- m[#dart.core.int] =
- (x, def) => int.parse(x, onError: (_) => def);
- m[#dart.core.double] =
- (x, def) => double.parse(x, (_) => def);
- return m;
-}();
+ },
+ bool: (x, _) => x != 'false',
+ int: (x, def) => int.parse(x, onError: (_) => def),
+ double: (x, def) => double.parse(x, (_) => def),
+};
-/**
- * Convert representation of [value] based on type of [currentValue].
- */
-Object deserializeValue(String value, Object currentValue, TypeMirror type) {
- var handler = _typeHandlers[type.qualifiedName];
+/// Convert representation of [value] based on [type] and [currentValue].
+Object deserializeValue(String value, Object currentValue, Type type) {
+ var handler = _typeHandlers[type];
if (handler != null) return handler(value, currentValue);
try {

Powered by Google App Engine
This is Rietveld 408576698