mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 17:10:48 +00:00
Added a few more methods to NSNumberFormatter and implemented NSLocale code that required changes to NSNumberFormatter. NSLocale now passes all tests in the testsuite.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31863 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d3857cd49f
commit
27bf149e78
3 changed files with 83 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
|||
2011-01-09 Stefan Bidigaray <stefanbidi@gmail.com>
|
||||
|
||||
* Source/NSNumberFormatter.m: Implemented a few more methods.
|
||||
* Source/NSLocale.m: Added code requiring NSNumberFormatter code.
|
||||
|
||||
2011-01-09 Stefan Bidigaray <stefanbidi@gmail.com>
|
||||
|
||||
* Headers/Additions/GNUstepBase/config.h.in:
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
//#import "Foundation/NSNumberFormatter.h"
|
||||
#import "Foundation/NSNumberFormatter.h"
|
||||
#import "Foundation/NSUserDefaults.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
|
@ -970,25 +970,60 @@ static NSRecursiveLock *classLock = nil;
|
|||
#endif
|
||||
}
|
||||
|
||||
// FIXME: these should be fairly simple, but require changes to NSNumberFormatter.
|
||||
- (NSString *) _getDecimalSeparator
|
||||
{
|
||||
return nil;
|
||||
NSNumberFormatter *nFor;
|
||||
NSString *result;
|
||||
|
||||
nFor = [[NSNumberFormatter alloc] init];
|
||||
[nFor setLocale: self];
|
||||
[nFor setNumberStyle: NSNumberFormatterDecimalStyle];
|
||||
result = [nFor decimalSeparator];
|
||||
|
||||
RELEASE(nFor);
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSString *) _getGroupingSeparator
|
||||
{
|
||||
return nil;
|
||||
NSNumberFormatter *nFor;
|
||||
NSString *result;
|
||||
|
||||
nFor = [[NSNumberFormatter alloc] init];
|
||||
[nFor setLocale: self];
|
||||
[nFor setNumberStyle: NSNumberFormatterDecimalStyle];
|
||||
result = [nFor groupingSeparator];
|
||||
|
||||
RELEASE(nFor);
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSString *) _getCurrencySymbol
|
||||
{
|
||||
return nil;
|
||||
NSNumberFormatter *nFor;
|
||||
NSString *result;
|
||||
|
||||
nFor = [[NSNumberFormatter alloc] init];
|
||||
[nFor setLocale: self];
|
||||
[nFor setNumberStyle: NSNumberFormatterCurrencyStyle];
|
||||
result = [nFor currencySymbol];
|
||||
|
||||
RELEASE(nFor);
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSString *) _getCurrencyCode
|
||||
{
|
||||
return nil;
|
||||
NSNumberFormatter *nFor;
|
||||
NSString *result;
|
||||
|
||||
nFor = [[NSNumberFormatter alloc] init];
|
||||
[nFor setLocale: self];
|
||||
[nFor setNumberStyle: NSNumberFormatterCurrencyStyle];
|
||||
result = [nFor currencyCode];
|
||||
|
||||
RELEASE(nFor);
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -414,7 +414,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
RELEASE(o);
|
||||
|
||||
_behavior = _defaultBehavior;
|
||||
_locale = [NSLocale currentLocale];
|
||||
_locale = RETAIN([NSLocale currentLocale]);
|
||||
[self _openUNumberFormat];
|
||||
|
||||
return self;
|
||||
|
@ -1315,12 +1315,20 @@ static NSUInteger _defaultBehavior = 0;
|
|||
|
||||
- (void) setCurrencyCode: (NSString *) string
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
[self _setTextAttribute: string : UNUM_CURRENCY_CODE];
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSString *) currencyCode
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return [self _getTextAttribute: UNUM_CURRENCY_CODE];
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void) setInternationalCurrencySymbol: (NSString *) string
|
||||
|
@ -1353,37 +1361,65 @@ static NSUInteger _defaultBehavior = 0;
|
|||
|
||||
- (NSString *) positivePrefix
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return [self _getTextAttribute: UNUM_POSITIVE_PREFIX];
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void) setPositiveSuffix: (NSString *) string
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
[self _setTextAttribute: string : UNUM_POSITIVE_SUFFIX];
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSString *) positiveSuffix
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return [self _getTextAttribute: UNUM_POSITIVE_SUFFIX];
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void) setNegativePrefix: (NSString *) string
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
[self _setTextAttribute: string : UNUM_NEGATIVE_PREFIX];
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSString *) negativePrefix
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return [self _getTextAttribute: UNUM_NEGATIVE_PREFIX];
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void) setNegativeSuffix: (NSString *) string
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
[self _setTextAttribute: string : UNUM_NEGATIVE_SUFFIX];
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSString *) negativeSuffix
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return [self _getTextAttribute: UNUM_NEGATIVE_SUFFIX];
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue