Mercurial > projects > dstep
comparison dstep/foundation/NSPointerArray.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.NSPointerArray; | |
8 | |
9 import dstep.foundation.NSArray; | |
10 import dstep.foundation.NSObject; | |
11 import dstep.foundation.NSPointerFunctions; | |
12 import dstep.objc.bridge.Bridge; | |
13 import dstep.objc.objc : id; | |
14 | |
15 class NSPointerArray : NSObject, INSFastEnumeration, INSCopying, INSCoding | |
16 { | |
17 mixin ObjcWrap; | |
18 mixin TNSArrayConveniences; | |
19 | |
20 Object initWithOptions (uint options) | |
21 { | |
22 return invokeObjcSelf!(Object, "initWithOptions:", uint)(options); | |
23 } | |
24 | |
25 this (uint options) | |
26 { | |
27 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
28 id result = Bridge.invokeObjcMethod!(id, "initWithOptions:", uint)(objcObject, options); | |
29 | |
30 if (result) | |
31 objcObject = ret; | |
32 | |
33 dObject = this; | |
34 } | |
35 | |
36 Object initWithPointerFunctions (NSPointerFunctions functions) | |
37 { | |
38 return invokeObjcSelf!(Object, "initWithPointerFunctions:", NSPointerFunctions)(functions); | |
39 } | |
40 | |
41 this (NSPointerFunctions functions) | |
42 { | |
43 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
44 id result = Bridge.invokeObjcMethod!(id, "initWithPointerFunctions:", NSPointerFunctions)(objcObject, functions); | |
45 | |
46 if (result) | |
47 objcObject = ret; | |
48 | |
49 dObject = this; | |
50 } | |
51 | |
52 static Object pointerArrayWithOptions (uint options) | |
53 { | |
54 return invokeObjcSelfClass!(Object, "pointerArrayWithOptions:", uint)(options); | |
55 } | |
56 | |
57 static Object pointerArrayWithPointerFunctions (NSPointerFunctions functions) | |
58 { | |
59 return invokeObjcSelfClass!(Object, "pointerArrayWithPointerFunctions:", NSPointerFunctions)(functions); | |
60 } | |
61 | |
62 NSPointerFunctions pointerFunctions () | |
63 { | |
64 return invokeObjcSelf!(NSPointerFunctions, "pointerFunctions"); | |
65 } | |
66 | |
67 void* pointerAtIndex (NSUInteger index) | |
68 { | |
69 return invokeObjcSelf!(void*, "pointerAtIndex:", NSUInteger)(index); | |
70 } | |
71 | |
72 void addPointer (void* pointer) | |
73 { | |
74 return invokeObjcSelf!(void, "addPointer:", void*)(pointer); | |
75 } | |
76 | |
77 void removePointerAtIndex (NSUInteger index) | |
78 { | |
79 return invokeObjcSelf!(void, "removePointerAtIndex:", NSUInteger)(index); | |
80 } | |
81 | |
82 void insertPointer (void* item, NSUInteger index) | |
83 { | |
84 return invokeObjcSelf!(void, "insertPointer:atIndex:", void*, NSUInteger)(item, index); | |
85 } | |
86 | |
87 void replacePointerAtIndex (NSUInteger index, void* item) | |
88 { | |
89 return invokeObjcSelf!(void, "replacePointerAtIndex:withPointer:", NSUInteger, void*)(index, item); | |
90 } | |
91 | |
92 void compact () | |
93 { | |
94 return invokeObjcSelf!(void, "compact"); | |
95 } | |
96 | |
97 NSUInteger count () | |
98 { | |
99 return invokeObjcSelf!(NSUInteger, "count"); | |
100 } | |
101 | |
102 void setCount (NSUInteger count) | |
103 { | |
104 return invokeObjcSelf!(void, "setCount:", NSUInteger)(count); | |
105 } | |
106 | |
107 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) | |
108 { | |
109 return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); | |
110 } | |
111 | |
112 Object copyWithZone (NSZone* zone) | |
113 { | |
114 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
115 } | |
116 | |
117 void encodeWithCoder (NSCoder aCoder) | |
118 { | |
119 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
120 } | |
121 | |
122 Object initWithCoder (NSCoder aDecoder) | |
123 { | |
124 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
125 } | |
126 | |
127 this (NSCoder aDecoder) | |
128 { | |
129 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
130 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
131 | |
132 if (result) | |
133 objcObject = ret; | |
134 | |
135 dObject = this; | |
136 } | |
137 } | |
138 | |
139 template TNSArrayConveniences () | |
140 { | |
141 static Object pointerArrayWithStrongObjects () | |
142 { | |
143 return invokeObjcSelfClass!(Object, "pointerArrayWithStrongObjects"); | |
144 } | |
145 | |
146 static Object pointerArrayWithWeakObjects () | |
147 { | |
148 return invokeObjcSelfClass!(Object, "pointerArrayWithWeakObjects"); | |
149 } | |
150 | |
151 NSArray allObjects () | |
152 { | |
153 return invokeObjcSelf!(NSArray, "allObjects"); | |
154 } | |
155 } | |
156 |