diff --git a/ChangeLog b/ChangeLog index 1e8064f9c..a77d1b61a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2002-03-13 Richard Frith-Macdonald + + * Headers/gnustep/base/NSObjCRuntime.h: Remove bad markup in comments. + * Headers/gnustep/base/NSString.h: Remove private class declaration + and hide internals of NXConstantString behind dummy interface while + improving comments. + * Source/GSUserDefaults.h: removed + * Source/GSPrivate.h: added + * Source/GSCompatibility.m: fix for hidden private info. + * Source/GSString.m: ditto + * Source/NSArray.m: ditto + * Source/NSCalendarDate.m: ditto + * Source/NSDate.m: ditto + * Source/NSDecimalNumber.m: ditto + * Source/NSDictionary.m: ditto + * Source/NSLog.m: ditto + * Source/NSObjCRuntime.m: ditto + * Source/NSScanner.m: ditto + * Source/NSSerializer.m: ditto + * Source/NSString.m: ditto + * Source/NSUser.m: ditto + * Source/NSUserDefaults.m: ditto + General tidyups to hide some internal workings which should really + not be exposed in public headers. + 2002-03-12 Richard Frith-Macdonald * NSTimeZones/NSTimeZones.tar: regenerated with latest data. diff --git a/Headers/gnustep/base/NSObjCRuntime.h b/Headers/gnustep/base/NSObjCRuntime.h index 871de8fd3..e45d667de 100644 --- a/Headers/gnustep/base/NSObjCRuntime.h +++ b/Headers/gnustep/base/NSObjCRuntime.h @@ -143,7 +143,7 @@ GSObjCIsKindOf(Class this, Class other) return NO; } -/** +/** ## deprecated ## */ FOUNDATION_STATIC_INLINE const char* GSObjCName(Class this) @@ -151,7 +151,7 @@ GSObjCName(Class this) return class_get_class_name(this); } -/** +/** ## deprecated ## */ FOUNDATION_STATIC_INLINE const char* GSObjCSelectorName(SEL this) @@ -161,7 +161,7 @@ GSObjCSelectorName(SEL this) return sel_get_name(this); } -/** +/** ## deprecated ## */ FOUNDATION_STATIC_INLINE const char* GSObjCSelectorTypes(SEL this) diff --git a/Headers/gnustep/base/NSString.h b/Headers/gnustep/base/NSString.h index 189483c82..e01e28bc1 100644 --- a/Headers/gnustep/base/NSString.h +++ b/Headers/gnustep/base/NSString.h @@ -325,25 +325,34 @@ enum { @interface NSMutableString : NSString @end -/* - * Information for NXConstantString +/** + *

The NXConstantString class is used to hold constant 8-bit character + * string objects produced by the compiler where it sees @"..." in the + * source. The compiler generates the instances of this class - which + * has three instance variables -

+ * + * a pointer to the class (this is the sole ivar of NSObject) + * a pointer to the 8-bit data + * the length of the string + * + *

In older versions of the compiler, the isa variable is always set to + * the NXConstantString class. In newer versions a compiler option was + * added for GNUstep, to permit the isa variable to be set to another + * class, and GNUstep uses this to avoid conflicts with the default + * implementation of NXConstantString in the ObjC runtime library (the + * preprocessor is used to change all occurances of NXConstantString + * in the source code to NSConstantString).

+ *

Since GNUstep will generally use the GNUstep extension to the + * compiler, you should never refer to the constnat string class by + * name, but should use the [NSString+constantStringClass] method to + * get the actual class being used for constant strings.

+ * What follows is a dummy declaration of the class to keep the compiler + * happy. */ @interface NXConstantString : NSString { -#if defined(__APPLE__) && __GCC__ >= 3 - /* Up to gcc 2.95.2 the compiler slipped these two in automatically. - With the advent of ObjC++ this is no longer possible (?). - There is no Apple modified gcc between 2.95.2 and 3.1. - This info ia as of 2002-03-04 and regarding the experimental - Apple gcc 3.1. Markus Hitter, mah@jump-ing.de */ - char *cString; - unsigned int len; -#endif - union { - unichar *u; - unsigned char *c; - } _contents; - unsigned int _count; + const char * const nxcsptr; + const unsigned int nxcslen; } @end @@ -354,28 +363,6 @@ extern struct objc_class _NSConstantStringClassReference; #endif #ifndef NO_GNUSTEP -/* - * Private concrete string classes. - * NB. All these concrete string classes MUST have the same initial ivar - * layout so that we can swap between them as necessary. - * The initial layout must also match that of NXConstantString (which is - * determined by the compiler). - */ -@interface GSString : NSString -{ - union { - unichar *u; - unsigned char *c; - } _contents; - unsigned int _count; - struct { - unsigned int wide: 1; // 16-bit characters in string? - unsigned int free: 1; // Should free memory? - unsigned int unused: 2; - unsigned int hash: 28; - } _flags; -} -@end @interface NSString (GSString) - (NSString*) stringWithoutSuffix: (NSString*)_suffix; diff --git a/Source/GSCompatibility.m b/Source/GSCompatibility.m index 2d6c31d90..879cab4fb 100644 --- a/Source/GSCompatibility.m +++ b/Source/GSCompatibility.m @@ -24,7 +24,7 @@ #include #include -#include "GSUserDefaults.h" +#include "GSPrivate.h" #ifndef HAVE_RINT #include diff --git a/Source/GSMime.m b/Source/GSMime.m index bc9484cef..e58dddecb 100644 --- a/Source/GSMime.m +++ b/Source/GSMime.m @@ -67,7 +67,6 @@ #include #include #include -#include "GSUserDefaults.h" static NSCharacterSet *specials = nil; diff --git a/Source/GSUserDefaults.h b/Source/GSPrivate.h similarity index 61% rename from Source/GSUserDefaults.h rename to Source/GSPrivate.h index 7ca3b46df..d90b62c7e 100644 --- a/Source/GSUserDefaults.h +++ b/Source/GSPrivate.h @@ -1,5 +1,5 @@ -/* GSUserDefaults - Copyright (C) 2001 Free Software Foundation, Inc. +/* GSPrivate + Copyright (C) 2001,2002 Free Software Foundation, Inc. Written by: Richard Frith-Macdonald @@ -20,12 +20,36 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#ifndef __GSUserDefaults_h_ -#define __GSUserDefaults_h_ +#ifndef __GSPrivate_h_ +#define __GSPrivate_h_ -#include /* + * Private concrete string classes. + * NB. All these concrete string classes MUST have the same initial ivar + * layout so that we can swap between them as necessary. + * The initial layout must also match that of NXConstantString (which is + * determined by the compiler) - an initial pointer to the string data + * followed by the string length (number of characters). + */ +@interface GSString : NSString +{ + union { + unichar *u; + unsigned char *c; + } _contents; + unsigned int _count; + struct { + unsigned int wide: 1; // 16-bit characters in string? + unsigned int free: 1; // Should free memory? + unsigned int unused: 2; + unsigned int hash: 28; + } _flags; +} +@end + +/* + * Enumeration for MacOS-X compatibility user defaults settings. * For efficiency, we save defaults information which is used by the * base library. */ @@ -47,4 +71,5 @@ NSDictionary *GSUserDefaultsDictionaryRepresentation(); */ BOOL GSUserDefaultsFlag(GSUserDefaultFlagType type); -#endif /* __GSUserDefaults_h_ */ +#endif /* __GSPrivate_h_ */ + diff --git a/Source/GSString.m b/Source/GSString.m index ec4988955..cb5850c3f 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -48,6 +48,9 @@ #include #include #include + +#include "GSPrivate.h" + /* memcpy(), strlen(), strcmp() are gcc builtin's */ #include @@ -3313,13 +3316,13 @@ transmute(ivars self, NSString *aString) -/* - * The NXConstantString class is used by the compiler for constant +/** + *

The NXConstantString class is used by the compiler for constant * strings, as such its ivar layout is determined by the compiler * and consists of a pointer (_contents.c) and a character count * (_count). So, while this class inherits GSCString behavior, * the code must make sure not to use any other GSCString ivars - * when accesssing an NXConstantString. + * when accesssing an NXConstantString.

*/ @implementation NXConstantString @@ -3355,7 +3358,7 @@ transmute(ivars self, NSString *aString) - (const char*) cString { - return (const char*)_contents.c; + return (const char*)nxcsptr; } - (id) retain @@ -3407,7 +3410,7 @@ transmute(ivars self, NSString *aString) { unsigned ret = 0; - int len = _count; + int len = nxcslen; if (len > NSHashStringLength) len = NSHashStringLength; @@ -3416,7 +3419,7 @@ transmute(ivars self, NSString *aString) const unsigned char *p; unsigned char_count = 0; - p = _contents.c; + p = nxcsptr; while (*p != 0 && char_count++ < NSHashStringLength) { unichar c = *p++; @@ -3468,16 +3471,16 @@ transmute(ivars self, NSString *aString) { ivars other = (ivars)anObject; - if (_count != other->_count) + if (nxcslen != other->_count) return NO; - if (memcmp(_contents.c, other->_contents.c, _count) != 0) + if (memcmp(nxcsptr, other->_contents.c, nxcslen) != 0) return NO; return YES; } else if (GSObjCIsKindOf(c, GSUnicodeStringClass) == YES || c == GSMutableStringClass) { - if (strCompCsUs(self, anObject, 0, (NSRange){0,_count}) == NSOrderedSame) + if (strCompCsUs(self, anObject, 0, (NSRange){0,nxcslen}) == NSOrderedSame) return YES; return NO; } @@ -3515,16 +3518,16 @@ transmute(ivars self, NSString *aString) { ivars other = (ivars)anObject; - if (_count != other->_count) + if (nxcslen != other->_count) return NO; - if (memcmp(_contents.c, other->_contents.c, _count) != 0) + if (memcmp(nxcsptr, other->_contents.c, nxcslen) != 0) return NO; return YES; } else if (GSObjCIsKindOf(c, GSUnicodeStringClass) == YES || c == GSMutableStringClass) { - if (strCompCsUs(self, anObject, 0, (NSRange){0,_count}) == NSOrderedSame) + if (strCompCsUs(self, anObject, 0, (NSRange){0,nxcslen}) == NSOrderedSame) return YES; return NO; } diff --git a/Source/NSArray.m b/Source/NSArray.m index 2773791b5..30d16c01c 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -43,7 +43,7 @@ #include #include #include -#include "GSUserDefaults.h" +#include "GSPrivate.h" @class NSArrayEnumerator; @class NSArrayEnumeratorReverse; diff --git a/Source/NSCalendarDate.m b/Source/NSCalendarDate.m index f69e17752..196ae0fd5 100644 --- a/Source/NSCalendarDate.m +++ b/Source/NSCalendarDate.m @@ -35,11 +35,12 @@ #include #include #include +#include #include #include #include #include -#include "GSUserDefaults.h" +#include "GSPrivate.h" // Absolute Gregorian date for NSDate reference date Jan 01 2001 // diff --git a/Source/NSDate.m b/Source/NSDate.m index cef038af7..259fc283c 100644 --- a/Source/NSDate.m +++ b/Source/NSDate.m @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #if HAVE_SYS_TIME_H @@ -47,7 +48,7 @@ #include #include #include -#include "GSUserDefaults.h" +#include "GSPrivate.h" /* The number of seconds between 1/1/2001 and 1/1/1970 = -978307200. */ /* This number comes from: diff --git a/Source/NSDecimalNumber.m b/Source/NSDecimalNumber.m index 64cf54577..3c131587b 100644 --- a/Source/NSDecimalNumber.m +++ b/Source/NSDecimalNumber.m @@ -28,7 +28,7 @@ #include #include #include -#include "GSUserDefaults.h" +#include "GSPrivate.h" static NSDecimalNumberHandler *handler; diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m index b9462c5d1..4a45f159b 100644 --- a/Source/NSDictionary.m +++ b/Source/NSDictionary.m @@ -38,7 +38,7 @@ #include #include #include -#include "GSUserDefaults.h" +#include "GSPrivate.h" @implementation NSDictionary diff --git a/Source/NSLog.m b/Source/NSLog.m index a24faa158..0c17b3c25 100644 --- a/Source/NSLog.m +++ b/Source/NSLog.m @@ -44,7 +44,7 @@ #include #endif -#include "GSUserDefaults.h" +#include "GSPrivate.h" static void _NSLog_standard_printf_handler (NSString* message) diff --git a/Source/NSObjCRuntime.m b/Source/NSObjCRuntime.m index a56ece3b6..c6b50f438 100644 --- a/Source/NSObjCRuntime.m +++ b/Source/NSObjCRuntime.m @@ -146,7 +146,7 @@ GSSetVariable(id obj, int offset, unsigned int size, const void *data) memcpy(((void*)obj) + offset, data, size); } -/** +/** ## deprecated ## */ BOOL GSInstanceVariableInfo(id obj, NSString *iVarName, @@ -157,7 +157,7 @@ GSInstanceVariableInfo(id obj, NSString *iVarName, return GSFindInstanceVariable(obj, name, type, size, offset); } -/** +/** ## deprecated ## */ BOOL GSGetInstanceVariable(id obj, NSString *iVarName, void *data) @@ -174,7 +174,7 @@ GSGetInstanceVariable(id obj, NSString *iVarName, void *data) return NO; } -/** +/** ## deprecated ## */ BOOL GSSetInstanceVariable(id obj, NSString *iVarName, const void *data) diff --git a/Source/NSScanner.m b/Source/NSScanner.m index 6b29e703f..d125fc371 100644 --- a/Source/NSScanner.m +++ b/Source/NSScanner.m @@ -31,11 +31,12 @@ #include #include #include +#include #include #include #include #include /* FIXME: May go away once I figure out Unicode */ -#include "GSUserDefaults.h" +#include "GSPrivate.h" /* BSD and Solaris have this */ #if defined(HANDLE_LLONG_MAX) && !defined(HANDLE_LONG_LONG_MAX) diff --git a/Source/NSSerializer.m b/Source/NSSerializer.m index c690af0e3..8cef8da5c 100644 --- a/Source/NSSerializer.m +++ b/Source/NSSerializer.m @@ -38,6 +38,8 @@ #include #include +#include "GSPrivate.h" + @class GSDictionary; @class GSMutableDictionary; @class NSDataMalloc; diff --git a/Source/NSString.m b/Source/NSString.m index 954043a65..80a1e80b2 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -78,7 +79,7 @@ #include -#include "GSUserDefaults.h" +#include "GSPrivate.h" @class GSString; @class GSMutableString; diff --git a/Source/NSUser.m b/Source/NSUser.m index 5f8d74247..a98eb74ac 100644 --- a/Source/NSUser.m +++ b/Source/NSUser.m @@ -39,6 +39,8 @@ #include #include +#include "GSPrivate.h" + #include // for getenv() #if HAVE_UNISTD_H #include // for getlogin() diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index e3671048e..3550655eb 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -50,7 +50,7 @@ #include #include -#include "GSUserDefaults.h" +#include "GSPrivate.h" /* Wait for access */ #define _MAX_COUNT 5 /* Max 10 sec. */