diff 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
line wrap: on
line diff
--- a/dstep/foundation/NSTimeZone.d	Mon Aug 03 15:31:48 2009 +0200
+++ b/dstep/foundation/NSTimeZone.d	Sun Jan 03 22:06:11 2010 +0100
@@ -7,20 +7,30 @@
 module dstep.foundation.NSTimeZone;
 
 import dstep.foundation.NSArray;
+import dstep.foundation.NSCoder;
 import dstep.foundation.NSData;
 import dstep.foundation.NSDate;
 import dstep.foundation.NSDictionary;
 import dstep.foundation.NSLocale;
+import dstep.foundation.NSObjCRuntime;
 import dstep.foundation.NSObject;
 import dstep.foundation.NSString;
+import dstep.foundation.NSZone;
 import dstep.objc.bridge.Bridge;
-import dstep.objc.objc : id;
-
+import dstep.objc.objc;
 import bindings = dstep.foundation.NSTimeZone_bindings;
 
 alias NSInteger NSTimeZoneNameStyle;
 
-const NSString NSSystemTimeZoneDidChangeNotification;
+private NSString NSSystemTimeZoneDidChangeNotification_;
+
+NSString NSSystemTimeZoneDidChangeNotification ()
+{
+	if (NSSystemTimeZoneDidChangeNotification_)
+		return NSSystemTimeZoneDidChangeNotification_;
+	
+	return NSSystemTimeZoneDidChangeNotification_ = new NSString(bindings.NSSystemTimeZoneDidChangeNotification);
+}
 
 enum
 {
@@ -30,16 +40,140 @@
 	NSTimeZoneNameStyleShortDaylightSaving
 }
 
