comparison dstep/foundation/NSDistributedLock.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 7ff919f595d5
children b9de51448c6b
comparison
equal deleted inserted replaced
15:7ff919f595d5 16:19885b43130e
6 */ 6 */
7 module dstep.foundation.NSDistributedLock; 7 module dstep.foundation.NSDistributedLock;
8 8
9 import dstep.foundation.NSDate; 9 import dstep.foundation.NSDate;
10 import dstep.foundation.NSObject; 10 import dstep.foundation.NSObject;
11 import dstep.foundation.NSString;
11 import dstep.objc.bridge.Bridge; 12 import dstep.objc.bridge.Bridge;
12 import dstep.objc.objc : id; 13 import dstep.objc.objc;
13 14
14 class NSDistributedLock : NSObject 15 class NSDistributedLock : NSObject
15 { 16 {
16 mixin ObjcWrap; 17 mixin (ObjcWrap);
18
19 this ()
20 {
21 super(typeof(this).alloc.init.objcObject);
22 }
23
24 typeof(this) init ()
25 {
26 return invokeObjcSelf!(typeof(this), "init");
27 }
17 28
18 static NSDistributedLock lockWithPath (NSString path) 29 static NSDistributedLock lockWithPath (NSString path)
19 { 30 {
20 return invokeObjcSelfClass!(NSDistributedLock, "lockWithPath:", NSString)(path); 31 return invokeObjcSuperClass!(NSDistributedLock, "lockWithPath:", NSString)(path);
21 } 32 }
22 33
23 Object initWithPath (NSString path) 34 Object initWithPath (NSString path)
24 { 35 {
25 return invokeObjcSelf!(Object, "initWithPath:", NSString)(path); 36 return invokeObjcSelf!(Object, "initWithPath:", NSString)(path);
26 } 37 }
27 38
28 this (NSString path) 39 this (NSString path)
29 { 40 {
30 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); 41 typeof(this).alloc.initWithPath(path);
31 id result = Bridge.invokeObjcMethod!(id, "initWithPath:", NSString)(objcObject, path);
32
33 if (result)
34 objcObject = ret;
35
36 dObject = this;
37 } 42 }
38 43
39 bool tryLock () 44 bool tryLock ()
40 { 45 {
41 return invokeObjcSelf!(bool, "tryLock"); 46 return invokeObjcSelf!(bool, "tryLock");