comparison dstep/foundation/NSLock.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
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) 5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6 */ 6 */
7 module dstep.foundation.NSLock; 7 module dstep.foundation.NSLock;
8 8
9 import dstep.foundation.NSDate; 9 import dstep.foundation.NSDate;
10 import dstep.foundation.NSObjCRuntime;
10 import dstep.foundation.NSObject; 11 import dstep.foundation.NSObject;
12 import dstep.foundation.NSString;
11 import dstep.objc.bridge.Bridge; 13 import dstep.objc.bridge.Bridge;
12 import dstep.objc.objc : id; 14 import dstep.objc.objc;
13 15
14 class NSLock : NSObject, INSLocking 16 class NSLock : NSObject, INSLocking
15 { 17 {
16 mixin ObjcWrap; 18 mixin (ObjcWrap);
19
20 this ()
21 {
22 super(typeof(this).alloc.init.objcObject);
23 }
24
25 typeof(this) init ()
26 {
27 return invokeObjcSelf!(typeof(this), "init");
28 }
17 29
18 bool tryLock () 30 bool tryLock ()
19 { 31 {
20 return invokeObjcSelf!(bool, "tryLock"); 32 return invokeObjcSelf!(bool, "tryLock");
21 } 33 }
46 } 58 }
47 } 59 }
48 60
49 class NSCondition : NSObject, INSLocking 61 class NSCondition : NSObject, INSLocking
50 { 62 {
51 mixin ObjcWrap; 63 mixin (ObjcWrap);
64
65 this ()
66 {
67 super(typeof(this).alloc.init.objcObject);
68 }
69
70 typeof(this) init ()
71 {
72 return invokeObjcSelf!(typeof(this), "init");
73 }
52 74
53 void wait () 75 void wait ()
54 { 76 {
55 return invokeObjcSelf!(void, "wait"); 77 return invokeObjcSelf!(void, "wait");
56 } 78 }
91 } 113 }
92 } 114 }
93 115
94 class NSConditionLock : NSObject, INSLocking 116 class NSConditionLock : NSObject, INSLocking
95 { 117 {
96 mixin ObjcWrap; 118 mixin (ObjcWrap);
119
120 this ()
121 {
122 super(typeof(this).alloc.init.objcObject);
123 }
124
125 typeof(this) init ()
126 {
127 return invokeObjcSelf!(typeof(this), "init");
128 }
97 129
98 Object initWithCondition (NSInteger condition) 130 Object initWithCondition (NSInteger condition)
99 { 131 {
100 return invokeObjcSelf!(Object, "initWithCondition:", NSInteger)(condition); 132 return invokeObjcSelf!(Object, "initWithCondition:", NSInteger)(condition);
101 } 133 }
102 134
103 this (NSInteger condition) 135 this (NSInteger condition)
104 { 136 {
105 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); 137 typeof(this).alloc.initWithCondition(condition);
106 id result = Bridge.invokeObjcMethod!(id, "initWithCondition:", NSInteger)(objcObject, condition);
107
108 if (result)
109 objcObject = ret;
110
111 dObject = this;
112 } 138 }
113 139
114 NSInteger condition () 140 NSInteger condition ()
115 { 141 {
116 return invokeObjcSelf!(NSInteger, "condition"); 142 return invokeObjcSelf!(NSInteger, "condition");
167 } 193 }
168 } 194 }
169 195
170 class NSRecursiveLock : NSObject, INSLocking 196 class NSRecursiveLock : NSObject, INSLocking
171 { 197 {
172 mixin ObjcWrap; 198 mixin (ObjcWrap);
199
200 this ()
201 {
202 super(typeof(this).alloc.init.objcObject);
203 }
204
205 typeof(this) init ()
206 {
207 return invokeObjcSelf!(typeof(this), "init");
208 }
173 209
174 bool tryLock () 210 bool tryLock ()
175 { 211 {
176 return invokeObjcSelf!(bool, "tryLock"); 212 return invokeObjcSelf!(bool, "tryLock");
177 } 213 }