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

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

Issue 11049036: Remove spurious types from constructor args that use "this." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Ready to review Created 8 years, 2 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 | 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 5
6 /** 6 /**
7 * Decodes the UTF-16 bytes as an iterable. Thus, the consumer can only convert 7 * Decodes the UTF-16 bytes as an iterable. Thus, the consumer can only convert
8 * as much of the input as needed. Determines the byte order from the BOM, 8 * as much of the input as needed. Determines the byte order from the BOM,
9 * or uses big-endian as a default. This method always strips a leading BOM. 9 * or uses big-endian as a default. This method always strips a leading BOM.
10 * Set the [replacementCodepoint] to null to throw an ArgumentError 10 * Set the [replacementCodepoint] to null to throw an ArgumentError
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 return _codepointsToUtf16CodeUnits(str.charCodes()); 207 return _codepointsToUtf16CodeUnits(str.charCodes());
208 } 208 }
209 } 209 }
210 210
211 /** 211 /**
212 * Return type of [decodeUtf16AsIterable] and variants. The Iterable type 212 * Return type of [decodeUtf16AsIterable] and variants. The Iterable type
213 * provides an iterator on demand and the iterator will only translate bytes 213 * provides an iterator on demand and the iterator will only translate bytes
214 * as requested by the user of the iterator. (Note: results are not cached.) 214 * as requested by the user of the iterator. (Note: results are not cached.)
215 */ 215 */
216 class IterableUtf16Decoder implements Iterable<int> { 216 class IterableUtf16Decoder implements Iterable<int> {
217 final Function codeunitsProvider; 217 final Function codeunitsProvider;
Siggi Cherem (dart-lang) 2012/10/04 00:09:11 I was thinking of maybe adding a typedef for this
Jacob 2012/10/04 00:44:10 Added a couple typedefs. The Utf16 and Utf32 case
218 final int replacementCodepoint; 218 final int replacementCodepoint;
219 219
220 IterableUtf16Decoder._(_ListRangeIterator this.codeunitsProvider(), 220 IterableUtf16Decoder._(this.codeunitsProvider, this.replacementCodepoint);
221 int this.replacementCodepoint);
222 221
223 Utf16CodeUnitDecoder iterator() => 222 Utf16CodeUnitDecoder iterator() =>
224 new Utf16CodeUnitDecoder.fromListRangeIterator(codeunitsProvider(), 223 new Utf16CodeUnitDecoder.fromListRangeIterator(codeunitsProvider(),
225 replacementCodepoint); 224 replacementCodepoint);
226 } 225 }
227 226
228 /** 227 /**
229 * Convert UTF-16 encoded bytes to UTF-16 code units by grouping 1-2 bytes 228 * Convert UTF-16 encoded bytes to UTF-16 code units by grouping 1-2 bytes
230 * to produce the code unit (0-(2^16)-1). Relies on BOM to determine 229 * to produce the code unit (0-(2^16)-1). Relies on BOM to determine
231 * endian-ness, and defaults to BE. 230 * endian-ness, and defaults to BE.
232 */ 231 */
233 class Utf16BytesToCodeUnitsDecoder implements _ListRangeIterator { 232 class Utf16BytesToCodeUnitsDecoder implements _ListRangeIterator {
234 final _ListRangeIterator utf16EncodedBytesIterator; 233 final _ListRangeIterator utf16EncodedBytesIterator;
235 final int replacementCodepoint; 234 final int replacementCodepoint;
236 235
237 Utf16BytesToCodeUnitsDecoder._fromListRangeIterator( 236 Utf16BytesToCodeUnitsDecoder._fromListRangeIterator(
238 _ListRangeIterator this.utf16EncodedBytesIterator, 237 this.utf16EncodedBytesIterator, this.replacementCodepoint);
239 int this.replacementCodepoint);
240 238
241 factory Utf16BytesToCodeUnitsDecoder(List<int> utf16EncodedBytes, [ 239 factory Utf16BytesToCodeUnitsDecoder(List<int> utf16EncodedBytes, [
242 int offset = 0, int length, 240 int offset = 0, int length,
243 int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) { 241 int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) {
244 if (length == null) { 242 if (length == null) {
245 length = utf16EncodedBytes.length - offset; 243 length = utf16EncodedBytes.length - offset;
246 } 244 }
247 if (hasUtf16beBom(utf16EncodedBytes, offset, length)) { 245 if (hasUtf16beBom(utf16EncodedBytes, offset, length)) {
248 return new Utf16beBytesToCodeUnitsDecoder(utf16EncodedBytes, offset + 2, 246 return new Utf16beBytesToCodeUnitsDecoder(utf16EncodedBytes, offset + 2,
249 length - 2, false, replacementCodepoint); 247 length - 2, false, replacementCodepoint);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 skip(); 341 skip();
344 } 342 }
345 } 343 }
346 344
347 int decode() { 345 int decode() {
348 int lo = utf16EncodedBytesIterator.next(); 346 int lo = utf16EncodedBytesIterator.next();
349 int hi = utf16EncodedBytesIterator.next(); 347 int hi = utf16EncodedBytesIterator.next();
350 return (hi << 8) + lo; 348 return (hi << 8) + lo;
351 } 349 }
352 } 350 }
OLDNEW
« no previous file with comments | « no previous file | lib/utf/utf32.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698