Mercurial > projects > dstep
view dstep/foundation/NSLocale.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.NSLocale; import dstep.foundation.NSArray; import dstep.foundation.NSCoder; import dstep.foundation.NSDictionary; import dstep.foundation.NSObject; import dstep.foundation.NSString; import dstep.foundation.NSZone; import dstep.objc.bridge.Bridge; import dstep.objc.objc; import bindings = dstep.foundation.NSLocale_bindings; private { NSString NSCurrentLocaleDidChangeNotification_; NSString NSLocaleIdentifier_; NSString NSLocaleLanguageCode_; NSString NSLocaleCountryCode_; NSString NSLocaleScriptCode_; NSString NSLocaleVariantCode_; NSString NSLocaleExemplarCharacterSet_; NSString NSLocaleCalendar_; NSString NSLocaleCollationIdentifier_; NSString NSLocaleUsesMetricSystem_; NSString NSLocaleMeasurementSystem_; NSString NSLocaleDecimalSeparator_; NSString NSLocaleGroupingSeparator_; NSString NSLocaleCurrencySymbol_; NSString NSLocaleCurrencyCode_; NSString NSGregorianCalendar_; NSString NSBuddhistCalendar_; NSString NSChineseCalendar_; NSString NSHebrewCalendar_; NSString NSIslamicCalendar_; NSString NSIslamicCivilCalendar_; NSString NSJapaneseCalendar_; } NSString NSCurrentLocaleDidChangeNotification () { if (NSCurrentLocaleDidChangeNotification_) return NSCurrentLocaleDidChangeNotification_; return NSCurrentLocaleDidChangeNotification_ = new NSString(bindings.NSCurrentLocaleDidChangeNotification); } NSString NSLocaleIdentifier () { if (NSLocaleIdentifier_) return NSLocaleIdentifier_; return NSLocaleIdentifier_ = new NSString(bindings.NSLocaleIdentifier); } NSString NSLocaleLanguageCode () { if (NSLocaleLanguageCode_) return NSLocaleLanguageCode_; return NSLocaleLanguageCode_ = new NSString(bindings.NSLocaleLanguageCode); } NSString NSLocaleCountryCode () { if (NSLocaleCountryCode_) return NSLocaleCountryCode_; return NSLocaleCountryCode_ = new NSString(bindings.NSLocaleCountryCode); } NSString NSLocaleScriptCode () { if (NSLocaleScriptCode_) return NSLocaleScriptCode_; return NSLocaleScriptCode_ = new NSString(bindings.NSLocaleScriptCode); } NSString NSLocaleVariantCode () { if (NSLocaleVariantCode_) return NSLocaleVariantCode_; return NSLocaleVariantCode_ = new NSString(bindings.NSLocaleVariantCode); } NSString NSLocaleExemplarCharacterSet () { if (NSLocaleExemplarCharacterSet_) return NSLocaleExemplarCharacterSet_; return NSLocaleExemplarCharacterSet_ = new NSString(bindings.NSLocaleExemplarCharacterSet); } NSString NSLocaleCalendar () { if (NSLocaleCalendar_) return NSLocaleCalendar_; return NSLocaleCalendar_ = new NSString(bindings.NSLocaleCalendar); } NSString NSLocaleCollationIdentifier () { if (NSLocaleCollationIdentifier_) return NSLocaleCollationIdentifier_; return NSLocaleCollationIdentifier_ = new NSString(bindings.NSLocaleCollationIdentifier); } NSString NSLocaleUsesMetricSystem () { if (NSLocaleUsesMetricSystem_) return NSLocaleUsesMetricSystem_; return NSLocaleUsesMetricSystem_ = new NSString(bindings.NSLocaleUsesMetricSystem); } NSString NSLocaleMeasurementSystem () { if (NSLocaleMeasurementSystem_) return NSLocaleMeasurementSystem_; return NSLocaleMeasurementSystem_ = new NSString(bindings.NSLocaleMeasurementSystem); } NSString NSLocaleDecimalSeparator () { if (NSLocaleDecimalSeparator_) return NSLocaleDecimalSeparator_; return NSLocaleDecimalSeparator_ = new NSString(bindings.NSLocaleDecimalSeparator); } NSString NSLocaleGroupingSeparator () { if (NSLocaleGroupingSeparator_) return NSLocaleGroupingSeparator_; return NSLocaleGroupingSeparator_ = new NSString(bindings.NSLocaleGroupingSeparator); } NSString NSLocaleCurrencySymbol () { if (NSLocaleCurrencySymbol_) return NSLocaleCurrencySymbol_; return NSLocaleCurrencySymbol_ = new NSString(bindings.NSLocaleCurrencySymbol); } NSString NSLocaleCurrencyCode () { if (NSLocaleCurrencyCode_) return NSLocaleCurrencyCode_; return NSLocaleCurrencyCode_ = new NSString(bindings.NSLocaleCurrencyCode); } NSString NSGregorianCalendar () { if (NSGregorianCalendar_) return NSGregorianCalendar_; return NSGregorianCalendar_ = new NSString(bindings.NSGregorianCalendar); } NSString NSBuddhistCalendar () { if (NSBuddhistCalendar_) return NSBuddhistCalendar_; return NSBuddhistCalendar_ = new NSString(bindings.NSBuddhistCalendar); } NSString NSChineseCalendar () { if (NSChineseCalendar_) return NSChineseCalendar_; return NSChineseCalendar_ = new NSString(bindings.NSChineseCalendar); } NSString NSHebrewCalendar () { if (NSHebrewCalendar_) return NSHebrewCalendar_; return NSHebrewCalendar_ = new NSString(bindings.NSHebrewCalendar); } NSString NSIslamicCalendar () { if (NSIslamicCalendar_) return NSIslamicCalendar_; return NSIslamicCalendar_ = new NSString(bindings.NSIslamicCalendar); } NSString NSIslamicCivilCalendar () { if (NSIslamicCivilCalendar_) return NSIslamicCivilCalendar_; return NSIslamicCivilCalendar_ = new NSString(bindings.NSIslamicCivilCalendar); } NSString NSJapaneseCalendar () { if (NSJapaneseCalendar_) return NSJapaneseCalendar_; return NSJapaneseCalendar_ = new NSString(bindings.NSJapaneseCalendar); } const TNSLocaleCreation = ` static Object systemLocale () { return invokeObjcSuperClass!(Object, "systemLocale"); } static Object currentLocale () { return invokeObjcSuperClass!(Object, "currentLocale"); } static Object autoupdatingCurrentLocale () { return invokeObjcSuperClass!(Object, "autoupdatingCurrentLocale"); } Object initWithLocaleIdentifier (NSString string) { return invokeObjcSelf!(Object, "initWithLocaleIdentifier:", NSString)(string); } this (NSString string) { typeof(this).alloc.initWithLocaleIdentifier(string); } `; const TNSLocaleGeneralInfo = ` static NSArray availableLocaleIdentifiers () { return invokeObjcSuperClass!(NSArray, "availableLocaleIdentifiers"); } static NSArray ISOLanguageCodes () { return invokeObjcSuperClass!(NSArray, "ISOLanguageCodes"); } static NSArray ISOCountryCodes () { return invokeObjcSuperClass!(NSArray, "ISOCountryCodes"); } static NSArray ISOCurrencyCodes () { return invokeObjcSuperClass!(NSArray, "ISOCurrencyCodes"); } static NSArray commonISOCurrencyCodes () { return invokeObjcSuperClass!(NSArray, "commonISOCurrencyCodes"); } static NSArray preferredLanguages () { return invokeObjcSuperClass!(NSArray, "preferredLanguages"); } static NSDictionary componentsFromLocaleIdentifier (NSString string) { return invokeObjcSuperClass!(NSDictionary, "componentsFromLocaleIdentifier:", NSString)(string); } static NSString localeIdentifierFromComponents (NSDictionary dict) { return invokeObjcSuperClass!(NSString, "localeIdentifierFromComponents:", NSDictionary)(dict); } static NSString canonicalLocaleIdentifierFromString (NSString string) { return invokeObjcSuperClass!(NSString, "canonicalLocaleIdentifierFromString:", NSString)(string); } `; const TNSExtendedLocale = ` NSString localeIdentifier () { return invokeObjcSelf!(NSString, "localeIdentifier"); } `; class NSLocale : NSObject, INSCopying, INSCoding { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } Object objectForKey (Object key) { return invokeObjcSelf!(Object, "objectForKey:", Object)(key); } NSString displayNameForKey (Object key, Object value) { return invokeObjcSelf!(NSString, "displayNameForKey:value:", Object, Object)(key, value); } Object copyWithZone (NSZone* zone) { return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); } void encodeWithCoder (NSCoder aCoder) { return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); } Object initWithCoder (NSCoder aDecoder) { return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); } this (NSCoder aDecoder) { typeof(this).alloc.initWithCoder(aDecoder); } // TNSLocaleCreation static Object systemLocale () { return invokeObjcSuperClass!(Object, "systemLocale"); } static Object currentLocale () { return invokeObjcSuperClass!(Object, "currentLocale"); } static Object autoupdatingCurrentLocale () { return invokeObjcSuperClass!(Object, "autoupdatingCurrentLocale"); } Object initWithLocaleIdentifier (NSString string) { return invokeObjcSelf!(Object, "initWithLocaleIdentifier:", NSString)(string); } this (NSString string) { typeof(this).alloc.initWithLocaleIdentifier(string); } // TNSLocaleGeneralInfo static NSArray availableLocaleIdentifiers () { return invokeObjcSuperClass!(NSArray, "availableLocaleIdentifiers"); } static NSArray ISOLanguageCodes () { return invokeObjcSuperClass!(NSArray, "ISOLanguageCodes"); } static NSArray ISOCountryCodes () { return invokeObjcSuperClass!(NSArray, "ISOCountryCodes"); } static NSArray ISOCurrencyCodes () { return invokeObjcSuperClass!(NSArray, "ISOCurrencyCodes"); } static NSArray commonISOCurrencyCodes () { return invokeObjcSuperClass!(NSArray, "commonISOCurrencyCodes"); } static NSArray preferredLanguages () { return invokeObjcSuperClass!(NSArray, "preferredLanguages"); } static NSDictionary componentsFromLocaleIdentifier (NSString string) { return invokeObjcSuperClass!(NSDictionary, "componentsFromLocaleIdentifier:", NSString)(string); } static NSString localeIdentifierFromComponents (NSDictionary dict) { return invokeObjcSuperClass!(NSString, "localeIdentifierFromComponents:", NSDictionary)(dict); } static NSString canonicalLocaleIdentifierFromString (NSString string) { return invokeObjcSuperClass!(NSString, "canonicalLocaleIdentifierFromString:", NSString)(string); } // TNSExtendedLocale NSString localeIdentifier () { return invokeObjcSelf!(NSString, "localeIdentifier"); } }