Mercurial > projects > dstep
annotate dstep/foundation/NSMapTable.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 |
rev | line source |
---|---|
14 | 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.NSMapTable; | |
8 | |
9 import dstep.foundation.NSArray; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
10 import dstep.foundation.NSCoder; |
14 | 11 import dstep.foundation.NSDictionary; |
12 import dstep.foundation.NSEnumerator; | |
13 import dstep.foundation.NSMapTable; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
14 import dstep.foundation.NSObjCRuntime; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
15 import dstep.foundation.NSObject; |
14 | 16 import dstep.foundation.NSPointerFunctions; |
17 import dstep.foundation.NSString; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
18 import dstep.foundation.NSZone; |
14 | 19 import dstep.objc.bridge.Bridge; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
20 import dstep.objc.objc; |
14 | 21 |
22 import bindings = dstep.foundation.NSMapTable_bindings; | |
23 | |
24 alias NSUInteger NSMapTableOptions; | |
25 | |
26 extern (C) | |
27 { | |
28 extern | |
29 { | |
30 const NSMapTableKeyCallBacks NSIntegerMapKeyCallBacks; | |
31 const NSMapTableKeyCallBacks NSNonOwnedPointerMapKeyCallBacks; | |
32 const NSMapTableKeyCallBacks NSNonOwnedPointerOrNullMapKeyCallBacks; | |
33 const NSMapTableKeyCallBacks NSNonRetainedObjectMapKeyCallBacks; | |
34 const NSMapTableKeyCallBacks NSObjectMapKeyCallBacks; | |
35 const NSMapTableKeyCallBacks NSOwnedPointerMapKeyCallBacks; | |
36 const NSMapTableValueCallBacks NSIntegerMapValueCallBacks; | |
37 const NSMapTableValueCallBacks NSNonOwnedPointerMapValueCallBacks; | |
38 const NSMapTableValueCallBacks NSObjectMapValueCallBacks; | |
39 const NSMapTableValueCallBacks NSNonRetainedObjectMapValueCallBacks; | |
40 const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks; | |
41 } | |
42 } | |
43 | |
44 enum | |
45 { | |
46 NSMapTableStrongMemory = 0, | |
47 NSMapTableZeroingWeakMemory = NSPointerFunctionsZeroingWeakMemory, | |
48 NSMapTableCopyIn = NSPointerFunctionsCopyIn, | |
49 NSMapTableObjectPointerPersonality = NSPointerFunctionsObjectPointerPersonality | |
50 } | |
51 | |
52 struct NSMapEnumerator | |
53 { | |
54 NSUInteger _pi; | |
55 NSUInteger _si; | |
56 void* _bs; | |
57 } | |
58 | |
59 | |
60 struct NSMapTableKeyCallBacks | |
61 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
62 extern (C) uint function (id table, /*const*/ void*) hash; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
63 extern (C) bool function (id table, /*const*/ void*, /*const*/ void*) isEqual; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
64 extern (C) void function (id table, /*const*/ void*) retain; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
65 extern (C) void function (id table, void*) release; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
66 extern (C) id function (id table, /*const*/ void*) describe; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
67 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
68 /*const*/ void* notAKeyMarker; |
14 | 69 } |
70 | |
71 struct NSMapTableValueCallBacks | |
72 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
73 extern (C) void function (id table, /*const*/ void*) retain; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
74 extern (C) void function (id table, /*const*/ void*) release; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
75 extern (C) id function (id table, /*const*/ void*) describe; |
14 | 76 } |
77 | |
78 class NSMapTable : NSObject, INSCopying, INSCoding, INSFastEnumeration | |
79 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
80 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
81 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
82 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
83 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
84 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
85 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
86 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
87 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
88 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
89 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
90 } |
14 | 91 |
92 Object initWithKeyOptions (uint keyOptions, uint valueOptions, NSUInteger initialCapacity) | |
93 { | |
94 return invokeObjcSelf!(Object, "initWithKeyOptions:valueOptions:capacity:", uint, uint, NSUInteger)(keyOptions, valueOptions, initialCapacity); | |
95 } | |
96 | |
97 this (uint keyOptions, uint valueOptions, NSUInteger initialCapacity) | |
98 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
99 typeof(this).alloc.initWithKeyOptions(keyOptions, valueOptions, initialCapacity); |
14 | 100 } |
101 | |
102 Object initWithKeyPointerFunctions (NSPointerFunctions keyFunctions, NSPointerFunctions valueFunctions, NSUInteger initialCapacity) | |
103 { | |
104 return invokeObjcSelf!(Object, "initWithKeyPointerFunctions:valuePointerFunctions:capacity:", NSPointerFunctions, NSPointerFunctions, NSUInteger)(keyFunctions, valueFunctions, initialCapacity); | |
105 } | |
106 | |
107 this (NSPointerFunctions keyFunctions, NSPointerFunctions valueFunctions, NSUInteger initialCapacity) | |
108 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
109 typeof(this).alloc.initWithKeyPointerFunctions(keyFunctions, valueFunctions, initialCapacity); |
14 | 110 } |
111 | |
112 static Object mapTableWithKeyOptions (uint keyOptions, uint valueOptions) | |
113 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
114 return invokeObjcSuperClass!(Object, "mapTableWithKeyOptions:valueOptions:", uint, uint)(keyOptions, valueOptions); |
14 | 115 } |
116 | |
117 static Object mapTableWithStrongToStrongObjects () | |
118 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
119 return invokeObjcSuperClass!(Object, "mapTableWithStrongToStrongObjects"); |
14 | 120 } |
121 | |
122 static Object mapTableWithWeakToStrongObjects () | |
123 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
124 return invokeObjcSuperClass!(Object, "mapTableWithWeakToStrongObjects"); |
14 | 125 } |
126 | |
127 static Object mapTableWithStrongToWeakObjects () | |
128 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
129 return invokeObjcSuperClass!(Object, "mapTableWithStrongToWeakObjects"); |
14 | 130 } |
131 | |
132 static Object mapTableWithWeakToWeakObjects () | |
133 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
134 return invokeObjcSuperClass!(Object, "mapTableWithWeakToWeakObjects"); |
14 | 135 } |
136 | |
137 NSPointerFunctions keyPointerFunctions () | |
138 { | |
139 return invokeObjcSelf!(NSPointerFunctions, "keyPointerFunctions"); | |
140 } | |
141 | |
142 NSPointerFunctions valuePointerFunctions () | |
143 { | |
144 return invokeObjcSelf!(NSPointerFunctions, "valuePointerFunctions"); | |
145 } | |
146 | |
147 Object objectForKey (Object aKey) | |
148 { | |
149 return invokeObjcSelf!(Object, "objectForKey:", Object)(aKey); | |
150 } | |
151 | |
152 void removeObjectForKey (Object aKey) | |
153 { | |
154 return invokeObjcSelf!(void, "removeObjectForKey:", Object)(aKey); | |
155 } | |
156 | |
157 void setObject (Object anObject, Object aKey) | |
158 { | |
159 return invokeObjcSelf!(void, "setObject:forKey:", Object, Object)(anObject, aKey); | |
160 } | |
161 | |
162 NSUInteger count () | |
163 { | |
164 return invokeObjcSelf!(NSUInteger, "count"); | |
165 } | |
166 | |
167 NSEnumerator keyEnumerator () | |
168 { | |
169 return invokeObjcSelf!(NSEnumerator, "keyEnumerator"); | |
170 } | |
171 | |
172 NSEnumerator objectEnumerator () | |
173 { | |
174 return invokeObjcSelf!(NSEnumerator, "objectEnumerator"); | |
175 } | |
176 | |
177 void removeAllObjects () | |
178 { | |
179 return invokeObjcSelf!(void, "removeAllObjects"); | |
180 } | |
181 | |
182 NSDictionary dictionaryRepresentation () | |
183 { | |
184 return invokeObjcSelf!(NSDictionary, "dictionaryRepresentation"); | |
185 } | |
186 | |
187 Object copyWithZone (NSZone* zone) | |
188 { | |
189 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
190 } | |
191 | |
192 void encodeWithCoder (NSCoder aCoder) | |
193 { | |
194 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
195 } | |
196 | |
197 Object initWithCoder (NSCoder aDecoder) | |
198 { | |
199 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
200 } | |
201 | |
202 this (NSCoder aDecoder) | |
203 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
204 typeof(this).alloc.initWithCoder(aDecoder); |
14 | 205 } |
206 | |
207 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) | |
208 { | |
209 return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); | |
210 } | |
211 } | |
212 | |
213 void NSFreeMapTable (NSMapTable table) | |
214 { | |
215 return Bridge.invokeObjcFunction!(void, bindings.NSFreeMapTable, NSMapTable)(table); | |
216 } | |
217 | |
218 void NSResetMapTable (NSMapTable table) | |
219 { | |
220 return Bridge.invokeObjcFunction!(void, bindings.NSResetMapTable, NSMapTable)(table); | |
221 } | |
222 | |
223 bool NSCompareMapTables (NSMapTable table1, NSMapTable table2) | |
224 { | |
225 return Bridge.invokeObjcFunction!(bool, bindings.NSCompareMapTables, NSMapTable, NSMapTable)(table1, table2); | |
226 } | |
227 | |
228 NSMapTable NSCopyMapTableWithZone (NSMapTable table, NSZone* zone) | |
229 { | |
230 return Bridge.invokeObjcFunction!(NSMapTable, bindings.NSCopyMapTableWithZone, NSMapTable, NSZone*)(table, zone); | |
231 } | |
232 | |
233 bool NSMapMember (NSMapTable table, void* key, void** originalKey, void** value) | |
234 { | |
235 return Bridge.invokeObjcFunction!(bool, bindings.NSMapMember, NSMapTable, void*, void**, void**)(table, key, originalKey, value); | |
236 } | |
237 | |
238 void* NSMapGet (NSMapTable table, void* key) | |
239 { | |
240 return Bridge.invokeObjcFunction!(void*, bindings.NSMapGet, NSMapTable, void*)(table, key); | |
241 } | |
242 | |
243 void NSMapInsert (NSMapTable table, void* key, void* value) | |
244 { | |
245 return Bridge.invokeObjcFunction!(void, bindings.NSMapInsert, NSMapTable, void*, void*)(table, key, value); | |
246 } | |
247 | |
248 void NSMapInsertKnownAbsent (NSMapTable table, void* key, void* value) | |
249 { | |
250 return Bridge.invokeObjcFunction!(void, bindings.NSMapInsertKnownAbsent, NSMapTable, void*, void*)(table, key, value); | |
251 } | |
252 | |
253 void* NSMapInsertIfAbsent (NSMapTable table, void* key, void* value) | |
254 { | |
255 return Bridge.invokeObjcFunction!(void*, bindings.NSMapInsertIfAbsent, NSMapTable, void*, void*)(table, key, value); | |
256 } | |
257 | |
258 void NSMapRemove (NSMapTable table, void* key) | |
259 { | |
260 return Bridge.invokeObjcFunction!(void, bindings.NSMapRemove, NSMapTable, void*)(table, key); | |
261 } | |
262 | |
263 NSMapEnumerator NSEnumerateMapTable (NSMapTable table) | |
264 { | |
265 return Bridge.invokeObjcFunction!(NSMapEnumerator, bindings.NSEnumerateMapTable, NSMapTable)(table); | |
266 } | |
267 | |
268 NSUInteger NSCountMapTable (NSMapTable table) | |
269 { | |
270 return Bridge.invokeObjcFunction!(NSUInteger, bindings.NSCountMapTable, NSMapTable)(table); | |
271 } | |
272 | |
273 NSString NSStringFromMapTable (NSMapTable table) | |
274 { | |
275 return Bridge.invokeObjcFunction!(NSString, bindings.NSStringFromMapTable, NSMapTable)(table); | |
276 } | |
277 | |
278 NSArray NSAllMapTableKeys (NSMapTable table) | |
279 { | |
280 return Bridge.invokeObjcFunction!(NSArray, bindings.NSAllMapTableKeys, NSMapTable)(table); | |
281 } | |
282 | |
283 NSArray NSAllMapTableValues (NSMapTable table) | |
284 { | |
285 return Bridge.invokeObjcFunction!(NSArray, bindings.NSAllMapTableValues, NSMapTable)(table); | |
286 } | |
287 | |
288 NSMapTable NSCreateMapTableWithZone (NSMapTableKeyCallBacks keyCallBacks, NSMapTableValueCallBacks valueCallBacks, NSUInteger capacity, NSZone* zone) | |
289 { | |
290 return Bridge.invokeObjcFunction!(NSMapTable, bindings.NSCreateMapTableWithZone, NSMapTableKeyCallBacks, NSMapTableValueCallBacks, NSUInteger, NSZone*)(keyCallBacks, valueCallBacks, capacity, zone); | |
291 } | |
292 | |
293 NSMapTable NSCreateMapTable (NSMapTableKeyCallBacks keyCallBacks, NSMapTableValueCallBacks valueCallBacks, NSUInteger capacity) | |
294 { | |
295 return Bridge.invokeObjcFunction!(NSMapTable, bindings.NSCreateMapTable, NSMapTableKeyCallBacks, NSMapTableValueCallBacks, NSUInteger)(keyCallBacks, valueCallBacks, capacity); | |
296 } | |
297 | |
298 extern (C) | |
299 { | |
300 bool NSNextMapEnumeratorPair (NSMapEnumerator* enumerator, void** key, void** value); | |
301 void NSEndMapTableEnumeration (NSMapEnumerator* enumerator); | |
302 } |