Mercurial > projects > dstep
annotate dstep/foundation/NSPointerArray.d @ 27:57371c29ef73 default tip
ObjcWrap is now automatically mixed in. Added support for building as a dylib with DMD.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Fri, 09 Apr 2010 23:00:22 +0200 |
parents | b9de51448c6b |
children |
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.NSPointerArray; | |
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; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
11 import dstep.foundation.NSEnumerator; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
12 import dstep.foundation.NSObjCRuntime; |
14 | 13 import dstep.foundation.NSObject; |
14 import dstep.foundation.NSPointerFunctions; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
15 import dstep.foundation.NSZone; |
14 | 16 import dstep.objc.bridge.Bridge; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
17 import dstep.objc.objc; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
18 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
19 const TNSArrayConveniences = ` |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
20 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
21 static Object pointerArrayWithStrongObjects () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
22 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
23 return invokeObjcSuperClass!(Object, "pointerArrayWithStrongObjects"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
24 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
25 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
26 static Object pointerArrayWithWeakObjects () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
27 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
28 return invokeObjcSuperClass!(Object, "pointerArrayWithWeakObjects"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
29 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
30 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
31 NSArray allObjects () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
32 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
33 return invokeObjcSelf!(NSArray, "allObjects"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
34 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
35 `; |
14 | 36 |
37 class NSPointerArray : NSObject, INSFastEnumeration, INSCopying, INSCoding | |
38 { | |
25
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
39 mixin ObjcWrap; |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
40 |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
41 this (id object) |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
42 { |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
43 super(object); |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
44 } |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
45 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
46 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
47 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
48 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
49 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
50 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
51 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
52 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
53 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
54 } |
14 | 55 |
56 Object initWithOptions (uint options) | |
57 { | |
58 return invokeObjcSelf!(Object, "initWithOptions:", uint)(options); | |
59 } | |
60 | |
61 this (uint options) | |
62 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
63 typeof(this).alloc.initWithOptions(options); |
14 | 64 } |
65 | |
66 Object initWithPointerFunctions (NSPointerFunctions functions) | |
67 { | |
68 return invokeObjcSelf!(Object, "initWithPointerFunctions:", NSPointerFunctions)(functions); | |
69 } | |
70 | |
71 this (NSPointerFunctions functions) | |
72 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
73 typeof(this).alloc.initWithPointerFunctions(functions); |
14 | 74 } |
75 | |
76 static Object pointerArrayWithOptions (uint options) | |
77 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
78 return invokeObjcSuperClass!(Object, "pointerArrayWithOptions:", uint)(options); |
14 | 79 } |
80 | |
81 static Object pointerArrayWithPointerFunctions (NSPointerFunctions functions) | |
82 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
83 return invokeObjcSuperClass!(Object, "pointerArrayWithPointerFunctions:", NSPointerFunctions)(functions); |
14 | 84 } |
85 | |
86 NSPointerFunctions pointerFunctions () | |
87 { | |
88 return invokeObjcSelf!(NSPointerFunctions, "pointerFunctions"); | |
89 } | |
90 | |
91 void* pointerAtIndex (NSUInteger index) | |
92 { | |
93 return invokeObjcSelf!(void*, "pointerAtIndex:", NSUInteger)(index); | |
94 } | |
95 | |
96 void addPointer (void* pointer) | |
97 { | |
98 return invokeObjcSelf!(void, "addPointer:", void*)(pointer); | |
99 } | |
100 | |
101 void removePointerAtIndex (NSUInteger index) | |
102 { | |
103 return invokeObjcSelf!(void, "removePointerAtIndex:", NSUInteger)(index); | |
104 } | |
105 | |
106 void insertPointer (void* item, NSUInteger index) | |
107 { | |
108 return invokeObjcSelf!(void, "insertPointer:atIndex:", void*, NSUInteger)(item, index); | |
109 } | |
110 | |
111 void replacePointerAtIndex (NSUInteger index, void* item) | |
112 { | |
113 return invokeObjcSelf!(void, "replacePointerAtIndex:withPointer:", NSUInteger, void*)(index, item); | |
114 } | |
115 | |
116 void compact () | |
117 { | |
118 return invokeObjcSelf!(void, "compact"); | |
119 } | |
120 | |
121 NSUInteger count () | |
122 { | |
123 return invokeObjcSelf!(NSUInteger, "count"); | |
124 } | |
125 | |
126 void setCount (NSUInteger count) | |
127 { | |
128 return invokeObjcSelf!(void, "setCount:", NSUInteger)(count); | |
129 } | |
130 | |
131 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) | |
132 { | |
133 return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); | |
134 } | |
135 | |
136 Object copyWithZone (NSZone* zone) | |
137 { | |
138 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
139 } | |
140 | |
141 void encodeWithCoder (NSCoder aCoder) | |
142 { | |
143 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
144 } | |
145 | |
146 Object initWithCoder (NSCoder aDecoder) | |
147 { | |
148 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
149 } | |
150 | |
151 this (NSCoder aDecoder) | |
152 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
153 typeof(this).alloc.initWithCoder(aDecoder); |
14 | 154 } |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
155 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
156 // TNSArrayConveniences |
14 | 157 static Object pointerArrayWithStrongObjects () |
158 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
159 return invokeObjcSuperClass!(Object, "pointerArrayWithStrongObjects"); |
14 | 160 } |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
161 |
14 | 162 static Object pointerArrayWithWeakObjects () |
163 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
164 return invokeObjcSuperClass!(Object, "pointerArrayWithWeakObjects"); |
14 | 165 } |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
166 |
14 | 167 NSArray allObjects () |
168 { | |
169 return invokeObjcSelf!(NSArray, "allObjects"); | |
170 } | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
171 } |