| 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 class _Platform { | 7 class _Platform { |
| 8 external static int _numberOfProcessors(); | 8 external static int _numberOfProcessors(); |
| 9 external static String _pathSeparator(); | 9 external static String _pathSeparator(); |
| 10 external static String _operatingSystem(); | 10 external static String _operatingSystem(); |
| 11 external static _localHostname(); | 11 external static _localHostname(); |
| 12 external static _executable(); | 12 external static _executable(); |
| 13 external static _environment(); | 13 external static _environment(); |
| 14 external static List<String> _executableArguments(); | 14 external static List<String> _executableArguments(); |
| 15 external static String _packageRoot(); | 15 external static String _packageRoot(); |
| 16 external static String _version(); | 16 external static String _version(); |
| 17 | 17 |
| 18 static String executable = _executable(); | 18 static String executable = _executable(); |
| 19 static String packageRoot = _packageRoot(); | 19 static String packageRoot = _packageRoot(); |
| 20 | 20 |
| 21 // Cache the OS environemnt. This can be an OSError instance if | 21 // Cache the OS environemnt. This can be an OSError instance if |
| 22 // retrieving the environment failed. | 22 // retrieving the environment failed. |
| 23 static var _environmentCache; | 23 static var _environmentCache; |
| 24 | 24 |
| 25 static int get numberOfProcessors => _numberOfProcessors(); | 25 static int get numberOfProcessors => _numberOfProcessors(); |
| 26 static String get pathSeparator => _pathSeparator(); | 26 static String get pathSeparator => _pathSeparator(); |
| 27 static String get operatingSystem => _operatingSystem(); | 27 static String get operatingSystem => _operatingSystem(); |
| 28 static Uri script = _script(); | 28 static Uri script; |
| 29 static Uri _script() { | 29 |
| 30 // The embedder (Dart executable) creates the Platform._nativeScript field. | 30 // This script singleton is written to by the embedder if applicable. |
| 31 var s = Platform._nativeScript; | 31 static String set _nativeScript(String path) { |
| 32 if (s.startsWith('http:') || | 32 if (path.startsWith('http:') || |
| 33 s.startsWith('https:') || | 33 path.startsWith('https:') || |
| 34 s.startsWith('file:')) { | 34 path.startsWith('file:')) { |
| 35 return Uri.parse(s); | 35 script = Uri.parse(path); |
| 36 } else { | 36 } else { |
| 37 return Uri.base.resolveUri(new Uri.file(s)); | 37 script = Uri.base.resolveUri(new Uri.file(path)); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 static String get localHostname { | 41 static String get localHostname { |
| 42 var result = _localHostname(); | 42 var result = _localHostname(); |
| 43 if (result is OSError) { | 43 if (result is OSError) { |
| 44 throw result; | 44 throw result; |
| 45 } else { | 45 } else { |
| 46 return result; | 46 return result; |
| 47 } | 47 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 V remove(String key) => _map.remove(key.toUpperCase()); | 107 V remove(String key) => _map.remove(key.toUpperCase()); |
| 108 void clear() => _map.clear(); | 108 void clear() => _map.clear(); |
| 109 void forEach(void f(String key, V value)) => _map.forEach(f); | 109 void forEach(void f(String key, V value)) => _map.forEach(f); |
| 110 Iterable<String> get keys => _map.keys; | 110 Iterable<String> get keys => _map.keys; |
| 111 Iterable<V> get values => _map.values; | 111 Iterable<V> get values => _map.values; |
| 112 int get length => _map.length; | 112 int get length => _map.length; |
| 113 bool get isEmpty => _map.isEmpty; | 113 bool get isEmpty => _map.isEmpty; |
| 114 bool get isNotEmpty => _map.isNotEmpty; | 114 bool get isNotEmpty => _map.isNotEmpty; |
| 115 String toString() => _map.toString(); | 115 String toString() => _map.toString(); |
| 116 } | 116 } |
| OLD | NEW |