Mercurial > projects > dstep
view dstep/foundation/NSDate.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 |
line wrap: on
line source
/** * Copyright: Copyright (c) 2009 Jacob Carlborg. * Authors: Jacob Carlborg * Version: Initial created: Aug 3, 2009 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) */ module dstep.foundation.NSDate; import dstep.foundation.NSCalendarDate; import dstep.foundation.NSCoder; import dstep.foundation.NSObject; import dstep.foundation.NSString; import dstep.foundation.NSTimeZone; import dstep.foundation.NSZone; import dstep.objc.bridge.Bridge; import dstep.objc.objc; alias double NSTimeInterval; const TNSExtendedDate = ` double timeIntervalSinceDate (NSDate anotherDate) { return invokeObjcSelf!(double, "timeIntervalSinceDate:", NSDate)(anotherDate); } double timeIntervalSinceNow () { return invokeObjcSelf!(double, "timeIntervalSinceNow"); } double timeIntervalSince1970 () { return invokeObjcSelf!(double, "timeIntervalSince1970"); } Object addTimeInterval (double seconds) { return invokeObjcSelf!(Object, "addTimeInterval:", double)(seconds); } NSDate earlierDate (NSDate anotherDate) { return invokeObjcSelf!(NSDate, "earlierDate:", NSDate)(anotherDate); } NSDate laterDate (NSDate anotherDate) { return invokeObjcSelf!(NSDate, "laterDate:", NSDate)(anotherDate); } int compare (NSDate other) { return invokeObjcSelf!(int, "compare:", NSDate)(other); } NSString description () { return invokeObjcSelf!(NSString, "description"); } bool isEqualToDate (NSDate otherDate) { return invokeObjcSelf!(bool, "isEqualToDate:", NSDate)(otherDate); } static double timeIntervalSinceReferenceDate_static () { return invokeObjcSuperClass!(double, "timeIntervalSinceReferenceDate"); } `; const TNSDateCreation = ` static Object date () { return invokeObjcSuperClass!(Object, "date"); } static Object dateWithTimeIntervalSinceNow (double secs) { return invokeObjcSuperClass!(Object, "dateWithTimeIntervalSinceNow:", double)(secs); } static Object dateWithTimeIntervalSinceReferenceDate (double secs) { return invokeObjcSuperClass!(Object, "dateWithTimeIntervalSinceReferenceDate:", double)(secs); } static Object dateWithTimeIntervalSince1970 (double secs) { return invokeObjcSuperClass!(Object, "dateWithTimeIntervalSince1970:", double)(secs); } static Object distantFuture () { return invokeObjcSuperClass!(Object, "distantFuture"); } static Object distantPast () { return invokeObjcSuperClass!(Object, "distantPast"); } Object initWithTimeIntervalSinceReferenceDate (double secsToBeAdded) { return invokeObjcSelf!(Object, "initWithTimeIntervalSinceReferenceDate:", double)(secsToBeAdded); } this (double secsToBeAdded) { typeof(this).alloc.initWithTimeIntervalSinceReferenceDate(secsToBeAdded); } Object initWithTimeInterval (double secsToBeAdded, NSDate anotherDate) { return invokeObjcSelf!(Object, "initWithTimeInterval:sinceDate:", double, NSDate)(secsToBeAdded, anotherDate); } this (double secsToBeAdded, NSDate anotherDate) { typeof(this).alloc.initWithTimeInterval(secsToBeAdded, anotherDate); } Object initWithTimeIntervalSinceNow (double secsToBeAddedToNow) { return invokeObjcSelf!(Object, "initWithTimeIntervalSinceNow:", double)(secsToBeAddedToNow); } this (double secsToBeAddedToNow) { typeof(this).alloc.initWithTimeIntervalSinceNow(secsToBeAddedToNow); } `; class NSDate : NSObject, INSCopying, INSCoding { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } double timeIntervalSinceReferenceDate () { return invokeObjcSelf!(double, "timeIntervalSinceReferenceDate"); } Object copyWithZone (NSZone* zone) { return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); } void encodeWithCoder (NSCoder aCoder) { return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); } NSDate initWithCoder (NSCoder aDecoder) { return invokeObjcSelf!(NSDate, "initWithCoder:", NSCoder)(aDecoder); } this (NSCoder aDecoder) { typeof(this).alloc.initWithCoder(aDecoder); } // TNSExtendedDate double timeIntervalSinceDate (NSDate anotherDate) { return invokeObjcSelf!(double, "timeIntervalSinceDate:", NSDate)(anotherDate); } double timeIntervalSinceNow () { return invokeObjcSelf!(double, "timeIntervalSinceNow"); } double timeIntervalSince1970 () { return invokeObjcSelf!(double, "timeIntervalSince1970"); } Object addTimeInterval (double seconds) { return invokeObjcSelf!(Object, "addTimeInterval:", double)(seconds); } NSDate earlierDate (NSDate anotherDate) { return invokeObjcSelf!(NSDate, "earlierDate:", NSDate)(anotherDate); } NSDate laterDate (NSDate anotherDate) { return invokeObjcSelf!(NSDate, "laterDate:", NSDate)(anotherDate); } int compare (NSDate other) { return invokeObjcSelf!(int, "compare:", NSDate)(other); } NSString description () { return invokeObjcSelf!(NSString, "description"); } bool isEqualToDate (NSDate otherDate) { return invokeObjcSelf!(bool, "isEqualToDate:", NSDate)(otherDate); } static double timeIntervalSinceReferenceDate_static () { return invokeObjcSuperClass!(double, "timeIntervalSinceReferenceDate"); } // TNSDateCreation static Object date () { return invokeObjcSuperClass!(Object, "date"); } static Object dateWithTimeIntervalSinceNow (double secs) { return invokeObjcSuperClass!(Object, "dateWithTimeIntervalSinceNow:", double)(secs); } static Object dateWithTimeIntervalSinceReferenceDate (double secs) { return invokeObjcSuperClass!(Object, "dateWithTimeIntervalSinceReferenceDate:", double)(secs); } static Object dateWithTimeIntervalSince1970 (double secs) { return invokeObjcSuperClass!(Object, "dateWithTimeIntervalSince1970:", double)(secs); } static Object distantFuture () { return invokeObjcSuperClass!(Object, "distantFuture"); } static Object distantPast () { return invokeObjcSuperClass!(Object, "distantPast"); } Object initWithTimeIntervalSinceReferenceDate (double secsToBeAdded) { return invokeObjcSelf!(Object, "initWithTimeIntervalSinceReferenceDate:", double)(secsToBeAdded); } this (double secsToBeAdded) { typeof(this).alloc.initWithTimeIntervalSinceReferenceDate(secsToBeAdded); } Object initWithTimeInterval (double secsToBeAdded, NSDate anotherDate) { return invokeObjcSelf!(Object, "initWithTimeInterval:sinceDate:", double, NSDate)(secsToBeAdded, anotherDate); } this (double secsToBeAdded, NSDate anotherDate) { typeof(this).alloc.initWithTimeInterval(secsToBeAdded, anotherDate); } Object initWithTimeIntervalSinceNow (double secsToBeAddedToNow) { return invokeObjcSelf!(Object, "initWithTimeIntervalSinceNow:", double)(secsToBeAddedToNow); } // TNSNaturalLangage static Object dateWithNaturalLanguageString (NSString string) { return invokeObjcSuperClass!(Object, "dateWithNaturalLanguageString:", NSString)(string); } static Object dateWithNaturalLanguageString (NSString string, Object locale) { return invokeObjcSuperClass!(Object, "dateWithNaturalLanguageString:locale:", NSString, Object)(string, locale); } // TNSCalendarDateExtras static Object dateWithString (NSString aString) { return invokeObjcSuperClass!(Object, "dateWithString:", NSString)(aString); } Object initWithString (NSString description) { return invokeObjcSelf!(Object, "initWithString:", NSString)(description); } this (NSString description) { typeof(this).alloc.initWithString(description); } NSCalendarDate dateWithCalendarFormat (NSString format, NSTimeZone aTimeZone) { return invokeObjcSelf!(NSCalendarDate, "dateWithCalendarFormat:timeZone:", NSString, NSTimeZone)(format, aTimeZone); } NSString descriptionWithLocale (Object locale) { return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); } NSString descriptionWithCalendarFormat (NSString format, NSTimeZone aTimeZone, Object locale) { return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:timeZone:locale:", NSString, NSTimeZone, Object)(format, aTimeZone, locale); } }