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

Side by Side Diff: sdk/lib/platform/platform.dart

Issue 36883005: Add fields to platform library, implement them on runtime dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comments. Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
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 /** 5 /**
6 * Runtime information about the current platform. 6 * Runtime information about the current platform.
7 */ 7 */
8 library dart.platform; 8 library dart.platform;
9
10 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
11 int get numberOfProcessors;
12 String get pathSeparator;
13 String get operatingSystem;
14 String get localHostname;
15 String get version;
16 Map get environment;
17 String get script;
18 String get executable;
19 List<String> get executableArguments;
20 String get packageRoot;
21 }
22
23 // The _Platform object from the patch file, or set by the embedder,
24 // that fetches the platform information.
25 _Platform get _platform => _PatchWorkaround._platform;
26
27 // 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.
28 class _PatchWorkaround {
29 external static _Platform get _platform;
30 }
31
32 /**
33 * 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.
34 * Returns null if no information is available.
floitsch 2013/10/24 15:50:58 New line before the "Returns".
35 */
36 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
37
38 /**
39 * Get the path separator used by the operating system to separate
40 * components in file paths.
41 */
42 final String pathSeparator = _platform.pathSeparator;
43
44
45 /**
46 * 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.
47 * 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.
48 */
49 final String operatingSystem = _platform.operatingSystem;
50
51 /**
52 * Get the local hostname for the system. Returns null if not supported.
53 */
54 final String localHostname = _platform.localHostname;
55
56 /**
57 * Returns the version of the current Dart runtime.
58 * Returns null if not supported.
59 */
60 final String version = _platform.version;
61
62 /**
63 * Returns true if the operating system is Linux.
64 */
65 bool get isLinux => operatingSystem == "linux";
66
67 /**
68 * Returns true if the operating system is Mac OS.
69 */
70 bool get isMacOS => operatingSystem == "macos";
71
72 /**
73 * Returns true if the operating system is Windows.
74 */
75 bool get isWindows => operatingSystem == "windows";
76
77 /**
78 * Returns true if the operating system is Android.
79 */
80 bool get isAndroid => operatingSystem == "android";
81
82 /**
83 * Get the environment for this process.
84 *
85 * Environment variables on Windows are case-insensitive. The map
86 * 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.
87 * all keys to upper case. On other platforms the returned map is
88 * a standard case-sensitive map.
89 * Returns null if not supported.
90 */
91 final Map<String, String> environment = _platform.environment;
92
93 /**
94 * Returns the path of the executable used to run the script in this
95 * isolate.
96 *
97 * Returns null if the execution environment does not support [executable].
98 */
99 final String executable = _platform.executable;
100
101 /**
102 * 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.
103 * isolate. If the URI is relative it is relative to the file URI of
104 * the working directory of the VM when it was started.
105 *
106 * Returns null if the executable environment does not support [script].
107 */
108 final String script = _platform.script;
109
110 /**
111 * Returns the flags passed to the executable used to run the script in this
112 * isolate. These are the command-line flags between the executable name
113 * 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.
114 * List, containing the flags passed to the executable.
115 *
116 * Returns the empty list if [executableArguments] is not supported.
117 */
118 final List<String> executableArguments = _platform.executableArguments;
119
120 /**
121 * Returns the value of the --package-root flag passed to the executable
122 * used to run the script in this isolate. This is the directory in which
123 * Dart packages are looked up.
124 *
125 * If there is no --package-root flag, then the empty string is returned.
126 *
127 * Returns null if not supported.
128 */
129 final String packageRoot = _platform.packageRoot;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698