OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 part of dart.io; | |
6 | |
7 @deprecated | |
8 /** | |
9 * Deprecated: the Options object allows accessing the arguments which | |
10 * have been passed to the current isolate. | |
11 * | |
12 * This class has been replaced by making the arguments an optional parameter | |
13 * to main. The other members, executable, script, and versione, are already | |
14 * available on Platform (which will move to the dart:plaform library). | |
15 * | |
16 * This class will be removed on October 28, 2013. | |
17 */ | |
18 abstract class Options { | |
19 /** | |
20 * A newly constructed Options object contains the arguments exactly as they | |
21 * have been passed to the isolate. | |
22 */ | |
23 factory Options() => new _OptionsImpl(); | |
24 | |
25 /** | |
26 * Returns a list of arguments that have been passed to this isolate. Any | |
27 * modifications to the list will be contained to the options object owning | |
28 * this list. | |
29 * | |
30 * If the execution environment does not support [arguments] an empty list | |
31 * is returned. | |
32 */ | |
33 List<String> get arguments; | |
34 | |
35 /** | |
36 * Returns the path of the executable used to run the script in this | |
37 * isolate. | |
38 * | |
39 * If the execution environment does not support [executable] an empty | |
40 * string is returned. | |
41 */ | |
42 String get executable; | |
43 | |
44 /** | |
45 * Returns the path of the script being run in this isolate. | |
46 * | |
47 * If the executable environment does not support [script] an empty | |
48 * string is returned. | |
49 */ | |
50 String get script; | |
51 | |
52 | |
53 /** | |
54 * Returns the version of the current Dart runtime. | |
55 */ | |
56 String get version; | |
57 } | |
58 | |
59 class _OptionsImpl implements Options { | |
60 List<String> _arguments = null; | |
61 | |
62 // This arguments singleton is written to by the embedder if applicable. | |
63 static List<String> _nativeArguments = const []; | |
64 | |
65 List<String> get arguments { | |
66 if (_arguments == null) { | |
67 // On first access make a copy of the native arguments. | |
68 _arguments = _nativeArguments.sublist(0, _nativeArguments.length); | |
69 } | |
70 return _arguments; | |
71 } | |
72 | |
73 String get executable => Platform.executable; | |
74 String get script => Platform.script; | |
75 String get version => Platform.version; | |
76 } | |
OLD | NEW |