Mercurial > projects > dstep
comparison dstep/foundation/NSHashTable.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.NSHashTable; | 7 module dstep.foundation.NSHashTable; |
8 | 8 |
9 import dstep.foundation.NSArray; | 9 import dstep.foundation.NSArray; |
10 import dstep.foundation.NSCoder; | |
10 import dstep.foundation.NSEnumerator; | 11 import dstep.foundation.NSEnumerator; |
11 import dstep.foundation.NSHashTable; | 12 import dstep.foundation.NSHashTable; |
13 import dstep.foundation.NSObjCRuntime; | |
14 import dstep.foundation.NSObject; | |
12 import dstep.foundation.NSPointerFunctions; | 15 import dstep.foundation.NSPointerFunctions; |
13 import dstep.foundation.NSSet; | 16 import dstep.foundation.NSSet; |
14 import dstep.foundation.NSString; | 17 import dstep.foundation.NSString; |
18 import dstep.foundation.NSZone; | |
15 import dstep.objc.bridge.Bridge; | 19 import dstep.objc.bridge.Bridge; |
16 import dstep.objc.objc : id; | 20 import dstep.objc.objc; |
21 | |
22 | |
17 | 23 |
18 import bindings = dstep.foundation.NSHashTable_bindings; | 24 import bindings = dstep.foundation.NSHashTable_bindings; |
19 | 25 |
20 alias NSUInteger NSHashTableOptions; | 26 alias NSUInteger NSHashTableOptions; |
21 alias {NSUInteger _pi; NSUInteger _si; void*_bs;} NSHashEnumerator; | |
22 | 27 |
23 extern (C) | 28 extern (C) |
24 { | 29 { |
25 extern | 30 extern |
26 { | 31 { |
50 } | 55 } |
51 | 56 |
52 | 57 |
53 struct NSHashTableCallBacks | 58 struct NSHashTableCallBacks |
54 { | 59 { |
60 extern (C) uint function (id table, /*const*/ void*) hash; | |
61 extern (C) bool function (id table, /*const*/ void*, /*const*/ void*) isEqual; | |
62 extern (C) void function (id table, /*const*/ void*) retain; | |
63 extern (C) uint function (id table, void*) release; | |
64 extern (C) id function (id table, /*const*/ void*) describe; | |
55 } | 65 } |
56 | 66 |
57 class NSHashTable : NSObject, INSCopying, INSCoding, INSFastEnumeration | 67 class NSHashTable : NSObject, INSCopying, INSCoding, INSFastEnumeration |
58 { | 68 { |
59 mixin ObjcWrap; | 69 mixin (ObjcWrap); |
70 | |
71 this () | |
72 { | |
73 super(typeof(this).alloc.init.objcObject); | |
74 } | |
75 | |
76 typeof(this) init () | |
77 { | |
78 return invokeObjcSelf!(typeof(this), "init"); | |
79 } | |
60 | 80 |
61 Object initWithOptions (uint options, NSUInteger initialCapacity) | 81 Object initWithOptions (uint options, NSUInteger initialCapacity) |
62 { | 82 { |
63 return invokeObjcSelf!(Object, "initWithOptions:capacity:", uint, NSUInteger)(options, initialCapacity); | 83 return invokeObjcSelf!(Object, "initWithOptions:capacity:", uint, NSUInteger)(options, initialCapacity); |
64 } | 84 } |
65 | 85 |
66 this (uint options, NSUInteger initialCapacity) | 86 this (uint options, NSUInteger initialCapacity) |
67 { | 87 { |
68 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 88 typeof(this).alloc.initWithOptions(options, initialCapacity); |
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 } | 89 } |
76 | 90 |
77 Object initWithPointerFunctions (NSPointerFunctions functions, NSUInteger initialCapacity) | 91 Object initWithPointerFunctions (NSPointerFunctions functions, NSUInteger initialCapacity) |
78 { | 92 { |
79 return invokeObjcSelf!(Object, "initWithPointerFunctions:capacity:", NSPointerFunctions, NSUInteger)(functions, initialCapacity); | 93 return invokeObjcSelf!(Object, "initWithPointerFunctions:capacity:", NSPointerFunctions, NSUInteger)(functions, initialCapacity); |
80 } | 94 } |
81 | 95 |
82 this (NSPointerFunctions functions, NSUInteger initialCapacity) | 96 this (NSPointerFunctions functions, NSUInteger initialCapacity) |
83 { | 97 { |
84 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 98 typeof(this).alloc.initWithPointerFunctions(functions, initialCapacity); |
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 } | 99 } |
92 | 100 |
93 static Object hashTableWithOptions (uint options) | 101 static Object hashTableWithOptions (uint options) |
94 { | 102 { |
95 return invokeObjcSelfClass!(Object, "hashTableWithOptions:", uint)(options); | 103 return invokeObjcSuperClass!(Object, "hashTableWithOptions:", uint)(options); |
96 } | 104 } |
97 | 105 |
98 static Object hashTableWithWeakObjects () | 106 static Object hashTableWithWeakObjects () |
99 { | 107 { |
100 return invokeObjcSelfClass!(Object, "hashTableWithWeakObjects"); | 108 return invokeObjcSuperClass!(Object, "hashTableWithWeakObjects"); |
101 } | 109 } |
102 | 110 |
103 NSPointerFunctions pointerFunctions () | 111 NSPointerFunctions pointerFunctions () |
104 { | 112 { |
105 return invokeObjcSelf!(NSPointerFunctions, "pointerFunctions"); | 113 return invokeObjcSelf!(NSPointerFunctions, "pointerFunctions"); |
200 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | 208 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); |
201 } | 209 } |
202 | 210 |
203 this (NSCoder aDecoder) | 211 this (NSCoder aDecoder) |
204 { | 212 { |
205 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 213 typeof(this).alloc.initWithCoder(aDecoder); |
206 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
207 | |
208 if (result) | |
209 objcObject = ret; | |
210 | |
211 dObject = this; | |
212 } | 214 } |
213 | 215 |
214 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) | 216 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) |
215 { | 217 { |
216 return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); | 218 return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); |