| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |