Mercurial > projects > dstep
comparison dstep/foundation/NSHashTable.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.NSHashTable; | |
8 | |
9 import dstep.foundation.NSArray; | |
10 import dstep.foundation.NSEnumerator; | |
11 import dstep.foundation.NSHashTable; | |
12 import dstep.foundation.NSPointerFunctions; | |
13 import dstep.foundation.NSSet; | |
14 import dstep.foundation.NSString; | |
15 import dstep.objc.bridge.Bridge; | |
16 import dstep.objc.objc : id; | |
17 | |
18 import bindings = dstep.foundation.NSHashTable_bindings; | |
19 | |
20 alias NSUInteger NSHashTableOptions; | |
21 alias {NSUInteger _pi; NSUInteger _si; void*_bs;} NSHashEnumerator; | |
22 | |
23 extern (C) | |
24 { | |
25 extern | |
26 { | |
27 const NSHashTableCallBacks NSIntegerHashCallBacks; | |
28 const NSHashTableCallBacks NSNonOwnedPointerHashCallBacks; | |
29 const NSHashTableCallBacks NSNonRetainedObjectHashCallBacks; | |
30 const NSHashTableCallBacks NSObjectHashCallBacks; | |
31 const NSHashTableCallBacks NSOwnedObjectIdentityHashCallBacks; | |
32 const NSHashTableCallBacks NSOwnedPointerHashCallBacks; | |
33 const NSHashTableCallBacks NSPointerToStructHashCallBacks; | |
34 } | |
35 } | |
36 | |
37 enum | |
38 { | |
39 NSHashTableStrongMemory = 0, | |
40 NSHashTableZeroingWeakMemory = NSPointerFunctionsZeroingWeakMemory, | |
41 NSHashTableCopyIn = NSPointerFunctionsCopyIn, | |
42 NSHashTableObjectPointerPersonality = NSPointerFunctionsObjectPointerPersonality | |
43 } | |
44 | |
45 struct NSHashEnumerator | |
46 { | |
47 NSUInteger _pi; | |
48 NSUInteger _si; | |
49 void* _bs; | |
50 } | |
51 | |
52 | |
53 struct NSHashTableCallBacks | |
54 { | |
55 } | |
56 | |
57 class NSHashTable : NSObject, INSCopying, INSCoding, INSFastEnumeration | |
58 { | |
59 mixin ObjcWrap; | |
60 | |
61 Object initWithOptions (uint options, NSUInteger initialCapacity) | |
62 { | |
63 return invokeObjcSelf!(Object, "initWithOptions:capacity:", uint, NSUInteger)(options, initialCapacity); | |
64 } | |
65 | |
66 this (uint options, NSUInteger initialCapacity) | |
67 { | |
68 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
69 id result = Bridge.invokeObjcMethod!(id, "initWithOptions:capacity:", uint, NSUInteger)(objcObject, options, initialCapacity); | |
70 | |
71 if (result) | |
72 objcObject = ret; | |
73 | |
74 dObject = this; | |
75 } | |
76 | |
77 Object initWithPointerFunctions (NSPointerFunctions functions, NSUInteger initialCapacity) | |
78 { | |
79 return invokeObjcSelf!(Object, "initWithPointerFunctions:capacity:", NSPointerFunctions, NSUInteger)(functions, initialCapacity); | |
80 } | |
81 | |
82 this (NSPointerFunctions functions, NSUInteger initialCapacity) | |
83 { | |
84 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
85 id result = Bridge.invokeObjcMethod!(id, "initWithPointerFunctions:capacity:", NSPointerFunctions, NSUInteger)(objcObject, functions, initialCapacity); | |
86 | |
87 if (result) | |
88 objcObject = ret; | |
89 | |
90 dObject = this; | |
91 } | |
92 | |
93 static Object hashTableWithOptions (uint options) | |
94 { | |
95 return invokeObjcSelfClass!(Object, "hashTableWithOptions:", uint)(options); | |
96 } | |
97 | |
98 static Object hashTableWithWeakObjects () | |
99 { | |
100 return invokeObjcSelfClass!(Object, "hashTableWithWeakObjects"); | |
101 } | |
102 | |
103 NSPointerFunctions pointerFunctions () | |
104 { | |
105 return invokeObjcSelf!(NSPointerFunctions, "pointerFunctions"); | |
106 } | |
107 | |
108 NSUInteger count () | |
109 { | |
110 return invokeObjcSelf!(NSUInteger, "count"); | |
111 } | |
112 | |
113 Object member (Object object) | |
114 { | |
115 return invokeObjcSelf!(Object, "member:", Object)(object); | |
116 } | |
117 | |
118 NSEnumerator objectEnumerator () | |
119 { | |
120 return invokeObjcSelf!(NSEnumerator, "objectEnumerator"); | |
121 } | |
122 | |
123 void addObject (Object object) | |
124 { | |
125 return invokeObjcSelf!(void, "addObject:", Object)(object); | |
126 } | |
127 | |
128 void removeObject (Object object) | |
129 { | |
130 return invokeObjcSelf!(void, "removeObject:", Object)(object); | |
131 } | |
132 | |
133 void removeAllObjects () | |
134 { | |
135 return invokeObjcSelf!(void, "removeAllObjects"); | |
136 } | |
137 | |
138 NSArray allObjects () | |
139 { | |
140 return invokeObjcSelf!(NSArray, "allObjects"); | |
141 } | |
142 | |
143 Object anyObject () | |
144 { | |
145 return invokeObjcSelf!(Object, "anyObject"); | |
146 } | |
147 | |
148 bool containsObject (Object anObject) | |
149 { | |
150 return invokeObjcSelf!(bool, "containsObject:", Object)(anObject); | |
151 } | |
152 | |
153 bool intersectsHashTable (NSHashTable other) | |
154 { | |
155 return invokeObjcSelf!(bool, "intersectsHashTable:", NSHashTable)(other); | |
156 } | |
157 | |
158 bool isEqualToHashTable (NSHashTable other) | |
159 { | |
160 return invokeObjcSelf!(bool, "isEqualToHashTable:", NSHashTable)(other); | |
161 } | |
162 | |
163 bool isSubsetOfHashTable (NSHashTable other) | |
164 { | |
165 return invokeObjcSelf!(bool, "isSubsetOfHashTable:", NSHashTable)(other); | |
166 } | |
167 | |
168 void intersectHashTable (NSHashTable other) | |
169 { | |
170 return invokeObjcSelf!(void, "intersectHashTable:", NSHashTable)(other); | |
171 } | |
172 | |
173 void unionHashTable (NSHashTable other) | |
174 { | |
175 return invokeObjcSelf!(void, "unionHashTable:", NSHashTable)(other); | |
176 } | |
177 | |
178 void minusHashTable (NSHashTable other) | |
179 { | |
180 return invokeObjcSelf!(void, "minusHashTable:", NSHashTable)(other); | |
181 } | |
182 | |
183 NSSet setRepresentation () | |
184 { | |
185 return invokeObjcSelf!(NSSet, "setRepresentation"); | |
186 } | |
187 | |
188 Object copyWithZone (NSZone* zone) | |
189 { | |
190 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
191 } | |
192 | |
193 void encodeWithCoder (NSCoder aCoder) | |
194 { | |
195 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
196 } | |
197 | |
198 Object initWithCoder (NSCoder aDecoder) | |
199 { | |
200 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
201 } | |
202 | |
203 this (NSCoder aDecoder) | |
204 { | |
205 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
206 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
207 | |
208 if (result) | |
209 objcObject = ret; | |
210 | |
211 dObject = this; | |
212 } | |
213 | |
214 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) | |
215 { | |
216 return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); | |
217 } | |
218 } | |
219 | |
220 void NSFreeHashTable (NSHashTable table) | |
221 { | |
222 return Bridge.invokeObjcFunction!(void, bindings.NSFreeHashTable, NSHashTable)(table); | |
223 } | |
224 | |
225 void NSResetHashTable (NSHashTable table) | |
226 { | |
227 return Bridge.invokeObjcFunction!(void, bindings.NSResetHashTable, NSHashTable)(table); | |
228 } | |
229 | |
230 bool NSCompareHashTables (NSHashTable table1, NSHashTable table2) | |
231 { | |
232 return Bridge.invokeObjcFunction!(bool, bindings.NSCompareHashTables, NSHashTable, NSHashTable)(table1, table2); | |
233 } | |
234 | |
235 NSHashTable NSCopyHashTableWithZone (NSHashTable table, NSZone* zone) | |
236 { | |
237 return Bridge.invokeObjcFunction!(NSHashTable, bindings.NSCopyHashTableWithZone, NSHashTable, NSZone*)(table, zone); | |
238 } | |
239 | |
240 void* NSHashGet (NSHashTable table, void* pointer) | |
241 { | |
242 return Bridge.invokeObjcFunction!(void*, bindings.NSHashGet, NSHashTable, void*)(table, pointer); | |
243 } | |
244 | |
245 void NSHashInsert (NSHashTable table, void* pointer) | |
246 { | |
247 return Bridge.invokeObjcFunction!(void, bindings.NSHashInsert, NSHashTable, void*)(table, pointer); | |
248 } | |
249 | |
250 void NSHashInsertKnownAbsent (NSHashTable table, void* pointer) | |
251 { | |
252 return Bridge.invokeObjcFunction!(void, bindings.NSHashInsertKnownAbsent, NSHashTable, void*)(table, pointer); | |
253 } | |
254 | |
255 void* NSHashInsertIfAbsent (NSHashTable table, void* pointer) | |
256 { | |
257 return Bridge.invokeObjcFunction!(void*, bindings.NSHashInsertIfAbsent, NSHashTable, void*)(table, pointer); | |
258 } | |
259 | |
260 void NSHashRemove (NSHashTable table, void* pointer) | |
261 { | |
262 return Bridge.invokeObjcFunction!(void, bindings.NSHashRemove, NSHashTable, void*)(table, pointer); | |
263 } | |
264 | |
265 NSHashEnumerator NSEnumerateHashTable (NSHashTable table) | |
266 { | |
267 return Bridge.invokeObjcFunction!(NSHashEnumerator, bindings.NSEnumerateHashTable, NSHashTable)(table); | |
268 } | |
269 | |
270 NSUInteger NSCountHashTable (NSHashTable table) | |
271 { | |
272 return Bridge.invokeObjcFunction!(NSUInteger, bindings.NSCountHashTable, NSHashTable)(table); | |
273 } | |
274 | |
275 NSString NSStringFromHashTable (NSHashTable table) | |
276 { | |
277 return Bridge.invokeObjcFunction!(NSString, bindings.NSStringFromHashTable, NSHashTable)(table); | |
278 } | |
279 | |
280 NSArray NSAllHashTableObjects (NSHashTable table) | |
281 { | |
282 return Bridge.invokeObjcFunction!(NSArray, bindings.NSAllHashTableObjects, NSHashTable)(table); | |
283 } | |
284 | |
285 NSHashTable NSCreateHashTableWithZone (NSHashTableCallBacks callBacks, NSUInteger capacity, NSZone* zone) | |
286 { | |
287 return Bridge.invokeObjcFunction!(NSHashTable, bindings.NSCreateHashTableWithZone, NSHashTableCallBacks, NSUInteger, NSZone*)(callBacks, capacity, zone); | |
288 } | |
289 | |
290 NSHashTable NSCreateHashTable (NSHashTableCallBacks callBacks, NSUInteger capacity) | |
291 { | |
292 return Bridge.invokeObjcFunction!(NSHashTable, bindings.NSCreateHashTable, NSHashTableCallBacks, NSUInteger)(callBacks, capacity); | |
293 } | |
294 | |
295 extern (C) | |
296 { | |
297 void* NSNextHashEnumeratorItem (NSHashEnumerator* enumerator); | |
298 void NSEndHashTableEnumeration (NSHashEnumerator* enumerator); | |
299 } |