Mercurial > projects > dstep
annotate dstep/foundation/NSCalendar.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 | b9de51448c6b |
children |
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 { | |
25
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
50 mixin ObjcWrap; |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
51 |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
52 this (id object) |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
53 { |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
54 super(object); |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
55 } |
16
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 this () |
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 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
60 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
61 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
62 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
63 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
64 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
65 } |
14 | 66 |
67 NSInteger era () | |
68 { | |
69 return invokeObjcSelf!(NSInteger, "era"); | |
70 } | |
71 | |
72 NSInteger year () | |
73 { | |
74 return invokeObjcSelf!(NSInteger, "year"); | |
75 } | |
76 | |
77 NSInteger month () | |
78 { | |
79 return invokeObjcSelf!(NSInteger, "month"); | |
80 } | |
81 | |
82 NSInteger day () | |
83 { | |
84 return invokeObjcSelf!(NSInteger, "day"); | |
85 } | |
86 | |
87 NSInteger hour () | |
88 { | |
89 return invokeObjcSelf!(NSInteger, "hour"); | |
90 } | |
91 | |
92 NSInteger minute () | |
93 { | |
94 return invokeObjcSelf!(NSInteger, "minute"); | |
95 } | |
96 | |
97 NSInteger second () | |
98 { | |
99 return invokeObjcSelf!(NSInteger, "second"); | |
100 } | |
101 | |
102 NSInteger week () | |
103 { | |
104 return invokeObjcSelf!(NSInteger, "week"); | |
105 } | |
106 | |
107 NSInteger weekday () | |
108 { | |
109 return invokeObjcSelf!(NSInteger, "weekday"); | |
110 } | |
111 | |
112 NSInteger weekdayOrdinal () | |
113 { | |
114 return invokeObjcSelf!(NSInteger, "weekdayOrdinal"); | |
115 } | |
116 | |
117 void setEra (NSInteger v) | |
118 { | |
119 return invokeObjcSelf!(void, "setEra:", NSInteger)(v); | |
120 } | |
121 | |
122 void setYear (NSInteger v) | |
123 { | |
124 return invokeObjcSelf!(void, "setYear:", NSInteger)(v); | |
125 } | |
126 | |
127 void setMonth (NSInteger v) | |
128 { | |
129 return invokeObjcSelf!(void, "setMonth:", NSInteger)(v); | |
130 } | |
131 | |
132 void setDay (NSInteger v) | |
133 { | |
134 return invokeObjcSelf!(void, "setDay:", NSInteger)(v); | |
135 } | |
136 | |
137 void setHour (NSInteger v) | |
138 { | |
139 return invokeObjcSelf!(void, "setHour:", NSInteger)(v); | |
140 } | |
141 | |
142 void setMinute (NSInteger v) | |
143 { | |
144 return invokeObjcSelf!(void, "setMinute:", NSInteger)(v); | |
145 } | |
146 | |
147 void setSecond (NSInteger v) | |
148 { | |
149 return invokeObjcSelf!(void, "setSecond:", NSInteger)(v); | |
150 } | |
151 | |
152 void setWeek (NSInteger v) | |
153 { | |
154 return invokeObjcSelf!(void, "setWeek:", NSInteger)(v); | |
155 } | |
156 | |
157 void setWeekday (NSInteger v) | |
158 { | |
159 return invokeObjcSelf!(void, "setWeekday:", NSInteger)(v); | |
160 } | |
161 | |
162 void setWeekdayOrdinal (NSInteger v) | |
163 { | |
164 return invokeObjcSelf!(void, "setWeekdayOrdinal:", NSInteger)(v); | |
165 } | |
166 | |
167 Object copyWithZone (NSZone* zone) | |
168 { | |
169 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
170 } | |
171 | |
172 void encodeWithCoder (NSCoder aCoder) | |
173 { | |
174 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
175 } | |
176 | |
177 Object initWithCoder (NSCoder aDecoder) | |
178 { | |
179 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
180 } | |
181 | |
182 this (NSCoder aDecoder) | |
183 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
184 typeof(this).alloc.initWithCoder(aDecoder); |
14 | 185 } |
186 } | |
187 | |
188 class NSCalendar : NSObject, INSCopying, INSCoding | |
189 { | |
25
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
190 mixin ObjcWrap; |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
191 |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
192 this (id object) |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
193 { |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
194 super(object); |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
195 } |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
196 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
197 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
198 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
199 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
200 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
201 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
202 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
203 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
204 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
205 } |
14 | 206 |
207 static Object currentCalendar () | |
208 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
209 return invokeObjcSuperClass!(Object, "currentCalendar"); |
14 | 210 } |
211 | |
212 static Object autoupdatingCurrentCalendar () | |
213 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
214 return invokeObjcSuperClass!(Object, "autoupdatingCurrentCalendar"); |
14 | 215 } |
216 | |
217 Object initWithCalendarIdentifier (NSString ident) | |
218 { | |
219 return invokeObjcSelf!(Object, "initWithCalendarIdentifier:", NSString)(ident); | |
220 } | |
221 | |
222 this (NSString ident) | |
223 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
224 typeof(this).alloc.initWithCalendarIdentifier(ident); |
14 | 225 } |
226 | |
227 NSString calendarIdentifier () | |
228 { | |
229 return invokeObjcSelf!(NSString, "calendarIdentifier"); | |
230 } | |
231 | |
232 void setLocale (NSLocale locale) | |
233 { | |
234 return invokeObjcSelf!(void, "setLocale:", NSLocale)(locale); | |
235 } | |
236 | |
237 NSLocale locale () | |
238 { | |
239 return invokeObjcSelf!(NSLocale, "locale"); | |
240 } | |
241 | |
242 void setTimeZone (NSTimeZone tz) | |
243 { | |
244 return invokeObjcSelf!(void, "setTimeZone:", NSTimeZone)(tz); | |
245 } | |
246 | |
247 NSTimeZone timeZone () | |
248 { | |
249 return invokeObjcSelf!(NSTimeZone, "timeZone"); | |
250 } | |
251 | |
252 void setFirstWeekday (NSUInteger weekday) | |
253 { | |
254 return invokeObjcSelf!(void, "setFirstWeekday:", NSUInteger)(weekday); | |
255 } | |
256 | |
257 NSUInteger firstWeekday () | |
258 { | |
259 return invokeObjcSelf!(NSUInteger, "firstWeekday"); | |
260 } | |
261 | |
262 void setMinimumDaysInFirstWeek (NSUInteger mdw) | |
263 { | |
264 return invokeObjcSelf!(void, "setMinimumDaysInFirstWeek:", NSUInteger)(mdw); | |
265 } | |
266 | |
267 NSUInteger minimumDaysInFirstWeek () | |
268 { | |
269 return invokeObjcSelf!(NSUInteger, "minimumDaysInFirstWeek"); | |
270 } | |
271 | |
272 NSRange minimumRangeOfUnit (uint unit) | |
273 { | |
274 return invokeObjcSelf!(NSRange, "minimumRangeOfUnit:", uint)(unit); | |
275 } | |
276 | |
277 NSRange maximumRangeOfUnit (uint unit) | |
278 { | |
279 return invokeObjcSelf!(NSRange, "maximumRangeOfUnit:", uint)(unit); | |
280 } | |
281 | |
282 NSRange rangeOfUnit (uint smaller, uint larger, NSDate date) | |
283 { | |
284 return invokeObjcSelf!(NSRange, "rangeOfUnit:inUnit:forDate:", uint, uint, NSDate)(smaller, larger, date); | |
285 } | |
286 | |
287 NSUInteger ordinalityOfUnit (uint smaller, uint larger, NSDate date) | |
288 { | |
289 return invokeObjcSelf!(NSUInteger, "ordinalityOfUnit:inUnit:forDate:", uint, uint, NSDate)(smaller, larger, date); | |
290 } | |
291 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
292 bool rangeOfUnit (uint unit, out NSDate datep, NSTimeInterval* tip, NSDate date) |
14 | 293 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
294 id d = new objc_object; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
295 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
|
296 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
297 if (d) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
298 datep = new NSDate(d); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
299 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
300 return result; |
14 | 301 } |
302 | |
303 NSDate dateFromComponents (NSDateComponents comps) | |
304 { | |
305 return invokeObjcSelf!(NSDate, "dateFromComponents:", NSDateComponents)(comps); | |
306 } | |
307 | |
308 NSDateComponents components (NSUInteger unitFlags, NSDate date) | |
309 { | |
310 return invokeObjcSelf!(NSDateComponents, "components:fromDate:", NSUInteger, NSDate)(unitFlags, date); | |
311 } | |
312 | |
313 NSDate dateByAddingComponents (NSDateComponents comps, NSDate date, NSUInteger opts) | |
314 { | |
315 return invokeObjcSelf!(NSDate, "dateByAddingComponents:toDate:options:", NSDateComponents, NSDate, NSUInteger)(comps, date, opts); | |
316 } | |
317 | |
318 NSDateComponents components (NSUInteger unitFlags, NSDate startingDate, NSDate resultDate, NSUInteger opts) | |
319 { | |
320 return invokeObjcSelf!(NSDateComponents, "components:fromDate:toDate:options:", NSUInteger, NSDate, NSDate, NSUInteger)(unitFlags, startingDate, resultDate, opts); | |
321 } | |
322 | |
323 Object copyWithZone (NSZone* zone) | |
324 { | |
325 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
326 } | |
327 | |
328 void encodeWithCoder (NSCoder aCoder) | |
329 { | |
330 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
331 } | |
332 | |
333 Object initWithCoder (NSCoder aDecoder) | |
334 { | |
335 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
336 } | |
337 | |
338 this (NSCoder aDecoder) | |
339 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
340 typeof(this).alloc.initWithCoder(aDecoder); |
14 | 341 } |
342 } | |
343 |