-static this ()
-{
-	NSSystemTimeZoneDidChangeNotification = new NSString(bindings.NSSystemTimeZoneDidChangeNotification);
-}
+const TNSExtendedTimeZone = `
+
+	static NSTimeZone systemTimeZone ()
+	{
+		return invokeObjcSuperClass!(NSTimeZone, "systemTimeZone");
+	}
+
+	static void resetSystemTimeZone ()
+	{
+		return invokeObjcSuperClass!(void, "resetSystemTimeZone");
+	}
+
+	static NSTimeZone defaultTimeZone ()
+	{
+		return invokeObjcSuperClass!(NSTimeZone, "defaultTimeZone");
+	}
+
+	static void setDefaultTimeZone (NSTimeZone aTimeZone)
+	{
+		return invokeObjcSuperClass!(void, "setDefaultTimeZone:", NSTimeZone)(aTimeZone);
+	}
+
+	static NSTimeZone localTimeZone ()
+	{
+		return invokeObjcSuperClass!(NSTimeZone, "localTimeZone");
+	}
+
+	static NSArray knownTimeZoneNames ()
+	{
+		return invokeObjcSuperClass!(NSArray, "knownTimeZoneNames");
+	}
+
+	static NSDictionary abbreviationDictionary ()
+	{
+		return invokeObjcSuperClass!(NSDictionary, "abbreviationDictionary");
+	}
+
+	NSInteger secondsFromGMT ()
+	{
+		return invokeObjcSelf!(NSInteger, "secondsFromGMT");
+	}
+
+	NSString abbreviation ()
+	{
+		return invokeObjcSelf!(NSString, "abbreviation");
+	}
+
+	bool isDaylightSavingTime ()
+	{
+		return invokeObjcSelf!(bool, "isDaylightSavingTime");
+	}
+
+	double daylightSavingTimeOffset ()
+	{
+		return invokeObjcSelf!(double, "daylightSavingTimeOffset");
+	}
+
+	NSDate nextDaylightSavingTimeTransition ()
+	{
+		return invokeObjcSelf!(NSDate, "nextDaylightSavingTimeTransition");
+	}
+
+	NSString description ()
+	{
+		return invokeObjcSelf!(NSString, "description");
+	}
+
+	bool isEqualToTimeZone (NSTimeZone aTimeZone)
+	{
+		return invokeObjcSelf!(bool, "isEqualToTimeZone:", NSTimeZone)(aTimeZone);
+	}
+
+	NSString localizedName (int style, NSLocale locale)
+	{
+		return invokeObjcSelf!(NSString, "localizedName:locale:", int, NSLocale)(style, locale);
+	}
+`;
+
+const TNSTimeZoneCreation = `
+
+	static Object timeZoneWithName (NSString tzName)
+	{
+		return invokeObjcSuperClass!(Object, "timeZoneWithName:", NSString)(tzName);
+	}
+
+	static Object timeZoneWithName (NSString tzName, NSData aData)
+	{
+		return invokeObjcSuperClass!(Object, "timeZoneWithName:data:", NSString, NSData)(tzName, aData);
+	}
+
+	Object initWithName (NSString tzName)
+	{
+		return invokeObjcSelf!(Object, "initWithName:", NSString)(tzName);
+	}
+
+	this (NSString tzName)
+	{
+		typeof(this).alloc.initWithName(tzName);
+	}
+
+	Object initWithName (NSString tzName, NSData aData)
+	{
+		return invokeObjcSelf!(Object, "initWithName:data:", NSString, NSData)(tzName, aData);
+	}
+
+	this (NSString tzName, NSData aData)
+	{
+		typeof(this).alloc.initWithName(tzName, aData);
+	}
+
+	static Object timeZoneForSecondsFromGMT (NSInteger seconds)
+	{
+		return invokeObjcSuperClass!(Object, "timeZoneForSecondsFromGMT:", NSInteger)(seconds);
+	}
+
+	static Object timeZoneWithAbbreviation (NSString abbreviation)
+	{
+		return invokeObjcSuperClass!(Object, "timeZoneWithAbbreviation:", NSString)(abbreviation);
+	}
+`;
 
 class NSTimeZone : NSObject, INSCopying, INSCoding
 {
-	mixin ObjcWrap;
-	mixin TNSExtendedTimeZone;
-	mixin TNSTimeZoneCreation;
+	mixin (ObjcWrap);
+	
+	this ()
+	{
+		super(typeof(this).alloc.init.objcObject);
+	}
+	
+	typeof(this) init ()
+	{
+		return invokeObjcSelf!(typeof(this), "init");
+	}
 
 	NSString name ()
 	{
@@ -93,146 +227,123 @@
 
 	this (NSCoder aDecoder)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithCoder(aDecoder);
 	}
-}
-
-template TNSExtendedTimeZone ()
-{
+	
+	// TNSExtendedTimeZone
 	static NSTimeZone systemTimeZone ()
 	{
-		return invokeObjcSelfClass!(NSTimeZone, "systemTimeZone");
+		return invokeObjcSuperClass!(NSTimeZone, "systemTimeZone");
 	}
-
+	
 	static void resetSystemTimeZone ()
 	{
-		return invokeObjcSelfClass!(void, "resetSystemTimeZone");
+		return invokeObjcSuperClass!(void, "resetSystemTimeZone");
 	}
-
+	
 	static NSTimeZone defaultTimeZone ()
 	{
-		return invokeObjcSelfClass!(NSTimeZone, "defaultTimeZone");
+		return invokeObjcSuperClass!(NSTimeZone, "defaultTimeZone");
 	}
-
+	
 	static void setDefaultTimeZone (NSTimeZone aTimeZone)
 	{
-		return invokeObjcSelfClass!(void, "setDefaultTimeZone:", NSTimeZone)(aTimeZone);
+		return invokeObjcSuperClass!(void, "setDefaultTimeZone:", NSTimeZone)(aTimeZone);
 	}
-
+	
 	static NSTimeZone localTimeZone ()
 	{
-		return invokeObjcSelfClass!(NSTimeZone, "localTimeZone");
+		return invokeObjcSuperClass!(NSTimeZone, "localTimeZone");
 	}
-
+	
 	static NSArray knownTimeZoneNames ()
 	{
-		return invokeObjcSelfClass!(NSArray, "knownTimeZoneNames");
+		return invokeObjcSuperClass!(NSArray, "knownTimeZoneNames");
 	}
-
+	
 	static NSDictionary abbreviationDictionary ()
 	{
-		return invokeObjcSelfClass!(NSDictionary, "abbreviationDictionary");
+		return invokeObjcSuperClass!(NSDictionary, "abbreviationDictionary");
 	}
-
+	
 	NSInteger secondsFromGMT ()
 	{
 		return invokeObjcSelf!(NSInteger, "secondsFromGMT");
 	}
-
+	
 	NSString abbreviation ()
 	{
 		return invokeObjcSelf!(NSString, "abbreviation");
 	}
-
+	
 	bool isDaylightSavingTime ()
 	{
 		return invokeObjcSelf!(bool, "isDaylightSavingTime");
 	}
-
+	
 	double daylightSavingTimeOffset ()
 	{
 		return invokeObjcSelf!(double, "daylightSavingTimeOffset");
 	}
-
+	
 	NSDate nextDaylightSavingTimeTransition ()
 	{
 		return invokeObjcSelf!(NSDate, "nextDaylightSavingTimeTransition");
 	}
-
+	
 	NSString description ()
 	{
 		return invokeObjcSelf!(NSString, "description");
 	}
-
+	
 	bool isEqualToTimeZone (NSTimeZone aTimeZone)
 	{
 		return invokeObjcSelf!(bool, "isEqualToTimeZone:", NSTimeZone)(aTimeZone);
 	}
-
+	
 	NSString localizedName (int style, NSLocale locale)
 	{
 		return invokeObjcSelf!(NSString, "localizedName:locale:", int, NSLocale)(style, locale);
 	}
-}
-
-template TNSTimeZoneCreation ()
-{
+	
+	// TNSTimeZoneCreation
 	static Object timeZoneWithName (NSString tzName)
 	{
-		return invokeObjcSelfClass!(Object, "timeZoneWithName:", NSString)(tzName);
+		return invokeObjcSuperClass!(Object, "timeZoneWithName:", NSString)(tzName);
 	}
-
+	
 	static Object timeZoneWithName (NSString tzName, NSData aData)
 	{
-		return invokeObjcSelfClass!(Object, "timeZoneWithName:data:", NSString, NSData)(tzName, aData);
+		return invokeObjcSuperClass!(Object, "timeZoneWithName:data:", NSString, NSData)(tzName, aData);
 	}
-
+	
 	Object initWithName (NSString tzName)
 	{
 		return invokeObjcSelf!(Object, "initWithName:", NSString)(tzName);
 	}
-
+	
 	this (NSString tzName)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithName:", NSString)(objcObject, tzName);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithName(tzName);
 	}
