Mercurial > projects > dstep
annotate dstep/foundation/NSConnection.d @ 15:7ff919f595d5
Added the Foundation framework, again
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:31:48 +0200 |
parents | 89f3c3ef1fd2 |
children | 19885b43130e |
rev | line source |
---|---|
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.NSConnection; | |
8 | |
9 import dstep.foundation.NSArray; | |
10 import dstep.foundation.NSData; | |
11 import dstep.foundation.NSDate; | |
12 import dstep.foundation.NSDictionary; | |
13 import dstep.foundation.NSDistantObject; | |
14 import dstep.foundation.NSException; | |
15 import dstep.foundation.NSMutableData; | |
16 import dstep.foundation.NSObject; | |
17 import dstep.foundation.NSPort; | |
18 import dstep.foundation.NSPortNameServer; | |
19 import dstep.foundation.NSRunLoop; | |
20 import dstep.objc.bridge.Bridge; | |
21 import dstep.objc.objc : id; | |
22 | |
23 import bindings = dstep.foundation.NSConnection_bindings; | |
24 | |
25 const NSString NSConnectionReplyMode; | |
26 const NSString NSConnectionDidDieNotification; | |
27 const NSString NSFailedAuthenticationException; | |
28 const NSString NSConnectionDidInitializeNotification; | |
29 | |
30 static this () | |
31 { | |
32 NSConnectionReplyMode = new NSString(bindings.NSConnectionReplyMode); | |
33 NSConnectionDidDieNotification = new NSString(bindings.NSConnectionDidDieNotification); | |
34 NSFailedAuthenticationException = new NSString(bindings.NSFailedAuthenticationException); | |
35 NSConnectionDidInitializeNotification = new NSString(bindings.NSConnectionDidInitializeNotification); | |
36 } | |
37 | |
38 class NSDistantObjectRequest : NSObject | |
39 { | |
40 mixin ObjcWrap; | |
41 | |
42 NSInvocation invocation () | |
43 { | |
44 return invokeObjcSelf!(NSInvocation, "invocation"); | |
45 } | |
46 | |
47 NSConnection connection () | |
48 { | |
49 return invokeObjcSelf!(NSConnection, "connection"); | |
50 } | |
51 | |
52 Object conversation () | |
53 { | |
54 return invokeObjcSelf!(Object, "conversation"); | |
55 } | |
56 | |
57 void replyWithException (NSException exception) | |
58 { | |
59 return invokeObjcSelf!(void, "replyWithException:", NSException)(exception); | |
60 } | |
61 } | |
62 | |
63 class NSConnection : NSObject | |
64 { | |
65 mixin ObjcWrap; | |
66 | |
67 NSDictionary statistics () | |
68 { | |
69 return invokeObjcSelf!(NSDictionary, "statistics"); | |
70 } | |
71 | |
72 static NSArray allConnections () | |
73 { | |
74 return invokeObjcSelfClass!(NSArray, "allConnections"); | |
75 } | |
76 | |
77 static NSConnection defaultConnection () | |
78 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
79 return invokeObjcSelfClass!(NSConnection, "defaultConnection"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
80 } |
14 | 81 |
82 static Object connectionWithRegisteredName (NSString name, NSString hostName) | |
83 { | |
84 return invokeObjcSelfClass!(Object, "connectionWithRegisteredName:host:", NSString, NSString)(name, hostName); | |
85 } | |
86 | |
87 static Object connectionWithRegisteredName (NSString name, NSString hostName, NSPortNameServer server) | |
88 { | |
89 return invokeObjcSelfClass!(Object, "connectionWithRegisteredName:host:usingNameServer:", NSString, NSString, NSPortNameServer)(name, hostName, server); | |
90 } | |
91 | |
92 static NSDistantObject rootProxyForConnectionWithRegisteredName (NSString name, NSString hostName) | |
93 { | |
94 return invokeObjcSelfClass!(NSDistantObject, "rootProxyForConnectionWithRegisteredName:host:", NSString, NSString)(name, hostName); | |
95 } | |
96 | |
97 static NSDistantObject rootProxyForConnectionWithRegisteredName (NSString name, NSString hostName, NSPortNameServer server) | |
98 { | |
99 return invokeObjcSelfClass!(NSDistantObject, "rootProxyForConnectionWithRegisteredName:host:usingNameServer:", NSString, NSString, NSPortNameServer)(name, hostName, server); | |
100 } | |
101 | |
102 static Object serviceConnectionWithName (NSString name, Object root, NSPortNameServer server) | |
103 { | |
104 return invokeObjcSelfClass!(Object, "serviceConnectionWithName:rootObject:usingNameServer:", NSString, Object, NSPortNameServer)(name, root, server); | |
105 } | |
106 | |
107 static Object serviceConnectionWithName (NSString name, Object root) | |
108 { | |
109 return invokeObjcSelfClass!(Object, "serviceConnectionWithName:rootObject:", NSString, Object)(name, root); | |
110 } | |
111 | |
112 void setRequestTimeout (double ti) | |
113 { | |
114 return invokeObjcSelf!(void, "setRequestTimeout:", double)(ti); | |
115 } | |
116 | |
117 double requestTimeout () | |
118 { | |
119 return invokeObjcSelf!(double, "requestTimeout"); | |
120 } | |
121 | |
122 void setReplyTimeout (double ti) | |
123 { | |
124 return invokeObjcSelf!(void, "setReplyTimeout:", double)(ti); | |
125 } | |
126 | |
127 double replyTimeout () | |
128 { | |
129 return invokeObjcSelf!(double, "replyTimeout"); | |
130 } | |
131 | |
132 void setRootObject (Object anObject) | |
133 { | |
134 return invokeObjcSelf!(void, "setRootObject:", Object)(anObject); | |
135 } | |
136 | |
137 Object rootObject () | |
138 { | |
139 return invokeObjcSelf!(Object, "rootObject"); | |
140 } | |
141 | |
142 NSDistantObject rootProxy () | |
143 { | |
144 return invokeObjcSelf!(NSDistantObject, "rootProxy"); | |
145 } | |
146 | |
147 void setDelegate (Object anObject) | |
148 { | |
149 return invokeObjcSelf!(void, "setDelegate:", Object)(anObject); | |
150 } | |
151 | |
152 Object delegate_ () | |
153 { | |
154 return invokeObjcSelf!(Object, "delegate"); | |
155 } | |
156 | |
157 void setIndependentConversationQueueing (bool yorn) | |
158 { | |
159 return invokeObjcSelf!(void, "setIndependentConversationQueueing:", bool)(yorn); | |
160 } | |
161 | |
162 bool independentConversationQueueing () | |
163 { | |
164 return invokeObjcSelf!(bool, "independentConversationQueueing"); | |
165 } | |
166 | |
167 bool isValid () | |
168 { | |
169 return invokeObjcSelf!(bool, "isValid"); | |
170 } | |
171 | |
172 void invalidate () | |
173 { | |
174 return invokeObjcSelf!(void, "invalidate"); | |
175 } | |
176 | |
177 void addRequestMode (NSString rmode) | |
178 { | |
179 return invokeObjcSelf!(void, "addRequestMode:", NSString)(rmode); | |
180 } | |
181 | |
182 void removeRequestMode (NSString rmode) | |
183 { | |
184 return invokeObjcSelf!(void, "removeRequestMode:", NSString)(rmode); | |
185 } | |
186 | |
187 NSArray requestModes () | |
188 { | |
189 return invokeObjcSelf!(NSArray, "requestModes"); | |
190 } | |
191 | |
192 bool registerName (NSString name) | |
193 { | |
194 return invokeObjcSelf!(bool, "registerName:", NSString)(name); | |
195 } | |
196 | |
197 bool registerName (NSString name, NSPortNameServer server) | |
198 { | |
199 return invokeObjcSelf!(bool, "registerName:withNameServer:", NSString, NSPortNameServer)(name, server); | |
200 } | |
201 | |
202 static Object connectionWithReceivePort (NSPort receivePort, NSPort sendPort) | |
203 { | |
204 return invokeObjcSelfClass!(Object, "connectionWithReceivePort:sendPort:", NSPort, NSPort)(receivePort, sendPort); | |
205 } | |
206 | |
207 static Object currentConversation () | |
208 { | |
209 return invokeObjcSelfClass!(Object, "currentConversation"); | |
210 } | |
211 | |
212 Object initWithReceivePort (NSPort receivePort, NSPort sendPort) | |
213 { | |
214 return invokeObjcSelf!(Object, "initWithReceivePort:sendPort:", NSPort, NSPort)(receivePort, sendPort); | |
215 } | |
216 | |
217 this (NSPort receivePort, NSPort sendPort) | |
218 { | |
219 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
220 id result = Bridge.invokeObjcMethod!(id, "initWithReceivePort:sendPort:", NSPort, NSPort)(objcObject, receivePort, sendPort); | |
221 | |
222 if (result) | |
223 objcObject = ret; | |
224 | |
225 dObject = this; | |
226 } | |
227 | |
228 NSPort sendPort () | |
229 { | |
230 return invokeObjcSelf!(NSPort, "sendPort"); | |
231 } | |
232 | |
233 NSPort receivePort () | |
234 { | |
235 return invokeObjcSelf!(NSPort, "receivePort"); | |
236 } | |
237 | |
238 void enableMultipleThreads () | |
239 { | |
240 return invokeObjcSelf!(void, "enableMultipleThreads"); | |
241 } | |
242 | |
243 bool multipleThreadsEnabled () | |
244 { | |
245 return invokeObjcSelf!(bool, "multipleThreadsEnabled"); | |
246 } | |
247 | |
248 void addRunLoop (NSRunLoop runloop) | |
249 { | |
250 return invokeObjcSelf!(void, "addRunLoop:", NSRunLoop)(runloop); | |
251 } | |
252 | |
253 void removeRunLoop (NSRunLoop runloop) | |
254 { | |
255 return invokeObjcSelf!(void, "removeRunLoop:", NSRunLoop)(runloop); | |
256 } | |
257 | |
258 void runInNewThread () | |
259 { | |
260 return invokeObjcSelf!(void, "runInNewThread"); | |
261 } | |
262 | |
263 NSArray remoteObjects () | |
264 { | |
265 return invokeObjcSelf!(NSArray, "remoteObjects"); | |
266 } | |
267 | |
268 NSArray localObjects () | |
269 { | |
270 return invokeObjcSelf!(NSArray, "localObjects"); | |
271 } | |
272 } | |
273 | |
274 template TNSDistantObjectRequestMethods () | |
275 { | |
276 bool connection (NSConnection connection, NSDistantObjectRequest doreq); | |
277 } | |
278 | |
279 template TNSConnectionDelegateMethods () | |
280 { | |
281 bool makeNewConnection (NSConnection conn, NSConnection ancestor); | |
282 bool connection (NSConnection ancestor, NSConnection conn); | |
283 NSData authenticationDataForComponents (NSArray components); | |
284 bool authenticateComponents (NSArray components, NSData signature); | |
285 Object createConversationForConnection (NSConnection conn); | |
286 } | |
287 |