Chromium Code Reviews| Index: lib/core/core_patch.dart |
| diff --git a/lib/core/core_patch.dart b/lib/core/core_patch.dart |
| index e9bd06128e0971b90600888de29a19ef38858147..a5905caf26b85b8b2ab836f6230ede6a3a936704 100644 |
| --- a/lib/core/core_patch.dart |
| +++ b/lib/core/core_patch.dart |
| @@ -5,6 +5,8 @@ |
| library dart.core_patch; |
| import 'dart:fletch._system' as fletch; |
| +import 'dart:fletch._system' show patch; |
| +import 'dart:collection' show LinkedHashMap, UnmodifiableMapView; |
| part 'bigint.dart'; |
| part 'case.dart'; |
| @@ -13,8 +15,6 @@ part 'int.dart'; |
| part 'regexp.dart'; |
| part 'string.dart'; |
| -const patch = "patch"; |
| - |
| @patch external bool identical(Object a, Object b); |
| @patch int identityHashCode(Object object) { |
| @@ -236,6 +236,18 @@ const patch = "patch"; |
| } |
| return list; |
| } |
| + |
| + @patch factory List.unmodifiable(Iterable elements) { |
| + return new UnmodifiableListView(new List.from(elements)); |
| + } |
| +} |
| + |
| +@patch class Map<K, V> { |
| + @patch factory Map() = LinkedHashMap<K, V>; |
| + |
| + @patch factory Map.unmodifiable(Map other) { |
| + return new UnmodifiableMapView<K, V>(new Map<K, V>.from(other)); |
| + } |
| } |
| @patch class NoSuchMethodError { |
| @@ -658,4 +670,34 @@ const patch = "patch"; |
| @fletch.native static String _base() { |
| throw new RangeError("The Uri.base path is too large"); |
| } |
| + |
| + @patch static String _uriEncode( |
|
ahe
2015/11/17 16:44:08
Where is this code from? Is it a copy of something
sigurdm
2015/11/19 14:33:46
This is the version that was in lib/core/uri.dart
|
| + List<int> canonicalTable, |
| + String text, |
| + Encoding encoding, |
| + bool spaceToPlus) { |
| + byteToHex(byte, buffer) { |
| + const String hex = '0123456789ABCDEF'; |
| + buffer.writeCharCode(hex.codeUnitAt(byte >> 4)); |
| + buffer.writeCharCode(hex.codeUnitAt(byte & 0x0f)); |
| + } |
| + |
| + // Encode the string into bytes then generate an ASCII only string |
| + // by percent encoding selected bytes. |
| + StringBuffer result = new StringBuffer(); |
| + var bytes = encoding.encode(text); |
| + for (int i = 0; i < bytes.length; i++) { |
| + int byte = bytes[i]; |
| + if (byte < 128 && |
| + ((canonicalTable[byte >> 4] & (1 << (byte & 0x0f))) != 0)) { |
| + result.writeCharCode(byte); |
| + } else if (spaceToPlus && byte == _SPACE) { |
| + result.writeCharCode(_PLUS); |
| + } else { |
| + result.writeCharCode(_PERCENT); |
| + byteToHex(byte, result); |
| + } |
| + } |
| + return result.toString(); |
| + } |
| } |