mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
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:
parent
27550994ee
commit
d07f49a9b6
41 changed files with 468 additions and 246 deletions
48
ChangeLog
48
ChangeLog
|
@ -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>
|
||||
|
||||
* Source/GSLocale.m:
|
||||
|
|
|
@ -75,11 +75,14 @@ extern "C" {
|
|||
NSMutableDictionary *objects;
|
||||
NSMutableDictionary *params;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
+ (NSString*) makeQuoted: (NSString*)v always: (BOOL)flag;
|
||||
|
|
|
@ -419,7 +419,7 @@ GSObjCDirectSubclassesOfClass(Class cls);
|
|||
#if GS_API_VERSION(GS_API_ANY,011500)
|
||||
|
||||
GS_EXPORT const char *
|
||||
GSLastErrorStr(long error_id) GS_ATTRIB_DEPRECATED;
|
||||
GSLastErrorStr(long error_id) GS_DEPRECATED_FUNC;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -229,13 +229,9 @@
|
|||
#define GS_EXPOSE(X) (!GS_NONFRAGILE || defined(EXPOSE_##X##_IVARS))
|
||||
|
||||
/* Static analyser macros: Provide annotations to help the analyser */
|
||||
// TODO: Make this more sensible when GCC supports __attribute__((unused)) on
|
||||
// ivars
|
||||
#ifdef __clang__
|
||||
# define GS_UNUSED_IVAR __attribute__((unused))
|
||||
# define GS_NORETURN_METHOD __attribute__((__noreturn__))
|
||||
#else
|
||||
# define GS_UNUSED_IVAR
|
||||
# define GS_NORETURN_METHOD
|
||||
#endif
|
||||
|
||||
|
@ -322,10 +318,23 @@ static inline void gs_consumed(id o) { return; }
|
|||
|
||||
#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))
|
||||
#define GS_ATTRIB_DEPRECATED __attribute__ ((deprecated))
|
||||
# define GS_DEPRECATED_FUNC __attribute__ ((deprecated))
|
||||
#else
|
||||
#define GS_ATTRIB_DEPRECATED
|
||||
# define GS_DEPRECATED_FUNC
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
# define GS_UNUSED_IVAR __attribute__((unused))
|
||||
#else
|
||||
# define GS_UNUSED_IVAR
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -70,11 +70,14 @@ extern "C" {
|
|||
BOOL _encodingRoot;
|
||||
BOOL _initialPass;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
@ -181,11 +184,14 @@ extern "C" {
|
|||
NSMutableDictionary *objDict; /* Class information store. */
|
||||
NSMutableArray *objSave;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -194,11 +194,14 @@ typedef struct autorelease_array_list
|
|||
/* The method to add an object to this pool */
|
||||
void (*_addImp)(id, SEL, id);
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -119,11 +119,14 @@ GS_EXPORT NSString* const NSLoadedClasses;
|
|||
unsigned _version;
|
||||
NSString *_frameworkVersion;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -61,11 +61,14 @@ extern "C" {
|
|||
/** Total number of accesses to objects */
|
||||
int64_t _totalAccesses;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -77,11 +77,14 @@ typedef enum _NSPredicateOperatorType
|
|||
NSUInteger _options;
|
||||
NSPredicateOperatorType _type;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
@public
|
||||
NSExpression *_left;
|
||||
|
|
|
@ -128,11 +128,18 @@ typedef NSUInteger NSDateFormatterBehavior;
|
|||
NSString *_dateFormat;
|
||||
BOOL _allowsNaturalLanguage;
|
||||
#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
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -129,11 +129,14 @@ extern "C" {
|
|||
BOOL _raiseOnUnderflow;
|
||||
BOOL _raiseOnDivideByZero;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -40,11 +40,14 @@ extern "C" {
|
|||
NSString *_lockPath;
|
||||
NSDate *_lockTime;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -86,11 +86,14 @@ GS_EXPORT NSString* const GSNetworkNotificationCenterType;
|
|||
id _remote; /* Proxy for center. */
|
||||
BOOL _suspended; /* Is delivery suspended? */
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
+ (NSNotificationCenter*) defaultCenter;
|
||||
|
|
|
@ -121,11 +121,14 @@ GS_EXPORT NSString* const NSCocoaErrorDomain;
|
|||
NSString *_domain;
|
||||
NSDictionary *_userInfo;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -162,11 +162,14 @@ GS_EXPORT NSString * const NSFileHandleOperationException;
|
|||
NSFileHandle *_readHandle;
|
||||
NSFileHandle *_writeHandle;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
+ (id) pipe;
|
||||
|
|
|
@ -203,11 +203,14 @@ typedef uint32_t OSType;
|
|||
@private
|
||||
NSString *_lastError;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
@ -392,11 +395,14 @@ typedef uint32_t OSType;
|
|||
BOOL justContents: 1;
|
||||
} _flags;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
- (NSDictionary*) directoryAttributes;
|
||||
|
|
|
@ -44,11 +44,14 @@ extern "C" {
|
|||
NSSet *_names;
|
||||
NSSet *_addresses;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -50,11 +50,14 @@ extern "C" {
|
|||
NSUInteger _length;
|
||||
NSUInteger *_indexes;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -50,11 +50,14 @@ extern "C" {
|
|||
BOOL _sendToSuper;
|
||||
void *_retptr;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -71,11 +71,14 @@ extern "C" {
|
|||
NSMutableArray *_obj; /* Array of objects. */
|
||||
NSPropertyListFormat _format;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
@ -243,11 +246,14 @@ extern "C" {
|
|||
#endif
|
||||
NSZone *_zone; /* Zone for allocating objs. */
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -104,11 +104,14 @@ GS_EXPORT NSString * const NSISO8601Calendar;
|
|||
NSString *_localeId;
|
||||
NSMutableDictionary *_components;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -138,11 +138,18 @@ typedef NSUInteger NSNumberFormatterRoundingMode;
|
|||
NSDictionary *_attributesForPositiveValues;
|
||||
NSDictionary *_attributesForNegativeValues;
|
||||
#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
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -211,11 +211,14 @@ typedef SOCKET NSSocketNativeHandle;
|
|||
NSMapTable *events;
|
||||
#endif
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -94,11 +94,14 @@ extern "C" {
|
|||
unsigned _version; /* Version of archiver used. */
|
||||
NSZone *_zone; /* Zone for allocating objs. */
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -51,11 +51,14 @@ extern "C" {
|
|||
NSPort *_send;
|
||||
NSMutableArray *_components;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -60,11 +60,14 @@ extern "C" {
|
|||
NSMapTable *_portMap; /* Registered ports information. */
|
||||
NSMapTable *_nameMap; /* Registered names information. */
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
+ (id) sharedInstance;
|
||||
|
|
|
@ -42,11 +42,14 @@ extern "C" {
|
|||
Protocol *_myProtocol;
|
||||
NSObject *_myTarget;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -39,11 +39,14 @@ DEFINE_BLOCK_TYPE(GSRegexBlock, void, NSTextCheckingResult*, NSMatchingFlags, BO
|
|||
GSREGEXTYPE *regex;
|
||||
NSRegularExpressionOptions options;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
+ (NSRegularExpression*)regularExpressionWithPattern: (NSString*)aPattern
|
||||
|
|
|
@ -50,11 +50,14 @@ extern "C" {
|
|||
BOOL _caseSensitive;
|
||||
BOOL _isUnicode;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -50,11 +50,14 @@ extern "C" {
|
|||
BOOL _ascending;
|
||||
SEL _selector;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -64,11 +64,14 @@ GS_EXPORT NSString *const NSGrammarUserDescription;
|
|||
NSString *_currentLanguage;
|
||||
NSArray *_ignoredWords;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -54,11 +54,14 @@ extern "C" {
|
|||
BOOL _hasCollected;
|
||||
BOOL _hasNotified;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -72,11 +72,14 @@ extern "C" {
|
|||
id _gcontext;
|
||||
void *_runLoopInfo; // Per-thread runloop related info.
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -51,11 +51,14 @@ extern "C" {
|
|||
SEL _selector;
|
||||
id _info;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -98,11 +98,14 @@ GS_EXPORT NSString* const NSUndoManagerWillUndoChangeNotification;
|
|||
unsigned _disableCount;
|
||||
unsigned _levelsOfUndo;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -228,11 +228,14 @@ GS_EXPORT NSString* const GSLocale;
|
|||
NSRecursiveLock *_lock;
|
||||
NSDistributedLock *_fileLock;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -88,11 +88,14 @@ typedef NSUInteger NSXMLNodeKind;
|
|||
NSUInteger _index;
|
||||
id _objectValue;
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -74,11 +74,14 @@ GS_EXPORT NSString* const NSXMLParserErrorDomain;
|
|||
void *_parser; // GSXMLParser
|
||||
void *_handler; // SAXHandler
|
||||
#endif
|
||||
#if !GS_NONFRAGILE
|
||||
#if GS_NONFRAGILE
|
||||
#else
|
||||
/* Pointer to private additional data used to avoid breaking ABI
|
||||
* 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
|
||||
}
|
||||
|
||||
|
|
|
@ -27,16 +27,26 @@
|
|||
* their code when the class implementation is changed in new versions of the
|
||||
* library.
|
||||
*
|
||||
* The public class MUST declare its instance variables using code of the
|
||||
* form:
|
||||
* The public class MUST declare its instance variables (after any public
|
||||
* instance variables which are part of the unchanging public API) using
|
||||
* code of the form:
|
||||
* #if GS_NONFRAGILE
|
||||
* # if defined(GS_X_IVARS)
|
||||
* @public GS_X_IVARS;
|
||||
* # endif
|
||||
* #else
|
||||
* @private id _internal;
|
||||
* @private void *_internal GS_UNUSED_IVAR;
|
||||
* #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,
|
||||
* you must define GS_X_IVARS (where X is the class name) to be the
|
||||
* list of actual instance variable declarations for the class.
|
||||
|
@ -62,8 +72,32 @@
|
|||
#if !GS_NONFRAGILE
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
#define GS_PRIVATE_INTERNAL(name) \
|
||||
|
@ -79,12 +113,14 @@ GS_##name##_IVARS; \
|
|||
/* Create holder for internal ivars.
|
||||
*/
|
||||
#define GS_CREATE_INTERNAL(name) \
|
||||
_internal = [name ## Internal new];
|
||||
_internal = (void*)[name ## Internal new];
|
||||
|
||||
/* Destroy holder for internal ivars.
|
||||
*/
|
||||
#define GS_DESTROY_INTERNAL(name) \
|
||||
if (_internal != 0) DESTROY(_internal);
|
||||
if (_internal != 0) {[(id)_internal release]; _internal = 0; }
|
||||
|
||||
#endif /* GS_INTERNAL_STRUCT */
|
||||
|
||||
#undef internal
|
||||
#define internal ((GSInternal*)_internal)
|
||||
|
|
|
@ -78,18 +78,19 @@ static inline NSInteger _NSToUDateFormatStyle (NSDateFormatterStyle style)
|
|||
return -1;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
NSUInteger _behavior;
|
||||
NSLocale *_locale;
|
||||
NSTimeZone *_tz;
|
||||
NSDateFormatterStyle _timeStyle;
|
||||
NSDateFormatterStyle _dateStyle;
|
||||
void *_formatter;
|
||||
} Internal;
|
||||
#define GS_NSDateFormatter_IVARS \
|
||||
NSUInteger _behavior; \
|
||||
NSLocale *_locale; \
|
||||
NSTimeZone *_tz; \
|
||||
NSDateFormatterStyle _timeStyle; \
|
||||
NSDateFormatterStyle _dateStyle; \
|
||||
void *_formatter
|
||||
|
||||
#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
|
||||
|
||||
|
@ -101,10 +102,11 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
if (self == nil)
|
||||
return nil;
|
||||
|
||||
_reserved = NSZoneCalloc([self zone], 1, sizeof(Internal));
|
||||
this->_behavior = _defaultBehavior;
|
||||
this->_locale = RETAIN([NSLocale currentLocale]);
|
||||
this->_tz = RETAIN([NSTimeZone defaultTimeZone]);
|
||||
GS_CREATE_INTERNAL(NSDateFormatter)
|
||||
|
||||
internal->_behavior = _defaultBehavior;
|
||||
internal->_locale = RETAIN([NSLocale currentLocale]);
|
||||
internal->_tz = RETAIN([NSTimeZone defaultTimeZone]);
|
||||
|
||||
[self _resetUDateFormat];
|
||||
|
||||
|
@ -117,10 +119,10 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
NSZone *z = [self zone];
|
||||
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);
|
||||
err = U_ZERO_ERROR;
|
||||
udat_toPattern (this->_formatter, 0, value, length, &err);
|
||||
udat_toPattern (internal->_formatter, 0, value, length, &err);
|
||||
if (U_SUCCESS(err))
|
||||
{
|
||||
_dateFormat = [[NSString allocWithZone: z]
|
||||
|
@ -155,15 +157,16 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
NSDateFormatter *o = (id)NSCopyObject(self, 0, zone);
|
||||
|
||||
IF_NO_GC(RETAIN(o->_dateFormat));
|
||||
if (0 != this)
|
||||
if (0 != internal)
|
||||
{
|
||||
o->_reserved = NSZoneCalloc([self zone], 1, sizeof(Internal));
|
||||
memcpy(inst, this, sizeof(Internal));
|
||||
IF_NO_GC(RETAIN(inst->_locale);)
|
||||
o->GS_CREATE_INTERNAL(NSDateFormatter)
|
||||
|
||||
memcpy(o->_internal, internal, sizeof(NSDateFormatterInternal));
|
||||
IF_NO_GC(RETAIN(GSIVar(o,_locale));)
|
||||
#if GS_USE_ICU == 1
|
||||
{
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
inst->_formatter = udat_clone (this->_formatter, &err);
|
||||
GSIVar(o,_formatter) = udat_clone (internal->_formatter, &err);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -179,14 +182,14 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_dateFormat);
|
||||
if (this != 0)
|
||||
if (internal != 0)
|
||||
{
|
||||
RELEASE(this->_locale);
|
||||
RELEASE(this->_tz);
|
||||
RELEASE(internal->_locale);
|
||||
RELEASE(internal->_tz);
|
||||
#if GS_USE_ICU == 1
|
||||
udat_close (this->_formatter);
|
||||
udat_close (internal->_formatter);
|
||||
#endif
|
||||
NSZoneFree([self zone], this);
|
||||
GS_DESTROY_INTERNAL(NSDateFormatter)
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -248,7 +251,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
{
|
||||
_dateFormat = [format copy];
|
||||
_allowsNaturalLanguage = flag;
|
||||
this->_behavior = NSDateFormatterBehavior10_0;
|
||||
internal->_behavior = NSDateFormatterBehavior10_0;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -292,12 +295,12 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
|
||||
- (NSDateFormatterBehavior) formatterBehavior
|
||||
{
|
||||
return this->_behavior;
|
||||
return internal->_behavior;
|
||||
}
|
||||
|
||||
- (void) setFormatterBehavior: (NSDateFormatterBehavior) behavior
|
||||
{
|
||||
this->_behavior = behavior;
|
||||
internal->_behavior = behavior;
|
||||
}
|
||||
|
||||
- (BOOL) generatesCalendarDates
|
||||
|
@ -313,7 +316,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
- (BOOL) isLenient
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return (BOOL)udat_isLenient (this->_formatter);
|
||||
return (BOOL)udat_isLenient (internal->_formatter);
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
|
@ -322,7 +325,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
- (void) setLenient: (BOOL) flag
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
udat_setLenient (this->_formatter, flag);
|
||||
udat_setLenient (internal->_formatter, flag);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -346,7 +349,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
|
||||
[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))
|
||||
result =
|
||||
[NSDate dateWithTimeIntervalSince1970: (NSTimeInterval)(date / 1000.0)];
|
||||
|
@ -368,10 +371,10 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
UDate udate = [date timeIntervalSince1970] * 1000.0;
|
||||
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));
|
||||
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))
|
||||
{
|
||||
result = AUTORELEASE([[NSString allocWithZone: z]
|
||||
|
@ -407,7 +410,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
pattern = NSZoneMalloc ([self zone], sizeof(UChar) * 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);
|
||||
#endif
|
||||
|
@ -418,29 +421,29 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
|
||||
- (NSDateFormatterStyle) dateStyle
|
||||
{
|
||||
return this->_dateStyle;
|
||||
return internal->_dateStyle;
|
||||
}
|
||||
|
||||
- (void) setDateStyle: (NSDateFormatterStyle) style
|
||||
{
|
||||
this->_dateStyle = style;
|
||||
internal->_dateStyle = style;
|
||||
[self _resetUDateFormat];
|
||||
}
|
||||
|
||||
- (NSDateFormatterStyle) timeStyle
|
||||
{
|
||||
return this->_timeStyle;
|
||||
return internal->_timeStyle;
|
||||
}
|
||||
|
||||
- (void) setTimeStyle: (NSDateFormatterStyle) style
|
||||
{
|
||||
this->_timeStyle = style;
|
||||
internal->_timeStyle = style;
|
||||
[self _resetUDateFormat];
|
||||
}
|
||||
|
||||
- (NSCalendar *) calendar
|
||||
{
|
||||
return [this->_locale objectForKey: NSLocaleCalendar];
|
||||
return [internal->_locale objectForKey: NSLocaleCalendar];
|
||||
}
|
||||
|
||||
- (void) setCalendar: (NSCalendar *) calendar
|
||||
|
@ -448,7 +451,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
NSMutableDictionary *dict;
|
||||
NSLocale *locale;
|
||||
|
||||
dict = [[NSLocale componentsFromLocaleIdentifier: [this->_locale localeIdentifier]]
|
||||
dict = [[NSLocale componentsFromLocaleIdentifier: [internal->_locale localeIdentifier]]
|
||||
mutableCopy];
|
||||
[dict setValue: calendar forKey: NSLocaleCalendar];
|
||||
locale = [[NSLocale alloc] initWithLocaleIdentifier:
|
||||
|
@ -472,31 +475,31 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
|
||||
- (NSLocale *) locale
|
||||
{
|
||||
return this->_locale;
|
||||
return internal->_locale;
|
||||
}
|
||||
|
||||
- (void) setLocale: (NSLocale *) locale
|
||||
{
|
||||
if (locale == this->_locale)
|
||||
if (locale == internal->_locale)
|
||||
return;
|
||||
RELEASE(this->_locale);
|
||||
RELEASE(internal->_locale);
|
||||
|
||||
this->_locale = RETAIN(locale);
|
||||
internal->_locale = RETAIN(locale);
|
||||
[self _resetUDateFormat];
|
||||
}
|
||||
|
||||
- (NSTimeZone *) timeZone
|
||||
{
|
||||
return this->_tz;
|
||||
return internal->_tz;
|
||||
}
|
||||
|
||||
- (void) setTimeZone: (NSTimeZone *) tz
|
||||
{
|
||||
if (tz == this->_tz)
|
||||
if (tz == internal->_tz)
|
||||
return;
|
||||
RELEASE(this->_tz);
|
||||
RELEASE(internal->_tz);
|
||||
|
||||
this->_tz = RETAIN(tz);
|
||||
internal->_tz = RETAIN(tz);
|
||||
[self _resetUDateFormat];
|
||||
}
|
||||
|
||||
|
@ -505,7 +508,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
#if GS_USE_ICU == 1
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
return [NSDate dateWithTimeIntervalSince1970:
|
||||
(udat_get2DigitYearStart (this->_formatter, &err) / 1000.0)];
|
||||
(udat_get2DigitYearStart (internal->_formatter, &err) / 1000.0)];
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
|
@ -515,7 +518,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
{
|
||||
#if GS_USE_ICU == 1
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
udat_set2DigitYearStart (this->_formatter,
|
||||
udat_set2DigitYearStart (internal->_formatter,
|
||||
([date timeIntervalSince1970] * 1000.0),
|
||||
&err);
|
||||
#else
|
||||
|
@ -943,12 +946,12 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
|
||||
- (BOOL) doesRelativeDateFormatting
|
||||
{
|
||||
return (this->_dateStyle & FormatterDoesRelativeDateFormatting) ? YES : NO;
|
||||
return (internal->_dateStyle & FormatterDoesRelativeDateFormatting) ? YES : NO;
|
||||
}
|
||||
|
||||
- (void) setDoesRelativeDateFormatting: (BOOL) flag
|
||||
{
|
||||
this->_dateStyle |= FormatterDoesRelativeDateFormatting;
|
||||
internal->_dateStyle |= FormatterDoesRelativeDateFormatting;
|
||||
}
|
||||
@end
|
||||
|
||||
|
@ -960,23 +963,23 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
int32_t tzIDLength;
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
|
||||
if (this->_formatter)
|
||||
udat_close (this->_formatter);
|
||||
if (internal->_formatter)
|
||||
udat_close (internal->_formatter);
|
||||
|
||||
tzIDLength = [[this->_tz name] length];
|
||||
tzIDLength = [[internal->_tz name] length];
|
||||
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),
|
||||
_NSToUDateFormatStyle(this->_dateStyle),
|
||||
[[this->_locale localeIdentifier] UTF8String],
|
||||
internal->_formatter = udat_open (_NSToUDateFormatStyle(internal->_timeStyle),
|
||||
_NSToUDateFormatStyle(internal->_dateStyle),
|
||||
[[internal->_locale localeIdentifier] UTF8String],
|
||||
tzID,
|
||||
tzIDLength,
|
||||
NULL,
|
||||
0,
|
||||
&err);
|
||||
if (U_FAILURE(err))
|
||||
this->_formatter = NULL;
|
||||
internal->_formatter = NULL;
|
||||
|
||||
NSZoneFree ([self zone], tzID);
|
||||
#else
|
||||
|
@ -988,7 +991,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
{
|
||||
#if GS_USE_ICU == 1
|
||||
int idx = 0;
|
||||
int count = udat_countSymbols (this->_formatter, symbol);
|
||||
int count = udat_countSymbols (internal->_formatter, symbol);
|
||||
|
||||
if ([array count] != count)
|
||||
return;
|
||||
|
@ -1004,7 +1007,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
value = NSZoneMalloc ([self zone], sizeof(unichar) * 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);
|
||||
|
||||
|
@ -1020,7 +1023,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
#if GS_USE_ICU == 1
|
||||
NSMutableArray *mArray;
|
||||
int idx = 0;
|
||||
int count = udat_countSymbols (this->_formatter, symbol);
|
||||
int count = udat_countSymbols (internal->_formatter, symbol);
|
||||
|
||||
mArray = [NSMutableArray arrayWithCapacity: count];
|
||||
while (idx < count)
|
||||
|
@ -1031,10 +1034,11 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
NSZone *z = [self zone];
|
||||
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));
|
||||
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))
|
||||
{
|
||||
str = AUTORELEASE([[NSString allocWithZone: z]
|
||||
|
|
|
@ -199,17 +199,18 @@ _ICUToNSRoundingMode (UNumberFormatRoundingMode mode)
|
|||
#endif
|
||||
|
||||
|
||||
// Internal data storage
|
||||
typedef struct {
|
||||
NSUInteger _behavior;
|
||||
BOOL _genDecimal;
|
||||
NSUInteger _style;
|
||||
NSLocale *_locale;
|
||||
void *_formatter;
|
||||
} Internal;
|
||||
#define GS_NSNumberFormatter_IVARS \
|
||||
NSUInteger _behavior; \
|
||||
BOOL _genDecimal; \
|
||||
NSUInteger _style; \
|
||||
NSLocale *_locale; \
|
||||
void *_formatter
|
||||
|
||||
#define this ((Internal*)(self->_reserved))
|
||||
#define inst ((Internal*)(o->_reserved))
|
||||
#define GSInternal NSNumberFormatterInternal
|
||||
#define GS_INTERNAL_STRUCT 1
|
||||
#include "GSInternal.h"
|
||||
GS_PRIVATE_INTERNAL(NSNumberFormatter)
|
||||
|
||||
|
||||
@interface NSNumberFormatter (PrivateMethods)
|
||||
- (void) _resetUNumberFormat;
|
||||
|
@ -295,15 +296,16 @@ static NSUInteger _defaultBehavior = 0;
|
|||
IF_NO_GC(RETAIN(o->_attributedStringForNil);)
|
||||
IF_NO_GC(RETAIN(o->_attributedStringForNotANumber);)
|
||||
IF_NO_GC(RETAIN(o->_attributedStringForZero);)
|
||||
if (0 != this)
|
||||
if (0 != internal)
|
||||
{
|
||||
o->_reserved = NSZoneCalloc([self zone], 1, sizeof(Internal));
|
||||
memcpy(inst, this, sizeof(Internal));
|
||||
IF_NO_GC(RETAIN(inst->_locale);)
|
||||
o->_internal = GS_CREATE_INTERNAL(NSNumberFormatter)
|
||||
|
||||
memcpy(o->_internal, internal, sizeof(NSNumberFormatterInternal));
|
||||
IF_NO_GC(RETAIN(GSIVar(o,_locale));)
|
||||
#if GS_USE_ICU == 1
|
||||
{
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
inst->_formatter = unum_clone (this->_formatter, &err);
|
||||
GSIVar(o,_formatter) = unum_clone (internal->_formatter, &err);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -322,27 +324,27 @@ static NSUInteger _defaultBehavior = 0;
|
|||
RELEASE(_attributedStringForNil);
|
||||
RELEASE(_attributedStringForNotANumber);
|
||||
RELEASE(_attributedStringForZero);
|
||||
if (this != 0)
|
||||
if (internal != 0)
|
||||
{
|
||||
RELEASE(this->_locale);
|
||||
RELEASE(internal->_locale);
|
||||
#if GS_USE_ICU == 1
|
||||
unum_close (this->_formatter);
|
||||
unum_close (internal->_formatter);
|
||||
#endif
|
||||
NSZoneFree([self zone], this);
|
||||
GS_DESTROY_INTERNAL(NSNumberFormatter)
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString*) decimalSeparator
|
||||
{
|
||||
if (this->_behavior == NSNumberFormatterBehavior10_4
|
||||
|| this->_behavior == NSNumberFormatterBehaviorDefault)
|
||||
if (internal->_behavior == NSNumberFormatterBehavior10_4
|
||||
|| internal->_behavior == NSNumberFormatterBehaviorDefault)
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return [self _getSymbol: UNUM_DECIMAL_SEPARATOR_SYMBOL];
|
||||
#endif
|
||||
}
|
||||
else if (this->_behavior == NSNumberFormatterBehavior10_0)
|
||||
else if (internal->_behavior == NSNumberFormatterBehavior10_0)
|
||||
{
|
||||
if (_decimalSeparator == 0)
|
||||
return @"";
|
||||
|
@ -441,7 +443,8 @@ static NSUInteger _defaultBehavior = 0;
|
|||
{
|
||||
id o;
|
||||
|
||||
_reserved = NSZoneCalloc([self zone], 1, sizeof(Internal));
|
||||
GS_CREATE_INTERNAL(NSNumberFormatter)
|
||||
|
||||
_allowsFloats = YES;
|
||||
_decimalSeparator = '.';
|
||||
_thousandSeparator = ',';
|
||||
|
@ -453,11 +456,11 @@ static NSUInteger _defaultBehavior = 0;
|
|||
[self setAttributedStringForNotANumber: o];
|
||||
RELEASE(o);
|
||||
|
||||
this->_behavior = _defaultBehavior;
|
||||
this->_locale = RETAIN([NSLocale currentLocale]);
|
||||
this->_style = NSNumberFormatterNoStyle;
|
||||
internal->_behavior = _defaultBehavior;
|
||||
internal->_locale = RETAIN([NSLocale currentLocale]);
|
||||
internal->_style = NSNumberFormatterNoStyle;
|
||||
[self _resetUNumberFormat];
|
||||
if (this->_formatter == NULL)
|
||||
if (internal->_formatter == NULL)
|
||||
{
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -641,14 +644,14 @@ static NSUInteger _defaultBehavior = 0;
|
|||
|
||||
- (void) setDecimalSeparator: (NSString*)newSeparator
|
||||
{
|
||||
if (this->_behavior == NSNumberFormatterBehavior10_4
|
||||
|| this->_behavior == NSNumberFormatterBehaviorDefault)
|
||||
if (internal->_behavior == NSNumberFormatterBehavior10_4
|
||||
|| internal->_behavior == NSNumberFormatterBehaviorDefault)
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
[self _setSymbol: newSeparator : UNUM_DECIMAL_SEPARATOR_SYMBOL];
|
||||
#endif
|
||||
}
|
||||
else if (this->_behavior == NSNumberFormatterBehavior10_0)
|
||||
else if (internal->_behavior == NSNumberFormatterBehavior10_0)
|
||||
{
|
||||
if ([newSeparator length] > 0)
|
||||
_decimalSeparator = [newSeparator characterAtIndex: 0];
|
||||
|
@ -745,8 +748,8 @@ static NSUInteger _defaultBehavior = 0;
|
|||
|
||||
- (NSString*) stringForObjectValue: (id)anObject
|
||||
{
|
||||
if (this->_behavior == NSNumberFormatterBehaviorDefault
|
||||
|| this->_behavior == NSNumberFormatterBehavior10_4)
|
||||
if (internal->_behavior == NSNumberFormatterBehaviorDefault
|
||||
|| internal->_behavior == NSNumberFormatterBehavior10_4)
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
|
||||
|
@ -757,11 +760,11 @@ static NSUInteger _defaultBehavior = 0;
|
|||
int32_t len; \
|
||||
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) \
|
||||
outStr = NSZoneMalloc ([self zone], len * sizeof(UChar));\
|
||||
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]; \
|
||||
if (len > MAX_BUFFER_SIZE) \
|
||||
NSZoneFree ([self zone], outStr); \
|
||||
|
@ -816,7 +819,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
}
|
||||
#endif
|
||||
}
|
||||
else if (this->_behavior == NSNumberFormatterBehavior10_0)
|
||||
else if (internal->_behavior == NSNumberFormatterBehavior10_0)
|
||||
{
|
||||
NSMutableDictionary *locale;
|
||||
NSCharacterSet *formattingCharacters;
|
||||
|
@ -1128,7 +1131,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
range = [string rangeOfString: @"."];
|
||||
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))
|
||||
return nil;
|
||||
if (intNum == 0 || intNum == 1)
|
||||
|
@ -1140,7 +1143,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
}
|
||||
else
|
||||
{
|
||||
doubleNum = unum_parseDouble (this->_formatter, ustring, length, NULL, &err);
|
||||
doubleNum = unum_parseDouble (internal->_formatter, ustring, length, NULL, &err);
|
||||
if (U_FAILURE(err))
|
||||
return nil;
|
||||
result = [NSNumber numberWithDouble: doubleNum];
|
||||
|
@ -1157,12 +1160,12 @@ static NSUInteger _defaultBehavior = 0;
|
|||
|
||||
- (void) setFormatterBehavior: (NSNumberFormatterBehavior) behavior
|
||||
{
|
||||
this->_behavior = behavior;
|
||||
internal->_behavior = behavior;
|
||||
}
|
||||
|
||||
- (NSNumberFormatterBehavior) formatterBehavior
|
||||
{
|
||||
return this->_behavior;
|
||||
return internal->_behavior;
|
||||
}
|
||||
|
||||
+ (void) setDefaultFormatterBehavior: (NSNumberFormatterBehavior) behavior
|
||||
|
@ -1177,18 +1180,18 @@ static NSUInteger _defaultBehavior = 0;
|
|||
|
||||
- (void) setNumberStyle: (NSNumberFormatterStyle) style
|
||||
{
|
||||
this->_style = style;
|
||||
internal->_style = style;
|
||||
[self _resetUNumberFormat];
|
||||
}
|
||||
|
||||
- (NSNumberFormatterStyle) numberStyle
|
||||
{
|
||||
return this->_style;
|
||||
return internal->_style;
|
||||
}
|
||||
|
||||
- (void) setGeneratesDecimalNumbers: (BOOL) flag
|
||||
{
|
||||
this->_genDecimal = flag;
|
||||
internal->_genDecimal = flag;
|
||||
}
|
||||
|
||||
- (BOOL) generatesDecimalNubmers
|
||||
|
@ -1199,18 +1202,18 @@ static NSUInteger _defaultBehavior = 0;
|
|||
|
||||
- (void) setLocale: (NSLocale *) locale
|
||||
{
|
||||
RELEASE(this->_locale);
|
||||
RELEASE(internal->_locale);
|
||||
|
||||
if (locale == nil)
|
||||
locale = [NSLocale currentLocale];
|
||||
this->_locale = RETAIN(locale);
|
||||
internal->_locale = RETAIN(locale);
|
||||
|
||||
[self _resetUNumberFormat];
|
||||
}
|
||||
|
||||
- (NSLocale *) locale
|
||||
{
|
||||
return this->_locale;
|
||||
return internal->_locale;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1218,7 +1221,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
{
|
||||
#if GS_USE_ICU == 1
|
||||
if ([number class] == [NSDoubleNumber class])
|
||||
unum_setDoubleAttribute (this->_formatter, UNUM_ROUNDING_INCREMENT,
|
||||
unum_setDoubleAttribute (internal->_formatter, UNUM_ROUNDING_INCREMENT,
|
||||
[number doubleValue]);
|
||||
#else
|
||||
return;
|
||||
|
@ -1228,7 +1231,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSNumber *) roundingIncrement
|
||||
{
|
||||
#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];
|
||||
#else
|
||||
return nil;
|
||||
|
@ -1238,7 +1241,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setRoundingMode: (NSNumberFormatterRoundingMode) mode
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_ROUNDING_MODE,
|
||||
unum_setAttribute (internal->_formatter, UNUM_ROUNDING_MODE,
|
||||
_NSToICURoundingMode(mode));
|
||||
#else
|
||||
return;
|
||||
|
@ -1248,7 +1251,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSNumberFormatterRoundingMode) roundingMode
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return _ICUToNSRoundingMode (unum_getAttribute (this->_formatter,
|
||||
return _ICUToNSRoundingMode (unum_getAttribute (internal->_formatter,
|
||||
UNUM_ROUNDING_MODE));
|
||||
#else
|
||||
return 0;
|
||||
|
@ -1259,7 +1262,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setFormatWidth: (NSUInteger) number
|
||||
{
|
||||
#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
|
||||
return;
|
||||
#endif
|
||||
|
@ -1268,7 +1271,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSUInteger) formatWidth
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return (NSUInteger)unum_getAttribute (this->_formatter, UNUM_FORMAT_WIDTH);
|
||||
return (NSUInteger)unum_getAttribute (internal->_formatter, UNUM_FORMAT_WIDTH);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -1278,7 +1281,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
{
|
||||
#if GS_USE_ICU == 1
|
||||
int32_t value = [number intValue];
|
||||
unum_setAttribute (this->_formatter, UNUM_MULTIPLIER, value);
|
||||
unum_setAttribute (internal->_formatter, UNUM_MULTIPLIER, value);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1287,7 +1290,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSNumber *) multiplier
|
||||
{
|
||||
#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];
|
||||
#else
|
||||
return nil;
|
||||
|
@ -1671,7 +1674,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
{
|
||||
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_GROUPING_USED, flag);
|
||||
unum_setAttribute (internal->_formatter, UNUM_GROUPING_USED, flag);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1680,7 +1683,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (BOOL) usesGroupingSeparator
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return (BOOL)unum_getAttribute (this->_formatter, UNUM_GROUPING_USED);
|
||||
return (BOOL)unum_getAttribute (internal->_formatter, UNUM_GROUPING_USED);
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
|
@ -1689,7 +1692,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setAlwaysShowsDecimalSeparator: (BOOL) flag
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_DECIMAL_ALWAYS_SHOWN, flag);
|
||||
unum_setAttribute (internal->_formatter, UNUM_DECIMAL_ALWAYS_SHOWN, flag);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1698,7 +1701,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (BOOL) alwaysShowsDecimalSeparator
|
||||
{
|
||||
#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
|
||||
return NO;
|
||||
#endif
|
||||
|
@ -1725,7 +1728,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setGroupingSize: (NSUInteger) number
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_GROUPING_SIZE, number);
|
||||
unum_setAttribute (internal->_formatter, UNUM_GROUPING_SIZE, number);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1734,7 +1737,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSUInteger) groupingSize
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return (NSUInteger)unum_getAttribute (this->_formatter, UNUM_GROUPING_SIZE);
|
||||
return (NSUInteger)unum_getAttribute (internal->_formatter, UNUM_GROUPING_SIZE);
|
||||
#else
|
||||
return 3;
|
||||
#endif
|
||||
|
@ -1743,7 +1746,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setSecondaryGroupingSize: (NSUInteger) number
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_SECONDARY_GROUPING_SIZE, number);
|
||||
unum_setAttribute (internal->_formatter, UNUM_SECONDARY_GROUPING_SIZE, number);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1752,7 +1755,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSUInteger) secondaryGroupingSize
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return (NSUInteger)unum_getAttribute (this->_formatter,
|
||||
return (NSUInteger)unum_getAttribute (internal->_formatter,
|
||||
UNUM_SECONDARY_GROUPING_SIZE);
|
||||
#else
|
||||
return 3;
|
||||
|
@ -1781,7 +1784,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setPaddingPosition: (NSNumberFormatterPadPosition) position
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_PADDING_POSITION,
|
||||
unum_setAttribute (internal->_formatter, UNUM_PADDING_POSITION,
|
||||
_NSToICUPadPosition (position));
|
||||
#else
|
||||
return;
|
||||
|
@ -1791,7 +1794,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSNumberFormatterPadPosition) paddingPosition
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return _ICUToNSPadPosition(unum_getAttribute (this->_formatter,
|
||||
return _ICUToNSPadPosition(unum_getAttribute (internal->_formatter,
|
||||
UNUM_PADDING_POSITION));
|
||||
#else
|
||||
return 0;
|
||||
|
@ -1802,7 +1805,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setMinimumIntegerDigits: (NSUInteger) number
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_MIN_INTEGER_DIGITS, number);
|
||||
unum_setAttribute (internal->_formatter, UNUM_MIN_INTEGER_DIGITS, number);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1811,7 +1814,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSUInteger) minimumIntegerDigits
|
||||
{
|
||||
#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
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -1820,7 +1823,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setMinimumFractionDigits: (NSUInteger) number
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_MIN_FRACTION_DIGITS, number);
|
||||
unum_setAttribute (internal->_formatter, UNUM_MIN_FRACTION_DIGITS, number);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1829,7 +1832,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSUInteger) minimumFractionDigits
|
||||
{
|
||||
#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
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -1838,7 +1841,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setMaximumIntegerDigits: (NSUInteger) number
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_MAX_INTEGER_DIGITS, number);
|
||||
unum_setAttribute (internal->_formatter, UNUM_MAX_INTEGER_DIGITS, number);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1847,7 +1850,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSUInteger) maximumIntegerDigits
|
||||
{
|
||||
#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
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -1856,7 +1859,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setMaximumFractionDigits: (NSUInteger) number
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_MAX_FRACTION_DIGITS, number);
|
||||
unum_setAttribute (internal->_formatter, UNUM_MAX_FRACTION_DIGITS, number);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1865,7 +1868,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSUInteger) maximumFractionDigits
|
||||
{
|
||||
#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
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -1884,7 +1887,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setUsesSignificantDigits: (BOOL) flag
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_SIGNIFICANT_DIGITS_USED, flag);
|
||||
unum_setAttribute (internal->_formatter, UNUM_SIGNIFICANT_DIGITS_USED, flag);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1893,7 +1896,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (BOOL) usesSignificantDigits
|
||||
{
|
||||
#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
|
||||
return NO;
|
||||
#endif
|
||||
|
@ -1902,7 +1905,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setMinimumSignificantDigits: (NSUInteger) number
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_MIN_SIGNIFICANT_DIGITS, number);
|
||||
unum_setAttribute (internal->_formatter, UNUM_MIN_SIGNIFICANT_DIGITS, number);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1911,7 +1914,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSUInteger) minimumSignificantDigits
|
||||
{
|
||||
#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
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -1920,7 +1923,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setMaximumSignificantDigits: (NSUInteger) number
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_MAX_SIGNIFICANT_DIGITS, number);
|
||||
unum_setAttribute (internal->_formatter, UNUM_MAX_SIGNIFICANT_DIGITS, number);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1929,7 +1932,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (NSUInteger) maximumSignificantDigits
|
||||
{
|
||||
#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
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -1958,7 +1961,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (void) setLenient: (BOOL) flag
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
unum_setAttribute (this->_formatter, UNUM_LENIENT_PARSE, flag);
|
||||
unum_setAttribute (internal->_formatter, UNUM_LENIENT_PARSE, flag);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -1967,7 +1970,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
- (BOOL) isLenient
|
||||
{
|
||||
#if GS_USE_ICU == 1
|
||||
return (BOOL)unum_getAttribute (this->_formatter, UNUM_LENIENT_PARSE);
|
||||
return (BOOL)unum_getAttribute (internal->_formatter, UNUM_LENIENT_PARSE);
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
|
@ -2014,15 +2017,15 @@ static NSUInteger _defaultBehavior = 0;
|
|||
UErrorCode err = U_ZERO_ERROR;
|
||||
const char *cLocaleId;
|
||||
|
||||
if (this->_formatter)
|
||||
unum_close(this->_formatter);
|
||||
if (internal->_formatter)
|
||||
unum_close(internal->_formatter);
|
||||
|
||||
cLocaleId = [[this->_locale localeIdentifier] UTF8String];
|
||||
style = _NSToICUFormatStyle (this->_style);
|
||||
cLocaleId = [[internal->_locale localeIdentifier] UTF8String];
|
||||
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))
|
||||
this->_formatter = NULL;
|
||||
internal->_formatter = NULL;
|
||||
|
||||
[self setMaximumFractionDigits: 0];
|
||||
#else
|
||||
|
@ -2043,7 +2046,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
str = (unichar *)NSZoneMalloc ([self zone], length * sizeof(unichar));
|
||||
[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)
|
||||
NSZoneFree ([self zone], str);
|
||||
|
@ -2061,12 +2064,12 @@ static NSUInteger _defaultBehavior = 0;
|
|||
UErrorCode err = U_ZERO_ERROR;
|
||||
NSString *result;
|
||||
|
||||
length = unum_getSymbol (this->_formatter, symbol, str,
|
||||
length = unum_getSymbol (internal->_formatter, symbol, str,
|
||||
MAX_SYMBOL_SIZE, &err);
|
||||
if (length > MAX_SYMBOL_SIZE)
|
||||
{
|
||||
str = (UChar *)NSZoneMalloc ([self zone], length * sizeof(UChar));
|
||||
length = unum_getSymbol (this->_formatter, symbol, str,
|
||||
length = unum_getSymbol (internal->_formatter, symbol, str,
|
||||
length, &err);
|
||||
}
|
||||
|
||||
|
@ -2093,7 +2096,7 @@ static NSUInteger _defaultBehavior = 0;
|
|||
str = (unichar *)NSZoneMalloc ([self zone], length * sizeof(unichar));
|
||||
[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)
|
||||
NSZoneFree ([self zone], str);
|
||||
|
@ -2111,12 +2114,12 @@ static NSUInteger _defaultBehavior = 0;
|
|||
UErrorCode err = U_ZERO_ERROR;
|
||||
NSString *result;
|
||||
|
||||
length = unum_getTextAttribute (this->_formatter, attrib, str,
|
||||
length = unum_getTextAttribute (internal->_formatter, attrib, str,
|
||||
MAX_TEXT_ATTRIB_SIZE, &err);
|
||||
if (length > MAX_TEXT_ATTRIB_SIZE)
|
||||
{
|
||||
str = (UChar *)NSZoneMalloc ([self zone], length * sizeof(UChar));
|
||||
length = unum_getTextAttribute (this->_formatter, attrib, str,
|
||||
length = unum_getTextAttribute (internal->_formatter, attrib, str,
|
||||
length, &err);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue