more work on reserved/private pointer use

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32182 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2011-02-16 05:49:45 +00:00
parent 21e22ecfb0
commit 6d3afd3d38
41 changed files with 468 additions and 246 deletions

View file

@ -1,3 +1,51 @@
2011-02-16 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSInternal.h:
* Source/NSDateFormatter.m:
* Source/NSNumberFormatter.m:
* Headers/Foundation/NSPortCoder.h:
* Headers/Foundation/NSCache.h:
* Headers/Foundation/NSSpellServer.h:
* Headers/Foundation/NSDecimalNumber.h:
* Headers/Foundation/NSBundle.h:
* Headers/Foundation/NSTimer.h:
* Headers/Foundation/NSScanner.h:
* Headers/Foundation/NSDistributedNotificationCenter.h:
* Headers/Foundation/NSComparisonPredicate.h:
* Headers/Foundation/NSUndoManager.h:
* Headers/Foundation/NSDateFormatter.h:
* Headers/Foundation/NSAutoreleasePool.h:
* Headers/Foundation/NSXMLNode.h:
* Headers/Foundation/NSUserDefaults.h:
* Headers/Foundation/NSThread.h:
* Headers/Foundation/NSHost.h:
* Headers/Foundation/NSRegularExpression.h:
* Headers/Foundation/NSKeyedArchiver.h:
* Headers/Foundation/NSProtocolChecker.h:
* Headers/Foundation/NSError.h:
* Headers/Foundation/NSPortMessage.h:
* Headers/Foundation/NSFileHandle.h:
* Headers/Foundation/NSDistributedLock.h:
* Headers/Foundation/NSPort.h:
* Headers/Foundation/NSSortDescriptor.h:
* Headers/Foundation/NSLocale.h:
* Headers/Foundation/NSTask.h:
* Headers/Foundation/NSArchiver.h:
* Headers/Foundation/NSInvocation.h:
* Headers/Foundation/NSFileManager.h:
* Headers/Foundation/NSNumberFormatter.h:
* Headers/Foundation/NSPortNameServer.h:
* Headers/Foundation/NSXMLParser.h:
* Headers/Foundation/NSIndexPath.h:
* Headers/Additions/GNUstepBase/GSMime.h:
* Headers/Additions/GNUstepBase/GSVersionMacros.h:
* Headers/Additions/GNUstepBase/GSObjCRuntime.h:
More work on clarifying the use of the reserved/private data
pointer. Reinstate accidentally lost '@private', and add the
GS_UNUSED_IVAR attribute as requested by David to avoid static
analyser warnings where the reserved pointer is not actually used
yet. Tidy up latest files to use GSInternal.h
2011-02-15 Richard Frith-Macdonald <rfm@gnu.org> 2011-02-15 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSLocale.m: * Source/GSLocale.m:

View file

@ -75,11 +75,14 @@ extern "C" {
NSMutableDictionary *objects; NSMutableDictionary *objects;
NSMutableDictionary *params; NSMutableDictionary *params;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }
+ (NSString*) makeQuoted: (NSString*)v always: (BOOL)flag; + (NSString*) makeQuoted: (NSString*)v always: (BOOL)flag;

View file

@ -419,7 +419,7 @@ GSObjCDirectSubclassesOfClass(Class cls);
#if GS_API_VERSION(GS_API_ANY,011500) #if GS_API_VERSION(GS_API_ANY,011500)
GS_EXPORT const char * GS_EXPORT const char *
GSLastErrorStr(long error_id) GS_ATTRIB_DEPRECATED; GSLastErrorStr(long error_id) GS_DEPRECATED_FUNC;
#endif #endif

View file

@ -229,13 +229,9 @@
#define GS_EXPOSE(X) (!GS_NONFRAGILE || defined(EXPOSE_##X##_IVARS)) #define GS_EXPOSE(X) (!GS_NONFRAGILE || defined(EXPOSE_##X##_IVARS))
/* Static analyser macros: Provide annotations to help the analyser */ /* Static analyser macros: Provide annotations to help the analyser */
// TODO: Make this more sensible when GCC supports __attribute__((unused)) on
// ivars
#ifdef __clang__ #ifdef __clang__
# define GS_UNUSED_IVAR __attribute__((unused))
# define GS_NORETURN_METHOD __attribute__((__noreturn__)) # define GS_NORETURN_METHOD __attribute__((__noreturn__))
#else #else
# define GS_UNUSED_IVAR
# define GS_NORETURN_METHOD # define GS_NORETURN_METHOD
#endif #endif
@ -322,10 +318,23 @@ static inline void gs_consumed(id o) { return; }
#endif #endif
/* Attribute definitions for attributes which may or may not be supported
* depending on the compiler being used.
* The definition should be of the form GS_XXX_CONTEXT where XXX is the
* name of the attribute and CONTEXT is one of FUNC, METH, or IVAR
* depending on where the attribute can be applied.
*/
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define GS_ATTRIB_DEPRECATED __attribute__ ((deprecated)) # define GS_DEPRECATED_FUNC __attribute__ ((deprecated))
#else #else
#define GS_ATTRIB_DEPRECATED # define GS_DEPRECATED_FUNC
#endif
#ifdef __clang__
# define GS_UNUSED_IVAR __attribute__((unused))
#else
# define GS_UNUSED_IVAR
#endif #endif

View file

@ -70,11 +70,14 @@ extern "C" {
BOOL _encodingRoot; BOOL _encodingRoot;
BOOL _initialPass; BOOL _initialPass;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }
@ -181,11 +184,14 @@ extern "C" {
NSMutableDictionary *objDict; /* Class information store. */ NSMutableDictionary *objDict; /* Class information store. */
NSMutableArray *objSave; NSMutableArray *objSave;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -194,11 +194,14 @@ typedef struct autorelease_array_list
/* The method to add an object to this pool */ /* The method to add an object to this pool */
void (*_addImp)(id, SEL, id); void (*_addImp)(id, SEL, id);
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -119,11 +119,14 @@ GS_EXPORT NSString* const NSLoadedClasses;
unsigned _version; unsigned _version;
NSString *_frameworkVersion; NSString *_frameworkVersion;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -61,11 +61,14 @@ extern "C" {
/** Total number of accesses to objects */ /** Total number of accesses to objects */
int64_t _totalAccesses; int64_t _totalAccesses;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }
/** /**

View file

@ -77,11 +77,14 @@ typedef enum _NSPredicateOperatorType
NSUInteger _options; NSUInteger _options;
NSPredicateOperatorType _type; NSPredicateOperatorType _type;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
@public @public
NSExpression *_left; NSExpression *_left;

View file

@ -128,11 +128,18 @@ typedef NSUInteger NSDateFormatterBehavior;
NSString *_dateFormat; NSString *_dateFormat;
BOOL _allowsNaturalLanguage; BOOL _allowsNaturalLanguage;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
# if defined(GS_NSDateFormatter_IVARS)
@public
GS_NSDateFormatter_IVARS;
# endif
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -129,11 +129,14 @@ extern "C" {
BOOL _raiseOnUnderflow; BOOL _raiseOnUnderflow;
BOOL _raiseOnDivideByZero; BOOL _raiseOnDivideByZero;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -40,11 +40,14 @@ extern "C" {
NSString *_lockPath; NSString *_lockPath;
NSDate *_lockTime; NSDate *_lockTime;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -86,11 +86,14 @@ GS_EXPORT NSString* const GSNetworkNotificationCenterType;
id _remote; /* Proxy for center. */ id _remote; /* Proxy for center. */
BOOL _suspended; /* Is delivery suspended? */ BOOL _suspended; /* Is delivery suspended? */
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }
+ (NSNotificationCenter*) defaultCenter; + (NSNotificationCenter*) defaultCenter;

