Mercurial > projects > dstep
comparison dstep/foundation/NSObject.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 19885b43130e |
comparison
equal
deleted
inserted
replaced
13:4f583f7e242e | 14:89f3c3ef1fd2 |
---|---|
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.NSObject; | |
8 | |
9 import dstep.foundation.NSCoder; | |
10 import dstep.foundation.NSEnumerator; | |
11 import dstep.foundation.NSInvocation; | |
12 import dstep.foundation.NSMethodSignature; | |
13 import dstep.foundation.NSObjCRuntime; | |
14 import dstep.foundation.NSString; | |
15 import dstep.foundation.NSZone; | |
16 import dstep.foundation.Protocol; | |
17 import dstep.objc.bridge.Bridge; | |
18 import dstep.objc.objc : id; | |
19 | |
20 class NSObject : INSObject | |
21 { | |
22 mixin ObjcWrap; | |
23 mixin TNSURLConnectionDelegate; | |
24 mixin TNSFileManagerFileOperationAdditions; | |
25 mixin TNSDeprecatedKeyValueCoding; | |
26 mixin TNSDistributedObjects; | |
27 mixin TNSArchiverCallback; | |
28 mixin TNSKeyValueObserverNotification; | |
29 mixin TNSMetadataQueryDelegate; | |
30 mixin TNSKeyValueObservingCustomization; | |
31 mixin TNSKeyedArchiverObjectSubstitution; | |
32 mixin TNSScriptClassDescription; | |
33 mixin TNSDelayedPerforming; | |
34 mixin TNSStreamDelegateEventExtensions; | |
35 mixin TNSCopyLinkMoveHandler; | |
36 mixin TNSMachPortDelegateMethods; | |
37 mixin TNSComparisonMethods; | |
38 mixin TNSSpellServerDelegate; | |
39 mixin TNSScriptKeyValueCoding; | |
40 mixin TNSDistantObjectRequestMethods; | |
41 mixin TNSClassDescriptionPrimitives; | |
42 mixin TNSKeyedUnarchiverObjectSubstitution; | |
43 mixin TNSScriptObjectSpecifiers; | |
44 mixin TNSNetServiceDelegateMethods; | |
45 mixin TNSConnectionDelegateMethods; | |
46 mixin TNSXMLParserDelegateEventAdditions; | |
47 mixin TNSErrorRecoveryAttempting; | |
48 mixin TNSDeprecatedMethods; | |
49 mixin TNSPortDelegateMethods; | |
50 mixin TNSURLClient; | |
51 mixin TNSScriptingComparisonMethods; | |
52 mixin TNSNetServiceBrowserDelegateMethods; | |
53 mixin TNSCoderMethods; | |
54 mixin TNSDeprecatedKeyValueObservingCustomization; | |
55 mixin TNSKeyedUnarchiverDelegate; | |
56 mixin TNSScripting; | |
57 mixin TNSURLDownloadDelegate; | |
58 mixin TNSKeyValueCoding; | |
59 mixin TNSKeyedArchiverDelegate; | |
60 mixin TNSThreadPerformAdditions; | |
61 mixin TNSKeyValueObserving; | |
62 | |
63 static void load () | |
64 { | |
65 return invokeObjcSelfClass!(void, "load"); | |
66 } | |
67 | |
68 static void initialize () | |
69 { | |
70 return invokeObjcSelfClass!(void, "initialize"); | |
71 } | |
72 | |
73 Object init () | |
74 { | |
75 return invokeObjcSelf!(Object, "init"); | |
76 } | |
77 | |
78 this () | |
79 { | |
80 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
81 id result = Bridge.invokeObjcMethod!(id, "init")(objcObject); | |
82 | |
83 if (result) | |
84 objcObject = ret; | |
85 | |
86 dObject = this; | |
87 } | |
88 | |
89 static Object new_ () | |
90 { | |
91 return invokeObjcSelfClass!(Object, "new"); | |
92 } | |
93 | |
94 static Object allocWithZone (NSZone* zone) | |
95 { | |
96 return invokeObjcSelfClass!(Object, "allocWithZone:", NSZone*)(zone); | |
97 } | |
98 | |
99 static Object alloc () | |
100 { | |
101 return invokeObjcSelfClass!(Object, "alloc"); | |
102 } | |
103 | |
104 void dealloc () | |
105 { | |
106 return invokeObjcSelf!(void, "dealloc"); | |
107 } | |
108 | |
109 void finalize () | |
110 { | |
111 return invokeObjcSelf!(void, "finalize"); | |
112 } | |
113 | |
114 Object copy () | |
115 { | |
116 return invokeObjcSelf!(Object, "copy"); | |
117 } | |
118 | |
119 Object mutableCopy () | |
120 { | |
121 return invokeObjcSelf!(Object, "mutableCopy"); | |
122 } | |
123 | |
124 static Object copyWithZone (NSZone* zone) | |
125 { | |
126 return invokeObjcSelfClass!(Object, "copyWithZone:", NSZone*)(zone); | |
127 } | |
128 | |
129 static Object mutableCopyWithZone (NSZone* zone) | |
130 { | |
131 return invokeObjcSelfClass!(Object, "mutableCopyWithZone:", NSZone*)(zone); | |
132 } | |
133 | |
134 static Class superclass () | |
135 { | |
136 return invokeObjcSelfClass!(Class, "superclass"); | |
137 } | |
138 | |
139 static Class class_ () | |
140 { | |
141 return invokeObjcSelfClass!(Class, "class"); | |
142 } | |
143 | |
144 static bool instancesRespondToSelector (SEL aSelector) | |
145 { | |
146 return invokeObjcSelfClass!(bool, "instancesRespondToSelector:", SEL)(aSelector); | |
147 } | |
148 | |
149 static bool conformsToProtocol (Protocol protocol) | |
150 { | |
151 return invokeObjcSelfClass!(bool, "conformsToProtocol:", Protocol)(protocol); | |
152 } | |
153 | |
154 IMP methodForSelector (SEL aSelector) | |
155 { | |
156 return invokeObjcSelf!(IMP, "methodForSelector:", SEL)(aSelector); | |
157 } | |
158 | |
159 static IMP instanceMethodForSelector (SEL aSelector) | |
160 { | |
161 return invokeObjcSelfClass!(IMP, "instanceMethodForSelector:", SEL)(aSelector); | |
162 } | |
163 | |
164 void doesNotRecognizeSelector (SEL aSelector) | |
165 { | |
166 return invokeObjcSelf!(void, "doesNotRecognizeSelector:", SEL)(aSelector); | |
167 } | |
168 | |
169 void forwardInvocation (NSInvocation anInvocation) | |
170 { | |
171 return invokeObjcSelf!(void, "forwardInvocation:", NSInvocation)(anInvocation); | |
172 } | |
173 | |
174 NSMethodSignature methodSignatureForSelector (SEL aSelector) | |
175 { | |
176 return invokeObjcSelf!(NSMethodSignature, "methodSignatureForSelector:", SEL)(aSelector); | |
177 } | |
178 | |
179 static NSMethodSignature instanceMethodSignatureForSelector (SEL aSelector) | |
180 { | |
181 return invokeObjcSelfClass!(NSMethodSignature, "instanceMethodSignatureForSelector:", SEL)(aSelector); | |
182 } | |
183 | |
184 static NSString description () | |
185 { | |
186 return invokeObjcSelfClass!(NSString, "description"); | |
187 } | |
188 | |
189 static bool isSubclassOfClass (Class aClass) | |
190 { | |
191 return invokeObjcSelfClass!(bool, "isSubclassOfClass:", Class)(aClass); | |
192 } | |
193 | |
194 static bool resolveClassMethod (SEL sel) | |
195 { | |
196 return invokeObjcSelfClass!(bool, "resolveClassMethod:", SEL)(sel); | |
197 } | |
198 | |
199 static bool resolveInstanceMethod (SEL sel) | |
200 { | |
201 return invokeObjcSelfClass!(bool, "resolveInstanceMethod:", SEL)(sel); | |
202 } | |
203 | |
204 bool isEqual (Object object) | |
205 { | |
206 return invokeObjcSelf!(bool, "isEqual:", Object)(object); | |
207 } | |
208 | |
209 NSUInteger hash () | |
210 { | |
211 return invokeObjcSelf!(NSUInteger, "hash"); | |
212 } | |
213 | |
214 Class superclass () | |
215 { | |
216 return invokeObjcSelf!(Class, "superclass"); | |
217 } | |
218 | |
219 Class class_ () | |
220 { | |
221 return invokeObjcSelf!(Class, "class"); | |
222 } | |
223 | |
224 Object self () | |
225 { | |
226 return invokeObjcSelf!(Object, "self"); | |
227 } | |
228 | |
229 NSZone* zone () | |
230 { | |
231 return invokeObjcSelf!(NSZone*, "zone"); | |
232 } | |
233 | |
234 Object performSelector (SEL aSelector) | |
235 { | |
236 return invokeObjcSelf!(Object, "performSelector:", SEL)(aSelector); | |
237 } | |
238 | |
239 Object performSelector (SEL aSelector, Object object) | |
240 { | |
241 return invokeObjcSelf!(Object, "performSelector:withObject:", SEL, Object)(aSelector, object); | |
242 } | |
243 | |
244 Object performSelector (SEL aSelector, Object object1, Object object2) | |
245 { | |
246 return invokeObjcSelf!(Object, "performSelector:withObject:withObject:", SEL, Object, Object)(aSelector, object1, object2); | |
247 } | |
248 | |
249 bool isProxy () | |
250 { | |
251 return invokeObjcSelf!(bool, "isProxy"); | |
252 } | |
253 | |
254 bool isKindOfClass (Class aClass) | |
255 { | |
256 return invokeObjcSelf!(bool, "isKindOfClass:", Class)(aClass); | |
257 } | |
258 | |
259 bool isMemberOfClass (Class aClass) | |
260 { | |
261 return invokeObjcSelf!(bool, "isMemberOfClass:", Class)(aClass); | |
262 } | |
263 | |
264 bool conformsToProtocol (Protocol aProtocol) | |
265 { | |
266 return invokeObjcSelf!(bool, "conformsToProtocol:", Protocol)(aProtocol); | |
267 } | |
268 | |
269 bool respondsToSelector (SEL aSelector) | |
270 { | |
271 return invokeObjcSelf!(bool, "respondsToSelector:", SEL)(aSelector); | |
272 } | |
273 | |
274 Object retain () | |
275 { | |
276 return invokeObjcSelf!(Object, "retain"); | |
277 } | |
278 | |
279 void release () | |
280 { | |
281 return invokeObjcSelf!(void, "release"); | |
282 } | |
283 | |
284 Object autorelease () | |
285 { | |
286 return invokeObjcSelf!(Object, "autorelease"); | |
287 } | |
288 | |
289 NSUInteger retainCount () | |
290 { | |
291 return invokeObjcSelf!(NSUInteger, "retainCount"); | |
292 } | |
293 | |
294 NSString description () | |
295 { | |
296 return invokeObjcSelf!(NSString, "description"); | |
297 } | |
298 } | |
299 | |
300 interface INSCopying | |
301 { | |
302 Object copyWithZone (NSZone* zone); | |
303 } | |
304 | |
305 interface INSObject | |
306 { | |
307 bool isEqual (Object object); | |
308 NSUInteger hash (); | |
309 Class superclass (); | |
310 Class class_ (); | |
311 Object self (); | |
312 NSZone* zone (); | |
313 Object performSelector (SEL aSelector); | |
314 Object performSelector (SEL aSelector, Object object); | |
315 Object performSelector (SEL aSelector, Object object1, Object object2); | |
316 bool isProxy (); | |
317 bool isKindOfClass (Class aClass); | |
318 bool isMemberOfClass (Class aClass); | |
319 bool conformsToProtocol (Protocol aProtocol); | |
320 bool respondsToSelector (SEL aSelector); | |
321 Object retain (); | |
322 void release (); | |
323 Object autorelease (); | |
324 NSUInteger retainCount (); | |
325 NSString description (); | |
326 } | |
327 | |
328 interface INSMutableCopying | |
329 { | |
330 Object mutableCopyWithZone (NSZone* zone); | |
331 } | |
332 | |
333 interface INSCoding | |
334 { | |
335 void encodeWithCoder (NSCoder aCoder); | |
336 Object initWithCoder (NSCoder aDecoder); | |
337 } | |
338 | |
339 template TNSDeprecatedMethods () | |
340 { | |
341 static void poseAsClass (Class aClass); | |
342 } | |
343 | |
344 template TNSCoderMethods () | |
345 { | |
346 static NSInteger version_ (); | |
347 static void setVersion (NSInteger aVersion); | |
348 Class classForCoder (); | |
349 Object replacementObjectForCoder (NSCoder aCoder); | |
350 Object awakeAfterUsingCoder (NSCoder aDecoder); | |
351 } | |
352 | |
353 Object NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone* zone) | |
354 { | |
355 return Bridge.invokeObjcFunction!(Object, bindings.NSAllocateObject, Class, NSUInteger, NSZone*)(aClass, extraBytes, zone); | |
356 } | |
357 | |
358 void NSDeallocateObject (Object object) | |
359 { | |
360 return Bridge.invokeObjcFunction!(void, bindings.NSDeallocateObject, Object)(object); | |
361 } | |
362 | |
363 Object NSCopyObject (Object object, NSUInteger extraBytes, NSZone* zone) | |
364 { | |
365 return Bridge.invokeObjcFunction!(Object, bindings.NSCopyObject, Object, NSUInteger, NSZone*)(object, extraBytes, zone); | |
366 } | |
367 | |
368 bool NSShouldRetainWithZone (Object anObject, NSZone* requestedZone) | |
369 { | |
370 return Bridge.invokeObjcFunction!(bool, bindings.NSShouldRetainWithZone, Object, NSZone*)(anObject, requestedZone); | |
371 } | |
372 | |
373 void NSIncrementExtraRefCount (Object object) | |
374 { | |
375 return Bridge.invokeObjcFunction!(void, bindings.NSIncrementExtraRefCount, Object)(object); | |
376 } | |
377 | |
378 bool NSDecrementExtraRefCountWasZero (Object object) | |
379 { | |
380 return Bridge.invokeObjcFunction!(bool, bindings.NSDecrementExtraRefCountWasZero, Object)(object); | |
381 } | |
382 | |
383 NSUInteger NSExtraRefCount (Object object) | |
384 { | |
385 return Bridge.invokeObjcFunction!(NSUInteger, bindings.NSExtraRefCount, Object)(object); | |
386 } | |
387 |