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

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

Issue 12136002: Some fixes to work better with the services framework (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes from review comments Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/serialization/lib/serialization.dart ('k') | pkg/serialization/lib/src/format.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 part of serialization; 5 part of serialization;
6 6
7 // TODO(alanknight): Figure out how to reasonably separate out the things 7 // TODO(alanknight): Figure out how to reasonably separate out the things
8 // that require reflection without making the API more awkward. Or if that is 8 // that require reflection without making the API more awkward. Or if that is
9 // in fact necessary. Maybe the tree-shaking will just remove it if unused. 9 // in fact necessary. Maybe the tree-shaking will just remove it if unused.
10 10
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 var newKey = (each is Reference) ? each.inflated() : each; 154 var newKey = (each is Reference) ? each.inflated() : each;
155 newState[newKey] = state[each]; 155 newState[newKey] = state[each];
156 } 156 }
157 return new _MapWrapper.fromMap(newState, fields.contents); 157 return new _MapWrapper.fromMap(newState, fields.contents);
158 } 158 }
159 159
160 /** 160 /**
161 * Extract the state from [object] using an instanceMirror and the field 161 * Extract the state from [object] using an instanceMirror and the field
162 * names in [fields]. Call the function [callback] on each value. 162 * names in [fields]. Call the function [callback] on each value.
163 */ 163 */
164 extractState(object, Function callback) { 164 extractState(object, Function callback, Writer w) {
165 var result = createStateHolder(); 165 var result = createStateHolder();
166 var mirror = reflect(object); 166 var mirror = reflect(object);
167 167
168 keysAndValues(fields).forEach( 168 keysAndValues(fields).forEach(
169 (index, field) { 169 (index, field) {
170 var value = _value(mirror, field); 170 var value = _value(mirror, field);
171 callback(field.name); 171 callback(field.name);
172 callback(checkForEssentialLists(index, value)); 172 callback(checkForEssentialLists(index, value));
173 result[index] = value; 173 result[index] = value;
174 }); 174 });
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 _MapWrapper(this.fieldList) : _map = new Map(); 623 _MapWrapper(this.fieldList) : _map = new Map();
624 _MapWrapper.fromMap(this._map, this.fieldList); 624 _MapWrapper.fromMap(this._map, this.fieldList);
625 625
626 operator [](key) => _map[fieldList[key].name]; 626 operator [](key) => _map[fieldList[key].name];
627 627
628 operator []=(key, value) { _map[fieldList[key].name] = value; } 628 operator []=(key, value) { _map[fieldList[key].name] = value; }
629 get length => _map.length; 629 get length => _map.length;
630 630
631 asMap() => _map; 631 asMap() => _map;
632 } 632 }
OLDNEW
« no previous file with comments | « pkg/serialization/lib/serialization.dart ('k') | pkg/serialization/lib/src/format.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698