comparison dstep/foundation/NSCalendar.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.NSCalendar; 7 module dstep.foundation.NSCalendar;
8 8
9 import dstep.corefoundation.CFCalendar; 9 import dstep.corefoundation.CFCalendar;
10 import dstep.foundation.NSCoder;
10 import dstep.foundation.NSDate; 11 import dstep.foundation.NSDate;
11 import dstep.foundation.NSDateComponents;
12 import dstep.foundation.NSLocale; 12 import dstep.foundation.NSLocale;
13 import dstep.foundation.NSObjCRuntime;
13 import dstep.foundation.NSObject; 14 import dstep.foundation.NSObject;
14 import dstep.foundation.NSRange; 15 import dstep.foundation.NSRange;
15 import dstep.foundation.NSString; 16 import dstep.foundation.NSString;
16 import dstep.foundation.NSTimeZone; 17 import dstep.foundation.NSTimeZone;
18 import dstep.foundation.NSZone;
17 import dstep.objc.bridge.Bridge; 19 import dstep.objc.bridge.Bridge;
18 import dstep.objc.objc : id; 20 import dstep.objc.objc;
19 21
20 alias NSUInteger NSCalendarUnit; 22 alias NSUInteger NSCalendarUnit;
21 23
22 enum 24 enum
23 { 25 {
43 NSUndefinedDateComponent = 2147483647L 45 NSUndefinedDateComponent = 2147483647L
44 } 46 }
45 47
46 class NSDateComponents : NSObject, INSCopying, INSCoding 48 class NSDateComponents : NSObject, INSCopying, INSCoding
47 { 49 {
48 mixin ObjcWrap; 50 mixin (ObjcWrap);
51
52 this ()
53 {
54 super(typeof(this).alloc.init.objcObject);
55 }
56
57 typeof(this) init ()
58 {
59 return invokeObjcSelf!(typeof(this), "init");
60 }
49 61
50 NSInteger era () 62 NSInteger era ()
51 { 63 {
52 return invokeObjcSelf!(NSInteger, "era"); 64 return invokeObjcSelf!(NSInteger, "era");
53 } 65 }
162 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); 174 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
163 } 175 }
164 176
165 this (NSCoder aDecoder) 177 this (NSCoder aDecoder)
166 { 178 {
167 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); 179 typeof(this).alloc.initWithCoder(aDecoder);
168 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder);
169
170 if (result)
171 objcObject = ret;
172
173 dObject = this;
174 } 180 }
175 } 181 }
176 182
177 class NSCalendar : NSObject, INSCopying, INSCoding 183 class NSCalendar : NSObject, INSCopying, INSCoding
178 { 184 {
179 mixin ObjcWrap; 185 mixin (ObjcWrap);
186
187 this ()
188 {
189 super(typeof(this).alloc.init.objcObject);
190 }
191
192 typeof(this) init ()
193 {
194 return invokeObjcSelf!(typeof(this), "init");
195 }
180 196
181 static Object currentCalendar () 197 static Object currentCalendar ()
182 { 198 {
183 return invokeObjcSelfClass!(Object, "currentCalendar"); 199 return invokeObjcSuperClass!(Object, "currentCalendar");
184 } 200 }
185 201
186 static Object autoupdatingCurrentCalendar () 202 static Object autoupdatingCurrentCalendar ()
187 { 203 {
188 return invokeObjcSelfClass!(Object, "autoupdatingCurrentCalendar"); 204 return invokeObjcSuperClass!(Object, "autoupdatingCurrentCalendar");
189 } 205 }
190 206
191 Object initWithCalendarIdentifier (NSString ident) 207 Object initWithCalendarIdentifier (NSString ident)
192 { 208 {
193 return invokeObjcSelf!(Object, "initWithCalendarIdentifier:", NSString)(ident); 209 return invokeObjcSelf!(Object, "initWithCalendarIdentifier:", NSString)(ident);
194 } 210 }
195 211
196 this (NSString ident) 212 this (NSString ident)
197 { 213 {
198 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); 214 typeof(this).alloc.initWithCalendarIdentifier(ident);
199 id result = Bridge.invokeObjcMethod!(id, "initWithCalendarIdentifier:", NSString)(objcObject, ident);
200
201 if (result)
202 objcObject = ret;
203
204 dObject = this;
205 } 215 }
206 216
207 NSString calendarIdentifier () 217 NSString calendarIdentifier ()
208 { 218 {
209 return invokeObjcSelf!(NSString, "calendarIdentifier"); 219 return invokeObjcSelf!(NSString, "calendarIdentifier");
267 NSUInteger ordinalityOfUnit (uint smaller, uint larger, NSDate date) 277 NSUInteger ordinalityOfUnit (uint smaller, uint larger, NSDate date)
268 { 278 {
269 return invokeObjcSelf!(NSUInteger, "ordinalityOfUnit:inUnit:forDate:", uint, uint, NSDate)(smaller, larger, date); 279 return invokeObjcSelf!(NSUInteger, "ordinalityOfUnit:inUnit:forDate:", uint, uint, NSDate)(smaller, larger, date);
270 } 280 }
271 281
272 bool rangeOfUnit (uint unit, NSDate** datep, NSTimeInterval* tip, NSDate date) 282 bool rangeOfUnit (uint unit, out NSDate datep, NSTimeInterval* tip, NSDate date)
273 { 283 {
274 return invokeObjcSelf!(bool, "rangeOfUnit:startDate:interval:forDate:", uint, NSDate**, NSTimeInterval*, NSDate)(unit, datep, tip, date); 284 id d = new objc_object;
285 bool result = invokeObjcSelf!(bool, "rangeOfUnit:startDate:interval:forDate:", uint, id*, NSTimeInterval*, NSDate)(unit, &d, tip, date);
286
287 if (d)
288 datep = new NSDate(d);
289
290 return result;
275 } 291 }
276 292
277 NSDate dateFromComponents (NSDateComponents comps) 293 NSDate dateFromComponents (NSDateComponents comps)
278 { 294 {
279 return invokeObjcSelf!(NSDate, "dateFromComponents:", NSDateComponents)(comps); 295 return invokeObjcSelf!(NSDate, "dateFromComponents:", NSDateComponents)(comps);
309 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); 325 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
310 } 326 }
311 327
312 this (NSCoder aDecoder) 328 this (NSCoder aDecoder)
313 { 329 {
314 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); 330 typeof(this).alloc.initWithCoder(aDecoder);
315 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); 331 }
316 332 }
317 if (result) 333
318 objcObject = ret;
319
320 dObject = this;
321 }
322 }
323