Mercurial > projects > dstep
comparison dstep/foundation/NSTask.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 89f3c3ef1fd2 |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
9 import dstep.foundation.NSArray; | 9 import dstep.foundation.NSArray; |
10 import dstep.foundation.NSDictionary; | 10 import dstep.foundation.NSDictionary; |
11 import dstep.foundation.NSObject; | 11 import dstep.foundation.NSObject; |
12 import dstep.foundation.NSString; | 12 import dstep.foundation.NSString; |
13 import dstep.objc.bridge.Bridge; | 13 import dstep.objc.bridge.Bridge; |
14 import dstep.objc.objc : id; | 14 import dstep.objc.objc; |
15 | |
16 | |
15 | 17 |
16 import bindings = dstep.foundation.NSTask_bindings; | 18 import bindings = dstep.foundation.NSTask_bindings; |
17 | 19 |
18 const NSString NSTaskDidTerminateNotification; | 20 private NSString NSTaskDidTerminateNotification_; |
19 | 21 |
20 static this () | 22 NSString NSTaskDidTerminateNotification () |
21 { | 23 { |
22 NSTaskDidTerminateNotification = new NSString(bindings.NSTaskDidTerminateNotification); | 24 if (NSTaskDidTerminateNotification_) |
25 return NSTaskDidTerminateNotification_; | |
26 | |
27 return NSTaskDidTerminateNotification_ = new NSString(bindings.NSTaskDidTerminateNotification); | |
23 } | 28 } |
29 | |
30 const TNSTaskConveniences = ` | |
31 | |
32 static NSTask launchedTaskWithLaunchPath (NSString path, NSArray arguments) | |
33 { | |
34 return invokeObjcSuperClass!(NSTask, "launchedTaskWithLaunchPath:arguments:", NSString, NSArray)(path, arguments); | |
35 } | |
36 | |
37 void waitUntilExit () | |
38 { | |
39 return invokeObjcSelf!(void, "waitUntilExit"); | |
40 } | |
41 `; | |
24 | 42 |
25 class NSTask : NSObject | 43 class NSTask : NSObject |
26 { | 44 { |
27 mixin ObjcWrap; | 45 mixin (ObjcWrap); |
28 mixin TNSTaskConveniences; | 46 |
29 | |
30 Object init () | |
31 { | |
32 return invokeObjcSelf!(Object, "init"); | |
33 } | |
34 | |
35 this () | 47 this () |
36 { | 48 { |
37 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 49 super(typeof(this).alloc.init.objcObject); |
38 id result = Bridge.invokeObjcMethod!(id, "init")(objcObject); | 50 } |
39 | 51 |
40 if (result) | 52 typeof(this) init () |
41 objcObject = ret; | 53 { |
42 | 54 return invokeObjcSelf!(typeof(this), "init"); |
43 dObject = this; | |
44 } | 55 } |
45 | 56 |
46 void setLaunchPath (NSString path) | 57 void setLaunchPath (NSString path) |
47 { | 58 { |
48 return invokeObjcSelf!(void, "setLaunchPath:", NSString)(path); | 59 return invokeObjcSelf!(void, "setLaunchPath:", NSString)(path); |
150 | 161 |
151 int terminationStatus () | 162 int terminationStatus () |
152 { | 163 { |
153 return invokeObjcSelf!(int, "terminationStatus"); | 164 return invokeObjcSelf!(int, "terminationStatus"); |
154 } | 165 } |
155 } | 166 |
156 | 167 // TNSTaskConveniences |
157 template TNSTaskConveniences () | |
158 { | |
159 static NSTask launchedTaskWithLaunchPath (NSString path, NSArray arguments) | 168 static NSTask launchedTaskWithLaunchPath (NSString path, NSArray arguments) |
160 { | 169 { |
161 return invokeObjcSelfClass!(NSTask, "launchedTaskWithLaunchPath:arguments:", NSString, NSArray)(path, arguments); | 170 return invokeObjcSuperClass!(NSTask, "launchedTaskWithLaunchPath:arguments:", NSString, NSArray)(path, arguments); |
162 } | 171 } |
163 | 172 |
164 void waitUntilExit () | 173 void waitUntilExit () |
165 { | 174 { |
166 return invokeObjcSelf!(void, "waitUntilExit"); | 175 return invokeObjcSelf!(void, "waitUntilExit"); |
167 } | 176 } |
168 } | 177 } |
169 |