Chromium Code Reviews| Index: sdk/lib/platform/platform.dart |
| diff --git a/sdk/lib/platform/platform.dart b/sdk/lib/platform/platform.dart |
| index 0ef0a572eed98bca60c9b1a1c3947e6a2b36cf6e..df580dae64c930610db5be70bd37bfce5665eb1c 100644 |
| --- a/sdk/lib/platform/platform.dart |
| +++ b/sdk/lib/platform/platform.dart |
| @@ -6,3 +6,124 @@ |
| * Runtime information about the current platform. |
| */ |
| library dart.platform; |
| + |
| +class _Platform { |
|
ahe
2013/10/24 15:38:16
This API does not make sense for dart2js.
Bill Hesse
2013/10/25 11:06:34
I think we would add fields that report important
|
| + int get numberOfProcessors; |
| + String get pathSeparator; |
| + String get operatingSystem; |
| + String get localHostname; |
| + String get version; |
| + Map get environment; |
| + String get script; |
| + String get executable; |
| + List<String> get executableArguments; |
| + String get packageRoot; |
| +} |
| + |
| +// The _Platform object from the patch file, or set by the embedder, |
| +// that fetches the platform information. |
| +_Platform get _platform => _PatchWorkaround._platform; |
| + |
| +// Issue 6997: Patching top-level statics has a problem. |
|
floitsch
2013/10/24 15:50:58
TODO(6997): ...
Bill Hesse
2013/10/25 11:06:34
Done.
|
| +class _PatchWorkaround { |
| + external static _Platform get _platform; |
| +} |
| + |
| +/** |
| + * Get the number of processors of the machine. |
|
floitsch
2013/10/24 15:50:58
"Gets" or simply "The number of ...".
Ditto for a
Bill Hesse
2013/10/25 11:06:34
Done.
|
| + * Returns null if no information is available. |
|
floitsch
2013/10/24 15:50:58
New line before the "Returns".
|
| + */ |
| +final int numberOfProcessors = _platform.numberOfProcessors; |
|
ahe
2013/10/24 15:38:16
This generates rather horrible code in dart2js.
W
Bill Hesse
2013/10/25 11:06:34
All of them changed to
external String get foo, a
|
| + |
| +/** |
| + * Get the path separator used by the operating system to separate |
| + * components in file paths. |
| + */ |
| +final String pathSeparator = _platform.pathSeparator; |
| + |
| + |
| +/** |
| + * Get a string (`linux`, `macos`, `windows` or `android` |
|
floitsch
2013/10/24 15:50:58
missing closing parenthesis.
Bill Hesse
2013/10/25 11:06:34
Done.
|
| + * representing the operating system. Returns null if not supported. |
|
Anders Johnsen
2013/10/24 17:21:01
Maybe change to
Returns `null` if the operating
Bill Hesse
2013/10/25 11:06:34
Done.
|
| + */ |
| +final String operatingSystem = _platform.operatingSystem; |
| + |
| +/** |
| + * Get the local hostname for the system. Returns null if not supported. |
| + */ |
| +final String localHostname = _platform.localHostname; |
| + |
| +/** |
| + * Returns the version of the current Dart runtime. |
| + * Returns null if not supported. |
| + */ |
| +final String version = _platform.version; |
| + |
| +/** |
| + * Returns true if the operating system is Linux. |
| + */ |
| +bool get isLinux => operatingSystem == "linux"; |
| + |
| +/** |
| + * Returns true if the operating system is Mac OS. |
| + */ |
| +bool get isMacOS => operatingSystem == "macos"; |
| + |
| +/** |
| + * Returns true if the operating system is Windows. |
| + */ |
| +bool get isWindows => operatingSystem == "windows"; |
| + |
| +/** |
| + * Returns true if the operating system is Android. |
| + */ |
| +bool get isAndroid => operatingSystem == "android"; |
| + |
| +/** |
| + * Get the environment for this process. |
| + * |
| + * Environment variables on Windows are case-insensitive. The map |
| + * returned on Windows is therefore case-insensitive and will convert |
|
floitsch
2013/10/24 15:50:58
converts (no need for future)
Bill Hesse
2013/10/25 11:06:34
Done.
|
| + * all keys to upper case. On other platforms the returned map is |
| + * a standard case-sensitive map. |
| + * Returns null if not supported. |
| + */ |
| +final Map<String, String> environment = _platform.environment; |
| + |
| +/** |
| + * Returns the path of the executable used to run the script in this |
| + * isolate. |
| + * |
| + * Returns null if the execution environment does not support [executable]. |
| + */ |
| +final String executable = _platform.executable; |
| + |
| +/** |
| + * Returns the URI (in String form of the script being run in this |
|
floitsch
2013/10/24 15:50:58
missing closing parenthesis.
Bill Hesse
2013/10/25 11:06:34
Done.
|
| + * isolate. If the URI is relative it is relative to the file URI of |
| + * the working directory of the VM when it was started. |
| + * |
| + * Returns null if the executable environment does not support [script]. |
| + */ |
| +final String script = _platform.script; |
| + |
| +/** |
| + * Returns the flags passed to the executable used to run the script in this |
| + * isolate. These are the command-line flags between the executable name |
| + * and the script name. Each fetch of [executableArguments] returns a new |
|
floitsch
2013/10/24 15:50:58
Don't overspecify. No need to specify that the res
Bill Hesse
2013/10/25 11:06:34
Done.
|
| + * List, containing the flags passed to the executable. |
| + * |
| + * Returns the empty list if [executableArguments] is not supported. |
| + */ |
| +final List<String> executableArguments = _platform.executableArguments; |
| + |
| +/** |
| + * Returns the value of the --package-root flag passed to the executable |
| + * used to run the script in this isolate. This is the directory in which |
| + * Dart packages are looked up. |
| + * |
| + * If there is no --package-root flag, then the empty string is returned. |
| + * |
| + * Returns null if not supported. |
| + */ |
| +final String packageRoot = _platform.packageRoot; |