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

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

Issue 2230383003: Implement @patch annotation for patch class members (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: wip Created 4 years, 4 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
« no previous file with comments | « runtime/lib/string_buffer_patch.dart ('k') | runtime/lib/symbol_patch.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 const int _maxAscii = 0x7f; 5 const int _maxAscii = 0x7f;
6 const int _maxLatin1 = 0xff; 6 const int _maxLatin1 = 0xff;
7 const int _maxUtf16 = 0xffff; 7 const int _maxUtf16 = 0xffff;
8 const int _maxUnicode = 0x10ffff; 8 const int _maxUnicode = 0x10ffff;
9 9
10 @patch class String { 10 @patch class String {
11 /* @patch */ factory String.fromCharCodes(Iterable<int> charCodes, 11 @patch factory String.fromCharCodes(Iterable<int> charCodes,
12 [int start = 0, int end]) { 12 [int start = 0, int end]) {
13 if (charCodes is! Iterable) throw new ArgumentError.value(charCodes, "charCo des"); 13 if (charCodes is! Iterable) throw new ArgumentError.value(charCodes, "charCo des");
14 if (start is! int) throw new ArgumentError.value(start, "start"); 14 if (start is! int) throw new ArgumentError.value(start, "start");
15 if (end != null && end is! int) throw new ArgumentError.value(end, "end"); 15 if (end != null && end is! int) throw new ArgumentError.value(end, "end");
16 return _StringBase.createFromCharCodes(charCodes, start, end, null); 16 return _StringBase.createFromCharCodes(charCodes, start, end, null);
17 } 17 }
18 18
19 /* @patch */ factory String.fromCharCode(int charCode) { 19 @patch factory String.fromCharCode(int charCode) {
20 if (charCode >= 0) { 20 if (charCode >= 0) {
21 if (charCode <= 0xff) { 21 if (charCode <= 0xff) {
22 return _OneByteString._allocate(1).._setAt(0, charCode); 22 return _OneByteString._allocate(1).._setAt(0, charCode);
23 } 23 }
24 if (charCode <= 0xffff) { 24 if (charCode <= 0xffff) {
25 return _StringBase._createFromCodePoints(new _List(1)..[0] = charCode, 25 return _StringBase._createFromCodePoints(new _List(1)..[0] = charCode,
26 0, 1); 26 0, 1);
27 } 27 }
28 if (charCode <= 0x10ffff) { 28 if (charCode <= 0x10ffff) {
29 var low = 0xDC00 | (charCode & 0x3ff); 29 var low = 0xDC00 | (charCode & 0x3ff);
30 int bits = charCode - 0x10000; 30 int bits = charCode - 0x10000;
31 var high = 0xD800 | (bits >> 10); 31 var high = 0xD800 | (bits >> 10);
32 return _StringBase._createFromCodePoints(new _List(2)..[0] = high 32 return _StringBase._createFromCodePoints(new _List(2)..[0] = high
33 ..[1] = low, 33 ..[1] = low,
34 0, 2); 34 0, 2);
35 } 35 }
36 } 36 }
37 throw new RangeError.range(charCode, 0, 0x10ffff); 37 throw new RangeError.range(charCode, 0, 0x10ffff);
38 } 38 }
39 39
40 /* @patch */ const factory String.fromEnvironment(String name, 40 @patch const factory String.fromEnvironment(String name,
41 {String defaultValue}) 41 {String defaultValue})
42 native "String_fromEnvironment"; 42 native "String_fromEnvironment";
43 } 43 }
44 44
45 45
46 /** 46 /**
47 * [_StringBase] contains common methods used by concrete String 47 * [_StringBase] contains common methods used by concrete String
48 * implementations, e.g., _OneByteString. 48 * implementations, e.g., _OneByteString.
49 */ 49 */
50 abstract class _StringBase { 50 abstract class _StringBase {
51 // Constants used by replaceAll encoding of string slices between matches. 51 // Constants used by replaceAll encoding of string slices between matches.
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 int end = index + _pattern.length; 1359 int end = index + _pattern.length;
1360 _current = new _StringMatch(index, _input, _pattern); 1360 _current = new _StringMatch(index, _input, _pattern);
1361 // Empty match, don't start at same location again. 1361 // Empty match, don't start at same location again.
1362 if (end == _index) end++; 1362 if (end == _index) end++;
1363 _index = end; 1363 _index = end;
1364 return true; 1364 return true;
1365 } 1365 }
1366 1366
1367 Match get current => _current; 1367 Match get current => _current;
1368 } 1368 }
OLDNEW
« no previous file with comments | « runtime/lib/string_buffer_patch.dart ('k') | runtime/lib/symbol_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698