Mercurial > projects > dstep
comparison dstep/foundation/NSEnumerator.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 | 89f3c3ef1fd2 |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | 5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) |
6 */ | 6 */ |
7 module dstep.foundation.NSEnumerator; | 7 module dstep.foundation.NSEnumerator; |
8 | 8 |
9 import dstep.foundation.NSArray; | 9 import dstep.foundation.NSArray; |
10 import dstep.foundation.NSObjCRuntime; | |
10 import dstep.foundation.NSObject; | 11 import dstep.foundation.NSObject; |
11 import dstep.objc.bridge.Bridge; | 12 import dstep.objc.bridge.Bridge; |
12 import dstep.objc.objc : id; | 13 import dstep.objc.objc; |
13 | 14 |
14 struct NSFastEnumerationState | 15 struct NSFastEnumerationState |
15 { | 16 { |
16 uint state; | 17 uint state; |
17 id* itemsPtr; | 18 id* itemsPtr; |
18 unsigned long* mutationsPtr; | 19 ulong* mutationsPtr; |
19 unsigned long* extra; | 20 ulong* extra; |
20 } | 21 } |
22 | |
23 const TNSExtendedEnumerator = ` | |
24 | |
25 NSArray allObjects () | |
26 { | |
27 return invokeObjcSelf!(NSArray, "allObjects"); | |
28 } | |
29 `; | |
21 | 30 |
22 class NSEnumerator : NSObject, INSFastEnumeration | 31 class NSEnumerator : NSObject, INSFastEnumeration |
23 { | 32 { |
24 mixin ObjcWrap; | 33 mixin (ObjcWrap); |
25 mixin TNSExtendedEnumerator; | 34 |
35 this () | |
36 { | |
37 super(typeof(this).alloc.init.objcObject); | |
38 } | |
39 | |
40 typeof(this) init () | |
41 { | |
42 return invokeObjcSelf!(typeof(this), "init"); | |
43 } | |
26 | 44 |
27 Object nextObject () | 45 Object nextObject () |
28 { | 46 { |
29 return invokeObjcSelf!(Object, "nextObject"); | 47 return invokeObjcSelf!(Object, "nextObject"); |
30 } | 48 } |
31 | 49 |
32 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) | 50 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) |
33 { | 51 { |
34 return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); | 52 return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); |
35 } | 53 } |
54 | |
55 // TNSExtendedEnumerator | |
56 NSArray allObjects () | |
57 { | |
58 return invokeObjcSelf!(NSArray, "allObjects"); | |
59 } | |
36 } | 60 } |
37 | 61 |
38 interface INSFastEnumeration | 62 interface INSFastEnumeration |
39 { | 63 { |
40 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len); | 64 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len); |
41 } | 65 } |
42 | |
43 template TNSExtendedEnumerator () | |
44 { | |
45 NSArray allObjects () | |
46 { | |
47 return invokeObjcSelf!(NSArray, "allObjects"); | |
48 } | |
49 } | |
50 |