Mercurial > projects > dstep
comparison dstep/foundation/NSDistantObject.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.NSDistantObject; | 7 module dstep.foundation.NSDistantObject; |
8 | 8 |
9 import dstep.foundation.NSCoder; | 9 import dstep.foundation.NSCoder; |
10 import dstep.foundation.NSConnection; | 10 import dstep.foundation.NSConnection; |
11 import dstep.foundation.NSObject; | |
11 import dstep.foundation.NSProxy; | 12 import dstep.foundation.NSProxy; |
12 import dstep.foundation.Protocol; | |
13 import dstep.objc.bridge.Bridge; | 13 import dstep.objc.bridge.Bridge; |
14 import dstep.objc.objc : id; | 14 import dstep.objc.objc; |
15 import dstep.objc.runtime; | |
15 | 16 |
16 class NSDistantObject : NSProxy, INSCoding | 17 class NSDistantObject : NSProxy, INSCoding |
17 { | 18 { |
18 mixin ObjcWrap; | 19 mixin (ObjcWrap); |
20 | |
21 this () | |
22 { | |
23 super(typeof(this).alloc.init.objcObject); | |
24 } | |
25 | |
26 typeof(this) init () | |
27 { | |
28 return invokeObjcSelf!(typeof(this), "init"); | |
29 } | |
19 | 30 |
20 static NSDistantObject proxyWithTarget (Object target, NSConnection connection) | 31 static NSDistantObject proxyWithTarget (Object target, NSConnection connection) |
21 { | 32 { |
22 return invokeObjcSelfClass!(NSDistantObject, "proxyWithTarget:connection:", Object, NSConnection)(target, connection); | 33 return invokeObjcSuperClass!(NSDistantObject, "proxyWithTarget:connection:", Object, NSConnection)(target, connection); |
23 } | 34 } |
24 | 35 |
25 Object initWithTarget (Object target, NSConnection connection) | 36 Object initWithTarget (Object target, NSConnection connection) |
26 { | 37 { |
27 return invokeObjcSelf!(Object, "initWithTarget:connection:", Object, NSConnection)(target, connection); | 38 return invokeObjcSelf!(Object, "initWithTarget:connection:", Object, NSConnection)(target, connection); |
28 } | 39 } |
29 | 40 |
30 this (Object target, NSConnection connection) | 41 this (Object target, NSConnection connection) |
31 { | 42 { |
32 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 43 typeof(this).alloc.initWithTarget(target, connection); |
33 id result = Bridge.invokeObjcMethod!(id, "initWithTarget:connection:", Object, NSConnection)(objcObject, target, connection); | |
34 | |
35 if (result) | |
36 objcObject = ret; | |
37 | |
38 dObject = this; | |
39 } | 44 } |
40 | 45 |
41 static NSDistantObject proxyWithLocal (Object target, NSConnection connection) | 46 static NSDistantObject proxyWithLocal (Object target, NSConnection connection) |
42 { | 47 { |
43 return invokeObjcSelfClass!(NSDistantObject, "proxyWithLocal:connection:", Object, NSConnection)(target, connection); | 48 return invokeObjcSuperClass!(NSDistantObject, "proxyWithLocal:connection:", Object, NSConnection)(target, connection); |
44 } | 49 } |
45 | 50 |
46 Object initWithLocal (Object target, NSConnection connection) | 51 Object initWithLocal (Object target, NSConnection connection) |
47 { | 52 { |
48 return invokeObjcSelf!(Object, "initWithLocal:connection:", Object, NSConnection)(target, connection); | 53 return invokeObjcSelf!(Object, "initWithLocal:connection:", Object, NSConnection)(target, connection); |
49 } | 54 } |
50 | 55 |
51 this (Object target, NSConnection connection) | |
52 { | |
53 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
54 id result = Bridge.invokeObjcMethod!(id, "initWithLocal:connection:", Object, NSConnection)(objcObject, target, connection); | |
55 | |
56 if (result) | |
57 objcObject = ret; | |
58 | |
59 dObject = this; | |
60 } | |
61 | |
62 void setProtocolForProxy (Protocol proto) | 56 void setProtocolForProxy (Protocol proto) |
63 { | 57 { |
64 return invokeObjcSelf!(void, "setProtocolForProxy:", Protocol)(proto); | 58 return invokeObjcSelf!(void, "setProtocolForProxy:", Protocol)(proto); |
65 } | 59 } |
66 | 60 |
79 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | 73 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); |
80 } | 74 } |
81 | 75 |
82 this (NSCoder aDecoder) | 76 this (NSCoder aDecoder) |
83 { | 77 { |
84 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 78 typeof(this).alloc.initWithCoder(aDecoder); |
85 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
86 | |
87 if (result) | |
88 objcObject = ret; | |
89 | |
90 dObject = this; | |
91 } | 79 } |
92 } | 80 } |
93 | 81 |