diff dstep/foundation/NSCalendarDate.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 7ff919f595d5
children b9de51448c6b
line wrap: on
line diff
--- a/dstep/foundation/NSCalendarDate.d	Mon Aug 03 15:31:48 2009 +0200
+++ b/dstep/foundation/NSCalendarDate.d	Sun Jan 03 22:06:11 2010 +0100
@@ -8,33 +8,90 @@
 
 import dstep.foundation.NSArray;
 import dstep.foundation.NSDate;
+import dstep.foundation.NSObjCRuntime;
 import dstep.foundation.NSString;
 import dstep.foundation.NSTimeZone;
 import dstep.objc.bridge.Bridge;
-import dstep.objc.objc : id;
+import dstep.objc.objc;
+
+const 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);
+	}
+`;
+
+const 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);
+	}
+`;
 
 class NSCalendarDate : NSDate
 {
-	mixin ObjcWrap;
+	mixin (ObjcWrap);
+	
+	this ()
+	{
+		super(typeof(this).alloc.init.objcObject);
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
+	}
 
 	static Object dateWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone)
 	{
-		return invokeObjcSelfClass!(Object, "dateWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(year, month, day, hour, minute, second, aTimeZone);
+		return invokeObjcSuperClass!(Object, "dateWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(year, month, day, hour, minute, second, aTimeZone);
 	}
 
 	static Object dateWithString (NSString description, NSString format)
 	{
-		return invokeObjcSelfClass!(Object, "dateWithString:calendarFormat:", NSString, NSString)(description, format);
+		return invokeObjcSuperClass!(Object, "dateWithString:calendarFormat:", NSString, NSString)(description, format);
 	}
 
 	static Object dateWithString (NSString description, NSString format, Object locale)
 	{
-		return invokeObjcSelfClass!(Object, "dateWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale);
+		return invokeObjcSuperClass!(Object, "dateWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale);
 	}
 
 	static Object calendarDate ()
 	{
-		return invokeObjcSelfClass!(Object, "calendarDate");
+		return invokeObjcSuperClass!(Object, "calendarDate");
 	}
 
 	Object initWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone)
@@ -44,13 +101,7 @@
 
 	this (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(objcObject, year, month, day, hour, minute, second, aTimeZone);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithYear(year, month, day, hour, minute, second, aTimeZone);
 	}
 
 	Object initWithString (NSString description)
@@ -60,13 +111,7 @@
 
 	this (NSString description)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithString:", NSString)(objcObject, description);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithString(description);
 	}
 
 	Object initWithString (NSString description, NSString format)
@@ -76,13 +121,7 @@
 
 	this (NSString description, NSString format)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithString:calendarFormat:", NSString, NSString)(objcObject, description, format);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithString(description, format);
 	}
 
 	Object initWithString (NSString description, NSString format, Object locale)
@@ -92,13 +131,7 @@
 
 	this (NSString description, NSString format, Object locale)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithString:calendarFormat:locale:", NSString, NSString, Object)(objcObject, description, format, locale);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithString(description, format, locale);
 	}
 
 	NSTimeZone timeZone ()
@@ -196,57 +229,4 @@
 	{
 		return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:locale:", NSString, Object)(format, locale);
 	}
-}
-
-template TNSNaturalLangage ()
-{
-	static Object dateWithNaturalLanguageString (NSString string)
-	{
-		return invokeObjcSelfClass!(Object, "dateWithNaturalLanguageString:", NSString)(string);
-	}
-
-	static Object dateWithNaturalLanguageString (NSString string, Object locale)
-	{
-		return invokeObjcSelfClass!(Object, "dateWithNaturalLanguageString:locale:", NSString, Object)(string, locale);
-	}
-}
-
-template TNSCalendarDateExtras ()
-{
-	static Object dateWithString (NSString aString)
-	{
-		return invokeObjcSelfClass!(Object, "dateWithString:", NSString)(aString);
-	}
-
-	Object initWithString (NSString description)
-	{
-		return invokeObjcSelf!(Object, "initWithString:", NSString)(description);
-	}
-
-	this (NSString description)
-	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithString:", NSString)(objcObject, description);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
-	}
-
-	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);
-	}
-}
-
+}
\ No newline at end of file