Chromium Code Reviews| 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 patch class String { | 5 patch class String { |
| 6 /* patch */ factory String.fromCharCodes(Iterable<int> charCodes) { | 6 /* patch */ factory String.fromCharCodes(Iterable<int> charCodes) { |
| 7 return _StringBase.createFromCharCodes(charCodes); | 7 return _StringBase.createFromCharCodes(charCodes); |
| 8 } | 8 } |
| 9 | 9 |
| 10 /* patch */ factory String.fromCharCode(int charCode) { | |
| 11 if (charCode >= 0) { | |
| 12 if (charCode <= 0xff) { | |
| 13 return _OneByteString._allocate(1).._setAt(0, charCode); | |
| 14 } | |
| 15 if (charCode <= 0xffff) { | |
|
Lasse Reichstein Nielsen
2014/03/26 09:59:59
What should I do to get _TwoByteString._allocate t
Søren Gjesse
2014/03/26 10:10:33
I think you can just add to to string.cc and send
| |
| 16 return _StringBase._createFromCodePoints([charCode]); | |
| 17 } | |
| 18 if (charCode <= 0x10ffff) { | |
| 19 var low = 0xDC00 | (charCode & 0x3ff); | |
| 20 int bits = charCode - 0x10000; | |
| 21 var high = 0xD800 | (bits >> 10); | |
| 22 return _StringBase._createFromCodePoints([high, low]); | |
| 23 } | |
| 24 } | |
| 25 throw new RangeError.range(charCode, 0, 0x10ffff); | |
| 26 } | |
| 27 | |
| 10 /* patch */ const factory String.fromEnvironment(String name, | 28 /* patch */ const factory String.fromEnvironment(String name, |
| 11 {String defaultValue}) | 29 {String defaultValue}) |
| 12 native "String_fromEnvironment"; | 30 native "String_fromEnvironment"; |
| 13 } | 31 } |
| 14 | 32 |
| 15 | 33 |
| 16 /** | 34 /** |
| 17 * [_StringBase] contains common methods used by concrete String | 35 * [_StringBase] contains common methods used by concrete String |
| 18 * implementations, e.g., _OneByteString. | 36 * implementations, e.g., _OneByteString. |
| 19 */ | 37 */ |
| (...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 943 class _CodeUnits extends Object with ListMixin<int>, | 961 class _CodeUnits extends Object with ListMixin<int>, |
| 944 UnmodifiableListMixin<int> { | 962 UnmodifiableListMixin<int> { |
| 945 /** The string that this is the code units of. */ | 963 /** The string that this is the code units of. */ |
| 946 String _string; | 964 String _string; |
| 947 | 965 |
| 948 _CodeUnits(this._string); | 966 _CodeUnits(this._string); |
| 949 | 967 |
| 950 int get length => _string.length; | 968 int get length => _string.length; |
| 951 int operator[](int i) => _string.codeUnitAt(i); | 969 int operator[](int i) => _string.codeUnitAt(i); |
| 952 } | 970 } |
| OLD | NEW |