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

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

Issue 13982012: Update pkg/serialization to use Symbols and synchronous mirrors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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/pkg.status ('k') | pkg/serialization/lib/src/basic_rule.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 * This provides a general-purpose serialization facility for Dart objects. A 6 * This provides a general-purpose serialization facility for Dart objects. A
7 * [Serialization] is defined in terms of [SerializationRule]s and supports 7 * [Serialization] is defined in terms of [SerializationRule]s and supports
8 * reading and writing to different formats. 8 * reading and writing to different formats.
9 * 9 *
10 * Setup 10 * Setup
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 312 }
313 313
314 /** Set up the default rules, for lists and primitives. */ 314 /** Set up the default rules, for lists and primitives. */
315 void addDefaultRules() { 315 void addDefaultRules() {
316 addRule(new PrimitiveRule()); 316 addRule(new PrimitiveRule());
317 addRule(new ListRule()); 317 addRule(new ListRule());
318 // Both these rules apply to lists, so unless otherwise indicated, 318 // Both these rules apply to lists, so unless otherwise indicated,
319 // it will always find the first one. 319 // it will always find the first one.
320 addRule(new ListRuleEssential()); 320 addRule(new ListRuleEssential());
321 addRule(new MapRule()); 321 addRule(new MapRule());
322 addRule(new SymbolRule());
322 } 323 }
323 324
324 /** 325 /**
325 * Add a new SerializationRule [rule]. The addRuleFor method will probably 326 * Add a new SerializationRule [rule]. The addRuleFor method will probably
326 * handle most simple cases, but for adding an arbitrary rule, including 327 * handle most simple cases, but for adding an arbitrary rule, including
327 * a SerializationRule subclass which you have created, you can use this 328 * a SerializationRule subclass which you have created, you can use this
328 * method. 329 * method.
329 */ 330 */
330 void addRule(SerializationRule rule) { 331 void addRule(SerializationRule rule) {
331 rule.number = _rules.length; 332 rule.number = _rules.length;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 ..addRuleFor(new ListRule()) 439 ..addRuleFor(new ListRule())
439 ..addRuleFor(new MapRule()) 440 ..addRuleFor(new MapRule())
440 ..addRuleFor(new PrimitiveRule()) 441 ..addRuleFor(new PrimitiveRule())
441 ..addRuleFor(new ListRuleEssential()) 442 ..addRuleFor(new ListRuleEssential())
442 ..addRuleFor(basicRule, 443 ..addRuleFor(basicRule,
443 constructorFields: ['type', 444 constructorFields: ['type',
444 'constructorName', 445 'constructorName',
445 'constructorFields', 'regularFields', []], 446 'constructorFields', 'regularFields', []],
446 fields: []) 447 fields: [])
447 ..addRule(new NamedObjectRule()) 448 ..addRule(new NamedObjectRule())
448 ..addRule(new MirrorRule()); 449 ..addRule(new MirrorRule())
450 ..addRule(new SymbolRule());
449 meta.namedObjects = namedObjects; 451 meta.namedObjects = namedObjects;
450 return meta; 452 return meta;
451 } 453 }
452 454
453 /** Return true if our [namedObjects] collection has an entry for [object].*/ 455 /** Return true if our [namedObjects] collection has an entry for [object].*/
454 bool _hasNameFor(object) { 456 bool _hasNameFor(object) {
455 var sentinel = const _Sentinel(); 457 var sentinel = const _Sentinel();
456 return _nameFor(object, () => sentinel) != sentinel; 458 return _nameFor(object, () => sentinel) != sentinel;
457 } 459 }
458 460
(...skipping 10 matching lines...) Expand all
469 } 471 }
470 472
471 /** 473 /**
472 * An exception class for errors during serialization. 474 * An exception class for errors during serialization.
473 */ 475 */
474 class SerializationException implements Exception { 476 class SerializationException implements Exception {
475 final String message; 477 final String message;
476 const SerializationException([this.message]); 478 const SerializationException([this.message]);
477 toString() => "SerializationException($message)"; 479 toString() => "SerializationException($message)";
478 } 480 }
OLDNEW
« no previous file with comments | « pkg/pkg.status ('k') | pkg/serialization/lib/src/basic_rule.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698