Mercurial > projects > dstep
comparison dstep/foundation/NSTask.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 19885b43130e |
comparison
equal
deleted
inserted
replaced
13:4f583f7e242e | 14:89f3c3ef1fd2 |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSTask; | |
8 | |
9 import dstep.foundation.NSArray; | |
10 import dstep.foundation.NSDictionary; | |
11 import dstep.foundation.NSObject; | |
12 import dstep.foundation.NSString; | |
13 import dstep.objc.bridge.Bridge; | |
14 import dstep.objc.objc : id; | |
15 | |
16 import bindings = dstep.foundation.NSTask_bindings; | |
17 | |
18 const NSString NSTaskDidTerminateNotification; | |
19 | |
20 static this () | |
21 { | |
22 NSTaskDidTerminateNotification = new NSString(bindings.NSTaskDidTerminateNotification); | |
23 } | |
24 | |
25 class NSTask : NSObject | |
26 { | |
27 mixin ObjcWrap; | |
28 mixin TNSTaskConveniences; | |
29 | |
30 Object init () | |
31 { | |
32 return invokeObjcSelf!(Object, "init"); | |
33 } | |
34 | |
35 this () | |
36 { | |
37 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
38 id result = Bridge.invokeObjcMethod!(id, "init")(objcObject); | |
39 | |
40 if (result) | |
41 objcObject = ret; | |
42 | |
43 dObject = this; | |
44 } | |
45 | |
46 void setLaunchPath (NSString path) | |
47 { | |
48 return invokeObjcSelf!(void, "setLaunchPath:", NSString)(path); | |
49 } | |
50 | |
51 void setArguments (NSArray arguments) | |
52 { | |
53 return invokeObjcSelf!(void, "setArguments:", NSArray)(arguments); | |
54 } | |
55 | |
56 void setEnvironment (NSDictionary dict) | |
57 { | |
58 return invokeObjcSelf!(void, "setEnvironment:", NSDictionary)(dict); | |
59 } | |
60 | |
61 void setCurrentDirectoryPath (NSString path) | |
62 { | |
63 return invokeObjcSelf!(void, "setCurrentDirectoryPath:", NSString)(path); | |
64 } | |
65 | |
66 void setStandardInput (Object input) | |
67 { | |
68 return invokeObjcSelf!(void, "setStandardInput:", Object)(input); | |
69 } | |
70 | |
71 void setStandardOutput (Object output) | |
72 { | |
73 return invokeObjcSelf!(void, "setStandardOutput:", Object)(output); | |
74 } | |
75 | |
76 void setStandardError (Object error) | |
77 { | |
78 return invokeObjcSelf!(void, "setStandardError:", Object)(error); | |
79 } | |
80 | |
81 NSString launchPath () | |
82 { | |
83 return invokeObjcSelf!(NSString, "launchPath"); | |
84 } | |
85 | |
86 NSArray arguments () | |
87 { | |
88 return invokeObjcSelf!(NSArray, "arguments"); | |
89 } | |
90 | |
91 NSDictionary environment () | |
92 { | |
93 return invokeObjcSelf!(NSDictionary, "environment"); | |
94 } | |
95 | |
96 NSString currentDirectoryPath () | |
97 { | |
98 return invokeObjcSelf!(NSString, "currentDirectoryPath"); | |
99 } | |
100 | |
101 Object standardInput () | |
102 { | |
103 return invokeObjcSelf!(Object, "standardInput"); | |
104 } | |
105 | |
106 Object standardOutput () | |
107 { | |
108 return invokeObjcSelf!(Object, "standardOutput"); | |
109 } | |
110 | |
111 Object standardError () | |
112 { | |
113 return invokeObjcSelf!(Object, "standardError"); | |
114 } | |
115 | |
116 void launch () | |
117 { | |
118 return invokeObjcSelf!(void, "launch"); | |
119 } | |
120 | |
121 void interrupt () | |
122 { | |
123 return invokeObjcSelf!(void, "interrupt"); | |
124 } | |
125 | |
126 void terminate () | |
127 { | |
128 return invokeObjcSelf!(void, "terminate"); | |
129 } | |
130 | |
131 bool suspend () | |
132 { | |
133 return invokeObjcSelf!(bool, "suspend"); | |
134 } | |
135 | |
136 bool resume () | |
137 { | |
138 return invokeObjcSelf!(bool, "resume"); | |
139 } | |
140 | |
141 int processIdentifier () | |
142 { | |
143 return invokeObjcSelf!(int, "processIdentifier"); | |
144 } | |
145 | |
146 bool isRunning () | |
147 { | |
148 return invokeObjcSelf!(bool, "isRunning"); | |
149 } | |
150 | |
151 int terminationStatus () | |
152 { | |
153 return invokeObjcSelf!(int, "terminationStatus"); | |
154 } | |
155 } | |
156 | |
157 template TNSTaskConveniences () | |
158 { | |
159 static NSTask launchedTaskWithLaunchPath (NSString path, NSArray arguments) | |
160 { | |
161 return invokeObjcSelfClass!(NSTask, "launchedTaskWithLaunchPath:arguments:", NSString, NSArray)(path, arguments); | |
162 } | |
163 | |
164 void waitUntilExit () | |
165 { | |
166 return invokeObjcSelf!(void, "waitUntilExit"); | |
167 } | |
168 } | |
169 |