| OLD | NEW |
| 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 * [_StringBase] contains common methods used by concrete String | 6 * [_StringBase] contains common methods used by concrete String |
| 7 * implementations, e.g., _OneByteString. | 7 * implementations, e.g., _OneByteString. |
| 8 */ | 8 */ |
| 9 class _StringBase { | 9 class _StringBase { |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 return _createFromCodePoints(objectArray); | 33 return _createFromCodePoints(objectArray); |
| 34 } | 34 } |
| 35 | 35 |
| 36 static String _createFromCodePoints(List<int> codePoints) | 36 static String _createFromCodePoints(List<int> codePoints) |
| 37 native "StringBase_createFromCodePoints"; | 37 native "StringBase_createFromCodePoints"; |
| 38 | 38 |
| 39 String operator [](int index) native "String_charAt"; | 39 String operator [](int index) native "String_charAt"; |
| 40 | 40 |
| 41 int charCodeAt(int index) { | 41 int charCodeAt(int index) native "String_charCodeAt"; |
| 42 return codeUnitAt(index); | |
| 43 } | |
| 44 | |
| 45 int codeUnitAt(int index) native "String_charCodeAt"; | |
| 46 | 42 |
| 47 int get length native "String_getLength"; | 43 int get length native "String_getLength"; |
| 48 | 44 |
| 49 bool get isEmpty { | 45 bool get isEmpty { |
| 50 return this.length == 0; | 46 return this.length == 0; |
| 51 } | 47 } |
| 52 | 48 |
| 53 String concat(String other) native "String_concat"; | 49 String concat(String other) native "String_concat"; |
| 54 | 50 |
| 55 String toString() { | 51 String toString() { |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 422 |
| 427 List<int> get charCodes { | 423 List<int> get charCodes { |
| 428 int len = this.length; | 424 int len = this.length; |
| 429 final result = new List<int>.fixedLength(len); | 425 final result = new List<int>.fixedLength(len); |
| 430 for (int i = 0; i < len; i++) { | 426 for (int i = 0; i < len; i++) { |
| 431 result[i] = this.charCodeAt(i); | 427 result[i] = this.charCodeAt(i); |
| 432 } | 428 } |
| 433 return result; | 429 return result; |
| 434 } | 430 } |
| 435 | 431 |
| 436 Iterable<int> get codeUnits { | |
| 437 throw new UnimplementedError("String.codeUnits"); | |
| 438 } | |
| 439 | |
| 440 Iterable<int> get runes { | |
| 441 throw new UnimplementedError("String.runes"); | |
| 442 } | |
| 443 | |
| 444 String toUpperCase() native "String_toUpperCase"; | 432 String toUpperCase() native "String_toUpperCase"; |
| 445 | 433 |
| 446 String toLowerCase() native "String_toLowerCase"; | 434 String toLowerCase() native "String_toLowerCase"; |
| 447 | 435 |
| 448 // Implementations of Strings methods follow below. | 436 // Implementations of Strings methods follow below. |
| 449 static String join(Iterable<String> strings, String separator) { | 437 static String join(Iterable<String> strings, String separator) { |
| 450 bool first = true; | 438 bool first = true; |
| 451 List<String> stringsList = <String>[]; | 439 List<String> stringsList = <String>[]; |
| 452 for (String string in strings) { | 440 for (String string in strings) { |
| 453 if (first) { | 441 if (first) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 for (int g in groups) { | 612 for (int g in groups) { |
| 625 result.add(group(g)); | 613 result.add(group(g)); |
| 626 } | 614 } |
| 627 return result; | 615 return result; |
| 628 } | 616 } |
| 629 | 617 |
| 630 final int start; | 618 final int start; |
| 631 final String str; | 619 final String str; |
| 632 final String pattern; | 620 final String pattern; |
| 633 } | 621 } |
| OLD | NEW |