| 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): We should have an example and tests for subclassing | 7 // TODO(alanknight): We should have an example and tests for subclassing | 
| 8 // serialization rule rather than using the hard-coded ClosureToMap rule. And | 8 // serialization rule rather than using the hard-coded ClosureToMap rule. And | 
| 9 // possibly an abstract superclass that's designed to be subclassed that way. | 9 // possibly an abstract superclass that's designed to be subclassed that way. | 
| 10 /** | 10 /** | 
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 268   pullStateFrom(Iterator stream) { | 268   pullStateFrom(Iterator stream) { | 
| 269     var dataLength = stream.next(); | 269     var dataLength = stream.next(); | 
| 270     var ruleData = new List(); | 270     var ruleData = new List(); | 
| 271     for (var i = 0; i < dataLength; i++) { | 271     for (var i = 0; i < dataLength; i++) { | 
| 272       ruleData.add(stream.next()); | 272       ruleData.add(stream.next()); | 
| 273     } | 273     } | 
| 274     return ruleData; | 274     return ruleData; | 
| 275   } | 275   } | 
| 276 } | 276 } | 
| 277 | 277 | 
| 278 /** Helper function for PrimitiveRule to tell which objects it applies to. */ |  | 
| 279 bool isPrimitive(Object object) { |  | 
| 280   return object is num || object is String || object is bool; |  | 
| 281 } |  | 
| 282 |  | 
| 283 /** Typedef for the object construction closure used in ClosureToMapRule. */ | 278 /** Typedef for the object construction closure used in ClosureToMapRule. */ | 
| 284 typedef Object ConstructType(Map m); | 279 typedef Object ConstructType(Map m); | 
| 285 | 280 | 
| 286 /** Typedef for the state-getting closure used in ClosureToMapRule. */ | 281 /** Typedef for the state-getting closure used in ClosureToMapRule. */ | 
| 287 typedef Map<String, Object> GetStateType(Object o); | 282 typedef Map<String, Object> GetStateType(Object o); | 
| 288 | 283 | 
| 289 /** Typedef for the state-setting closure used in ClosureToMapRule. */ | 284 /** Typedef for the state-setting closure used in ClosureToMapRule. */ | 
| 290 typedef void NonEssentialStateType(Object o, Map m); | 285 typedef void NonEssentialStateType(Object o, Map m); | 
| 291 | 286 | 
| 292 /** | 287 /** | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 358 class ClassMirrorRule extends SerializationRule { | 353 class ClassMirrorRule extends SerializationRule { | 
| 359   // TODO(alanknight): This probably generalizes to any named object. | 354   // TODO(alanknight): This probably generalizes to any named object. | 
| 360   bool appliesTo(object) { | 355   bool appliesTo(object) { | 
| 361     return object is ClassMirror; | 356     return object is ClassMirror; | 
| 362   } | 357   } | 
| 363   extractState(object, Function f) => f(object.simpleName); | 358   extractState(object, Function f) => f(object.simpleName); | 
| 364   void flatten(object, Writer writer) {} | 359   void flatten(object, Writer writer) {} | 
| 365   inflateEssential(state, Reader r) => r.externalObjectNamed(state); | 360   inflateEssential(state, Reader r) => r.externalObjectNamed(state); | 
| 366   inflateNonEssential(state, object, Reader r) {} | 361   inflateNonEssential(state, object, Reader r) {} | 
| 367 } | 362 } | 
| OLD | NEW | 
|---|