14
|
1 /**
|
|
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
|
|
3 * Authors: Jacob Carlborg
|
|
4 * Version: Initial created: Aug 3, 2009
|
|
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
|
|
6 */
|
|
7 module dstep.foundation.NSDistantObject;
|
|
8
|
|
9 import dstep.foundation.NSCoder;
|
|
10 import dstep.foundation.NSConnection;
|
|
11 import dstep.foundation.NSProxy;
|
|
12 import dstep.foundation.Protocol;
|
|
13 import dstep.objc.bridge.Bridge;
|
|
14 import dstep.objc.objc : id;
|
|
15
|
|
16 class NSDistantObject : NSProxy, INSCoding
|
|
17 {
|
|
18 mixin ObjcWrap;
|
|
19
|
|
20 static NSDistantObject proxyWithTarget (Object target, NSConnection connection)
|
|
21 {
|
|
22 return invokeObjcSelfClass!(NSDistantObject, "proxyWithTarget:connection:", Object, NSConnection)(target, connectionreturn result is this.objcObject ? this : (result !is null ? new NSDistantObject(result) : null); }
|
|
23
|
|
24 Object initWithTarget (Object target, NSConnection connection)
|
|
25 {
|
|
26 return invokeObjcSelf!(Object, "initWithTarget:connection:", Object, NSConnection)(target, connection);
|
|
27 }
|
|
28
|
|
29 this (Object target, NSConnection connection)
|
|
30 {
|
|
31 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
32 id result = Bridge.invokeObjcMethod!(id, "initWithTarget:connection:", Object, NSConnection)(objcObject, target, connection);
|
|
33
|
|
34 if (result)
|
|
35 objcObject = ret;
|
|
36
|
|
37 dObject = this;
|
|
38 }
|
|
39
|
|
40 static NSDistantObject proxyWithLocal (Object target, NSConnection connection)
|
|
41 {
|
|
42 return invokeObjcSelfClass!(NSDistantObject, "proxyWithLocal:connection:", Object, NSConnection)(target, connectionreturn result is this.objcObject ? this : (result !is null ? new NSDistantObject(result) : null); }
|
|
43
|
|
44 Object initWithLocal (Object target, NSConnection connection)
|
|
45 {
|
|
46 return invokeObjcSelf!(Object, "initWithLocal:connection:", Object, NSConnection)(target, connection);
|
|
47 }
|
|
48
|
|
49 this (Object target, NSConnection connection)
|
|
50 {
|
|
51 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
52 id result = Bridge.invokeObjcMethod!(id, "initWithLocal:connection:", Object, NSConnection)(objcObject, target, connection);
|
|
53
|
|
54 if (result)
|
|
55 objcObject = ret;
|
|
56
|
|
57 dObject = this;
|
|
58 }
|
|
59
|
|
60 void setProtocolForProxy (Protocol proto)
|
|
61 {
|
|
62 return invokeObjcSelf!(void, "setProtocolForProxy:", Protocol)(proto);
|
|
63 }
|
|
64
|
|
65 NSConnection connectionForProxy ()
|
|
66 {
|
|
67 return invokeObjcSelf!(NSConnection, "connectionForProxy");
|
|
68 }
|
|
69
|
|
70 void encodeWithCoder (NSCoder aCoder)
|
|
71 {
|
|
72 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
|
|
73 }
|
|
74
|
|
75 Object initWithCoder (NSCoder aDecoder)
|
|
76 {
|
|
77 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
|
|
78 }
|
|
79
|
|
80 this (NSCoder aDecoder)
|
|
81 {
|
|
82 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
83 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder);
|
|
84
|
|
85 if (result)
|
|
86 objcObject = ret;
|
|
87
|
|
88 dObject = this;
|
|
89 }
|
|
90 }
|
|
91
|