OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library utils; | 5 library utils; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:math' show min; | 9 import 'dart:math' show min; |
10 import 'dart:utf' as utf; | 10 import 'dart:convert'; |
11 | 11 |
12 part 'legacy_path.dart'; | 12 part 'legacy_path.dart'; |
13 | 13 |
14 class DebugLogger { | 14 class DebugLogger { |
15 static IOSink _sink; | 15 static IOSink _sink; |
16 | 16 |
17 /** | 17 /** |
18 * If [path] was null, the DebugLogger will write messages to stdout. | 18 * If [path] was null, the DebugLogger will write messages to stdout. |
19 */ | 19 */ |
20 static init(Path path, {append: false}) { | 20 static init(Path path, {append: false}) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 } | 111 } |
112 if (found) { | 112 if (found) { |
113 return i; | 113 return i; |
114 } | 114 } |
115 } | 115 } |
116 return -1; | 116 return -1; |
117 } | 117 } |
118 | 118 |
119 List<int> encodeUtf8(String string) { | 119 List<int> encodeUtf8(String string) { |
120 return utf.encodeUtf8(string); | 120 return UTF8.encode(string); |
121 } | 121 } |
122 | 122 |
123 // TODO(kustermann,ricow): As soon we have a debug log we should log | 123 // TODO(kustermann,ricow): As soon we have a debug log we should log |
124 // invalid utf8-encoded input to the log. | 124 // invalid utf8-encoded input to the log. |
125 // Currently invalid bytes will be replaced by a replacement character. | 125 // Currently invalid bytes will be replaced by a replacement character. |
126 String decodeUtf8(List<int> bytes) { | 126 String decodeUtf8(List<int> bytes) { |
127 return utf.decodeUtf8(bytes); | 127 return UTF8.decode(bytes, allowMalformed: true); |
128 } | 128 } |
129 | 129 |
130 class Locations { | 130 class Locations { |
131 static String getDartiumLocation(Map globalConfiguration) { | 131 static String getDartiumLocation(Map globalConfiguration) { |
132 var dartium = globalConfiguration['dartium']; | 132 var dartium = globalConfiguration['dartium']; |
133 if (dartium != null && dartium != '') { | 133 if (dartium != null && dartium != '') { |
134 return dartium; | 134 return dartium; |
135 } | 135 } |
136 if (Platform.operatingSystem == 'macos') { | 136 if (Platform.operatingSystem == 'macos') { |
137 return new Path('client/tests/dartium/Chromium.app/Contents/' | 137 return new Path('client/tests/dartium/Chromium.app/Contents/' |
(...skipping 24 matching lines...) Expand all Loading... |
162 | 162 |
163 class UniqueObject { | 163 class UniqueObject { |
164 static int _nextId = 1; | 164 static int _nextId = 1; |
165 final int _hashCode; | 165 final int _hashCode; |
166 | 166 |
167 int get hashCode => _hashCode; | 167 int get hashCode => _hashCode; |
168 operator==(other) => other is UniqueObject && _hashCode == other._hashCode; | 168 operator==(other) => other is UniqueObject && _hashCode == other._hashCode; |
169 | 169 |
170 UniqueObject() : _hashCode = ++_nextId; | 170 UniqueObject() : _hashCode = ++_nextId; |
171 } | 171 } |
OLD | NEW |