Mercurial > projects > dstep
diff 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 |
line wrap: on
line diff
--- a/dstep/foundation/NSLock.d Mon Aug 03 15:31:48 2009 +0200 +++ b/dstep/foundation/NSLock.d Sun Jan 03 22:06:11 2010 +0100 @@ -7,13 +7,25 @@ module dstep.foundation.NSLock; import dstep.foundation.NSDate; +import dstep.foundation.NSObjCRuntime; import dstep.foundation.NSObject; +import dstep.foundation.NSString; import dstep.objc.bridge.Bridge; -import dstep.objc.objc : id; +import dstep.objc.objc; class NSLock : NSObject, INSLocking { - mixin ObjcWrap; + mixin (ObjcWrap); + + this () + { + super(typeof(this).alloc.init.objcObject); + } + + typeof(this) init () + { + return invokeObjcSelf!(typeof(this), "init"); + } bool tryLock () { @@ -48,7 +60,17 @@ class NSCondition : NSObject, INSLocking { - mixin ObjcWrap; + mixin (ObjcWrap); + + this () + { + super(typeof(this).alloc.init.objcObject); + } + + typeof(this) init () + { + return invokeObjcSelf!(typeof(this), "init"); + } void wait () { @@ -93,7 +115,17 @@ class NSConditionLock : NSObject, INSLocking { - mixin ObjcWrap; + mixin (ObjcWrap); + + this () + { + super(typeof(this).alloc.init.objcObject); + } + + typeof(this) init () + { + return invokeObjcSelf!(typeof(this), "init"); + } Object initWithCondition (NSInteger condition) { @@ -102,13 +134,7 @@ this (NSInteger condition) { - objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); - id result = Bridge.invokeObjcMethod!(id, "initWithCondition:", NSInteger)(objcObject, condition); - - if (result) - objcObject = ret; - - dObject = this; + typeof(this).alloc.initWithCondition(condition); } NSInteger condition () @@ -169,7 +195,17 @@ class NSRecursiveLock : NSObject, INSLocking { - mixin ObjcWrap; + mixin (ObjcWrap); + + this () + { + super(typeof(this).alloc.init.objcObject); + } + + typeof(this) init () + { + return invokeObjcSelf!(typeof(this), "init"); + } bool tryLock () {