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

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

Issue 12296011: Version 0.3.7.4 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 10 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 | « dart/pkg/http/lib/src/byte_stream.dart ('k') | dart/runtime/lib/array.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 part of serialization; 1 part of serialization;
2 2
3 /** 3 /**
4 * An abstract class for serialization formats. Subclasses define how data 4 * An abstract class for serialization formats. Subclasses define how data
5 * is read or written to a particular output mechanism. 5 * is read or written to a particular output mechanism.
6 */ 6 */
7 abstract class Format { 7 abstract class Format {
8 /** 8 /**
9 * Return true if this format stores primitives in their own area and uses 9 * Return true if this format stores primitives in their own area and uses
10 * references to them (e.g. [SimpleFlatFormat]) and false if primitives 10 * references to them (e.g. [SimpleFlatFormat]) and false if primitives
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 result[r._primitiveRule().number].add(data); 203 result[r._primitiveRule().number].add(data);
204 return data; 204 return data;
205 } 205 }
206 var ruleNumber; 206 var ruleNumber;
207 // If we've added the rule number on as the last item in a list we have 207 // If we've added the rule number on as the last item in a list we have
208 // to get rid of it or it will be interpreted as extra data. For a map 208 // to get rid of it or it will be interpreted as extra data. For a map
209 // the library will be ok, but we need to get rid of the extra key before 209 // the library will be ok, but we need to get rid of the extra key before
210 // the data is shown to the user, so we destructively modify. 210 // the data is shown to the user, so we destructively modify.
211 if (data is List) { 211 if (data is List) {
212 ruleNumber = data.last; 212 ruleNumber = data.last;
213 data = data.take(data.length -1); 213 data = data.take(data.length - 1).toList();
214 } else if (data is Map) { 214 } else if (data is Map) {
215 ruleNumber = data.remove(RULE); 215 ruleNumber = data.remove(RULE);
216 } else { 216 } else {
217 throw new SerializationException("Invalid data format"); 217 throw new SerializationException("Invalid data format");
218 } 218 }
219 // Do not use mappedBy or other lazy operations for this. They do not play 219 // Do not use map or other lazy operations for this. They do not play
220 // well with a function that destructively modifies its arguments. 220 // well with a function that destructively modifies its arguments.
221 var newData = mapValues(data, (each) => recursivelyFixUp(each, r, result)); 221 var newData = mapValues(data, (each) => recursivelyFixUp(each, r, result));
222 result[ruleNumber].add(newData); 222 result[ruleNumber].add(newData);
223 return new Reference(r, ruleNumber, result[ruleNumber].length - 1); 223 return new Reference(r, ruleNumber, result[ruleNumber].length - 1);
224 } 224 }
225 } 225 }
226 226
227 /** 227 /**
228 * Writes to a simple mostly-flat format. Details are subject to change. 228 * Writes to a simple mostly-flat format. Details are subject to change.
229 * Right now this produces a List containing null, num, and String. This is 229 * Right now this produces a List containing null, num, and String. This is
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 return new Reference(r, a, b); 462 return new Reference(r, a, b);
463 } 463 }
464 } 464 }
465 465
466 /** Return the next element from the input. */ 466 /** Return the next element from the input. */
467 _next(Iterator input) { 467 _next(Iterator input) {
468 input.moveNext(); 468 input.moveNext();
469 return input.current; 469 return input.current;
470 } 470 }
471 } 471 }
OLDNEW
« no previous file with comments | « dart/pkg/http/lib/src/byte_stream.dart ('k') | dart/runtime/lib/array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698