Mercurial > projects > dstep
comparison dstep/foundation/NSTimeZone.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.NSTimeZone; | 7 module dstep.foundation.NSTimeZone; |
8 | 8 |
9 import dstep.foundation.NSArray; | 9 import dstep.foundation.NSArray; |
10 import dstep.foundation.NSCoder; | |
10 import dstep.foundation.NSData; | 11 import dstep.foundation.NSData; |
11 import dstep.foundation.NSDate; | 12 import dstep.foundation.NSDate; |
12 import dstep.foundation.NSDictionary; | 13 import dstep.foundation.NSDictionary; |
13 import dstep.foundation.NSLocale; | 14 import dstep.foundation.NSLocale; |
15 import dstep.foundation.NSObjCRuntime; | |
14 import dstep.foundation.NSObject; | 16 import dstep.foundation.NSObject; |
15 import dstep.foundation.NSString; | 17 import dstep.foundation.NSString; |
18 import dstep.foundation.NSZone; | |
16 import dstep.objc.bridge.Bridge; | 19 import dstep.objc.bridge.Bridge; |
17 import dstep.objc.objc : id; | 20 import dstep.objc.objc; |
18 | |
19 import bindings = dstep.foundation.NSTimeZone_bindings; | 21 import bindings = dstep.foundation.NSTimeZone_bindings; |
20 | 22 |
21 alias NSInteger NSTimeZoneNameStyle; | 23 alias NSInteger NSTimeZoneNameStyle; |
22 | 24 |
23 const NSString NSSystemTimeZoneDidChangeNotification; | 25 private NSString NSSystemTimeZoneDidChangeNotification_; |
26 | |
27 NSString NSSystemTimeZoneDidChangeNotification () | |
28 { | |
29 if (NSSystemTimeZoneDidChangeNotification_) | |
30 return NSSystemTimeZoneDidChangeNotification_; | |
31 | |
32 return NSSystemTimeZoneDidChangeNotification_ = new NSString(bindings.NSSystemTimeZoneDidChangeNotification); | |
33 } | |
24 | 34 |
25 enum | 35 enum |
26 { | 36 { |
27 NSTimeZoneNameStyleStandard, | 37 NSTimeZoneNameStyleStandard, |
28 NSTimeZoneNameStyleShortStandard, | 38 NSTimeZoneNameStyleShortStandard, |
29 NSTimeZoneNameStyleDaylightSaving, | 39 NSTimeZoneNameStyleDaylightSaving, |
30 NSTimeZoneNameStyleShortDaylightSaving | 40 NSTimeZoneNameStyleShortDaylightSaving |
31 } | 41 } |
32 | 42 |
33 static this () | 43 const TNSExtendedTimeZone = ` |
34 { | 44 |
35 NSSystemTimeZoneDidChangeNotification = new NSString(bindings.NSSystemTimeZoneDidChangeNotification); | 45 static NSTimeZone systemTimeZone () |
36 } | 46 { |
47 return invokeObjcSuperClass!(NSTimeZone, "systemTimeZone"); | |
48 } | |
49 | |
50 static void resetSystemTimeZone () | |
51 { | |
52 return invokeObjcSuperClass!(void, "resetSystemTimeZone"); | |
53 } | |
54 | |
55 static NSTimeZone defaultTimeZone () | |
56 { | |
57 return invokeObjcSuperClass!(NSTimeZone, "defaultTimeZone"); | |
58 } | |
59 | |
60 static void setDefaultTimeZone (NSTimeZone aTimeZone) | |
61 { | |
62 return invokeObjcSuperClass!(void, "setDefaultTimeZone:", NSTimeZone)(aTimeZone); | |
63 } | |
64 | |
65 static NSTimeZone localTimeZone () | |
66 { | |
67 return invokeObjcSuperClass!(NSTimeZone, "localTimeZone"); | |
68 } | |
69 | |
70 static NSArray knownTimeZoneNames () | |
71 { | |
72 return invokeObjcSuperClass!(NSArray, "knownTimeZoneNames"); | |
73 } | |
74 | |
75 static NSDictionary abbreviationDictionary () | |
76 { | |
77 return invokeObjcSuperClass!(NSDictionary, "abbreviationDictionary"); | |
78 } | |
79 | |
80 NSInteger secondsFromGMT () | |
81 { | |
82 return invokeObjcSelf!(NSInteger, "secondsFromGMT"); | |
83 } | |
84 | |
85 NSString abbreviation () | |
86 { | |
87 return invokeObjcSelf!(NSString, "abbreviation"); | |
88 } | |
89 | |
90 bool isDaylightSavingTime () | |
91 { | |
92 return invokeObjcSelf!(bool, "isDaylightSavingTime"); | |
93 } | |
94 | |
95 double daylightSavingTimeOffset () | |
96 { | |
97 return invokeObjcSelf!(double, "daylightSavingTimeOffset"); | |
98 } | |
99 | |
100 NSDate nextDaylightSavingTimeTransition () | |
101 { | |
102 return invokeObjcSelf!(NSDate, "nextDaylightSavingTimeTransition"); | |
103 } | |
104 | |
105 NSString description () | |
106 { | |
107 return invokeObjcSelf!(NSString, "description"); | |
108 } | |
109 | |
110 bool isEqualToTimeZone (NSTimeZone aTimeZone) | |
111 { | |
112 return invokeObjcSelf!(bool, "isEqualToTimeZone:", NSTimeZone)(aTimeZone); | |
113 } | |
114 | |
115 NSString localizedName (int style, NSLocale locale) | |
116 { | |
117 return invokeObjcSelf!(NSString, "localizedName:locale:", int, NSLocale)(style, locale); | |
118 } | |
119 `; | |
120 | |
121 const TNSTimeZoneCreation = ` | |
122 | |
123 static Object timeZoneWithName (NSString tzName) | |
124 { | |
125 return invokeObjcSuperClass!(Object, "timeZoneWithName:", NSString)(tzName); | |
126 } | |
127 | |
128 static Object timeZoneWithName (NSString tzName, NSData aData) | |
129 { | |
130 return invokeObjcSuperClass!(Object, "timeZoneWithName:data:", NSString, NSData)(tzName, aData); | |
131 } | |
132 | |
133 Object initWithName (NSString tzName) | |
134 { | |
135 return invokeObjcSelf!(Object, "initWithName:", NSString)(tzName); | |
136 } | |
137 | |
138 this (NSString tzName) | |
139 { | |
140 typeof(this).alloc.initWithName(tzName); | |
141 } | |
142 | |
143 Object initWithName (NSString tzName, NSData aData) | |
144 { | |
145 return invokeObjcSelf!(Object, "initWithName:data:", NSString, NSData)(tzName, aData); | |
146 } | |
147 | |
148 this (NSString tzName, NSData aData) | |
149 { | |
150 typeof(this).alloc.initWithName(tzName, aData); | |
151 } | |
152 | |
153 static Object timeZoneForSecondsFromGMT (NSInteger seconds) | |
154 { | |
155 return invokeObjcSuperClass!(Object, "timeZoneForSecondsFromGMT:", NSInteger)(seconds); | |
156 } | |
157 | |
158 static Object timeZoneWithAbbreviation (NSString abbreviation) | |
159 { | |
160 return invokeObjcSuperClass!(Object, "timeZoneWithAbbreviation:", NSString)(abbreviation); | |
161 } | |
162 `; | |
37 | 163 |
38 class NSTimeZone : NSObject, INSCopying, INSCoding | 164 class NSTimeZone : NSObject, INSCopying, INSCoding |
39 { | 165 { |
40 mixin ObjcWrap; | 166 mixin (ObjcWrap); |
41 mixin TNSExtendedTimeZone; | 167 |
42 mixin TNSTimeZoneCreation; | 168 this () |
169 { | |
170 super(typeof(this).alloc.init.objcObject); | |
171 } | |
172 | |
173 typeof(this) init () | |
174 { | |
175 return invokeObjcSelf!(typeof(this), "init"); | |
176 } | |
43 | 177 |
44 NSString name () | 178 NSString name () |
45 { | 179 { |
46 return invokeObjcSelf!(NSString, "name"); | 180 return invokeObjcSelf!(NSString, "name"); |
47 } | 181 } |
91 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | 225 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); |
92 } | 226 } |
93 | 227 |
94 this (NSCoder aDecoder) | 228 this (NSCoder aDecoder) |
95 { | 229 { |
96 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 230 typeof(this).alloc.initWithCoder(aDecoder); |
97 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | 231 } |
98 | 232 |
99 if (result) | 233 // TNSExtendedTimeZone |
100 objcObject = ret; | 234 static NSTimeZone systemTimeZone () |
101 | 235 { |
102 dObject = this; | 236 return invokeObjcSuperClass!(NSTimeZone, "systemTimeZone"); |
237 } | |
238 | |
239 static void resetSystemTimeZone () | |
240 { | |
241 return invokeObjcSuperClass!(void, "resetSystemTimeZone"); | |
242 } | |
243 | |
244 static NSTimeZone defaultTimeZone () | |
245 { | |
246 return invokeObjcSuperClass!(NSTimeZone, "defaultTimeZone"); | |
247 } | |
248 | |
249 static void setDefaultTimeZone (NSTimeZone aTimeZone) | |
250 { | |
251 return invokeObjcSuperClass!(void, "setDefaultTimeZone:", NSTimeZone)(aTimeZone); | |
252 } | |
253 | |
254 static NSTimeZone localTimeZone () | |
255 { | |
256 return invokeObjcSuperClass!(NSTimeZone, "localTimeZone"); | |
257 } | |
258 | |
259 static NSArray knownTimeZoneNames () | |
260 { | |
261 return invokeObjcSuperClass!(NSArray, "knownTimeZoneNames"); | |
262 } | |
263 | |
264 static NSDictionary abbreviationDictionary () | |
265 { | |
266 return invokeObjcSuperClass!(NSDictionary, "abbreviationDictionary"); | |
267 } | |
268 | |
269 NSInteger secondsFromGMT () | |
270 { | |
271 return invokeObjcSelf!(NSInteger, "secondsFromGMT"); | |
272 } | |
273 | |
274 NSString abbreviation () | |
275 { | |
276 return invokeObjcSelf!(NSString, "abbreviation"); | |
277 } | |
278 | |
279 bool isDaylightSavingTime () | |
280 { | |
281 return invokeObjcSelf!(bool, "isDaylightSavingTime"); | |
282 } | |
283 | |
284 double daylightSavingTimeOffset () | |
285 { | |
286 return invokeObjcSelf!(double, "daylightSavingTimeOffset"); | |
287 } | |
288 | |
289 NSDate nextDaylightSavingTimeTransition () | |
290 { | |
291 return invokeObjcSelf!(NSDate, "nextDaylightSavingTimeTransition"); | |
292 } | |
293 | |
294 NSString description () | |
295 { | |
296 return invokeObjcSelf!(NSString, "description"); | |
297 } | |
298 | |
299 bool isEqualToTimeZone (NSTimeZone aTimeZone) | |
300 { | |
301 return invokeObjcSelf!(bool, "isEqualToTimeZone:", NSTimeZone)(aTimeZone); | |
302 } | |
303 | |
304 NSString localizedName (int style, NSLocale locale) | |
305 { | |
306 return invokeObjcSelf!(NSString, "localizedName:locale:", int, NSLocale)(style, locale); | |
307 } | |
308 | |
309 // TNSTimeZoneCreation | |
310 static Object timeZoneWithName (NSString tzName) | |
311 { | |
312 return invokeObjcSuperClass!(Object, "timeZoneWithName:", NSString)(tzName); | |
313 } | |
314 | |
315 static Object timeZoneWithName (NSString tzName, NSData aData) | |
316 { | |
317 return invokeObjcSuperClass!(Object, "timeZoneWithName:data:", NSString, NSData)(tzName, aData); | |
318 } | |
319 | |
320 Object initWithName (NSString tzName) | |
321 { | |
322 return invokeObjcSelf!(Object, "initWithName:", NSString)(tzName); | |
323 } | |
324 | |
325 this (NSString tzName) | |
326 { | |
327 typeof(this).alloc.initWithName(tzName); | |
328 } | |
329 | |
330 Object initWithName (NSString tzName, NSData aData) | |
331 { | |
332 return invokeObjcSelf!(Object, "initWithName:data:", NSString, NSData)(tzName, aData); | |
333 } | |
334 | |
335 this (NSString tzName, NSData aData) | |
336 { | |
337 typeof(this).alloc.initWithName(tzName, aData); | |
338 } | |
339 | |
340 static Object timeZoneForSecondsFromGMT (NSInteger seconds) | |
341 { | |
342 return invokeObjcSuperClass!(Object, "timeZoneForSecondsFromGMT:", NSInteger)(seconds); | |
343 } | |
344 | |
345 static Object timeZoneWithAbbreviation (NSString abbreviation) | |
346 { | |
347 return invokeObjcSuperClass!(Object, "timeZoneWithAbbreviation:", NSString)(abbreviation); | |
103 } | 348 } |
104 } | 349 } |
105 | |
106 template TNSExtendedTimeZone () | |
107 { | |
108 static NSTimeZone systemTimeZone () | |
109 { | |
110 return invokeObjcSelfClass!(NSTimeZone, "systemTimeZone"); | |
111 } | |
112 | |
113 static void resetSystemTimeZone () | |
114 { | |
115 return invokeObjcSelfClass!(void, "resetSystemTimeZone"); | |
116 } | |
117 | |
118 static NSTimeZone defaultTimeZone () | |
119 { | |
120 return invokeObjcSelfClass!(NSTimeZone, "defaultTimeZone"); | |
121 } | |
122 | |
123 static void setDefaultTimeZone (NSTimeZone aTimeZone) | |
124 { | |
125 return invokeObjcSelfClass!(void, "setDefaultTimeZone:", NSTimeZone)(aTimeZone); | |
126 } | |
127 | |
128 static NSTimeZone localTimeZone () | |
129 { | |
130 return invokeObjcSelfClass!(NSTimeZone, "localTimeZone"); | |
131 } | |
132 | |
133 static NSArray knownTimeZoneNames () | |
134 { | |
135 return invokeObjcSelfClass!(NSArray, "knownTimeZoneNames"); | |
136 } | |
137 | |
138 static NSDictionary abbreviationDictionary () | |
139 { | |
140 return invokeObjcSelfClass!(NSDictionary, "abbreviationDictionary"); | |
141 } | |
142 | |
143 NSInteger secondsFromGMT () | |
144 { | |
145 return invokeObjcSelf!(NSInteger, "secondsFromGMT"); | |
146 } | |
147 | |
148 NSString abbreviation () | |
149 { | |
150 return invokeObjcSelf!(NSString, "abbreviation"); | |
151 } | |
152 | |
153 bool isDaylightSavingTime () | |
154 { | |
155 return invokeObjcSelf!(bool, "isDaylightSavingTime"); | |
156 } | |
157 | |
158 double daylightSavingTimeOffset () | |
159 { | |
160 return invokeObjcSelf!(double, "daylightSavingTimeOffset"); | |
161 } | |
162 | |
163 NSDate nextDaylightSavingTimeTransition () | |
164 { | |
165 return invokeObjcSelf!(NSDate, "nextDaylightSavingTimeTransition"); | |
166 } | |
167 | |
168 NSString description () | |
169 { | |
170 return invokeObjcSelf!(NSString, "description"); | |
171 } | |
172 | |
173 bool isEqualToTimeZone (NSTimeZone aTimeZone) | |
174 { | |
175 return invokeObjcSelf!(bool, "isEqualToTimeZone:", NSTimeZone)(aTimeZone); | |
176 } | |
177 | |
178 NSString localizedName (int style, NSLocale locale) | |
179 { | |
180 return invokeObjcSelf!(NSString, "localizedName:locale:", int, NSLocale)(style, locale); | |
181 } | |
182 } | |
183 | |
184 template TNSTimeZoneCreation () | |
185 { | |
186 static Object timeZoneWithName (NSString tzName) | |
187 { | |
188 return invokeObjcSelfClass!(Object, "timeZoneWithName:", NSString)(tzName); | |
189 } | |
190 | |
191 static Object timeZoneWithName (NSString tzName, NSData aData) | |
192 { | |
193 return invokeObjcSelfClass!(Object, "timeZoneWithName:data:", NSString, NSData)(tzName, aData); | |
194 } | |
195 | |
196 Object initWithName (NSString tzName) | |
197 { | |
198 return invokeObjcSelf!(Object, "initWithName:", NSString)(tzName); | |
199 } | |
200 | |
201 this (NSString tzName) | |
202 { | |
203 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
204 id result = Bridge.invokeObjcMethod!(id, "initWithName:", NSString)(objcObject, tzName); | |
205 | |
206 if (result) | |
207 objcObject = ret; | |
208 | |
209 dObject = this; | |
210 } | |
211 | |
212 Object initWithName (NSString tzName, NSData aData) | |
213 { | |
214 return invokeObjcSelf!(Object, "initWithName:data:", NSString, NSData)(tzName, aData); | |
215 } | |
216 | |
217 this (NSString tzName, NSData aData) | |
218 { | |
219 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
220 id result = Bridge.invokeObjcMethod!(id, "initWithName:data:", NSString, NSData)(objcObject, tzName, aData); | |
221 | |
222 if (result) | |
223 objcObject = ret; | |
224 | |
225 dObject = this; | |
226 } | |
227 | |
228 static Object timeZoneForSecondsFromGMT (NSInteger seconds) | |
229 { | |
230 return invokeObjcSelfClass!(Object, "timeZoneForSecondsFromGMT:", NSInteger)(seconds); | |
231 } | |
232 | |
233 static Object timeZoneWithAbbreviation (NSString abbreviation) | |
234 { | |
235 return invokeObjcSelfClass!(Object, "timeZoneWithAbbreviation:", NSString)(abbreviation); | |
236 } | |
237 } | |
238 |