Mercurial > projects > dstep
comparison dstep/foundation/NSEnumerator.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.NSEnumerator; | |
8 | |
9 import dstep.foundation.NSArray; | |
10 import dstep.foundation.NSObject; | |
11 import dstep.objc.bridge.Bridge; | |
12 import dstep.objc.objc : id; | |
13 | |
14 struct NSFastEnumerationState | |
15 { | |
16 uint state; | |
17 id* itemsPtr; | |
18 unsigned long* mutationsPtr; | |
19 unsigned long* extra; | |
20 } | |
21 | |
22 class NSEnumerator : NSObject, INSFastEnumeration | |
23 { | |
24 mixin ObjcWrap; | |
25 mixin TNSExtendedEnumerator; | |
26 | |
27 Object nextObject () | |
28 { | |
29 return invokeObjcSelf!(Object, "nextObject"); | |
30 } | |
31 | |
32 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) | |
33 { | |
34 return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); | |
35 } | |
36 } | |
37 | |
38 interface INSFastEnumeration | |
39 { | |
40 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len); | |
41 } | |
42 | |
43 template TNSExtendedEnumerator () | |
44 { | |
45 NSArray allObjects () | |
46 { | |
47 return invokeObjcSelf!(NSArray, "allObjects"); | |
48 } | |
49 } | |
50 |