git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13100 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-03-13 09:58:43 +00:00
parent f31bbc08e8
commit 85a0e0e943
19 changed files with 120 additions and 73 deletions

View file

@ -1,3 +1,28 @@
2002-03-13 Richard Frith-Macdonald <rfm@gnu.org>
* 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 <rfm@gnu.org>
* NSTimeZones/NSTimeZones.tar: regenerated with latest data.

View file

@ -143,7 +143,7 @@ GSObjCIsKindOf(Class this, Class other)
return NO;
}
/** <deprecated />
/** ## deprecated ##
*/
FOUNDATION_STATIC_INLINE const char*
GSObjCName(Class this)
@ -151,7 +151,7 @@ GSObjCName(Class this)
return class_get_class_name(this);
}
/** <deprecated />
/** ## deprecated ##
*/
FOUNDATION_STATIC_INLINE const char*
GSObjCSelectorName(SEL this)
@ -161,7 +161,7 @@ GSObjCSelectorName(SEL this)
return sel_get_name(this);
}
/** <deprecated />
/** ## deprecated ##
*/
FOUNDATION_STATIC_INLINE const char*
GSObjCSelectorTypes(SEL this)

View file

@ -325,25 +325,34 @@ enum {
@interface NSMutableString : NSString <NSMutableString>
@end
/*
* Information for NXConstantString
/**
* <p>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 -</p>
* <list>
* <item>a pointer to the class (this is the sole ivar of NSObject)</item>
* <item>a pointer to the 8-bit data</item>
* <item>the length of the string</item>
* </list>
* <p>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).</p>
* <p>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.</p>
* 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;

View file

@ -24,7 +24,7 @@
#include <config.h>
#include <Foundation/Foundation.h>
#include "GSUserDefaults.h"
#include "GSPrivate.h"
#ifndef HAVE_RINT
#include <math.h>

View file

@ -67,7 +67,6 @@
#include <Foundation/GSMime.h>
#include <string.h>
#include <ctype.h>
#include "GSUserDefaults.h"
static NSCharacterSet *specials = nil;

View file

@ -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 <rfm@gnu.org>
@ -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 <Foundation/NSUserDefaults.h>
/*
* 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_ */

View file

@ -48,6 +48,9 @@
#include <base/GSFormat.h>
#include <base/behavior.h>
#include <limits.h>
#include "GSPrivate.h"
/* memcpy(), strlen(), strcmp() are gcc builtin's */
#include <base/Unicode.h>
@ -3313,13 +3316,13 @@ transmute(ivars self, NSString *aString)
/*
* The NXConstantString class is used by the compiler for constant
/**
* <p>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.</p>
*/
@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;
}

View file

@ -43,7 +43,7 @@
#include <Foundation/NSMapTable.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSDebug.h>
#include "GSUserDefaults.h"
#include "GSPrivate.h"
@class NSArrayEnumerator;
@class NSArrayEnumeratorReverse;

View file

@ -35,11 +35,12 @@
#include <Foundation/NSString.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSException.h>
#include <Foundation/NSUserDefaults.h>
#include <base/behavior.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "GSUserDefaults.h"
#include "GSPrivate.h"
// Absolute Gregorian date for NSDate reference date Jan 01 2001
//

View file

@ -39,6 +39,7 @@
#include <Foundation/NSScanner.h>
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSPortCoder.h>
#include <Foundation/NSUserDefaults.h>
#include <base/preface.h>
#include <base/behavior.h>
#if HAVE_SYS_TIME_H
@ -47,7 +48,7 @@
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include "GSUserDefaults.h"
#include "GSPrivate.h"
/* The number of seconds between 1/1/2001 and 1/1/1970 = -978307200. */
/* This number comes from:

View file

@ -28,7 +28,7 @@
#include <Foundation/NSException.h>
#include <Foundation/NSDecimal.h>
#include <Foundation/NSDecimalNumber.h>
#include "GSUserDefaults.h"
#include "GSPrivate.h"
static NSDecimalNumberHandler *handler;

View file

@ -38,7 +38,7 @@
#include <Foundation/NSDebug.h>
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSValue.h>
#include "GSUserDefaults.h"
#include "GSPrivate.h"
@implementation NSDictionary

View file

@ -44,7 +44,7 @@
#include <unistd.h>
#endif
#include "GSUserDefaults.h"
#include "GSPrivate.h"
static void
_NSLog_standard_printf_handler (NSString* message)

View file

@ -146,7 +146,7 @@ GSSetVariable(id obj, int offset, unsigned int size, const void *data)
memcpy(((void*)obj) + offset, data, size);
}
/** <deprecated />
/** ## deprecated ##
*/
BOOL
GSInstanceVariableInfo(id obj, NSString *iVarName,
@ -157,7 +157,7 @@ GSInstanceVariableInfo(id obj, NSString *iVarName,
return GSFindInstanceVariable(obj, name, type, size, offset);
}
/** <deprecated />
/** ## deprecated ##
*/
BOOL
GSGetInstanceVariable(id obj, NSString *iVarName, void *data)
@ -174,7 +174,7 @@ GSGetInstanceVariable(id obj, NSString *iVarName, void *data)
return NO;
}
/** <deprecated />
/** ## deprecated ##
*/
BOOL
GSSetInstanceVariable(id obj, NSString *iVarName, const void *data)

View file

@ -31,11 +31,12 @@
#include <Foundation/NSScanner.h>
#include <Foundation/NSException.h>
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSUserDefaults.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <ctype.h> /* 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)

View file

@ -38,6 +38,8 @@
#include <Foundation/NSNotificationQueue.h>
#include <Foundation/NSObjCRuntime.h>
#include "GSPrivate.h"
@class GSDictionary;
@class GSMutableDictionary;
@class NSDataMalloc;

View file

@ -63,6 +63,7 @@
#include <Foundation/NSURL.h>
#include <Foundation/NSMapTable.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSDebug.h>
#include <base/GSFormat.h>
#include <limits.h>
@ -78,7 +79,7 @@
#include <base/Unicode.h>
#include "GSUserDefaults.h"
#include "GSPrivate.h"
@class GSString;
@class GSMutableString;

View file

@ -39,6 +39,8 @@
#include <Foundation/NSLock.h>
#include <Foundation/NSUserDefaults.h>
#include "GSPrivate.h"
#include <stdlib.h> // for getenv()
#if HAVE_UNISTD_H
#include <unistd.h> // for getlogin()

View file

@ -50,7 +50,7 @@
#include <Foundation/NSLock.h>
#include <base/GSLocale.h>
#include "GSUserDefaults.h"
#include "GSPrivate.h"
/* Wait for access */
#define _MAX_COUNT 5 /* Max 10 sec. */