View file

@ -121,11 +121,14 @@ GS_EXPORT NSString* const NSCocoaErrorDomain;
NSString *_domain; NSString *_domain;
NSDictionary *_userInfo; NSDictionary *_userInfo;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -162,11 +162,14 @@ GS_EXPORT NSString * const NSFileHandleOperationException;
NSFileHandle *_readHandle; NSFileHandle *_readHandle;
NSFileHandle *_writeHandle; NSFileHandle *_writeHandle;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }
+ (id) pipe; + (id) pipe;

View file

@ -203,11 +203,14 @@ typedef uint32_t OSType;
@private @private
NSString *_lastError; NSString *_lastError;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }
@ -392,11 +395,14 @@ typedef uint32_t OSType;
BOOL justContents: 1; BOOL justContents: 1;
} _flags; } _flags;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }
- (NSDictionary*) directoryAttributes; - (NSDictionary*) directoryAttributes;

View file

@ -44,11 +44,14 @@ extern "C" {
NSSet *_names; NSSet *_names;
NSSet *_addresses; NSSet *_addresses;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -50,11 +50,14 @@ extern "C" {
NSUInteger _length; NSUInteger _length;
NSUInteger *_indexes; NSUInteger *_indexes;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -50,11 +50,14 @@ extern "C" {
BOOL _sendToSuper; BOOL _sendToSuper;
void *_retptr; void *_retptr;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -71,11 +71,14 @@ extern "C" {
NSMutableArray *_obj; /* Array of objects. */ NSMutableArray *_obj; /* Array of objects. */
NSPropertyListFormat _format; NSPropertyListFormat _format;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }
@ -243,11 +246,14 @@ extern "C" {
#endif #endif
NSZone *_zone; /* Zone for allocating objs. */ NSZone *_zone; /* Zone for allocating objs. */
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -104,11 +104,14 @@ GS_EXPORT NSString * const NSISO8601Calendar;
NSString *_localeId; NSString *_localeId;
NSMutableDictionary *_components; NSMutableDictionary *_components;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -138,11 +138,18 @@ typedef NSUInteger NSNumberFormatterRoundingMode;
NSDictionary *_attributesForPositiveValues; NSDictionary *_attributesForPositiveValues;
NSDictionary *_attributesForNegativeValues; NSDictionary *_attributesForNegativeValues;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
# if defined(GS_NSNumberFormatter_IVARS)
@public
GS_NSNumberFormatter_IVARS;
# endif
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -211,11 +211,14 @@ typedef SOCKET NSSocketNativeHandle;
NSMapTable *events; NSMapTable *events;
#endif #endif
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -94,11 +94,14 @@ extern "C" {
unsigned _version; /* Version of archiver used. */ unsigned _version; /* Version of archiver used. */
NSZone *_zone; /* Zone for allocating objs. */ NSZone *_zone; /* Zone for allocating objs. */
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -51,11 +51,14 @@ extern "C" {
NSPort *_send; NSPort *_send;
NSMutableArray *_components; NSMutableArray *_components;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }
/** /**

View file

@ -60,11 +60,14 @@ extern "C" {
NSMapTable *_portMap; /* Registered ports information. */ NSMapTable *_portMap; /* Registered ports information. */
NSMapTable *_nameMap; /* Registered names information. */ NSMapTable *_nameMap; /* Registered names information. */
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }
+ (id) sharedInstance; + (id) sharedInstance;

View file

@ -42,11 +42,14 @@ extern "C" {
Protocol *_myProtocol; Protocol *_myProtocol;
NSObject *_myTarget; NSObject *_myTarget;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -39,11 +39,14 @@ DEFINE_BLOCK_TYPE(GSRegexBlock, void, NSTextCheckingResult*, NSMatchingFlags, BO
GSREGEXTYPE *regex; GSREGEXTYPE *regex;
NSRegularExpressionOptions options; NSRegularExpressionOptions options;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }
+ (NSRegularExpression*)regularExpressionWithPattern: (NSString*)aPattern + (NSRegularExpression*)regularExpressionWithPattern: (NSString*)aPattern

View file

@ -50,11 +50,14 @@ extern "C" {
BOOL _caseSensitive; BOOL _caseSensitive;
BOOL _isUnicode; BOOL _isUnicode;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -50,11 +50,14 @@ extern "C" {
BOOL _ascending; BOOL _ascending;
SEL _selector; SEL _selector;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -64,11 +64,14 @@ GS_EXPORT NSString *const NSGrammarUserDescription;
NSString *_currentLanguage; NSString *_currentLanguage;
NSArray *_ignoredWords; NSArray *_ignoredWords;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -54,11 +54,14 @@ extern "C" {
BOOL _hasCollected; BOOL _hasCollected;
BOOL _hasNotified; BOOL _hasNotified;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -72,11 +72,14 @@ extern "C" {
id _gcontext; id _gcontext;
void *_runLoopInfo; // Per-thread runloop related info. void *_runLoopInfo; // Per-thread runloop related info.
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -51,11 +51,14 @@ extern "C" {
SEL _selector; SEL _selector;
id _info; id _info;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -98,11 +98,14 @@ GS_EXPORT NSString* const NSUndoManagerWillUndoChangeNotification;
unsigned _disableCount; unsigned _disableCount;
unsigned _levelsOfUndo; unsigned _levelsOfUndo;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -228,11 +228,14 @@ GS_EXPORT NSString* const GSLocale;
NSRecursiveLock *_lock; NSRecursiveLock *_lock;
NSDistributedLock *_fileLock; NSDistributedLock *_fileLock;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -88,11 +88,14 @@ typedef NSUInteger NSXMLNodeKind;
NSUInteger _index; NSUInteger _index;
id _objectValue; id _objectValue;
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -74,11 +74,14 @@ GS_EXPORT NSString* const NSXMLParserErrorDomain;
void *_parser; // GSXMLParser void *_parser; // GSXMLParser
void *_handler; // SAXHandler void *_handler; // SAXHandler
#endif #endif
#if !GS_NONFRAGILE #if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI /* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available. * when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/ */
void *_reserved; @private void *_internal GS_UNUSED_IVAR;
#endif #endif
} }

View file

@ -27,16 +27,26 @@
* their code when the class implementation is changed in new versions of the * their code when the class implementation is changed in new versions of the
* library. * library.
* *
* The public class MUST declare its instance variables using code of the * The public class MUST declare its instance variables (after any public
* form: * instance variables which are part of the unchanging public API) using
* code of the form:
* #if GS_NONFRAGILE * #if GS_NONFRAGILE
* # if defined(GS_X_IVARS) * # if defined(GS_X_IVARS)
* @public GS_X_IVARS; * @public GS_X_IVARS;
* # endif * # endif
* #else * #else
* @private id _internal; * @private void *_internal GS_UNUSED_IVAR;
* #endif * #endif
* *
* In the non fragile case, this means that the public header has nothing
* visible, but the ivars defined in GS_X_IVARS are visible within the
* implementation.
*
* In the fragile case, the '_internal' pinter is visible in the public
* header, but as an opaque private instance variable, while macros from
* this file allow the actual memory to be accessed either as a malloc'ed
* structure or as a private class.
*
* Before including the header file containing the public class declaration, * Before including the header file containing the public class declaration,
* you must define GS_X_IVARS (where X is the class name) to be the * you must define GS_X_IVARS (where X is the class name) to be the
* list of actual instance variable declarations for the class. * list of actual instance variable declarations for the class.
@ -62,8 +72,32 @@
#if !GS_NONFRAGILE #if !GS_NONFRAGILE
/* Code for when we don't have non-fragile instance variables /* Code for when we don't have non-fragile instance variables
* The presence of GS_INTERNAL_STRUCT means that the instance variables are
* accessible as a struct rather than as a class.
*/ */
#if defined(GS_INTERNAL_STRUCT)
/* Start declaration of internal ivars.
*/
#define GS_PRIVATE_INTERNAL(name) \
typedef struct name ## InternalStruct \
{ \
GS_##name##_IVARS; \
} name ## Internal;
/* Create holder for internal ivars.
*/
#define GS_CREATE_INTERNAL(name) \
_internal = (void*)NSZoneCalloc([self zone], 1, sizeof(name ## Internal));
/* Destroy holder for internal ivars.
*/
#define GS_DESTROY_INTERNAL(name) \
if (_internal != 0) { NSZoneFree([self zone], _internal); _internal = 0; }
#else /* GS_INTERNAL_STRUCT */
/* Start declaration of internal ivars. /* Start declaration of internal ivars.
*/ */
#define GS_PRIVATE_INTERNAL(name) \ #define GS_PRIVATE_INTERNAL(name) \
@ -79,12 +113,14 @@ GS_##name##_IVARS; \
/* Create holder for internal ivars. /* Create holder for internal ivars.
*/ */
#define GS_CREATE_INTERNAL(name) \ #define GS_CREATE_INTERNAL(name) \
_internal = [name ## Internal new]; _internal = (void*)[name ## Internal new];
/* Destroy holder for internal ivars. /* Destroy holder for internal ivars.
*/ */
#define GS_DESTROY_INTERNAL(name) \ #define GS_DESTROY_INTERNAL(name) \
if (_internal != 0) DESTROY(_internal); if (_internal != 0) {[(id)_internal release]; _internal = 0; }
#endif /* GS_INTERNAL_STRUCT */
#undef internal #undef internal
#define internal ((GSInternal*)_internal) #define internal ((GSInternal*)_internal)

View file

@ -78,18 +78,19 @@ static inline NSInteger _NSToUDateFormatStyle (NSDateFormatterStyle style)
return -1; return -1;
} }
typedef struct #define GS_NSDateFormatter_IVARS \
{ NSUInteger _behavior; \
NSUInteger _behavior; NSLocale *_locale; \
NSLocale *_locale; NSTimeZone *_tz; \
NSTimeZone *_tz; NSDateFormatterStyle _timeStyle; \
NSDateFormatterStyle _timeStyle; NSDateFormatterStyle _dateStyle; \
NSDateFormatterStyle _dateStyle; void *_formatter
void *_formatter;
} Internal; #define GSInternal NSDateFormatterInternal
#define GS_INTERNAL_STRUCT 1
#include "GSInternal.h"
GS_PRIVATE_INTERNAL(NSDateFormatter)
#define this ((Internal*)(self->_reserved))
#define inst ((Internal*)(o->_reserved))
@implementation NSDateFormatter @implementation NSDateFormatter
@ -101,10 +102,11 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
if (self == nil) if (self == nil)
return nil; return nil;
_reserved = NSZoneCalloc([self zone], 1, sizeof(Internal)); GS_CREATE_INTERNAL(NSDateFormatter)
this->_behavior = _defaultBehavior;
this->_locale = RETAIN([NSLocale currentLocale]); internal->_behavior = _defaultBehavior;
this->_tz = RETAIN([NSTimeZone defaultTimeZone]); internal->_locale = RETAIN([NSLocale currentLocale]);
internal->_tz = RETAIN([NSTimeZone defaultTimeZone]);
[self _resetUDateFormat]; [self _resetUDateFormat];
@ -117,10 +119,10 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
NSZone *z = [self zone]; NSZone *z = [self zone];
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
length = udat_toPattern (this->_formatter, 0, NULL, 0, &err); length = udat_toPattern (internal->_formatter, 0, NULL, 0, &err);
value = NSZoneMalloc (z, sizeof(unichar) * length); value = NSZoneMalloc (z, sizeof(unichar) * length);
err = U_ZERO_ERROR; err = U_ZERO_ERROR;
udat_toPattern (this->_formatter, 0, value, length, &err); udat_toPattern (internal->_formatter, 0, value, length, &err);
if (U_SUCCESS(err)) if (U_SUCCESS(err))
{ {
_dateFormat = [[NSString allocWithZone: z] _dateFormat = [[NSString allocWithZone: z]
@ -155,15 +157,16 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
NSDateFormatter *o = (id)NSCopyObject(self, 0, zone); NSDateFormatter *o = (id)NSCopyObject(self, 0, zone);
IF_NO_GC(RETAIN(o->_dateFormat)); IF_NO_GC(RETAIN(o->_dateFormat));
if (0 != this) if (0 != internal)
{ {
o->_reserved = NSZoneCalloc([self zone], 1, sizeof(Internal)); o->GS_CREATE_INTERNAL(NSDateFormatter)
memcpy(inst, this, sizeof(Internal));
IF_NO_GC(RETAIN(inst->_locale);) memcpy(o->_internal, internal, sizeof(NSDateFormatterInternal));
IF_NO_GC(RETAIN(GSIVar(o,_locale));)
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
{ {
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
inst->_formatter = udat_clone (this->_formatter, &err); GSIVar(o,_formatter) = udat_clone (internal->_formatter, &err);
} }
#endif #endif
} }
@ -179,14 +182,14 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
- (void) dealloc - (void) dealloc
{ {
RELEASE(_dateFormat); RELEASE(_dateFormat);
if (this != 0) if (internal != 0)
{ {
RELEASE(this->_locale); RELEASE(internal->_locale);
RELEASE(this->_tz); RELEASE(internal->_tz);
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
udat_close (this->_formatter); udat_close (internal->_formatter);
#endif #endif
NSZoneFree([self zone], this); GS_DESTROY_INTERNAL(NSDateFormatter)
} }
[super dealloc]; [super dealloc];
} }
@ -248,7 +251,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
{ {
_dateFormat = [format copy]; _dateFormat = [format copy];
_allowsNaturalLanguage = flag; _allowsNaturalLanguage = flag;
this->_behavior = NSDateFormatterBehavior10_0; internal->_behavior = NSDateFormatterBehavior10_0;
return self; return self;
} }
@ -292,12 +295,12 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
- (NSDateFormatterBehavior) formatterBehavior - (NSDateFormatterBehavior) formatterBehavior
{ {
return this->_behavior; return internal->_behavior;
} }
- (void) setFormatterBehavior: (NSDateFormatterBehavior) behavior - (void) setFormatterBehavior: (NSDateFormatterBehavior) behavior
{ {
this->_behavior = behavior; internal->_behavior = behavior;
} }
- (BOOL) generatesCalendarDates - (BOOL) generatesCalendarDates
@ -313,7 +316,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
- (BOOL) isLenient - (BOOL) isLenient
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (BOOL)udat_isLenient (this->_formatter); return (BOOL)udat_isLenient (internal->_formatter);
#else #else
return NO; return NO;
#endif #endif
@ -322,7 +325,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
- (void) setLenient: (BOOL) flag - (void) setLenient: (BOOL) flag
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
udat_setLenient (this->_formatter, flag); udat_setLenient (internal->_formatter, flag);
#else #else
return; return;
#endif #endif
@ -346,7 +349,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
[string getCharacters: text range: NSMakeRange (0, textLength)]; [string getCharacters: text range: NSMakeRange (0, textLength)];
date = udat_parse (this->_formatter, text, textLength, &pPos, &err); date = udat_parse (internal->_formatter, text, textLength, &pPos, &err);
if (U_SUCCESS(err)) if (U_SUCCESS(err))
result = result =
[NSDate dateWithTimeIntervalSince1970: (NSTimeInterval)(date / 1000.0)]; [NSDate dateWithTimeIntervalSince1970: (NSTimeInterval)(date / 1000.0)];
@ -368,10 +371,10 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
UDate udate = [date timeIntervalSince1970] * 1000.0; UDate udate = [date timeIntervalSince1970] * 1000.0;
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
length = udat_format (this->_formatter, udate, NULL, 0, NULL, &err); length = udat_format (internal->_formatter, udate, NULL, 0, NULL, &err);
string = NSZoneMalloc (z, sizeof(UChar) * (length + 1)); string = NSZoneMalloc (z, sizeof(UChar) * (length + 1));
err = U_ZERO_ERROR; err = U_ZERO_ERROR;
udat_format (this->_formatter, udate, string, length, NULL, &err); udat_format (internal->_formatter, udate, string, length, NULL, &err);
if (U_SUCCESS(err)) if (U_SUCCESS(err))
{ {
result = AUTORELEASE([[NSString allocWithZone: z] result = AUTORELEASE([[NSString allocWithZone: z]
@ -407,7 +410,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
pattern = NSZoneMalloc ([self zone], sizeof(UChar) * patternLength); pattern = NSZoneMalloc ([self zone], sizeof(UChar) * patternLength);
[string getCharacters: pattern range: NSMakeRange(0, patternLength)]; [string getCharacters: pattern range: NSMakeRange(0, patternLength)];
udat_applyPattern (this->_formatter, 0, pattern, patternLength); udat_applyPattern (internal->_formatter, 0, pattern, patternLength);
NSZoneFree ([self zone], pattern); NSZoneFree ([self zone], pattern);
#endif #endif
@ -418,29 +421,29 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
- (NSDateFormatterStyle) dateStyle - (NSDateFormatterStyle) dateStyle
{ {
return this->_dateStyle; return internal->_dateStyle;
} }
- (void) setDateStyle: (NSDateFormatterStyle) style - (void) setDateStyle: (NSDateFormatterStyle) style
{ {
this->_dateStyle = style; internal->_dateStyle = style;
[self _resetUDateFormat]; [self _resetUDateFormat];
} }
- (NSDateFormatterStyle) timeStyle - (NSDateFormatterStyle) timeStyle
{ {
return this->_timeStyle; return internal->_timeStyle;
} }
- (void) setTimeStyle: (NSDateFormatterStyle) style - (void) setTimeStyle: (NSDateFormatterStyle) style
{ {
this->_timeStyle = style; internal->_timeStyle = style;
[self _resetUDateFormat]; [self _resetUDateFormat];
} }
- (NSCalendar *) calendar - (NSCalendar *) calendar
{ {
return [this->_locale objectForKey: NSLocaleCalendar]; return [internal->_locale objectForKey: NSLocaleCalendar];
} }
- (void) setCalendar: (NSCalendar *) calendar - (void) setCalendar: (NSCalendar *) calendar
@ -448,7 +451,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
NSMutableDictionary *dict; NSMutableDictionary *dict;
NSLocale *locale; NSLocale *locale;
dict = [[NSLocale componentsFromLocaleIdentifier: [this->_locale localeIdentifier]] dict = [[NSLocale componentsFromLocaleIdentifier: [internal->_locale localeIdentifier]]
mutableCopy]; mutableCopy];
[dict setValue: calendar forKey: NSLocaleCalendar]; [dict setValue: calendar forKey: NSLocaleCalendar];
locale = [[NSLocale alloc] initWithLocaleIdentifier: locale = [[NSLocale alloc] initWithLocaleIdentifier:
@ -472,31 +475,31 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
- (NSLocale *) locale - (NSLocale *) locale
{ {
return this->_locale; return internal->_locale;
} }
- (void) setLocale: (NSLocale *) locale - (void) setLocale: (NSLocale *) locale
{ {
if (locale == this->_locale) if (locale == internal->_locale)
return; return;
RELEASE(this->_locale); RELEASE(internal->_locale);
this->_locale = RETAIN(locale); internal->_locale = RETAIN(locale);
[self _resetUDateFormat]; [self _resetUDateFormat];
} }
- (NSTimeZone *) timeZone - (NSTimeZone *) timeZone
{ {
return this->_tz; return internal->_tz;
} }
- (void) setTimeZone: (NSTimeZone *) tz - (void) setTimeZone: (NSTimeZone *) tz
{ {
if (tz == this->_tz) if (tz == internal->_tz)
return; return;
RELEASE(this->_tz); RELEASE(internal->_tz);
this->_tz = RETAIN(tz); internal->_tz = RETAIN(tz);
[self _resetUDateFormat]; [self _resetUDateFormat];
} }
@ -505,7 +508,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
return [NSDate dateWithTimeIntervalSince1970: return [NSDate dateWithTimeIntervalSince1970:
(udat_get2DigitYearStart (this->_formatter, &err) / 1000.0)]; (udat_get2DigitYearStart (internal->_formatter, &err) / 1000.0)];
#else #else
return nil; return nil;
#endif #endif
@ -515,7 +518,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
udat_set2DigitYearStart (this->_formatter, udat_set2DigitYearStart (internal->_formatter,
([date timeIntervalSince1970] * 1000.0), ([date timeIntervalSince1970] * 1000.0),
&err); &err);
#else #else
@ -943,12 +946,12 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
- (BOOL) doesRelativeDateFormatting - (BOOL) doesRelativeDateFormatting
{ {
return (this->_dateStyle & FormatterDoesRelativeDateFormatting) ? YES : NO; return (internal->_dateStyle & FormatterDoesRelativeDateFormatting) ? YES : NO;
} }
- (void) setDoesRelativeDateFormatting: (BOOL) flag - (void) setDoesRelativeDateFormatting: (BOOL) flag
{ {
this->_dateStyle |= FormatterDoesRelativeDateFormatting; internal->_dateStyle |= FormatterDoesRelativeDateFormatting;
} }
@end @end
@ -960,23 +963,23 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
int32_t tzIDLength; int32_t tzIDLength;
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
if (this->_formatter) if (internal->_formatter)
udat_close (this->_formatter); udat_close (internal->_formatter);
tzIDLength = [[this->_tz name] length]; tzIDLength = [[internal->_tz name] length];
tzID = NSZoneMalloc ([self zone], sizeof(UChar) * tzIDLength); tzID = NSZoneMalloc ([self zone], sizeof(UChar) * tzIDLength);
[[this->_tz name] getCharacters: tzID range: NSMakeRange (0, tzIDLength)]; [[internal->_tz name] getCharacters: tzID range: NSMakeRange (0, tzIDLength)];
this->_formatter = udat_open (_NSToUDateFormatStyle(this->_timeStyle), internal->_formatter = udat_open (_NSToUDateFormatStyle(internal->_timeStyle),
_NSToUDateFormatStyle(this->_dateStyle), _NSToUDateFormatStyle(internal->_dateStyle),
[[this->_locale localeIdentifier] UTF8String], [[internal->_locale localeIdentifier] UTF8String],
tzID, tzID,
tzIDLength, tzIDLength,
NULL, NULL,
0, 0,
&err); &err);
if (U_FAILURE(err)) if (U_FAILURE(err))
this->_formatter = NULL; internal->_formatter = NULL;
NSZoneFree ([self zone], tzID); NSZoneFree ([self zone], tzID);
#else #else
@ -988,7 +991,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
int idx = 0; int idx = 0;
int count = udat_countSymbols (this->_formatter, symbol); int count = udat_countSymbols (internal->_formatter, symbol);
if ([array count] != count) if ([array count] != count)
return; return;
@ -1004,7 +1007,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
value = NSZoneMalloc ([self zone], sizeof(unichar) * length); value = NSZoneMalloc ([self zone], sizeof(unichar) * length);
[string getCharacters: value range: NSMakeRange(0, length)]; [string getCharacters: value range: NSMakeRange(0, length)];
udat_setSymbols (this->_formatter, symbol, idx, value, length, &err); udat_setSymbols (internal->_formatter, symbol, idx, value, length, &err);
NSZoneFree ([self zone], value); NSZoneFree ([self zone], value);
@ -1020,7 +1023,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
NSMutableArray *mArray; NSMutableArray *mArray;
int idx = 0; int idx = 0;
int count = udat_countSymbols (this->_formatter, symbol); int count = udat_countSymbols (internal->_formatter, symbol);
mArray = [NSMutableArray arrayWithCapacity: count]; mArray = [NSMutableArray arrayWithCapacity: count];
while (idx < count) while (idx < count)
@ -1031,10 +1034,11 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
NSZone *z = [self zone]; NSZone *z = [self zone];
UErrorCode err = U_ERROR_LIMIT; UErrorCode err = U_ERROR_LIMIT;
length = udat_getSymbols (this->_formatter, symbol, idx, NULL, 0, &err); length
= udat_getSymbols (internal->_formatter, symbol, idx, NULL, 0, &err);
value = NSZoneMalloc (z, sizeof(unichar) * (length + 1)); value = NSZoneMalloc (z, sizeof(unichar) * (length + 1));
err = U_ZERO_ERROR; err = U_ZERO_ERROR;
udat_getSymbols (this->_formatter, symbol, idx, value, length, &err); udat_getSymbols (internal->_formatter, symbol, idx, value, length, &err);
if (U_SUCCESS(err)) if (U_SUCCESS(err))
{ {
str = AUTORELEASE([[NSString allocWithZone: z] str = AUTORELEASE([[NSString allocWithZone: z]

View file

@ -199,17 +199,18 @@ _ICUToNSRoundingMode (UNumberFormatRoundingMode mode)
#endif #endif
// Internal data storage #define GS_NSNumberFormatter_IVARS \
typedef struct { NSUInteger _behavior; \
NSUInteger _behavior; BOOL _genDecimal; \
BOOL _genDecimal; NSUInteger _style; \
NSUInteger _style; NSLocale *_locale; \
NSLocale *_locale; void *_formatter
void *_formatter;
} Internal;
#define this ((Internal*)(self->_reserved)) #define GSInternal NSNumberFormatterInternal
#define inst ((Internal*)(o->_reserved)) #define GS_INTERNAL_STRUCT 1
#include "GSInternal.h"
GS_PRIVATE_INTERNAL(NSNumberFormatter)
@interface NSNumberFormatter (PrivateMethods) @interface NSNumberFormatter (PrivateMethods)
- (void) _resetUNumberFormat; - (void) _resetUNumberFormat;
@ -295,15 +296,16 @@ static NSUInteger _defaultBehavior = 0;
IF_NO_GC(RETAIN(o->_attributedStringForNil);) IF_NO_GC(RETAIN(o->_attributedStringForNil);)
IF_NO_GC(RETAIN(o->_attributedStringForNotANumber);) IF_NO_GC(RETAIN(o->_attributedStringForNotANumber);)
IF_NO_GC(RETAIN(o->_attributedStringForZero);) IF_NO_GC(RETAIN(o->_attributedStringForZero);)
if (0 != this) if (0 != internal)
{ {
o->_reserved = NSZoneCalloc([self zone], 1, sizeof(Internal)); o->_internal = GS_CREATE_INTERNAL(NSNumberFormatter)
memcpy(inst, this, sizeof(Internal));
IF_NO_GC(RETAIN(inst->_locale);) memcpy(o->_internal, internal, sizeof(NSNumberFormatterInternal));
IF_NO_GC(RETAIN(GSIVar(o,_locale));)
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
{ {
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
inst->_formatter = unum_clone (this->_formatter, &err); GSIVar(o,_formatter) = unum_clone (internal->_formatter, &err);
} }
#endif #endif
} }
@ -322,27 +324,27 @@ static NSUInteger _defaultBehavior = 0;
RELEASE(_attributedStringForNil); RELEASE(_attributedStringForNil);
RELEASE(_attributedStringForNotANumber); RELEASE(_attributedStringForNotANumber);
RELEASE(_attributedStringForZero); RELEASE(_attributedStringForZero);
if (this != 0) if (internal != 0)
{ {
RELEASE(this->_locale); RELEASE(internal->_locale);
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_close (this->_formatter); unum_close (internal->_formatter);
#endif #endif
NSZoneFree([self zone], this); GS_DESTROY_INTERNAL(NSNumberFormatter)
} }
[super dealloc]; [super dealloc];
} }
- (NSString*) decimalSeparator - (NSString*) decimalSeparator
{ {
if (this->_behavior == NSNumberFormatterBehavior10_4 if (internal->_behavior == NSNumberFormatterBehavior10_4
|| this->_behavior == NSNumberFormatterBehaviorDefault) || internal->_behavior == NSNumberFormatterBehaviorDefault)
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return [self _getSymbol: UNUM_DECIMAL_SEPARATOR_SYMBOL]; return [self _getSymbol: UNUM_DECIMAL_SEPARATOR_SYMBOL];
#endif #endif
} }
else if (this->_behavior == NSNumberFormatterBehavior10_0) else if (internal->_behavior == NSNumberFormatterBehavior10_0)
{ {
if (_decimalSeparator == 0) if (_decimalSeparator == 0)
return @""; return @"";
@ -441,7 +443,8 @@ static NSUInteger _defaultBehavior = 0;
{ {
id o; id o;
_reserved = NSZoneCalloc([self zone], 1, sizeof(Internal)); GS_CREATE_INTERNAL(NSNumberFormatter)
_allowsFloats = YES; _allowsFloats = YES;
_decimalSeparator = '.'; _decimalSeparator = '.';
_thousandSeparator = ','; _thousandSeparator = ',';
@ -453,11 +456,11 @@ static NSUInteger _defaultBehavior = 0;
[self setAttributedStringForNotANumber: o]; [self setAttributedStringForNotANumber: o];
RELEASE(o); RELEASE(o);
this->_behavior = _defaultBehavior; internal->_behavior = _defaultBehavior;
this->_locale = RETAIN([NSLocale currentLocale]); internal->_locale = RETAIN([NSLocale currentLocale]);
this->_style = NSNumberFormatterNoStyle; internal->_style = NSNumberFormatterNoStyle;
[self _resetUNumberFormat]; [self _resetUNumberFormat];
if (this->_formatter == NULL) if (internal->_formatter == NULL)
{ {
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -641,14 +644,14 @@ static NSUInteger _defaultBehavior = 0;
- (void) setDecimalSeparator: (NSString*)newSeparator - (void) setDecimalSeparator: (NSString*)newSeparator
{ {
if (this->_behavior == NSNumberFormatterBehavior10_4 if (internal->_behavior == NSNumberFormatterBehavior10_4
|| this->_behavior == NSNumberFormatterBehaviorDefault) || internal->_behavior == NSNumberFormatterBehaviorDefault)
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
[self _setSymbol: newSeparator : UNUM_DECIMAL_SEPARATOR_SYMBOL]; [self _setSymbol: newSeparator : UNUM_DECIMAL_SEPARATOR_SYMBOL];
#endif #endif
} }
else if (this->_behavior == NSNumberFormatterBehavior10_0) else if (internal->_behavior == NSNumberFormatterBehavior10_0)
{ {
if ([newSeparator length] > 0) if ([newSeparator length] > 0)
_decimalSeparator = [newSeparator characterAtIndex: 0]; _decimalSeparator = [newSeparator characterAtIndex: 0];
@ -745,8 +748,8 @@ static NSUInteger _defaultBehavior = 0;
- (NSString*) stringForObjectValue: (id)anObject - (NSString*) stringForObjectValue: (id)anObject
{ {
if (this->_behavior == NSNumberFormatterBehaviorDefault if (internal->_behavior == NSNumberFormatterBehaviorDefault
|| this->_behavior == NSNumberFormatterBehavior10_4) || internal->_behavior == NSNumberFormatterBehavior10_4)
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
@ -757,11 +760,11 @@ static NSUInteger _defaultBehavior = 0;
int32_t len; \ int32_t len; \
NSString *result; \ NSString *result; \
\ \
len = function (this->_formatter, number, outStr, MAX_BUFFER_SIZE, NULL, &err); \ len = function (internal->_formatter, number, outStr, MAX_BUFFER_SIZE, NULL, &err); \
if (len > MAX_BUFFER_SIZE) \ if (len > MAX_BUFFER_SIZE) \
outStr = NSZoneMalloc ([self zone], len * sizeof(UChar));\ outStr = NSZoneMalloc ([self zone], len * sizeof(UChar));\
err = U_ZERO_ERROR; \ err = U_ZERO_ERROR; \
function (this->_formatter, number, outStr, MAX_BUFFER_SIZE, NULL, &err); \ function (internal->_formatter, number, outStr, MAX_BUFFER_SIZE, NULL, &err); \
result = [NSString stringWithCharacters: outStr length: len]; \ result = [NSString stringWithCharacters: outStr length: len]; \
if (len > MAX_BUFFER_SIZE) \ if (len > MAX_BUFFER_SIZE) \
NSZoneFree ([self zone], outStr); \ NSZoneFree ([self zone], outStr); \
@ -816,7 +819,7 @@ static NSUInteger _defaultBehavior = 0;
} }
#endif #endif
} }
else if (this->_behavior == NSNumberFormatterBehavior10_0) else if (internal->_behavior == NSNumberFormatterBehavior10_0)
{ {
NSMutableDictionary *locale; NSMutableDictionary *locale;
NSCharacterSet *formattingCharacters; NSCharacterSet *formattingCharacters;
@ -1128,7 +1131,7 @@ static NSUInteger _defaultBehavior = 0;
range = [string rangeOfString: @"."]; range = [string rangeOfString: @"."];
if (range.location == NSNotFound) if (range.location == NSNotFound)
{ {
intNum = unum_parseInt64 (this->_formatter, ustring, length, NULL, &err); intNum = unum_parseInt64 (internal->_formatter, ustring, length, NULL, &err);
if (U_FAILURE(err)) if (U_FAILURE(err))
return nil; return nil;
if (intNum == 0 || intNum == 1) if (intNum == 0 || intNum == 1)
@ -1140,7 +1143,7 @@ static NSUInteger _defaultBehavior = 0;
} }
else else
{ {
doubleNum = unum_parseDouble (this->_formatter, ustring, length, NULL, &err); doubleNum = unum_parseDouble (internal->_formatter, ustring, length, NULL, &err);
if (U_FAILURE(err)) if (U_FAILURE(err))
return nil; return nil;
result = [NSNumber numberWithDouble: doubleNum]; result = [NSNumber numberWithDouble: doubleNum];
@ -1157,12 +1160,12 @@ static NSUInteger _defaultBehavior = 0;
- (void) setFormatterBehavior: (NSNumberFormatterBehavior) behavior - (void) setFormatterBehavior: (NSNumberFormatterBehavior) behavior
{ {
this->_behavior = behavior; internal->_behavior = behavior;
} }
- (NSNumberFormatterBehavior) formatterBehavior - (NSNumberFormatterBehavior) formatterBehavior
{ {
return this->_behavior; return internal->_behavior;
} }
+ (void) setDefaultFormatterBehavior: (NSNumberFormatterBehavior) behavior + (void) setDefaultFormatterBehavior: (NSNumberFormatterBehavior) behavior
@ -1177,18 +1180,18 @@ static NSUInteger _defaultBehavior = 0;
- (void) setNumberStyle: (NSNumberFormatterStyle) style - (void) setNumberStyle: (NSNumberFormatterStyle) style
{ {
this->_style = style; internal->_style = style;
[self _resetUNumberFormat]; [self _resetUNumberFormat];
} }
- (NSNumberFormatterStyle) numberStyle - (NSNumberFormatterStyle) numberStyle
{ {
return this->_style; return internal->_style;
} }
- (void) setGeneratesDecimalNumbers: (BOOL) flag - (void) setGeneratesDecimalNumbers: (BOOL) flag
{ {
this->_genDecimal = flag; internal->_genDecimal = flag;
} }
- (BOOL) generatesDecimalNubmers - (BOOL) generatesDecimalNubmers
@ -1199,18 +1202,18 @@ static NSUInteger _defaultBehavior = 0;
- (void) setLocale: (NSLocale *) locale - (void) setLocale: (NSLocale *) locale
{ {
RELEASE(this->_locale); RELEASE(internal->_locale);
if (locale == nil) if (locale == nil)
locale = [NSLocale currentLocale]; locale = [NSLocale currentLocale];
this->_locale = RETAIN(locale); internal->_locale = RETAIN(locale);
[self _resetUNumberFormat]; [self _resetUNumberFormat];
} }
- (NSLocale *) locale - (NSLocale *) locale
{ {
return this->_locale; return internal->_locale;
} }
@ -1218,7 +1221,7 @@ static NSUInteger _defaultBehavior = 0;
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
if ([number class] == [NSDoubleNumber class]) if ([number class] == [NSDoubleNumber class])
unum_setDoubleAttribute (this->_formatter, UNUM_ROUNDING_INCREMENT, unum_setDoubleAttribute (internal->_formatter, UNUM_ROUNDING_INCREMENT,
[number doubleValue]); [number doubleValue]);
#else #else
return; return;
@ -1228,7 +1231,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSNumber *) roundingIncrement - (NSNumber *) roundingIncrement
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
double value = unum_getDoubleAttribute (this->_formatter, UNUM_ROUNDING_INCREMENT); double value = unum_getDoubleAttribute (internal->_formatter, UNUM_ROUNDING_INCREMENT);
return [NSNumber numberWithDouble: value]; return [NSNumber numberWithDouble: value];
#else #else
return nil; return nil;
@ -1238,7 +1241,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setRoundingMode: (NSNumberFormatterRoundingMode) mode - (void) setRoundingMode: (NSNumberFormatterRoundingMode) mode
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_ROUNDING_MODE, unum_setAttribute (internal->_formatter, UNUM_ROUNDING_MODE,
_NSToICURoundingMode(mode)); _NSToICURoundingMode(mode));
#else #else
return; return;
@ -1248,7 +1251,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSNumberFormatterRoundingMode) roundingMode - (NSNumberFormatterRoundingMode) roundingMode
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return _ICUToNSRoundingMode (unum_getAttribute (this->_formatter, return _ICUToNSRoundingMode (unum_getAttribute (internal->_formatter,
UNUM_ROUNDING_MODE)); UNUM_ROUNDING_MODE));
#else #else
return 0; return 0;
@ -1259,7 +1262,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setFormatWidth: (NSUInteger) number - (void) setFormatWidth: (NSUInteger) number
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_FORMAT_WIDTH, (int32_t)number); unum_setAttribute (internal->_formatter, UNUM_FORMAT_WIDTH, (int32_t)number);
#else #else
return; return;
#endif #endif
@ -1268,7 +1271,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSUInteger) formatWidth - (NSUInteger) formatWidth
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (NSUInteger)unum_getAttribute (this->_formatter, UNUM_FORMAT_WIDTH); return (NSUInteger)unum_getAttribute (internal->_formatter, UNUM_FORMAT_WIDTH);
#else #else
return 0; return 0;
#endif #endif
@ -1278,7 +1281,7 @@ static NSUInteger _defaultBehavior = 0;
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
int32_t value = [number intValue]; int32_t value = [number intValue];
unum_setAttribute (this->_formatter, UNUM_MULTIPLIER, value); unum_setAttribute (internal->_formatter, UNUM_MULTIPLIER, value);
#else #else
return; return;
#endif #endif
@ -1287,7 +1290,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSNumber *) multiplier - (NSNumber *) multiplier
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
int32_t value = unum_getAttribute (this->_formatter, UNUM_MULTIPLIER); int32_t value = unum_getAttribute (internal->_formatter, UNUM_MULTIPLIER);
return [NSNumber numberWithInt: value]; return [NSNumber numberWithInt: value];
#else #else
return nil; return nil;
@ -1671,7 +1674,7 @@ static NSUInteger _defaultBehavior = 0;
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_GROUPING_USED, flag); unum_setAttribute (internal->_formatter, UNUM_GROUPING_USED, flag);
#else #else
return; return;
#endif #endif
@ -1680,7 +1683,7 @@ static NSUInteger _defaultBehavior = 0;
- (BOOL) usesGroupingSeparator - (BOOL) usesGroupingSeparator
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (BOOL)unum_getAttribute (this->_formatter, UNUM_GROUPING_USED); return (BOOL)unum_getAttribute (internal->_formatter, UNUM_GROUPING_USED);
#else #else
return NO; return NO;
#endif #endif
@ -1689,7 +1692,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setAlwaysShowsDecimalSeparator: (BOOL) flag - (void) setAlwaysShowsDecimalSeparator: (BOOL) flag
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_DECIMAL_ALWAYS_SHOWN, flag); unum_setAttribute (internal->_formatter, UNUM_DECIMAL_ALWAYS_SHOWN, flag);
#else #else
return; return;
#endif #endif
@ -1698,7 +1701,7 @@ static NSUInteger _defaultBehavior = 0;
- (BOOL) alwaysShowsDecimalSeparator - (BOOL) alwaysShowsDecimalSeparator
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (BOOL)unum_getAttribute (this->_formatter, UNUM_DECIMAL_ALWAYS_SHOWN); return (BOOL)unum_getAttribute (internal->_formatter, UNUM_DECIMAL_ALWAYS_SHOWN);
#else #else
return NO; return NO;
#endif #endif
@ -1725,7 +1728,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setGroupingSize: (NSUInteger) number - (void) setGroupingSize: (NSUInteger) number
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_GROUPING_SIZE, number); unum_setAttribute (internal->_formatter, UNUM_GROUPING_SIZE, number);
#else #else
return; return;
#endif #endif
@ -1734,7 +1737,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSUInteger) groupingSize - (NSUInteger) groupingSize
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (NSUInteger)unum_getAttribute (this->_formatter, UNUM_GROUPING_SIZE); return (NSUInteger)unum_getAttribute (internal->_formatter, UNUM_GROUPING_SIZE);
#else #else
return 3; return 3;
#endif #endif
@ -1743,7 +1746,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setSecondaryGroupingSize: (NSUInteger) number - (void) setSecondaryGroupingSize: (NSUInteger) number
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_SECONDARY_GROUPING_SIZE, number); unum_setAttribute (internal->_formatter, UNUM_SECONDARY_GROUPING_SIZE, number);
#else #else
return; return;
#endif #endif
@ -1752,7 +1755,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSUInteger) secondaryGroupingSize - (NSUInteger) secondaryGroupingSize
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (NSUInteger)unum_getAttribute (this->_formatter, return (NSUInteger)unum_getAttribute (internal->_formatter,
UNUM_SECONDARY_GROUPING_SIZE); UNUM_SECONDARY_GROUPING_SIZE);
#else #else
return 3; return 3;
@ -1781,7 +1784,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setPaddingPosition: (NSNumberFormatterPadPosition) position - (void) setPaddingPosition: (NSNumberFormatterPadPosition) position
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_PADDING_POSITION, unum_setAttribute (internal->_formatter, UNUM_PADDING_POSITION,
_NSToICUPadPosition (position)); _NSToICUPadPosition (position));
#else #else
return; return;
@ -1791,7 +1794,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSNumberFormatterPadPosition) paddingPosition - (NSNumberFormatterPadPosition) paddingPosition
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return _ICUToNSPadPosition(unum_getAttribute (this->_formatter, return _ICUToNSPadPosition(unum_getAttribute (internal->_formatter,
UNUM_PADDING_POSITION)); UNUM_PADDING_POSITION));
#else #else
return 0; return 0;
@ -1802,7 +1805,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setMinimumIntegerDigits: (NSUInteger) number - (void) setMinimumIntegerDigits: (NSUInteger) number
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_MIN_INTEGER_DIGITS, number); unum_setAttribute (internal->_formatter, UNUM_MIN_INTEGER_DIGITS, number);
#else #else
return; return;
#endif #endif
@ -1811,7 +1814,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSUInteger) minimumIntegerDigits - (NSUInteger) minimumIntegerDigits
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (NSUInteger)unum_getAttribute (this->_formatter, UNUM_MIN_INTEGER_DIGITS); return (NSUInteger)unum_getAttribute (internal->_formatter, UNUM_MIN_INTEGER_DIGITS);
#else #else
return 0; return 0;
#endif #endif
@ -1820,7 +1823,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setMinimumFractionDigits: (NSUInteger) number - (void) setMinimumFractionDigits: (NSUInteger) number
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_MIN_FRACTION_DIGITS, number); unum_setAttribute (internal->_formatter, UNUM_MIN_FRACTION_DIGITS, number);
#else #else
return; return;
#endif #endif
@ -1829,7 +1832,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSUInteger) minimumFractionDigits - (NSUInteger) minimumFractionDigits
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (NSUInteger)unum_getAttribute (this->_formatter, UNUM_MIN_FRACTION_DIGITS); return (NSUInteger)unum_getAttribute (internal->_formatter, UNUM_MIN_FRACTION_DIGITS);
#else #else
return 0; return 0;
#endif #endif
@ -1838,7 +1841,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setMaximumIntegerDigits: (NSUInteger) number - (void) setMaximumIntegerDigits: (NSUInteger) number
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_MAX_INTEGER_DIGITS, number); unum_setAttribute (internal->_formatter, UNUM_MAX_INTEGER_DIGITS, number);
#else #else
return; return;
#endif #endif
@ -1847,7 +1850,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSUInteger) maximumIntegerDigits - (NSUInteger) maximumIntegerDigits
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (NSUInteger)unum_getAttribute (this->_formatter, UNUM_MAX_INTEGER_DIGITS); return (NSUInteger)unum_getAttribute (internal->_formatter, UNUM_MAX_INTEGER_DIGITS);
#else #else
return 0; return 0;
#endif #endif
@ -1856,7 +1859,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setMaximumFractionDigits: (NSUInteger) number - (void) setMaximumFractionDigits: (NSUInteger) number
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_MAX_FRACTION_DIGITS, number); unum_setAttribute (internal->_formatter, UNUM_MAX_FRACTION_DIGITS, number);
#else #else
return; return;
#endif #endif
@ -1865,7 +1868,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSUInteger) maximumFractionDigits - (NSUInteger) maximumFractionDigits
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (NSUInteger)unum_getAttribute (this->_formatter, UNUM_MAX_FRACTION_DIGITS); return (NSUInteger)unum_getAttribute (internal->_formatter, UNUM_MAX_FRACTION_DIGITS);
#else #else
return 0; return 0;
#endif #endif
@ -1884,7 +1887,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setUsesSignificantDigits: (BOOL) flag - (void) setUsesSignificantDigits: (BOOL) flag
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_SIGNIFICANT_DIGITS_USED, flag); unum_setAttribute (internal->_formatter, UNUM_SIGNIFICANT_DIGITS_USED, flag);
#else #else
return; return;
#endif #endif
@ -1893,7 +1896,7 @@ static NSUInteger _defaultBehavior = 0;
- (BOOL) usesSignificantDigits - (BOOL) usesSignificantDigits
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (BOOL)unum_getAttribute (this->_formatter, UNUM_SIGNIFICANT_DIGITS_USED); return (BOOL)unum_getAttribute (internal->_formatter, UNUM_SIGNIFICANT_DIGITS_USED);
#else #else
return NO; return NO;
#endif #endif
@ -1902,7 +1905,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setMinimumSignificantDigits: (NSUInteger) number - (void) setMinimumSignificantDigits: (NSUInteger) number
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_MIN_SIGNIFICANT_DIGITS, number); unum_setAttribute (internal->_formatter, UNUM_MIN_SIGNIFICANT_DIGITS, number);
#else #else
return; return;
#endif #endif
@ -1911,7 +1914,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSUInteger) minimumSignificantDigits - (NSUInteger) minimumSignificantDigits
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (BOOL)unum_getAttribute (this->_formatter, UNUM_MIN_SIGNIFICANT_DIGITS); return (BOOL)unum_getAttribute (internal->_formatter, UNUM_MIN_SIGNIFICANT_DIGITS);
#else #else
return 0; return 0;
#endif #endif
@ -1920,7 +1923,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setMaximumSignificantDigits: (NSUInteger) number - (void) setMaximumSignificantDigits: (NSUInteger) number
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_MAX_SIGNIFICANT_DIGITS, number); unum_setAttribute (internal->_formatter, UNUM_MAX_SIGNIFICANT_DIGITS, number);
#else #else
return; return;
#endif #endif
@ -1929,7 +1932,7 @@ static NSUInteger _defaultBehavior = 0;
- (NSUInteger) maximumSignificantDigits - (NSUInteger) maximumSignificantDigits
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (BOOL)unum_getAttribute (this->_formatter, UNUM_MAX_SIGNIFICANT_DIGITS); return (BOOL)unum_getAttribute (internal->_formatter, UNUM_MAX_SIGNIFICANT_DIGITS);
#else #else
return 0; return 0;
#endif #endif
@ -1958,7 +1961,7 @@ static NSUInteger _defaultBehavior = 0;
- (void) setLenient: (BOOL) flag - (void) setLenient: (BOOL) flag
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
unum_setAttribute (this->_formatter, UNUM_LENIENT_PARSE, flag); unum_setAttribute (internal->_formatter, UNUM_LENIENT_PARSE, flag);
#else #else
return; return;
#endif #endif
@ -1967,7 +1970,7 @@ static NSUInteger _defaultBehavior = 0;
- (BOOL) isLenient - (BOOL) isLenient
{ {
#if GS_USE_ICU == 1 #if GS_USE_ICU == 1
return (BOOL)unum_getAttribute (this->_formatter, UNUM_LENIENT_PARSE); return (BOOL)unum_getAttribute (internal->_formatter, UNUM_LENIENT_PARSE);
#else #else
return NO; return NO;
#endif #endif
@ -2014,15 +2017,15 @@ static NSUInteger _defaultBehavior = 0;
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
const char *cLocaleId; const char *cLocaleId;
if (this->_formatter) if (internal->_formatter)
unum_close(this->_formatter); unum_close(internal->_formatter);
cLocaleId = [[this->_locale localeIdentifier] UTF8String]; cLocaleId = [[internal->_locale localeIdentifier] UTF8String];
style = _NSToICUFormatStyle (this->_style); style = _NSToICUFormatStyle (internal->_style);
this->_formatter = unum_open (style, NULL, 0, cLocaleId, NULL, &err); internal->_formatter = unum_open (style, NULL, 0, cLocaleId, NULL, &err);
if (U_FAILURE(err)) if (U_FAILURE(err))
this->_formatter = NULL; internal->_formatter = NULL;
[self setMaximumFractionDigits: 0]; [self setMaximumFractionDigits: 0];
#else #else
@ -2043,7 +2046,7 @@ static NSUInteger _defaultBehavior = 0;
str = (unichar *)NSZoneMalloc ([self zone], length * sizeof(unichar)); str = (unichar *)NSZoneMalloc ([self zone], length * sizeof(unichar));
[string getCharacters: str range: NSMakeRange (0, length)]; [string getCharacters: str range: NSMakeRange (0, length)];
unum_setSymbol (this->_formatter, symbol, str, length, &err); unum_setSymbol (internal->_formatter, symbol, str, length, &err);
if (length > MAX_SYMBOL_SIZE) if (length > MAX_SYMBOL_SIZE)
NSZoneFree ([self zone], str); NSZoneFree ([self zone], str);
@ -2061,12 +2064,12 @@ static NSUInteger _defaultBehavior = 0;
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
NSString *result; NSString *result;
length = unum_getSymbol (this->_formatter, symbol, str, length = unum_getSymbol (internal->_formatter, symbol, str,
MAX_SYMBOL_SIZE, &err); MAX_SYMBOL_SIZE, &err);
if (length > MAX_SYMBOL_SIZE) if (length > MAX_SYMBOL_SIZE)
{ {
str = (UChar *)NSZoneMalloc ([self zone], length * sizeof(UChar)); str = (UChar *)NSZoneMalloc ([self zone], length * sizeof(UChar));
length = unum_getSymbol (this->_formatter, symbol, str, length = unum_getSymbol (internal->_formatter, symbol, str,
length, &err); length, &err);
} }
@ -2093,7 +2096,7 @@ static NSUInteger _defaultBehavior = 0;
str = (unichar *)NSZoneMalloc ([self zone], length * sizeof(unichar)); str = (unichar *)NSZoneMalloc ([self zone], length * sizeof(unichar));
[string getCharacters: str range: NSMakeRange (0, length)]; [string getCharacters: str range: NSMakeRange (0, length)];
unum_setTextAttribute (this->_formatter, attrib, str, length, &err); unum_setTextAttribute (internal->_formatter, attrib, str, length, &err);
if (length > MAX_TEXT_ATTRIB_SIZE) if (length > MAX_TEXT_ATTRIB_SIZE)
NSZoneFree ([self zone], str); NSZoneFree ([self zone], str);
@ -2111,12 +2114,12 @@ static NSUInteger _defaultBehavior = 0;
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
NSString *result; NSString *result;
length = unum_getTextAttribute (this->_formatter, attrib, str, length = unum_getTextAttribute (internal->_formatter, attrib, str,
MAX_TEXT_ATTRIB_SIZE, &err); MAX_TEXT_ATTRIB_SIZE, &err);
if (length > MAX_TEXT_ATTRIB_SIZE) if (length > MAX_TEXT_ATTRIB_SIZE)
{ {
str = (UChar *)NSZoneMalloc ([self zone], length * sizeof(UChar)); str = (UChar *)NSZoneMalloc ([self zone], length * sizeof(UChar));
length = unum_getTextAttribute (this->_formatter, attrib, str, length = unum_getTextAttribute (internal->_formatter, attrib, str,
length, &err); length, &err);
} }