Mercurial > projects > dstep
annotate dstep/foundation/NSOperation.d @ 25:b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Tue, 06 Apr 2010 11:37:27 +0200 |
parents | 19885b43130e |
children |
rev | line source |
---|---|
14 | 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.NSOperation; | |
8 | |
9 import dstep.foundation.NSArray; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
10 import dstep.foundation.NSInvocation; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
11 import dstep.foundation.NSObjCRuntime; |
14 | 12 import dstep.foundation.NSObject; |
13 import dstep.foundation.NSSet; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
14 import dstep.foundation.NSString; |
14 | 15 import dstep.objc.bridge.Bridge; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
16 import dstep.objc.objc; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
17 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
18 |
14 | 19 |
20 import bindings = dstep.foundation.NSOperation_bindings; | |
21 | |
22 alias NSInteger NSOperationQueuePriority; | |
23 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
24 private |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
25 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
26 NSString NSInvocationOperationVoidResultException_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
27 NSString NSInvocationOperationCancelledException_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
28 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
29 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
30 NSString NSInvocationOperationVoidResultException () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
31 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
32 if (NSInvocationOperationVoidResultException_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
33 return NSInvocationOperationVoidResultException_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
34 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
35 return NSInvocationOperationVoidResultException_ = new NSString(bindings.NSInvocationOperationVoidResultException); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
36 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
37 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
38 NSString NSInvocationOperationCancelledException () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
39 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
40 if (NSInvocationOperationCancelledException_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
41 return NSInvocationOperationCancelledException_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
42 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
43 return NSInvocationOperationCancelledException_ = new NSString(bindings.NSInvocationOperationCancelledException); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
44 } |
14 | 45 |
46 enum | |
47 { | |
48 NSOperationQueuePriorityVeryLow = -8, | |
49 NSOperationQueuePriorityLow = -4, | |
50 NSOperationQueuePriorityNormal = 0, | |
51 NSOperationQueuePriorityHigh = 4, | |
52 NSOperationQueuePriorityVeryHigh = 8 | |
53 } | |
54 | |
55 enum | |
56 { | |
57 NSOperationQueueDefaultMaxConcurrentOperationCount = -1 | |
58 } | |
59 | |
60 class NSOperation : NSObject | |
61 { | |
25
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
62 mixin ObjcWrap; |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
63 |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
64 this (id object) |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
65 { |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
66 super(object); |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
67 } |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
68 |
14 | 69 this () |
70 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
71 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
72 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
73 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
74 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
75 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
76 return invokeObjcSelf!(typeof(this), "init"); |
14 | 77 } |
78 | |
79 void start () | |
80 { | |
81 return invokeObjcSelf!(void, "start"); | |
82 } | |
83 | |
84 void main () | |
85 { | |
86 return invokeObjcSelf!(void, "main"); | |
87 } | |
88 | |
89 bool isCancelled () | |
90 { | |
91 return invokeObjcSelf!(bool, "isCancelled"); | |
92 } | |
93 | |
94 void cancel () | |
95 { | |
96 return invokeObjcSelf!(void, "cancel"); | |
97 } | |
98 | |
99 bool isExecuting () | |
100 { | |
101 return invokeObjcSelf!(bool, "isExecuting"); | |
102 } | |
103 | |
104 bool isFinished () | |
105 { | |
106 return invokeObjcSelf!(bool, "isFinished"); | |
107 } | |
108 | |
109 bool isConcurrent () | |
110 { | |
111 return invokeObjcSelf!(bool, "isConcurrent"); | |
112 } | |
113 | |
114 bool isReady () | |
115 { | |
116 return invokeObjcSelf!(bool, "isReady"); | |
117 } | |
118 | |
119 void addDependency (NSOperation op) | |
120 { | |
121 return invokeObjcSelf!(void, "addDependency:", NSOperation)(op); | |
122 } | |
123 | |
124 void removeDependency (NSOperation op) | |
125 { | |
126 return invokeObjcSelf!(void, "removeDependency:", NSOperation)(op); | |
127 } | |
128 | |
129 NSArray dependencies () | |
130 { | |
131 return invokeObjcSelf!(NSArray, "dependencies"); | |
132 } | |
133 | |
134 int queuePriority () | |
135 { | |
136 return invokeObjcSelf!(int, "queuePriority"); | |
137 } | |
138 | |
139 void setQueuePriority (int p) | |
140 { | |
141 return invokeObjcSelf!(void, "setQueuePriority:", int)(p); | |
142 } | |
143 } | |
144 | |
145 class NSOperationQueue : NSObject | |
146 { | |
25
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
147 mixin ObjcWrap; |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
148 |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
149 this (id object) |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
150 { |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
151 super(object); |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
152 } |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
153 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
154 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
155 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
156 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
157 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
158 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
159 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
160 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
161 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
162 } |
14 | 163 |
164 void addOperation (NSOperation op) | |
165 { | |
166 return invokeObjcSelf!(void, "addOperation:", NSOperation)(op); | |
167 } | |
168 | |
169 NSArray operations () | |
170 { | |
171 return invokeObjcSelf!(NSArray, "operations"); | |
172 } | |
173 | |
174 NSInteger maxConcurrentOperationCount () | |
175 { | |
176 return invokeObjcSelf!(NSInteger, "maxConcurrentOperationCount"); | |
177 } | |
178 | |
179 void setMaxConcurrentOperationCount (NSInteger cnt) | |
180 { | |
181 return invokeObjcSelf!(void, "setMaxConcurrentOperationCount:", NSInteger)(cnt); | |
182 } | |
183 | |
184 void setSuspended (bool b) | |
185 { | |
186 return invokeObjcSelf!(void, "setSuspended:", bool)(b); | |
187 } | |
188 | |
189 bool isSuspended () | |
190 { | |
191 return invokeObjcSelf!(bool, "isSuspended"); | |
192 } | |
193 | |
194 void cancelAllOperations () | |
195 { | |
196 return invokeObjcSelf!(void, "cancelAllOperations"); | |
197 } | |
198 | |
199 void waitUntilAllOperationsAreFinished () | |
200 { | |
201 return invokeObjcSelf!(void, "waitUntilAllOperationsAreFinished"); | |
202 } | |
203 } | |
204 | |
205 class NSInvocationOperation : NSOperation | |
206 { | |
25
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
207 mixin ObjcWrap; |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
208 |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
209 this (id object) |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
210 { |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
211 super(object); |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
212 } |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
213 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
214 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
215 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
216 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
217 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
218 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
219 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
220 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
221 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
222 } |
14 | 223 |
224 Object initWithTarget (Object target, SEL sel, Object arg) | |
225 { | |
226 return invokeObjcSelf!(Object, "initWithTarget:selector:object:", Object, SEL, Object)(target, sel, arg); | |
227 } | |
228 | |
229 this (Object target, SEL sel, Object arg) | |
230 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
231 typeof(this).alloc.initWithTarget(target, sel, arg); |
14 | 232 } |
233 | |
234 Object initWithInvocation (NSInvocation inv) | |
235 { | |
236 return invokeObjcSelf!(Object, "initWithInvocation:", NSInvocation)(inv); | |
237 } | |
238 | |
239 this (NSInvocation inv) | |
240 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
241 typeof(this).alloc.initWithInvocation(inv); |
14 | 242 } |
243 | |
244 NSInvocation invocation () | |
245 { | |
246 return invokeObjcSelf!(NSInvocation, "invocation"); | |
247 } | |
248 | |
249 Object result () | |
250 { | |
251 return invokeObjcSelf!(Object, "result"); | |
252 } | |
253 } | |
254 |