-
+	
 	Object initWithName (NSString tzName, NSData aData)
 	{
 		return invokeObjcSelf!(Object, "initWithName:data:", NSString, NSData)(tzName, aData);
 	}
-
+	
 	this (NSString tzName, NSData aData)
 	{
-		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
-		id result = Bridge.invokeObjcMethod!(id, "initWithName:data:", NSString, NSData)(objcObject, tzName, aData);
-
-		if (result)
-			objcObject = ret;
-
-		dObject = this;
+		typeof(this).alloc.initWithName(tzName, aData);
 	}
-
+	
 	static Object timeZoneForSecondsFromGMT (NSInteger seconds)
 	{
-		return invokeObjcSelfClass!(Object, "timeZoneForSecondsFromGMT:", NSInteger)(seconds);
+		return invokeObjcSuperClass!(Object, "timeZoneForSecondsFromGMT:", NSInteger)(seconds);
 	}
-
+	
 	static Object timeZoneWithAbbreviation (NSString abbreviation)
 	{
-		return invokeObjcSelfClass!(Object, "timeZoneWithAbbreviation:", NSString)(abbreviation);
+		return invokeObjcSuperClass!(Object, "timeZoneWithAbbreviation:", NSString)(abbreviation);
 	}
-}
-
+}
\ No newline at end of file