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

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

Issue 14985015: pkg/serialization - more types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | « no previous file | pkg/serialization/lib/src/serialization_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 part of serialization; 5 part of serialization;
6 6
7 /** 7 /**
8 * This writes out the state of the objects to an external format. It holds 8 * This writes out the state of the objects to an external format. It holds
9 * all of the intermediate state needed. The primary API for it is the 9 * all of the intermediate state needed. The primary API for it is the
10 * [write] method. 10 * [write] method.
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 * This class works by doing a breadth-first traversal of the objects, 502 * This class works by doing a breadth-first traversal of the objects,
503 * with the traversal order maintained in [queue]. 503 * with the traversal order maintained in [queue].
504 */ 504 */
505 final Queue queue = new Queue(); 505 final Queue queue = new Queue();
506 506
507 /** The root objects from which we will be tracing. */ 507 /** The root objects from which we will be tracing. */
508 final List roots = []; 508 final List roots = [];
509 509
510 Trace(this.writer); 510 Trace(this.writer);
511 511
512 addRoot(object) { 512 void addRoot(object) {
513 roots.add(object); 513 roots.add(object);
514 } 514 }
515 515
516 /** A convenience method to add a single root and trace it in one step. */ 516 /** A convenience method to add a single root and trace it in one step. */
517 trace(object) { 517 void trace(object) {
518 addRoot(object); 518 addRoot(object);
519 traceAll(); 519 traceAll();
520 } 520 }
521 521
522 /** 522 /**
523 * Process all of the objects reachable from our roots via state that the 523 * Process all of the objects reachable from our roots via state that the
524 * serialization rules access. 524 * serialization rules access.
525 */ 525 */
526 traceAll() { 526 void traceAll() {
527 queue.addAll(roots); 527 queue.addAll(roots);
528 while (!queue.isEmpty) { 528 while (!queue.isEmpty) {
529 var next = queue.removeFirst(); 529 var next = queue.removeFirst();
530 if (!hasProcessed(next)) writer._process(next, this); 530 if (!hasProcessed(next)) writer._process(next, this);
531 } 531 }
532 } 532 }
533 533
534 /** 534 /**
535 * Has this object been seen yet? We test for this by checking if the 535 * Has this object been seen yet? We test for this by checking if the
536 * writer has a reference for it. See comment for _hasIndexFor. 536 * writer has a reference for it. See comment for _hasIndexFor.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 * for an example. It knows how to return its object and how to filter. 608 * for an example. It knows how to return its object and how to filter.
609 */ 609 */
610 class DesignatedRuleForObject { 610 class DesignatedRuleForObject {
611 final Function rulePredicate; 611 final Function rulePredicate;
612 final target; 612 final target;
613 613
614 DesignatedRuleForObject(this.target, this.rulePredicate); 614 DesignatedRuleForObject(this.target, this.rulePredicate);
615 615
616 List possibleRules(List rules) => rules.where(rulePredicate).toList(); 616 List possibleRules(List rules) => rules.where(rulePredicate).toList();
617 } 617 }
OLDNEW
« no previous file with comments | « no previous file | pkg/serialization/lib/src/serialization_rule.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698