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

Side by Side Diff: pkg/serialization/lib/src/mirrors_helpers.dart

Issue 23447003: Change reflective serialization rules to be able to take type literals (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/serialization/lib/serialization.dart ('k') | pkg/serialization/test/no_library_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Provides some additional convenience methods on top of the basic mirrors 6 * Provides some additional convenience methods on top of the basic mirrors
7 */ 7 */
8 library mirrors_helpers; 8 library mirrors_helpers;
9 9
10 // Import and re-export mirrors here to minimize both dependence on mirrors 10 // Import and re-export mirrors here to minimize both dependence on mirrors
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 * Return a list of all the public getters of a class which have corresponding 75 * Return a list of all the public getters of a class which have corresponding
76 * setters. 76 * setters.
77 */ 77 */
78 Iterable<MethodMirror> publicGettersWithMatchingSetters(ClassMirror mirror) { 78 Iterable<MethodMirror> publicGettersWithMatchingSetters(ClassMirror mirror) {
79 var setters = mirror.setters; 79 var setters = mirror.setters;
80 return publicGetters(mirror).where((each) => 80 return publicGetters(mirror).where((each) =>
81 setters["${each.simpleName}="] != null); 81 setters["${each.simpleName}="] != null);
82 } 82 }
83 83
84 /** 84 /**
85 * A particularly bad case of polyfill, because we cannot yet use type names 85 * Given either an instance or a type, returns the type. Instances of Type
86 * as literals, so we have to be passed an instance and then extract a 86 * will be treated as types. Passing in an instance is really just backward
87 * ClassMirror from that. Given a horrible name as an extra reminder to fix it. 87 * compatibility.
88 */ 88 */
89 ClassMirror turnInstanceIntoSomethingWeCanUse(x) => reflect(x).type; 89 ClassMirror turnInstanceIntoSomethingWeCanUse(x) {
90 if (x is Type) return reflectClass(x);
91 return reflect(x).type;
92 }
OLDNEW
« no previous file with comments | « pkg/serialization/lib/serialization.dart ('k') | pkg/serialization/test/no_library_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698