| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 * Note that the function is passed the owning object as well as the field | 92 * Note that the function is passed the owning object as well as the field |
| 93 * value, but that it is passed as a mirror. | 93 * value, but that it is passed as a mirror. |
| 94 */ | 94 */ |
| 95 specialTreatmentFor(String fieldName, SetWithFunction setWith) { | 95 specialTreatmentFor(String fieldName, SetWithFunction setWith) { |
| 96 fields.addAllByName([fieldName]); | 96 fields.addAllByName([fieldName]); |
| 97 _Field field = fields.named(fieldName); | 97 _Field field = fields.named(fieldName); |
| 98 Function setter = (setWith == null) ? field.defaultSetter : setWith; | 98 Function setter = (setWith == null) ? field.defaultSetter : setWith; |
| 99 field.specialTreatment = setter; | 99 field.specialTreatment = setter; |
| 100 } | 100 } |
| 101 | 101 |
| 102 // TODO(alanknight): Polyfill for the non-hashability of mirrors. Issue 6880. | |
| 103 get typeWrapped => new ClassMirrorWrapper(type); | |
| 104 | |
| 105 /** Return the name of the constructor used to create new instances on read.*/ | 102 /** Return the name of the constructor used to create new instances on read.*/ |
| 106 String get constructorName => constructor.name; | 103 String get constructorName => constructor.name; |
| 107 | 104 |
| 108 /** Return the list of field names to be passed to the constructor.*/ | 105 /** Return the list of field names to be passed to the constructor.*/ |
| 109 List<String> get constructorFields => fields.constructorFieldNames(); | 106 List<String> get constructorFields => fields.constructorFieldNames(); |
| 110 | 107 |
| 111 /** Return the list of field names not used in the constructor. */ | 108 /** Return the list of field names not used in the constructor. */ |
| 112 List<String> get regularFields => fields.regularFieldNames(); | 109 List<String> get regularFields => fields.regularFieldNames(); |
| 113 | 110 |
| 114 String toString() => "Basic Rule for ${type.simpleName}"; | 111 String toString() => "Basic Rule for ${type.simpleName}"; |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 List fieldList; | 540 List fieldList; |
| 544 _MapWrapper(this.fieldList); | 541 _MapWrapper(this.fieldList); |
| 545 _MapWrapper.fromMap(this._map, this.fieldList); | 542 _MapWrapper.fromMap(this._map, this.fieldList); |
| 546 | 543 |
| 547 operator [](key) => _map[fieldList[key].name]; | 544 operator [](key) => _map[fieldList[key].name]; |
| 548 operator []=(key, value) { _map[fieldList[key].name] = value; } | 545 operator []=(key, value) { _map[fieldList[key].name] = value; } |
| 549 get length => _map.length; | 546 get length => _map.length; |
| 550 | 547 |
| 551 asMap() => _map; | 548 asMap() => _map; |
| 552 } | 549 } |
| OLD | NEW |