Mercurial > projects > dstep
annotate 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 |
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.NSCalendar; | |
8 | |
9 import dstep.corefoundation.CFCalendar; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
10 import dstep.foundation.NSCoder; |
14 | 11 import dstep.foundation.NSDate; |
12 import dstep.foundation.NSLocale; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
13 import dstep.foundation.NSObjCRuntime; |
14 | 14 import dstep.foundation.NSObject; |
15 import dstep.foundation.NSRange; | |
16 import dstep.foundation.NSString; | |
17 import dstep.foundation.NSTimeZone; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
18 import dstep.foundation.NSZone; |
14 | 19 import dstep.objc.bridge.Bridge; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
20 import dstep.objc.objc; |
14 | 21 |
22 alias NSUInteger NSCalendarUnit; | |
23 | |
24 enum | |
25 { | |
26 NSEraCalendarUnit = kCFCalendarUnitEra, | |
27 NSYearCalendarUnit = kCFCalendarUnitYear, | |
28 NSMonthCalendarUnit = kCFCalendarUnitMonth, | |
29 NSDayCalendarUnit = kCFCalendarUnitDay, | |
30 NSHourCalendarUnit = kCFCalendarUnitHour, | |
31 NSMinuteCalendarUnit = kCFCalendarUnitMinute, | |
32 NSSecondCalendarUnit = kCFCalendarUnitSecond, | |
33 NSWeekCalendarUnit = kCFCalendarUnitWeek, | |
34 NSWeekdayCalendarUnit = kCFCalendarUnitWeekday, | |
35 NSWeekdayOrdinalCalendarUnit = kCFCalendarUnitWeekdayOrdinal | |
36 } | |
37 | |
38 enum | |
39 { | |
40 NSWrapCalendarComponents = kCFCalendarComponentsWrap | |
41 } | |
42 | |
43 enum | |
44 { | |
45 NSUndefinedDateComponent = 2147483647L | |
46 } | |
47 | |
48 class NSDateComponents : NSObject, INSCopying, INSCoding | |
49 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
50 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
51 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
52 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
53 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
54 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
55 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
56 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
57 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
58 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
59 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
60 } |
14 | 61 |
62 NSInteger era () | |
63 { | |
64 return invokeObjcSelf!(NSInteger, "era"); | |
65 } | |
66 | |
67 NSInteger year () | |
68 { | |
69 return invokeObjcSelf!(NSInteger, "year"); | |
70 } | |
71 | |
72 NSInteger month () | |
73 { | |
74 return invokeObjcSelf!(NSInteger, "month"); | |
75 } | |
76 | |
77 NSInteger day () | |
78 { | |
79 return invokeObjcSelf!(NSInteger, "day"); | |
80 } | |
81 | |
82 NSInteger hour () | |
83 { | |
84 return invokeObjcSelf!(NSInteger, "hour"); | |
85 } | |
86 | |
87 NSInteger minute () | |
88 { | |
89 return invokeObjcSelf!(NSInteger, "minute"); | |
90 } | |
91 | |
92 NSInteger second () | |
93 { | |
94 return invokeObjcSelf!(NSInteger, "second"); | |
95 } | |
96 | |
97 NSInteger week () | |
98 { | |
99 return invokeObjcSelf!(NSInteger, "week"); | |
100 } | |
101 | |
102 NSInteger weekday () | |
103 { | |
104 return invokeObjcSelf!(NSInteger, "weekday"); | |
105 } | |
106 | |
107 NSInteger weekdayOrdinal () | |
108 { | |
109 return invokeObjcSelf!(NSInteger, "weekdayOrdinal"); | |
110 } | |
111 | |
112 void setEra (NSInteger v) | |
113 { | |
114 return invokeObjcSelf!(void, "setEra:", NSInteger)(v); | |
115 } | |
116 | |
117 void setYear (NSInteger v) | |
118 { | |
119 return invokeObjcSelf!(void, "setYear:", NSInteger)(v); | |
120 } | |
121 | |
122 void setMonth (NSInteger v) | |
123 { | |
124 return invokeObjcSelf!(void, "setMonth:", NSInteger)(v); | |
125 } | |
126 | |
127 void setDay (NSInteger v) | |
128 { | |
129 return invokeObjcSelf!(void, "setDay:", NSInteger)(v); | |
130 } | |
131 | |
132 void setHour (NSInteger v) | |
133 { | |
134 return invokeObjcSelf!(void, "setHour:", NSInteger)(v); | |
135 } | |
136 | |
137 void setMinute (NSInteger v) | |
138 { | |
139 return invokeObjcSelf!(void, "setMinute:", NSInteger)(v); | |
140 } | |
141 | |
142 void setSecond (NSInteger v) | |
143 { | |
144 return invokeObjcSelf!(void, "setSecond:", NSInteger)(v); | |
145 } | |
146 | |
147 void setWeek (NSInteger v) | |
148 { | |
149 return invokeObjcSelf!(void, "setWeek:", NSInteger)(v); | |
150 } | |
151 | |
152 void setWeekday (NSInteger v) | |
153 { | |
154 return invokeObjcSelf!(void, "setWeekday:", NSInteger)(v); | |
155 } | |
156 | |
157 void setWeekdayOrdinal (NSInteger v) | |
158 { | |
159 return invokeObjcSelf!(void, "setWeekdayOrdinal:", NSInteger)(v); | |
160 } | |
161 | |
162 Object copyWithZone (NSZone* zone) | |
163 { | |
164 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
165 } | |
166 | |
167 void encodeWithCoder (NSCoder aCoder) | |
168 { | |
169 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
170 } | |
171 | |
172 Object initWithCoder (NSCoder aDecoder) | |
173 { | |
174 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
175 } | |
176 | |
177 this (NSCoder aDecoder) | |
178 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
179 typeof(this).alloc.initWithCoder(aDecoder); |
14 | 180 } |
181 } | |
182 | |
183 class NSCalendar : NSObject, INSCopying, INSCoding | |
184 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
185 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
186 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
187 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
188 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
189 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
190 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
191 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
192 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
193 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
194 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
195 } |
14 | 196 |
197 static Object currentCalendar () | |
198 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
199 return invokeObjcSuperClass!(Object, "currentCalendar"); |
14 | 200 } |
201 | |
202 static Object autoupdatingCurrentCalendar () | |
203 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
204 return invokeObjcSuperClass!(Object, "autoupdatingCurrentCalendar"); |
14 | 205 } |
206 | |
207 Object initWithCalendarIdentifier (NSString ident) | |
208 { | |
209 return invokeObjcSelf!(Object, "initWithCalendarIdentifier:", NSString)(ident); | |
210 } | |
211 | |
212 this (NSString ident) | |
213 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
214 typeof(this).alloc.initWithCalendarIdentifier(ident); |
14 | 215 } |
216 | |
217 NSString calendarIdentifier () | |
218 { | |
219 return invokeObjcSelf!(NSString, "calendarIdentifier"); | |
220 } | |
221 | |
222 void setLocale (NSLocale locale) | |
223 { | |
224 return invokeObjcSelf!(void, "setLocale:", NSLocale)(locale); | |
225 } | |
226 | |
227 NSLocale locale () | |
228 { | |
229 return invokeObjcSelf!(NSLocale, "locale"); | |
230 } | |
231 | |
232 void setTimeZone (NSTimeZone tz) | |
233 { | |
234 return invokeObjcSelf!(void, "setTimeZone:", NSTimeZone)(tz); | |
235 } | |
236 | |
237 NSTimeZone timeZone () | |
238 { | |
239 return invokeObjcSelf!(NSTimeZone, "timeZone"); | |
240 } | |
241 | |
242 void setFirstWeekday (NSUInteger weekday) | |
243 { | |
244 return invokeObjcSelf!(void, "setFirstWeekday:", NSUInteger)(weekday); | |
245 } | |
246 | |
247 NSUInteger firstWeekday () | |
248 { | |
249 return invokeObjcSelf!(NSUInteger, "firstWeekday"); | |
250 } | |
251 | |
252 void setMinimumDaysInFirstWeek (NSUInteger mdw) | |
253 { | |
254 return invokeObjcSelf!(void, "setMinimumDaysInFirstWeek:", NSUInteger)(mdw); | |
255 } | |
256 | |
257 NSUInteger minimumDaysInFirstWeek () | |
258 { | |
259 return invokeObjcSelf!(NSUInteger, "minimumDaysInFirstWeek"); | |
260 } | |
261 | |
262 NSRange minimumRangeOfUnit (uint unit) | |
263 { | |
264 return invokeObjcSelf!(NSRange, "minimumRangeOfUnit:", uint)(unit); | |
265 } | |
266 | |
267 NSRange maximumRangeOfUnit (uint unit) | |
268 { | |
269 return invokeObjcSelf!(NSRange, "maximumRangeOfUnit:", uint)(unit); | |
270 } | |
271 | |
272 NSRange rangeOfUnit (uint smaller, uint larger, NSDate date) | |
273 { | |
274 return invokeObjcSelf!(NSRange, "rangeOfUnit:inUnit:forDate:", uint, uint, NSDate)(smaller, larger, date); | |
275 } | |
276 | |
277 NSUInteger ordinalityOfUnit (uint smaller, uint larger, NSDate date) | |
278 { | |
279 return invokeObjcSelf!(NSUInteger, "ordinalityOfUnit:inUnit:forDate:", uint, uint, NSDate)(smaller, larger, date); | |
280 } | |
281 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
282 bool rangeOfUnit (uint unit, out NSDate datep, NSTimeInterval* tip, NSDate date) |
14 | 283 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
284 id d = new objc_object; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
285 bool result = invokeObjcSelf!(bool, "rangeOfUnit:startDate:interval:forDate:", uint, id*, NSTimeInterval*, NSDate)(unit, &d, tip, date); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
286 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
287 if (d) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
288 datep = new NSDate(d); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
289 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
290 return result; |
14 | 291 } |
292 | |
293 NSDate dateFromComponents (NSDateComponents comps) | |
294 { | |
295 return invokeObjcSelf!(NSDate, "dateFromComponents:", NSDateComponents)(comps); | |
296 } | |
297 | |
298 NSDateComponents components (NSUInteger unitFlags, NSDate date) | |
299 { | |
300 return invokeObjcSelf!(NSDateComponents, "components:fromDate:", NSUInteger, NSDate)(unitFlags, date); | |
301 } | |
302 | |
303 NSDate dateByAddingComponents (NSDateComponents comps, NSDate date, NSUInteger opts) | |
304 { | |
305 return invokeObjcSelf!(NSDate, "dateByAddingComponents:toDate:options:", NSDateComponents, NSDate, NSUInteger)(comps, date, opts); | |
306 } | |
307 | |
308 NSDateComponents components (NSUInteger unitFlags, NSDate startingDate, NSDate resultDate, NSUInteger opts) | |
309 { | |
310 return invokeObjcSelf!(NSDateComponents, "components:fromDate:toDate:options:", NSUInteger, NSDate, NSDate, NSUInteger)(unitFlags, startingDate, resultDate, opts); | |
311 } | |
312 | |
313 Object copyWithZone (NSZone* zone) | |
314 { | |
315 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
316 } | |
317 | |
318 void encodeWithCoder (NSCoder aCoder) | |
319 { | |
320 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
321 } | |
322 | |
323 Object initWithCoder (NSCoder aDecoder) | |
324 { | |
325 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
326 } | |
327 | |
328 this (NSCoder aDecoder) | |
329 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
330 typeof(this).alloc.initWithCoder(aDecoder); |
14 | 331 } |
332 } | |
333 |