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

Side by Side Diff: runtime/lib/string.dart

Issue 8383029: Implement external strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address final review comments Created 9 years, 1 month 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 | « runtime/include/dart_api.h ('k') | runtime/vm/class_finalizer.cc » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 * [StringBase] contains common methods used by concrete String implementations, 6 * [StringBase] contains common methods used by concrete String implementations,
7 * e.g., OneByteString. 7 * e.g., OneByteString.
8 */ 8 */
9 class StringBase { 9 class StringBase {
10 10
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 // Checks for one-byte whitespaces only. 413 // Checks for one-byte whitespaces only.
414 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid 414 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
415 // whitespaces. Add checking for multi-byte whitespace codepoints. 415 // whitespaces. Add checking for multi-byte whitespace codepoints.
416 bool _isWhitespace(int codePoint) { 416 bool _isWhitespace(int codePoint) {
417 return 417 return
418 (codePoint === 32) || // Space. 418 (codePoint === 32) || // Space.
419 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. 419 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
420 } 420 }
421 } 421 }
422 422
423
424 class ExternalOneByteString extends StringBase implements String {
425 // Checks for one-byte whitespaces only.
426 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
427 // whitespaces for one byte strings.
428 bool _isWhitespace(int codePoint) {
429 return
430 (codePoint === 32) || // Space.
431 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
432 }
433 }
434
435
436 class ExternalTwoByteString extends StringBase implements String {
437 // Checks for one-byte whitespaces only.
438 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
439 // whitespaces. Add checking for multi-byte whitespace codepoints.
440 bool _isWhitespace(int codePoint) {
441 return
442 (codePoint === 32) || // Space.
443 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
444 }
445 }
446
447
448 class ExternalFourByteString extends StringBase implements String {
449 // Checks for one-byte whitespaces only.
450 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
451 // whitespaces. Add checking for multi-byte whitespace codepoints.
452 bool _isWhitespace(int codePoint) {
453 return
454 (codePoint === 32) || // Space.
455 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
456 }
457 }
458
459
423 class _StringMatch implements Match { 460 class _StringMatch implements Match {
424 const _StringMatch(int this._start, 461 const _StringMatch(int this._start,
425 String this.str, 462 String this.str,
426 String this.pattern); 463 String this.pattern);
427 464
428 int start() => _start; 465 int start() => _start;
429 int end() => _start + pattern.length; 466 int end() => _start + pattern.length;
430 String operator[](int g) => group(g); 467 String operator[](int g) => group(g);
431 int groupCount() => 0; 468 int groupCount() => 0;
432 469
433 String group(int group) { 470 String group(int group) {
434 if (group != 0) { 471 if (group != 0) {
435 throw new IndexOutOfRangeException(group); 472 throw new IndexOutOfRangeException(group);
436 } 473 }
437 return pattern; 474 return pattern;
438 } 475 }
439 476
440 List<String> groups(List<int> groups) { 477 List<String> groups(List<int> groups) {
441 List<String> result = new List<String>(); 478 List<String> result = new List<String>();
442 for (int g in groups) { 479 for (int g in groups) {
443 result.add(group(g)); 480 result.add(group(g));
444 } 481 }
445 return result; 482 return result;
446 } 483 }
447 484
448 final int _start; 485 final int _start;
449 final String str; 486 final String str;
450 final String pattern; 487 final String pattern;
451 } 488 }
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/class_finalizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698