Mercurial > projects > dstep
annotate dstep/objc/objc.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 | 420969b22201 |
children |
rev | line source |
---|---|
1 | 1 /** |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Feb 1, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.objc.objc; | |
8 | |
9 import dstep.internal.String; | |
10 import dstep.internal.Types; | |
11 import bindings = dstep.objc.bindings; | |
12 import dstep.objc.message; | |
13 import dstep.objc.runtime; | |
14 | |
15 alias objc_object* id; | |
16 alias objc_class* Class; | |
17 alias objc_selector* SEL; | |
18 alias extern (C) id function(id self, SEL op, ...) IMP; | |
19 alias bool BOOL; | |
20 alias char* STR; | |
21 | |
22 alias typeof(null) Nil; | |
23 alias typeof(null) nil; | |
24 | |
25 alias c_long arith_t; | |
26 alias c_ulong uarith_t; | |
27 | |
28 const bool YES = true; | |
29 const bool NO = false; | |
30 | |
31 struct objc_object | |
32 { | |
33 Class isa; | |
34 | |
35 // D Extensions: | |
36 | |
37 string getClassName () | |
38 { | |
39 return fromStringz(bindings.object_getClassName(this)); | |
40 } | |
41 | |
42 Ivar setInstanceVariable (T, string name) (T value) | |
43 { | |
44 return bindings.object_setInstanceVariable(this, name.ptr, value); | |
45 } | |
46 | |
47 Ivar getInstanceVariable (T, string name) (out T outValue) | |
48 { | |
49 return bindings.object_getInstanceVariable(this, name.ptr, &outValue); | |
50 } | |
51 | |
52 objc_property_t* getProperty (string name, bool isRequiredProperty, bool isInstanceProperty) | |
53 { | |
54 return bindings.protocol_getProperty(this, name.toStringz(), isRequiredProperty, isInstanceProperty); | |
55 } | |
56 | |
57 objc_property_t* copyPropertyList (out uint outCount) | |
58 { | |
59 return bindings.protocol_copyPropertyList(this, &outCount); | |
60 } | |
61 | |
62 Protocol** copyProtocolList (out uint outCount) | |
63 { | |
64 return bindings.protocol_copyProtocolList(this, &outCount); | |
65 } | |
66 | |
67 string getName () | |
68 { | |
69 return fromStringz(bindings.protocol_getName(this)); | |
70 } | |
71 | |
72 objc_method_description* copyMethodDescriptionList (bool isRequiredMethod, bool isInstanceMethod, out uint outCount) | |
73 { | |
74 return bindings.protocol_copyMethodDescriptionList(this, isRequiredMethod, isInstanceMethod, &outCount); | |
75 } | |
76 | |
77 id copy (size_t size) | |
78 { | |
79 return bindings.object_copy(this, size); | |
80 } | |
81 | |
82 id dispose () | |
83 { | |
84 return bindings.object_dispose(this); | |
85 } | |
86 | |
87 Class getClass () | |
88 { | |
89 return bindings.object_getClass(this); | |
90 } | |
91 | |
92 Class setClass (Class cls) | |
93 { | |
94 return bindings.object_setClass(this, cls); | |
95 } | |
96 | |
97 void* getIndexedIvars () | |
98 { | |
99 return bindings.object_getIndexedIvars(this); | |
100 } | |
101 | |
102 id getIvar (Ivar ivar) | |
103 { | |
104 return bindings.object_getIvar(this, ivar); | |
105 } | |
106 | |
107 void setIvar (Ivar ivar, Protocol* value) | |
108 { | |
109 return bindings.object_setIvar(this, ivar, value); | |
110 } | |
111 | |
112 bool conformsToProtocol (Protocol* other) | |
113 { | |
114 return bindings.protocol_conformsToProtocol(this, other); | |
115 } | |
116 | |
117 bool isEqual (id other) | |
118 { | |
119 return bindings.protocol_isEqual(this, other); | |
120 } | |
121 | |
122 objc_method_description getMethodDescription (SEL aSel, bool isRequiredMethod, bool isInstanceMethod) | |
123 { | |
124 return bindings.protocol_getMethodDescription(this, aSel, isRequiredMethod, isInstanceMethod); | |
125 } | |
126 | |
127 | |
128 | |
129 // message.h | |
130 | |
131 R msgSend (R = id, ARGS...) (SEL op, ARGS args) | |
132 { | |
6
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
133 alias extern (C) R function (id, SEL, ARGS) fp; |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
134 return (cast(fp)&bindings.objc_msgSend)(this, op, args); |
1 | 135 } |
136 | |
137 void msgSend_stret (T, ARGS...) (out T stretAddr, SEL op, ARGS args) | |
138 { | |
139 if (T.sizeof > STRUCT_SIZE_LIMIT) | |
6
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
140 { |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
141 alias extern (C) void function (T*, id, SEL, ARGS...) fp; |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
142 (cast(fp)&bindings.objc_msgSend_stret)(&stretAddr, this, op, args); |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
143 } |
1 | 144 |
145 else | |
6
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
146 { |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
147 alias extern (C) T function (id, SEL, ARGS) fp; |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
148 stretAddr = (*cast(fp)&bindings.objc_msgSend)(this, op, args); |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
149 } |
1 | 150 } |
151 | |
20 | 152 static if (dstep.internal.Version.X86 || dstep.internal.Version.X86_64) |
1 | 153 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
154 R msgSend_fpret (R, ARGS...) (SEL op, ARGS args) |
1 | 155 { |
156 version (X86_64) | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
157 static assert(is(R == real), "dstep.objc.objc.objc_object.msgSend_fpret: Only real are legal return value for objc_msgSend_fpret"); |
1 | 158 |
159 else | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
160 static assert(is(R == double) || is(R == float), "dstep.objc.objc.objc_object.msgSend_fpret: Only double and float are legal return values for objc_msgSend_fpret"); |
1 | 161 |
6
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
162 alias extern (C) R function (id, SEL, ARGS) fp; |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
163 return (cast(fp)&bindings.objc_msgSend_fpret)(this, op, args); |
1 | 164 } |
165 } | |
166 | |
167 R invoke (R = id, ARGS...) (Method m, ARGS args) | |
168 { | |
6
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
169 alias extern (C) R function (id, SEL, ARGS) fp; |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
170 return (cast(fp)&bindings.method_invoke)(this, m, args); |
1 | 171 } |
172 | |
173 void invoke_stret (ARGS...) (Method m, ARGS args) | |
174 { | |
6
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
175 alias extern (C) R function (id, SEL, ARGS) fp; |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
176 return (cast(fp)&bindings.method_invoke_stret)(this, m, args); |
1 | 177 } |
178 | |
179 R msgSendv (R = id, T) (SEL op, size_t arg_size, T arg_frame) | |
180 { | |
6
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
181 alias extern (C) R function (id, SEL, size_t, T) fp; |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
182 (cast(fp)&bindings.objc_msgSendv)(this, op, arg_size, arg_frame); |
1 | 183 } |
184 | |
185 void msgSendv_stret (R = id, T) (out T stretAddr, SEL op, size_t arg_size, T arg_frame) | |
186 { | |
187 if (R.sizeof > STRUCT_SIZE_LIMIT) | |
6
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
188 { |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
189 alias extern (C) void function (R*, id, SEL, size_t, T) fp; |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
190 (cast(fp)&bindings.objc_msgSendv_stret)(&stretAddr, this, op, arg_size, arg_frame); |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
191 } |
1 | 192 |
193 else | |
6
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
194 { |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
195 alias extern (C) R function (id, SEL, size_t, T) fp; |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
196 stretAddr = (*cast(fp)&bindings.objc_msgSendv)(this, op, arg_size, arg_frame); |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
197 } |
1 | 198 } |
199 | |
200 version (X86) | |
201 { | |
202 R msgSendv_fpret (R = id, T) (SEL op, uint arg_size, T arg_frame) | |
203 { | |
204 static assert(!is(R == double) && !is(R == float), "dstep.objc.objc.objc_object.msgSend_fpret: Only double and float are legal return values for objc_msgSendv_fpret"); | |
6
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
205 alias extern (C) R function (id, SEL, uint, T) fp; |
c0cfd40362ee
Fixed the bridge to work with ldc and dmd. Added a couple of hooks to manipulate the source code
Jacob Carlborg <doob@me.com>
parents:
1
diff
changeset
|
206 return (cast(fp)&bindings.objc_msgSendv_fpret)(this, op, arg_size, arg_frame); |
1 | 207 } |
208 } | |
209 } | |
210 | |
211 struct objc_selector | |
212 { | |
213 void* sel_id; | |
214 char* sel_types; | |
215 | |
216 | |
217 | |
218 // D Extensions: | |
219 | |
220 string getName () | |
221 { | |
222 return fromStringz(bindings.sel_getName(this)); | |
223 } | |
224 | |
225 bool isEqual (SEL rhs) | |
226 { | |
227 return bindings.sel_isEqual(this, rhs); | |
228 } | |
229 | |
230 bool isMapped () | |
231 { | |
232 return bindings.sel_isMapped(this); | |
233 } | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
234 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
235 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
236 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
237 //D Extensions: |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
238 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
239 struct objc |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
240 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
241 static string[] copyImageNames (out uint outCount) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
242 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
243 string[] ret; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
244 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
245 char** result = bindings.objc_copyImageNames(&outCount); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
246 ret.length = outCount; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
247 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
248 for (size_t i = 0; i < outCount; i++) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
249 ret[i] = fromStringz(result[i]); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
250 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
251 return ret; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
252 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
253 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
254 alias bindings.objc_enumerationMutation objc_enumerationMutation; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
255 alias bindings.objc_setForwardHandler objc_setForwardHandler; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
256 alias bindings.objc_setMultithreaded objc_setMultithreaded; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
257 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
258 static id getClass (string name) () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
259 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
260 return bindings.objc_getClass(name.ptr); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
261 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
262 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
263 static id getMetaClass (string name) () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
264 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
265 return bindings.objc_getMetaClass(name.ptr); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
266 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
267 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
268 static id lookUpClass (string name) () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
269 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
270 return bindings.objc_lookUpClass(name.ptr); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
271 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
272 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
273 static id getRequiredClass (string name) () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
274 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
275 return bindings.objc_getRequiredClass(name.ptr); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
276 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
277 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
278 static Class getFutureClass (string name) () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
279 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
280 return bindings.objc_getFutureClass(name.ptr); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
281 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
282 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
283 static string[] objc_copyClassNamesForImage (string image) (out uint outCount) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
284 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
285 string[] ret; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
286 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
287 char** result = bindings.objc_copyClassNamesForImage(image.ptr, &outCount); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
288 ret.length = outCount; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
289 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
290 for (size_t i = 0; i < outCount; i++) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
291 ret[i] = fromStringz(result[i]); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
292 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
293 return ret; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
294 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
295 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
296 static Class objc_getOrigClass (string name) () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
297 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
298 return bindings.objc_getOrigClass(name.ptr); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
299 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
300 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
301 static Class allocateClassPair (string name) (Class superclass, size_t extraBytes) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
302 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
303 return bindings.objc_allocateClassPair(superclass, name.ptr, extraBytes); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
304 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
305 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
306 alias bindings.objc_registerClassPair registerClassPair; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
307 alias bindings.objc_disposeClassPair disposeClassPair; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
308 alias bindings.objc_getClasses getClasses; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
309 alias bindings.objc_addClass addClass; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
310 alias bindings.class_createInstance createInstance; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
311 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
312 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
313 struct property |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
314 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
315 static string getName (objc_property_t* property) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
316 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
317 return fromStringz(bindings.property_getName(property)); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
318 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
319 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
320 static string getAttributes (objc_property_t* property) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
321 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
322 return fromStringz(bindings.property_getAttributes(property)); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
323 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
324 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
325 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
326 struct sel |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
327 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
328 static SEL getUid (string str) () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
329 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
330 return bindings.sel_getUid(str.ptr); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
331 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
332 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
333 static SEL registerName (string str) () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
334 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
335 return bindings.sel_registerName(str.ptr); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
6
diff
changeset
|
336 } |
1 | 337 } |