Mercurial > projects > dwt-mac
comparison dwt/internal/objc/runtime.d @ 1:8b48be5454ce
The internal cocoa classes compile now
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Tue, 19 Aug 2008 17:35:17 +0200 |
parents | 380af2bdd8e5 |
children | e831403a80a9 762fbe6f17d3 |
comparison
equal
deleted
inserted
replaced
0:380af2bdd8e5 | 1:8b48be5454ce |
---|---|
8 module dwt.internal.objc.runtime; | 8 module dwt.internal.objc.runtime; |
9 | 9 |
10 import tango.stdc.stringz : fromStringz, toStringz; | 10 import tango.stdc.stringz : fromStringz, toStringz; |
11 | 11 |
12 import dwt.dwthelper.utils : string; | 12 import dwt.dwthelper.utils : string; |
13 import dwt.internal.cocoa.NSPoint; | |
14 import dwt.internal.cocoa.NSRange; | |
15 import dwt.internal.cocoa.NSSize; | |
13 static import dwt.internal.objc.bindings; | 16 static import dwt.internal.objc.bindings; |
17 | |
18 | |
14 | 19 |
15 alias objc_ivar* Ivar; | 20 alias objc_ivar* Ivar; |
16 alias objc_method* Method; | 21 alias objc_method* Method; |
17 alias objc_object Protocol; | 22 alias objc_object Protocol; |
18 | 23 |
100 objc_protocol_list* next; | 105 objc_protocol_list* next; |
101 long count; | 106 long count; |
102 Protocol* list[1]; | 107 Protocol* list[1]; |
103 } | 108 } |
104 | 109 |
105 template Runtime () | 110 |
106 { | 111 |
107 alias dwt.internal.objc.bindings.objc_msgSendSuper objc_msgSendSuper; | 112 alias dwt.internal.objc.bindings.objc_registerClassPair objc_registerClassPair; |
108 alias dwt.internal.objc.bindings.objc_registerClassPair objc_registerClassPair; | 113 |
109 alias dwt.internal.objc.bindings.objc_msgSend objc_msgSend; | 114 bool class_addIvar (Class cls, string name, size_t size, byte alignment, string types) |
110 alias dwt.internal.objc.bindings.objc_msgSend_fpret objc_msgSend_fpret; | 115 { |
111 alias dwt.internal.objc.bindings.objc_msgSend_stret objc_msgSend_stret; | 116 return dwt.internal.objc.bindings.class_addIvar(cls, name.ptr, size, alignment, types.ptr); |
112 | 117 } |
113 bool class_addIvar (Class cls, string name, size_t size, byte alignment, string types) | 118 |
119 bool class_addMethod (Class cls, SEL name, IMP imp, string types) | |
120 { | |
121 return dwt.internal.objc.bindings.class_addMethod(cls, name, imp, types.ptr); | |
122 } | |
123 | |
124 Class objc_allocateClassPair (Class superclass, string name, size_t extraBytes) | |
125 { | |
126 return dwt.internal.objc.bindings.objc_allocateClassPair(superclass, name.ptr, extraBytes); | |
127 } | |
128 | |
129 id objc_getClass (string name) | |
130 { | |
131 return dwt.internal.objc.bindings.objc_getClass(name.ptr); | |
132 } | |
133 | |
134 id objc_lookUpClass (string name) | |
135 { | |
136 return dwt.internal.objc.bindings.objc_lookUpClass(name.ptr); | |
137 } | |
138 | |
139 string object_getClassName (id obj) | |
140 { | |
141 return fromStringz(dwt.internal.objc.bindings.object_getClassName(obj)); | |
142 } | |
143 | |
144 Ivar object_getInstanceVariable (id obj, string name, void** outValue) | |
145 { | |
146 return dwt.internal.objc.bindings.object_getInstanceVariable(obj, name.ptr, outValue); | |
147 } | |
148 | |
149 Ivar object_setInstanceVariable (id obj, string name, void* value) | |
150 { | |
151 return dwt.internal.objc.bindings.object_setInstanceVariable(obj, name.ptr, value); | |
152 } | |
153 | |
154 string sel_registerName (string str) | |
155 { | |
156 return fromStringz(dwt.internal.objc.bindings.sel_registerName(str.ptr)); | |
157 } | |
158 | |
159 id objc_msgSend (ARGS...)(id theReceiver, string theSelector, ARGS args) | |
160 { | |
161 return dwt.internal.objc.bindings.objc_msgSend(theReceiver, theSelector.ptr, args); | |
162 } | |
163 | |
164 /// dummy function for now | |
165 int objc_msgSend_struct (T, ARGS...)(T* result, id theReceiver, string theSelector, ARGS args) | |
166 { | |
167 //result = *cast(T) dwt.internal.objc.bindings.objc_msgSend(theReceiver, theSelector.ptr, args); | |
168 return 0; | |
169 } | |
170 | |
171 void objc_msgSend_stret (T, ARGS...)(T* stretAddr, id theReceiver, string theSelector, ARGS args) | |
172 { | |
173 dwt.internal.objc.bindings.objc_msgSend_stret(stretAddr, theReceiver, theSelector.ptr, args); | |
174 } | |
175 | |
176 id objc_msgSendSuper (ARGS...)(objc_super* superr, string op, ARGS args) | |
177 { | |
178 return dwt.internal.objc.bindings.objc_msgSendSuper(superr, op.ptr, args); | |
179 } | |
180 | |
181 version (X86) | |
182 { | |
183 double objc_msgSend_fpret(ARGS...)(id self, string op, ARGS args) | |
114 { | 184 { |
115 return dwt.internal.objc.bindings.class_addIvar(cls, name.toStringz(), size, alignment, types.toStringz()); | 185 return dwt.internal.objc.bindings.objc_msgSend_fpret(self, op.ptr, args); |
116 } | |
117 | |
118 bool class_addMethod (Class cls, SEL name, IMP imp, string types) | |
119 { | |
120 return dwt.internal.objc.bindings.class_addMethod(cls, name, imp, types.toStringz()); | |
121 } | |
122 | |
123 Class objc_allocateClassPair (Class superclass, string name, size_t extraBytes) | |
124 { | |
125 return dwt.internal.objc.bindings.objc_allocateClassPair(superclass, name.toStringz(), extraBytes); | |
126 } | |
127 | |
128 id objc_getClass (string name) | |
129 { | |
130 return dwt.internal.objc.bindings.objc_getClass(name.toStringz()); | |
131 } | |
132 | |
133 id objc_lookUpClass (string name) | |
134 { | |
135 return dwt.internal.objc.bindings.objc_lookUpClass(name.toStringz()); | |
136 } | |
137 | |
138 string object_getClassName (id obj) | |
139 { | |
140 return fromStringz(dwt.internal.objc.bindings.object_getClassName(obj)); | |
141 } | |
142 | |
143 Ivar object_getInstanceVariable (id obj, string name, void** outValue) | |
144 { | |
145 return dwt.internal.objc.bindings.object_getInstanceVariable(obj, name.toStringz(), outValue); | |
146 } | |
147 | |
148 Ivar object_setInstanceVariable (id obj, string name, void* value) | |
149 { | |
150 return dwt.internal.objc.bindings.object_setInstanceVariable(obj, name.toStringz(), value); | |
151 } | |
152 | |
153 string sel_registerName (string str) | |
154 { | |
155 return fromStringz(dwt.internal.objc.bindings.sel_registerName(str.toStringz())); | |
156 } | 186 } |
157 } | 187 } |