comparison dstep/foundation/NSDateFormatter.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
8 8
9 import dstep.corefoundation.CFDateFormatter; 9 import dstep.corefoundation.CFDateFormatter;
10 import dstep.foundation.NSArray; 10 import dstep.foundation.NSArray;
11 import dstep.foundation.NSCalendar; 11 import dstep.foundation.NSCalendar;
12 import dstep.foundation.NSDate; 12 import dstep.foundation.NSDate;
13 import dstep.foundation.NSDictionary;
13 import dstep.foundation.NSError; 14 import dstep.foundation.NSError;
14 import dstep.foundation.NSFormatter; 15 import dstep.foundation.NSFormatter;
15 import dstep.foundation.NSLocale; 16 import dstep.foundation.NSLocale;
16 import dstep.foundation.NSMutableDictionary; 17 import dstep.foundation.NSObjCRuntime;
18 import dstep.foundation.NSRange;
19 import dstep.foundation.NSString;
17 import dstep.foundation.NSTimeZone; 20 import dstep.foundation.NSTimeZone;
18 import dstep.objc.bridge.Bridge; 21 import dstep.objc.bridge.Bridge;
19 import dstep.objc.objc : id; 22 import dstep.objc.objc;
20 23
21 alias NSUInteger NSDateFormatterStyle; 24 alias NSUInteger NSDateFormatterStyle;
22 alias NSUInteger NSDateFormatterBehavior; 25 alias NSUInteger NSDateFormatterBehavior;
23 26
24 enum 27 enum
35 NSDateFormatterBehaviorDefault = 0, 38 NSDateFormatterBehaviorDefault = 0,
36 NSDateFormatterBehavior10_0 = 1000, 39 NSDateFormatterBehavior10_0 = 1000,
37 NSDateFormatterBehavior10_4 = 1040 40 NSDateFormatterBehavior10_4 = 1040
38 } 41 }
39 42
43 const TNSDateFormatterCompatibility = `
44
45 Object initWithDateFormat (NSString format, bool flag)
46 {
47 return invokeObjcSelf!(Object, "initWithDateFormat:allowNaturalLanguage:", NSString, bool)(format, flag);
48 }
49
50 this (NSString format, bool flag)
51 {
52 typeof(this).alloc.initWithDateFormat(format, flag);
53 }
54
55 bool allowsNaturalLanguage ()
56 {
57 return invokeObjcSelf!(bool, "allowsNaturalLanguage");
58 }
59 `;
60
40 class NSDateFormatter : NSFormatter 61 class NSDateFormatter : NSFormatter
41 { 62 {
42 mixin ObjcWrap; 63 mixin (ObjcWrap);
43 mixin TNSDateFormatterCompatibility; 64
44
45 Object init ()
46 {
47 return invokeObjcSelf!(Object, "init");
48 }
49
50 this () 65 this ()
51 { 66 {
52 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); 67 super(typeof(this).alloc.init.objcObject);
53 id result = Bridge.invokeObjcMethod!(id, "init")(objcObject); 68 }
54 69
55 if (result) 70 typeof(this) init ()
56 objcObject = ret; 71 {
57 72 return invokeObjcSelf!(typeof(this), "init");
58 dObject = this;
59 } 73 }
60 74
61 bool getObjectValue (id* obj, NSString string, NSRange* rangep, NSError** error) 75 bool getObjectValue (id* obj, NSString string, NSRange* rangep, NSError** error)
62 { 76 {
63 return invokeObjcSelf!(bool, "getObjectValue:forString:range:error:", id*, NSString, NSRange*, NSError**)(obj, string, rangep, error); 77 return invokeObjcSelf!(bool, "getObjectValue:forString:range:error:", id*, NSString, NSRange*, NSError**)(obj, string, rangep, error);
128 return invokeObjcSelf!(void, "setFormatterBehavior:", uint)(behavior); 142 return invokeObjcSelf!(void, "setFormatterBehavior:", uint)(behavior);
129 } 143 }
130 144
131 static uint defaultFormatterBehavior () 145 static uint defaultFormatterBehavior ()
132 { 146 {
133 return invokeObjcSelfClass!(uint, "defaultFormatterBehavior"); 147 return invokeObjcSuperClass!(uint, "defaultFormatterBehavior");
134 } 148 }
135 149
136 static void setDefaultFormatterBehavior (uint behavior) 150 static void setDefaultFormatterBehavior (uint behavior)
137 { 151 {
138 return invokeObjcSelfClass!(void, "setDefaultFormatterBehavior:", uint)(behavior); 152 return invokeObjcSuperClass!(void, "setDefaultFormatterBehavior:", uint)(behavior);
139 } 153 }
140 154
141 void setDateFormat (NSString string) 155 void setDateFormat (NSString string)
142 { 156 {
143 return invokeObjcSelf!(void, "setDateFormat:", NSString)(string); 157 return invokeObjcSelf!(void, "setDateFormat:", NSString)(string);
400 414
401 void setGregorianStartDate (NSDate date) 415 void setGregorianStartDate (NSDate date)
402 { 416 {
403 return invokeObjcSelf!(void, "setGregorianStartDate:", NSDate)(date); 417 return invokeObjcSelf!(void, "setGregorianStartDate:", NSDate)(date);
404 } 418 }
419
420 // TNSDateFormatterCompatibility
421 Object initWithDateFormat (NSString format, bool flag)
422 {
423 return invokeObjcSelf!(Object, "initWithDateFormat:allowNaturalLanguage:", NSString, bool)(format, flag);
424 }
425
426 this (NSString format, bool flag)
427 {
428 typeof(this).alloc.initWithDateFormat(format, flag);
429 }
430
431 bool allowsNaturalLanguage ()
432 {
433 return invokeObjcSelf!(bool, "allowsNaturalLanguage");
434 }
405 } 435 }
406
407 template TNSDateFormatterCompatibility ()
408 {
409 Object initWithDateFormat (NSString format, bool flag)
410 {
411 return invokeObjcSelf!(Object, "initWithDateFormat:allowNaturalLanguage:", NSString, bool)(format, flag);
412 }
413
414 this (NSString format, bool flag)
415 {
416 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
417 id result = Bridge.invokeObjcMethod!(id, "initWithDateFormat:allowNaturalLanguage:", NSString, bool)(objcObject, format, flag);
418
419 if (result)
420 objcObject = ret;
421
422 dObject = this;
423 }
424
425 bool allowsNaturalLanguage ()
426 {
427 return invokeObjcSelf!(bool, "allowsNaturalLanguage");
428 }
429 }
430