Mercurial > projects > dstep
comparison dstep/foundation/NSPointerArray.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.NSPointerArray; | 7 module dstep.foundation.NSPointerArray; |
8 | 8 |
9 import dstep.foundation.NSArray; | 9 import dstep.foundation.NSArray; |
10 import dstep.foundation.NSCoder; | |
11 import dstep.foundation.NSEnumerator; | |
12 import dstep.foundation.NSObjCRuntime; | |
10 import dstep.foundation.NSObject; | 13 import dstep.foundation.NSObject; |
11 import dstep.foundation.NSPointerFunctions; | 14 import dstep.foundation.NSPointerFunctions; |
15 import dstep.foundation.NSZone; | |
12 import dstep.objc.bridge.Bridge; | 16 import dstep.objc.bridge.Bridge; |
13 import dstep.objc.objc : id; | 17 import dstep.objc.objc; |
18 | |
19 const TNSArrayConveniences = ` | |
20 | |
21 static Object pointerArrayWithStrongObjects () | |
22 { | |
23 return invokeObjcSuperClass!(Object, "pointerArrayWithStrongObjects"); | |
24 } | |
25 | |
26 static Object pointerArrayWithWeakObjects () | |
27 { | |
28 return invokeObjcSuperClass!(Object, "pointerArrayWithWeakObjects"); | |
29 } | |
30 | |
31 NSArray allObjects () | |
32 { | |
33 return invokeObjcSelf!(NSArray, "allObjects"); | |
34 } | |
35 `; | |
14 | 36 |
15 class NSPointerArray : NSObject, INSFastEnumeration, INSCopying, INSCoding | 37 class NSPointerArray : NSObject, INSFastEnumeration, INSCopying, INSCoding |
16 { | 38 { |
17 mixin ObjcWrap; | 39 mixin (ObjcWrap); |
18 mixin TNSArrayConveniences; | 40 |
41 this () | |
42 { | |
43 super(typeof(this).alloc.init.objcObject); | |
44 } | |
45 | |
46 typeof(this) init () | |
47 { | |
48 return invokeObjcSelf!(typeof(this), "init"); | |
49 } | |
19 | 50 |
20 Object initWithOptions (uint options) | 51 Object initWithOptions (uint options) |
21 { | 52 { |
22 return invokeObjcSelf!(Object, "initWithOptions:", uint)(options); | 53 return invokeObjcSelf!(Object, "initWithOptions:", uint)(options); |
23 } | 54 } |
24 | 55 |
25 this (uint options) | 56 this (uint options) |
26 { | 57 { |
27 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 58 typeof(this).alloc.initWithOptions(options); |
28 id result = Bridge.invokeObjcMethod!(id, "initWithOptions:", uint)(objcObject, options); | |
29 | |
30 if (result) | |
31 objcObject = ret; | |
32 | |
33 dObject = this; | |
34 } | 59 } |
35 | 60 |
36 Object initWithPointerFunctions (NSPointerFunctions functions) | 61 Object initWithPointerFunctions (NSPointerFunctions functions) |
37 { | 62 { |
38 return invokeObjcSelf!(Object, "initWithPointerFunctions:", NSPointerFunctions)(functions); | 63 return invokeObjcSelf!(Object, "initWithPointerFunctions:", NSPointerFunctions)(functions); |
39 } | 64 } |
40 | 65 |
41 this (NSPointerFunctions functions) | 66 this (NSPointerFunctions functions) |
42 { | 67 { |
43 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 68 typeof(this).alloc.initWithPointerFunctions(functions); |
44 id result = Bridge.invokeObjcMethod!(id, "initWithPointerFunctions:", NSPointerFunctions)(objcObject, functions); | |
45 | |
46 if (result) | |
47 objcObject = ret; | |
48 | |
49 dObject = this; | |
50 } | 69 } |
51 | 70 |
52 static Object pointerArrayWithOptions (uint options) | 71 static Object pointerArrayWithOptions (uint options) |
53 { | 72 { |
54 return invokeObjcSelfClass!(Object, "pointerArrayWithOptions:", uint)(options); | 73 return invokeObjcSuperClass!(Object, "pointerArrayWithOptions:", uint)(options); |
55 } | 74 } |
56 | 75 |
57 static Object pointerArrayWithPointerFunctions (NSPointerFunctions functions) | 76 static Object pointerArrayWithPointerFunctions (NSPointerFunctions functions) |
58 { | 77 { |
59 return invokeObjcSelfClass!(Object, "pointerArrayWithPointerFunctions:", NSPointerFunctions)(functions); | 78 return invokeObjcSuperClass!(Object, "pointerArrayWithPointerFunctions:", NSPointerFunctions)(functions); |
60 } | 79 } |
61 | 80 |
62 NSPointerFunctions pointerFunctions () | 81 NSPointerFunctions pointerFunctions () |
63 { | 82 { |
64 return invokeObjcSelf!(NSPointerFunctions, "pointerFunctions"); | 83 return invokeObjcSelf!(NSPointerFunctions, "pointerFunctions"); |
124 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | 143 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); |
125 } | 144 } |
126 | 145 |
127 this (NSCoder aDecoder) | 146 this (NSCoder aDecoder) |
128 { | 147 { |
129 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 148 typeof(this).alloc.initWithCoder(aDecoder); |
130 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
131 | |
132 if (result) | |
133 objcObject = ret; | |
134 | |
135 dObject = this; | |
136 } | 149 } |
137 } | 150 |
138 | 151 // TNSArrayConveniences |
139 template TNSArrayConveniences () | |
140 { | |
141 static Object pointerArrayWithStrongObjects () | 152 static Object pointerArrayWithStrongObjects () |
142 { | 153 { |
143 return invokeObjcSelfClass!(Object, "pointerArrayWithStrongObjects"); | 154 return invokeObjcSuperClass!(Object, "pointerArrayWithStrongObjects"); |
144 } | 155 } |
145 | 156 |
146 static Object pointerArrayWithWeakObjects () | 157 static Object pointerArrayWithWeakObjects () |
147 { | 158 { |
148 return invokeObjcSelfClass!(Object, "pointerArrayWithWeakObjects"); | 159 return invokeObjcSuperClass!(Object, "pointerArrayWithWeakObjects"); |
149 } | 160 } |
150 | 161 |
151 NSArray allObjects () | 162 NSArray allObjects () |
152 { | 163 { |
153 return invokeObjcSelf!(NSArray, "allObjects"); | 164 return invokeObjcSelf!(NSArray, "allObjects"); |
154 } | 165 } |
155 } | 166 } |
156 |