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

Side by Side Diff: sdk/lib/utf/utf16.dart

Issue 14022007: Move Iterable implementation to collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Merge to head. 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 | « sdk/lib/utf/utf.dart ('k') | sdk/lib/utf/utf32.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 dart.utf; 5 part of dart.utf;
6 6
7 /** 7 /**
8 * Decodes the UTF-16 bytes as an iterable. Thus, the consumer can only convert 8 * Decodes the UTF-16 bytes as an iterable. Thus, the consumer can only convert
9 * as much of the input as needed. Determines the byte order from the BOM, 9 * as much of the input as needed. Determines the byte order from the BOM,
10 * or uses big-endian as a default. This method always strips a leading BOM. 10 * or uses big-endian as a default. This method always strips a leading BOM.
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 typedef _ListRangeIterator _CodeUnitsProvider(); 184 typedef _ListRangeIterator _CodeUnitsProvider();
185 185
186 /** 186 /**
187 * Return type of [decodeUtf16AsIterable] and variants. The Iterable type 187 * Return type of [decodeUtf16AsIterable] and variants. The Iterable type
188 * provides an iterator on demand and the iterator will only translate bytes 188 * provides an iterator on demand and the iterator will only translate bytes
189 * as requested by the user of the iterator. (Note: results are not cached.) 189 * as requested by the user of the iterator. (Note: results are not cached.)
190 */ 190 */
191 // TODO(floitsch): Consider removing the extend and switch to implements since 191 // TODO(floitsch): Consider removing the extend and switch to implements since
192 // that's cheaper to allocate. 192 // that's cheaper to allocate.
193 class IterableUtf16Decoder extends Iterable<int> { 193 class IterableUtf16Decoder extends IterableBase<int> {
194 final _CodeUnitsProvider codeunitsProvider; 194 final _CodeUnitsProvider codeunitsProvider;
195 final int replacementCodepoint; 195 final int replacementCodepoint;
196 196
197 IterableUtf16Decoder._(this.codeunitsProvider, this.replacementCodepoint); 197 IterableUtf16Decoder._(this.codeunitsProvider, this.replacementCodepoint);
198 198
199 Utf16CodeUnitDecoder get iterator => 199 Utf16CodeUnitDecoder get iterator =>
200 new Utf16CodeUnitDecoder.fromListRangeIterator(codeunitsProvider(), 200 new Utf16CodeUnitDecoder.fromListRangeIterator(codeunitsProvider(),
201 replacementCodepoint); 201 replacementCodepoint);
202 } 202 }
203 203
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 328 }
329 329
330 int decode() { 330 int decode() {
331 utf16EncodedBytesIterator.moveNext(); 331 utf16EncodedBytesIterator.moveNext();
332 int lo = utf16EncodedBytesIterator.current; 332 int lo = utf16EncodedBytesIterator.current;
333 utf16EncodedBytesIterator.moveNext(); 333 utf16EncodedBytesIterator.moveNext();
334 int hi = utf16EncodedBytesIterator.current; 334 int hi = utf16EncodedBytesIterator.current;
335 return (hi << 8) + lo; 335 return (hi << 8) + lo;
336 } 336 }
337 } 337 }
OLDNEW
« no previous file with comments | « sdk/lib/utf/utf.dart ('k') | sdk/lib/utf/utf32.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698