Mercurial > projects > dstep
comparison dstep/foundation/NSCalendarDate.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 | 7ff919f595d5 |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
6 */ | 6 */ |
7 module dstep.foundation.NSCalendarDate; | 7 module dstep.foundation.NSCalendarDate; |
8 | 8 |
9 import dstep.foundation.NSArray; | 9 import dstep.foundation.NSArray; |
10 import dstep.foundation.NSDate; | 10 import dstep.foundation.NSDate; |
11 import dstep.foundation.NSObjCRuntime; | |
11 import dstep.foundation.NSString; | 12 import dstep.foundation.NSString; |
12 import dstep.foundation.NSTimeZone; | 13 import dstep.foundation.NSTimeZone; |
13 import dstep.objc.bridge.Bridge; | 14 import dstep.objc.bridge.Bridge; |
14 import dstep.objc.objc : id; | 15 import dstep.objc.objc; |
16 | |
17 const TNSNaturalLangage = ` | |
18 | |
19 static Object dateWithNaturalLanguageString (NSString string) | |
20 { | |
21 return invokeObjcSuperClass!(Object, "dateWithNaturalLanguageString:", NSString)(string); | |
22 } | |
23 | |
24 static Object dateWithNaturalLanguageString (NSString string, Object locale) | |
25 { | |
26 return invokeObjcSuperClass!(Object, "dateWithNaturalLanguageString:locale:", NSString, Object)(string, locale); | |
27 } | |
28 `; | |
29 | |
30 const TNSCalendarDateExtras = ` | |
31 | |
32 static Object dateWithString (NSString aString) | |
33 { | |
34 return invokeObjcSuperClass!(Object, "dateWithString:", NSString)(aString); | |
35 } | |
36 | |
37 Object initWithString (NSString description) | |
38 { | |
39 return invokeObjcSelf!(Object, "initWithString:", NSString)(description); | |
40 } | |
41 | |
42 this (NSString description) | |
43 { | |
44 typeof(this).alloc.initWithString(description); | |
45 } | |
46 | |
47 NSCalendarDate dateWithCalendarFormat (NSString format, NSTimeZone aTimeZone) | |
48 { | |
49 return invokeObjcSelf!(NSCalendarDate, "dateWithCalendarFormat:timeZone:", NSString, NSTimeZone)(format, aTimeZone); | |
50 } | |
51 | |
52 NSString descriptionWithLocale (Object locale) | |
53 { | |
54 return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); | |
55 } | |
56 | |
57 NSString descriptionWithCalendarFormat (NSString format, NSTimeZone aTimeZone, Object locale) | |
58 { | |
59 return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:timeZone:locale:", NSString, NSTimeZone, Object)(format, aTimeZone, locale); | |
60 } | |
61 `; | |
15 | 62 |
16 class NSCalendarDate : NSDate | 63 class NSCalendarDate : NSDate |
17 { | 64 { |
18 mixin ObjcWrap; | 65 mixin (ObjcWrap); |
66 | |
67 this () | |
68 { | |
69 super(typeof(this).alloc.init.objcObject); | |
70 } | |
71 | |
72 typeof(this) init () | |
73 { | |
74 return invokeObjcSelf!(typeof(this), "init"); | |
75 } | |
19 | 76 |
20 static Object dateWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) | 77 static Object dateWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) |
21 { | 78 { |
22 return invokeObjcSelfClass!(Object, "dateWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(year, month, day, hour, minute, second, aTimeZone); | 79 return invokeObjcSuperClass!(Object, "dateWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(year, month, day, hour, minute, second, aTimeZone); |
23 } | 80 } |
24 | 81 |
25 static Object dateWithString (NSString description, NSString format) | 82 static Object dateWithString (NSString description, NSString format) |
26 { | 83 { |
27 return invokeObjcSelfClass!(Object, "dateWithString:calendarFormat:", NSString, NSString)(description, format); | 84 return invokeObjcSuperClass!(Object, "dateWithString:calendarFormat:", NSString, NSString)(description, format); |
28 } | 85 } |
29 | 86 |
30 static Object dateWithString (NSString description, NSString format, Object locale) | 87 static Object dateWithString (NSString description, NSString format, Object locale) |
31 { | 88 { |
32 return invokeObjcSelfClass!(Object, "dateWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale); | 89 return invokeObjcSuperClass!(Object, "dateWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale); |
33 } | 90 } |
34 | 91 |
35 static Object calendarDate () | 92 static Object calendarDate () |
36 { | 93 { |
37 return invokeObjcSelfClass!(Object, "calendarDate"); | 94 return invokeObjcSuperClass!(Object, "calendarDate"); |
38 } | 95 } |
39 | 96 |
40 Object initWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) | 97 Object initWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) |
41 { | 98 { |
42 return invokeObjcSelf!(Object, "initWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(year, month, day, hour, minute, second, aTimeZone); | 99 return invokeObjcSelf!(Object, "initWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(year, month, day, hour, minute, second, aTimeZone); |
43 } | 100 } |
44 | 101 |
45 this (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) | 102 this (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) |
46 { | 103 { |
47 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 104 typeof(this).alloc.initWithYear(year, month, day, hour, minute, second, aTimeZone); |
48 id result = Bridge.invokeObjcMethod!(id, "initWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(objcObject, year, month, day, hour, minute, second, aTimeZone); | |
49 | |
50 if (result) | |
51 objcObject = ret; | |
52 | |
53 dObject = this; | |
54 } | 105 } |
55 | 106 |
56 Object initWithString (NSString description) | 107 Object initWithString (NSString description) |
57 { | 108 { |
58 return invokeObjcSelf!(Object, "initWithString:", NSString)(description); | 109 return invokeObjcSelf!(Object, "initWithString:", NSString)(description); |
59 } | 110 } |
60 | 111 |
61 this (NSString description) | 112 this (NSString description) |
62 { | 113 { |
63 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 114 typeof(this).alloc.initWithString(description); |
64 id result = Bridge.invokeObjcMethod!(id, "initWithString:", NSString)(objcObject, description); | |
65 | |
66 if (result) | |
67 objcObject = ret; | |
68 | |
69 dObject = this; | |
70 } | 115 } |
71 | 116 |
72 Object initWithString (NSString description, NSString format) | 117 Object initWithString (NSString description, NSString format) |
73 { | 118 { |
74 return invokeObjcSelf!(Object, "initWithString:calendarFormat:", NSString, NSString)(description, format); | 119 return invokeObjcSelf!(Object, "initWithString:calendarFormat:", NSString, NSString)(description, format); |
75 } | 120 } |
76 | 121 |
77 this (NSString description, NSString format) | 122 this (NSString description, NSString format) |
78 { | 123 { |
79 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 124 typeof(this).alloc.initWithString(description, format); |
80 id result = Bridge.invokeObjcMethod!(id, "initWithString:calendarFormat:", NSString, NSString)(objcObject, description, format); | |
81 | |
82 if (result) | |
83 objcObject = ret; | |
84 | |
85 dObject = this; | |
86 } | 125 } |
87 | 126 |
88 Object initWithString (NSString description, NSString format, Object locale) | 127 Object initWithString (NSString description, NSString format, Object locale) |
89 { | 128 { |
90 return invokeObjcSelf!(Object, "initWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale); | 129 return invokeObjcSelf!(Object, "initWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale); |
91 } | 130 } |
92 | 131 |
93 this (NSString description, NSString format, Object locale) | 132 this (NSString description, NSString format, Object locale) |
94 { | 133 { |
95 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 134 typeof(this).alloc.initWithString(description, format, locale); |
96 id result = Bridge.invokeObjcMethod!(id, "initWithString:calendarFormat:locale:", NSString, NSString, Object)(objcObject, description, format, locale); | |
97 | |
98 if (result) | |
99 objcObject = ret; | |
100 | |
101 dObject = this; | |
102 } | 135 } |
103 | 136 |
104 NSTimeZone timeZone () | 137 NSTimeZone timeZone () |
105 { | 138 { |
106 return invokeObjcSelf!(NSTimeZone, "timeZone"); | 139 return invokeObjcSelf!(NSTimeZone, "timeZone"); |
195 NSString descriptionWithCalendarFormat (NSString format, Object locale) | 228 NSString descriptionWithCalendarFormat (NSString format, Object locale) |
196 { | 229 { |
197 return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:locale:", NSString, Object)(format, locale); | 230 return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:locale:", NSString, Object)(format, locale); |
198 } | 231 } |
199 } | 232 } |
200 | |
201 template TNSNaturalLangage () | |
202 { | |
203 static Object dateWithNaturalLanguageString (NSString string) | |
204 { | |
205 return invokeObjcSelfClass!(Object, "dateWithNaturalLanguageString:", NSString)(string); | |
206 } | |
207 | |
208 static Object dateWithNaturalLanguageString (NSString string, Object locale) | |
209 { | |
210 return invokeObjcSelfClass!(Object, "dateWithNaturalLanguageString:locale:", NSString, Object)(string, locale); | |
211 } | |
212 } | |
213 | |
214 template TNSCalendarDateExtras () | |
215 { | |
216 static Object dateWithString (NSString aString) | |
217 { | |
218 return invokeObjcSelfClass!(Object, "dateWithString:", NSString)(aString); | |
219 } | |
220 | |
221 Object initWithString (NSString description) | |
222 { | |
223 return invokeObjcSelf!(Object, "initWithString:", NSString)(description); | |
224 } | |
225 | |
226 this (NSString description) | |
227 { | |
228 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
229 id result = Bridge.invokeObjcMethod!(id, "initWithString:", NSString)(objcObject, description); | |
230 | |
231 if (result) | |
232 objcObject = ret; | |
233 | |
234 dObject = this; | |
235 } | |
236 | |
237 NSCalendarDate dateWithCalendarFormat (NSString format, NSTimeZone aTimeZone) | |
238 { | |
239 return invokeObjcSelf!(NSCalendarDate, "dateWithCalendarFormat:timeZone:", NSString, NSTimeZone)(format, aTimeZone); | |
240 } | |
241 | |
242 NSString descriptionWithLocale (Object locale) | |
243 { | |
244 return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); | |
245 } | |
246 | |
247 NSString descriptionWithCalendarFormat (NSString format, NSTimeZone aTimeZone, Object locale) | |
248 { | |
249 return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:timeZone:locale:", NSString, NSTimeZone, Object)(format, aTimeZone, locale); | |
250 } | |
251 } | |
252 |