Mercurial > projects > dstep
diff dstep/foundation/NSDistantObject.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 7ff919f595d5 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dstep/foundation/NSDistantObject.d Mon Aug 03 15:23:15 2009 +0200 @@ -0,0 +1,91 @@ +/** + * Copyright: Copyright (c) 2009 Jacob Carlborg. + * Authors: Jacob Carlborg + * Version: Initial created: Aug 3, 2009 + * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) + */ +module dstep.foundation.NSDistantObject; + +import dstep.foundation.NSCoder; +import dstep.foundation.NSConnection; +import dstep.foundation.NSProxy; +import dstep.foundation.Protocol; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc : id; + +class NSDistantObject : NSProxy, INSCoding +{ + mixin ObjcWrap; + + static NSDistantObject proxyWithTarget (Object target, NSConnection connection) + { + return invokeObjcSelfClass!(NSDistantObject, "proxyWithTarget:connection:", Object, NSConnection)(target, connectionreturn result is this.objcObject ? this : (result !is null ? new NSDistantObject(result) : null); } + + Object initWithTarget (Object target, NSConnection connection) + { + return invokeObjcSelf!(Object, "initWithTarget:connection:", Object, NSConnection)(target, connection); + } + + this (Object target, NSConnection connection) + { + objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); + id result = Bridge.invokeObjcMethod!(id, "initWithTarget:connection:", Object, NSConnection)(objcObject, target, connection); + + if (result) + objcObject = ret; + + dObject = this; + } + + static NSDistantObject proxyWithLocal (Object target, NSConnection connection) + { + return invokeObjcSelfClass!(NSDistantObject, "proxyWithLocal:connection:", Object, NSConnection)(target, connectionreturn result is this.objcObject ? this : (result !is null ? new NSDistantObject(result) : null); } + + Object initWithLocal (Object target, NSConnection connection) + { + return invokeObjcSelf!(Object, "initWithLocal:connection:", Object, NSConnection)(target, connection); + } + + this (Object target, NSConnection connection) + { + objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); + id result = Bridge.invokeObjcMethod!(id, "initWithLocal:connection:", Object, NSConnection)(objcObject, target, connection); + + if (result) + objcObject = ret; + + dObject = this; + } + + void setProtocolForProxy (Protocol proto) + { + return invokeObjcSelf!(void, "setProtocolForProxy:", Protocol)(proto); + } + + NSConnection connectionForProxy () + { + return invokeObjcSelf!(NSConnection, "connectionForProxy"); + } + + void encodeWithCoder (NSCoder aCoder) + { + return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); + } + + Object initWithCoder (NSCoder aDecoder) + { + return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); + } + + this (NSCoder aDecoder) + { + objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); + id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); + + if (result) + objcObject = ret; + + dObject = this; + } +} +