More tidyups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8534 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2001-01-09 09:17:31 +00:00
parent 5d3f3cc453
commit be5162cd2b
9 changed files with 133 additions and 91 deletions

View file

@ -1,11 +1,19 @@
2001-01-09 Richard Frith-Macdonald <rfm@gnu.org> 2001-01-09 Richard Frith-Macdonald <rfm@gnu.org>
General tidyups to simplify code and to make class names
consistent with the other libraries.
* Headers/Foundation/NSGAttributedString.h: removed * Headers/Foundation/NSGAttributedString.h: removed
* Source/NSGAttributedString.m: renamed to GSAttributedString.m * Source/NSGAttributedString.m: renamed to GSAttributedString.m
concrete classes renamed for consistency with other gstep libs. concrete classes renamed for consistency with other gstep libs.
* Source/NSGDictionary.m: renamed to GSDictionary.m
concrete classes renamed for consistency with other gstep libs.
* Source/NSAttributedString.m: classes renamed * Source/NSAttributedString.m: classes renamed
* Source/GNUmakefile: replace NSGAttrinbutedString with GS. * Source/NSDictionary.m: classes renamed
* Source/GNUmakefile: replace NSGAttrinbutedString with and
NSGDictionary with GS prefixed classes.
Don't try to install old header. Don't try to install old header.
* Source/NSString.m: updates for class renaming.
* Source/NSSerializer.m: ditto
2001-01-08 Adam Fedor <fedor@gnu.org> 2001-01-08 Adam Fedor <fedor@gnu.org>

View file

@ -29,17 +29,6 @@
@class NSArray, NSString, NSEnumerator; @class NSArray, NSString, NSEnumerator;
@interface NSDictionary : NSObject <NSCoding, NSCopying, NSMutableCopying> @interface NSDictionary : NSObject <NSCoding, NSCopying, NSMutableCopying>
- (id) initWithObjects: (id*)objects
forKeys: (id*)keys
count: (unsigned)count;
- (unsigned) count;
- (id) objectForKey: (id)aKey;
- (NSEnumerator*) keyEnumerator;
- (NSEnumerator*) objectEnumerator;
@end
@interface NSDictionary (NonCore)
+ (id) dictionary; + (id) dictionary;
+ (id) dictionaryWithContentsOfFile: (NSString*)path; + (id) dictionaryWithContentsOfFile: (NSString*)path;
+ (id) dictionaryWithDictionary: (NSDictionary*)aDict; + (id) dictionaryWithDictionary: (NSDictionary*)aDict;
@ -49,27 +38,34 @@
forKeys: (id*)keys forKeys: (id*)keys
count: (unsigned)count; count: (unsigned)count;
+ (id) dictionaryWithObjectsAndKeys: (id)object, ...; + (id) dictionaryWithObjectsAndKeys: (id)object, ...;
- (NSArray*) allKeys;
- (NSArray*) allKeysForObject: (id)anObject;
- (NSArray*) allValues;
- (unsigned) count; // Primitive
- (NSString*) description;
- (NSString*) descriptionInStringsFileFormat;
- (NSString*) descriptionWithLocale: (NSDictionary*)locale;
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
indent: (unsigned int)level;
- (id) initWithContentsOfFile: (NSString*)path; - (id) initWithContentsOfFile: (NSString*)path;
- (id) initWithDictionary: (NSDictionary*)otherDictionary; - (id) initWithDictionary: (NSDictionary*)otherDictionary;
- (id) initWithDictionary: (NSDictionary*)otherDictionary - (id) initWithDictionary: (NSDictionary*)otherDictionary
copyItems: (BOOL)shouldCopy; copyItems: (BOOL)shouldCopy;
- (id) initWithObjects: (NSArray*)objects forKeys: (NSArray*)keys; - (id) initWithObjects: (NSArray*)objects forKeys: (NSArray*)keys;
- (id) initWithObjectsAndKeys: (id)object, ...; - (id) initWithObjectsAndKeys: (id)object, ...;
- (id) initWithObjects: (id*)objects
forKeys: (id*)keys
count: (unsigned)count; // Primitive
- (BOOL) isEqualToDictionary: (NSDictionary*)other; - (BOOL) isEqualToDictionary: (NSDictionary*)other;
- (NSArray*) allKeys; - (NSEnumerator*) keyEnumerator; // Primitive
- (NSArray*) allKeysForObject: (id)anObject;
- (NSArray*) allValues;
- (NSArray*) keysSortedByValueUsingSelector: (SEL)comp; - (NSArray*) keysSortedByValueUsingSelector: (SEL)comp;
- (NSEnumerator*) objectEnumerator; // Primitive
- (id) objectForKey: (id)aKey; // Primitive
- (NSArray*) objectsForKeys: (NSArray*)keys notFoundMarker: (id)anObject; - (NSArray*) objectsForKeys: (NSArray*)keys notFoundMarker: (id)anObject;
- (NSString*) description;
- (NSString*) descriptionInStringsFileFormat;
- (NSString*) descriptionWithLocale: (NSDictionary*)locale;
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
indent: (unsigned int)level;
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile; - (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile;
/* Accessing file attributes is a catagory declared in NSFileManager.h*/ /* Accessing file attributes is a catagory declared in NSFileManager.h*/
@ -77,18 +73,15 @@
@end @end
@interface NSMutableDictionary: NSDictionary @interface NSMutableDictionary: NSDictionary
- (id) initWithCapacity: (unsigned)numItems;
- (void) setObject: (id)anObject forKey: (id)aKey;
- (void) removeObjectForKey: (id)aKey;
@end
@interface NSMutableDictionary (NonCore)
+ (id) dictionaryWithCapacity: (unsigned)numItems; + (id) dictionaryWithCapacity: (unsigned)numItems;
- (void) removeAllObjects;
- (void) removeObjectsForKeys: (NSArray*)keyArray;
- (void) addEntriesFromDictionary: (NSDictionary*)otherDictionary; - (void) addEntriesFromDictionary: (NSDictionary*)otherDictionary;
- (id) initWithCapacity: (unsigned)numItems; // Primitive
- (void) removeAllObjects;
- (void) removeObjectForKey: (id)aKey; // Primitive
- (void) removeObjectsForKeys: (NSArray*)keyArray;
- (void) setObject: (id)anObject forKey: (id)aKey; // Primitive
- (void) setDictionary: (NSDictionary*)otherDictionary; - (void) setDictionary: (NSDictionary*)otherDictionary;
@end @end

View file

@ -147,6 +147,7 @@ BASE_MFILES = \
GSArray.m \ GSArray.m \
GSAttributedString.m \ GSAttributedString.m \
GSCountedSet.m \ GSCountedSet.m \
GSDictionary.m \
GSHTTPURLHandle.m \ GSHTTPURLHandle.m \
GSMime.m \ GSMime.m \
GSSet.m \ GSSet.m \
@ -183,7 +184,6 @@ NSFileHandle.m \
NSFileManager.m \ NSFileManager.m \
NSFormatter.m \ NSFormatter.m \
NSGeometry.m \ NSGeometry.m \
NSGDictionary.m \
NSHashTable.m \ NSHashTable.m \
NSHost.m \ NSHost.m \
NSInvocation.m \ NSInvocation.m \

View file

@ -829,3 +829,32 @@ SANITY();
} }
@end @end
@interface NSGAttributedString : NSAttributedString
@end
@implementation NSGAttributedString
- (id) initWithCoder: (NSCoder*)aCoder
{
NSLog(@"Warning - decoding archive containing obsolete %@ object - please delete/replace this archive", NSStringFromClass([self class]));
RELEASE(self);
self = (id)NSAllocateObject([GSAttributedString class], 0, NSDefaultMallocZone());
self = [self initWithCoder: aCoder];
return self;
}
@end
@interface NSGMutableAttributedString : NSMutableAttributedString
@end
@implementation NSGMutableAttributedString
- (id) initWithCoder: (NSCoder*)aCoder
{
NSLog(@"Warning - decoding archive containing obsolete %@ object - please delete/replace this archive", NSStringFromClass([self class]));
RELEASE(self);
self = (id)NSAllocateObject([GSMutableAttributedString class], 0, NSDefaultMallocZone());
self = [self initWithCoder: aCoder];
return self;
}
@end

View file

@ -49,42 +49,41 @@
@class NSDictionaryNonCore; @class NSDictionaryNonCore;
@class NSMutableDictionaryNonCore; @class NSMutableDictionaryNonCore;
@interface NSGDictionary : NSDictionary @interface GSDictionary : NSDictionary
{ {
@public @public
GSIMapTable_t map; GSIMapTable_t map;
} }
@end @end
@interface NSGMutableDictionary : NSMutableDictionary @interface GSMutableDictionary : NSMutableDictionary
{ {
@public @public
GSIMapTable_t map; GSIMapTable_t map;
} }
@end @end
@interface NSGDictionaryKeyEnumerator : NSEnumerator @interface GSDictionaryKeyEnumerator : NSEnumerator
{ {
NSGDictionary *dictionary; GSDictionary *dictionary;
GSIMapEnumerator_t enumerator; GSIMapEnumerator_t enumerator;
} }
@end @end
@interface NSGDictionaryObjectEnumerator : NSGDictionaryKeyEnumerator @interface GSDictionaryObjectEnumerator : GSDictionaryKeyEnumerator
@end @end
@implementation NSGDictionary @implementation GSDictionary
static SEL nxtSel; static SEL nxtSel;
static SEL objSel; static SEL objSel;
+ (void) initialize + (void) initialize
{ {
if (self == [NSGDictionary class]) if (self == [GSDictionary class])
{ {
nxtSel = @selector(nextObject); nxtSel = @selector(nextObject);
objSel = @selector(objectForKey:); objSel = @selector(objectForKey:);
behavior_class_add_class(self, [NSDictionaryNonCore class]);
} }
} }
@ -244,13 +243,13 @@ static SEL objSel;
- (NSEnumerator*) keyEnumerator - (NSEnumerator*) keyEnumerator
{ {
return AUTORELEASE([[NSGDictionaryKeyEnumerator allocWithZone: return AUTORELEASE([[GSDictionaryKeyEnumerator allocWithZone:
NSDefaultMallocZone()] initWithDictionary: self]); NSDefaultMallocZone()] initWithDictionary: self]);
} }
- (NSEnumerator*) objectEnumerator - (NSEnumerator*) objectEnumerator
{ {
return AUTORELEASE([[NSGDictionaryObjectEnumerator allocWithZone: return AUTORELEASE([[GSDictionaryObjectEnumerator allocWithZone:
NSDefaultMallocZone()] initWithDictionary: self]); NSDefaultMallocZone()] initWithDictionary: self]);
} }
@ -270,14 +269,13 @@ static SEL objSel;
@end @end
@implementation NSGMutableDictionary @implementation GSMutableDictionary
+ (void) initialize + (void) initialize
{ {
if (self == [NSGMutableDictionary class]) if (self == [GSMutableDictionary class])
{ {
behavior_class_add_class(self, [NSMutableDictionaryNonCore class]); behavior_class_add_class(self, [GSDictionary class]);
behavior_class_add_class(self, [NSGDictionary class]);
} }
} }
@ -332,12 +330,12 @@ static SEL objSel;
@end @end
@implementation NSGDictionaryKeyEnumerator @implementation GSDictionaryKeyEnumerator
- (id) initWithDictionary: (NSDictionary*)d - (id) initWithDictionary: (NSDictionary*)d
{ {
[super init]; [super init];
dictionary = (NSGDictionary*)RETAIN(d); dictionary = (GSDictionary*)RETAIN(d);
enumerator = GSIMapEnumeratorForMap(&dictionary->map); enumerator = GSIMapEnumeratorForMap(&dictionary->map);
return self; return self;
} }
@ -361,7 +359,7 @@ static SEL objSel;
@end @end
@implementation NSGDictionaryObjectEnumerator @implementation GSDictionaryObjectEnumerator
- (id) nextObject - (id) nextObject
{ {
@ -375,3 +373,32 @@ static SEL objSel;
} }
@end @end
@interface NSGDictionary : NSDictionary
@end
@implementation NSGDictionary
- (id) initWithCoder: (NSCoder*)aCoder
{
NSLog(@"Warning - decoding archive containing obsolete %@ object - please delete/replace this archive", NSStringFromClass([self class]));
RELEASE(self);
self = (id)NSAllocateObject([GSDictionary class], 0, NSDefaultMallocZone());
self = [self initWithCoder: aCoder];
return self;
}
@end
@interface NSGMutableDictionary : NSMutableDictionary
@end
@implementation NSGMutableDictionary
- (id) initWithCoder: (NSCoder*)aCoder
{
NSLog(@"Warning - decoding archive containing obsolete %@ object - please delete/replace this archive", NSStringFromClass([self class]));
RELEASE(self);
self = (id)NSAllocateObject([GSMutableDictionary class], 0, NSDefaultMallocZone());
self = [self initWithCoder: aCoder];
return self;
}
@end

View file

@ -55,7 +55,7 @@
@class GSAttributedString; @class GSAttributedString;
@class GSMutableAttributedString; @class GSMutableAttributedString;
@class NSGMutableDictionary; @class GSMutableDictionary;
static Class dictionaryClass = 0; static Class dictionaryClass = 0;
static SEL eqSel; static SEL eqSel;
@ -100,7 +100,7 @@ static Class GSMutableAttributedStringClass;
= [NSMutableAttributedString class]; = [NSMutableAttributedString class];
GSMutableAttributedStringClass GSMutableAttributedStringClass
= [GSMutableAttributedString class]; = [GSMutableAttributedString class];
dictionaryClass = [NSGMutableDictionary class]; dictionaryClass = [GSMutableDictionary class];
eqSel = @selector(isEqual:); eqSel = @selector(isEqual:);
setSel = @selector(setAttributes:range:); setSel = @selector(setAttributes:range:);

View file

@ -36,21 +36,16 @@
#include <Foundation/NSDebug.h> #include <Foundation/NSDebug.h>
#include <Foundation/NSObjCRuntime.h> #include <Foundation/NSObjCRuntime.h>
@interface NSDictionaryNonCore : NSDictionary
@end
@interface NSMutableDictionaryNonCore: NSMutableDictionary
@end
@implementation NSDictionary @implementation NSDictionary
@class NSGDictionary; @class GSDictionary;
@class NSGMutableDictionary; @class GSMutableDictionary;
static Class NSArray_class; static Class NSArray_class;
static Class NSDictionary_abstract_class; static Class NSDictionaryClass;
static Class NSMutableDictionary_abstract_class; static Class NSMutableDictionaryClass;
static Class NSDictionary_concrete_class; static Class GSDictionaryClass;
static Class NSMutableDictionary_concrete_class; static Class GSMutableDictionaryClass;
static SEL eqSel; static SEL eqSel;
static SEL nxtSel; static SEL nxtSel;
@ -63,12 +58,11 @@ static SEL appSel;
{ {
if (self == [NSDictionary class]) if (self == [NSDictionary class])
{ {
behavior_class_add_class (self, [NSDictionaryNonCore class]);
NSArray_class = [NSArray class]; NSArray_class = [NSArray class];
NSDictionary_abstract_class = [NSDictionary class]; NSDictionaryClass = [NSDictionary class];
NSMutableDictionary_abstract_class = [NSMutableDictionary class]; NSMutableDictionaryClass = [NSMutableDictionary class];
NSDictionary_concrete_class = [NSGDictionary class]; GSDictionaryClass = [GSDictionary class];
NSMutableDictionary_concrete_class = [NSGMutableDictionary class]; GSMutableDictionaryClass = [GSMutableDictionary class];
eqSel = @selector(isEqual:); eqSel = @selector(isEqual:);
nxtSel = @selector(nextObject); nxtSel = @selector(nextObject);
@ -81,9 +75,9 @@ static SEL appSel;
+ (id) allocWithZone: (NSZone*)z + (id) allocWithZone: (NSZone*)z
{ {
if (self == NSDictionary_abstract_class) if (self == NSDictionaryClass)
{ {
return NSAllocateObject(NSDictionary_concrete_class, 0, z); return NSAllocateObject(GSDictionaryClass, 0, z);
} }
else else
{ {
@ -131,13 +125,13 @@ static SEL appSel;
- (id) mutableCopyWithZone: (NSZone*)z - (id) mutableCopyWithZone: (NSZone*)z
{ {
return [[NSMutableDictionary_concrete_class allocWithZone: z] return [[GSMutableDictionaryClass allocWithZone: z]
initWithDictionary: self]; initWithDictionary: self];
} }
- (Class) classForCoder - (Class) classForCoder
{ {
return NSDictionary_abstract_class; return NSDictionaryClass;
} }
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
@ -192,9 +186,6 @@ static SEL appSel;
return self; return self;
} }
@end
@implementation NSDictionaryNonCore
+ (id) dictionary + (id) dictionary
{ {
@ -431,7 +422,7 @@ static SEL appSel;
} }
NS_ENDHANDLER NS_ENDHANDLER
RELEASE(myString); RELEASE(myString);
if ([result isKindOfClass: NSDictionary_abstract_class]) if ([result isKindOfClass: NSDictionaryClass])
{ {
[self initWithDictionary: result]; [self initWithDictionary: result];
return self; return self;
@ -453,7 +444,7 @@ static SEL appSel;
if (other == self) if (other == self)
return YES; return YES;
if ([other isKindOfClass: NSDictionary_abstract_class]) if ([other isKindOfClass: NSDictionaryClass])
return [self isEqualToDictionary: other]; return [self isEqualToDictionary: other];
return NO; return NO;
@ -904,16 +895,14 @@ static NSString *indentStrings[] = {
{ {
if (self == [NSMutableDictionary class]) if (self == [NSMutableDictionary class])
{ {
behavior_class_add_class (self, [NSMutableDictionaryNonCore class]);
behavior_class_add_class (self, [NSDictionaryNonCore class]);
} }
} }
+ (id) allocWithZone: (NSZone*)z + (id) allocWithZone: (NSZone*)z
{ {
if (self == NSMutableDictionary_abstract_class) if (self == NSMutableDictionaryClass)
{ {
return NSAllocateObject(NSMutableDictionary_concrete_class, 0, z); return NSAllocateObject(GSMutableDictionaryClass, 0, z);
} }
else else
{ {
@ -940,7 +929,7 @@ static NSString *indentStrings[] = {
objects[i] = (*objImp)(self, objSel, key); objects[i] = (*objImp)(self, objSel, key);
objects[i] = [objects[i] copyWithZone: z]; objects[i] = [objects[i] copyWithZone: z];
} }
newDictionary = [[NSDictionary_concrete_class allocWithZone: z] newDictionary = [[GSDictionaryClass allocWithZone: z]
initWithObjects: objects initWithObjects: objects
forKeys: keys forKeys: keys
count: count]; count: count];
@ -955,7 +944,7 @@ static NSString *indentStrings[] = {
- (Class) classForCoder - (Class) classForCoder
{ {
return NSMutableDictionary_abstract_class; return NSMutableDictionaryClass;
} }
/* This is the designated initializer */ /* This is the designated initializer */
@ -975,10 +964,6 @@ static NSString *indentStrings[] = {
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
} }
@end
@implementation NSMutableDictionaryNonCore
+ (id) dictionaryWithCapacity: (unsigned)numItems + (id) dictionaryWithCapacity: (unsigned)numItems
{ {
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]

View file

@ -35,8 +35,8 @@
#include <Foundation/NSNotificationQueue.h> #include <Foundation/NSNotificationQueue.h>
#include <Foundation/NSObjCRuntime.h> #include <Foundation/NSObjCRuntime.h>
@class NSGDictionary; @class GSDictionary;
@class NSGMutableDictionary; @class GSMutableDictionary;
@class NSDataMalloc; @class NSDataMalloc;
@class GSInlineArray; @class GSInlineArray;
@class GSMutableArray; @class GSMutableArray;
@ -690,8 +690,8 @@ deserializeFromInfo(_NSDeserializerInfo* info)
IACls = [GSInlineArray class]; IACls = [GSInlineArray class];
MACls = [GSMutableArray class]; MACls = [GSMutableArray class];
DCls = [NSDataMalloc class]; DCls = [NSDataMalloc class];
IDCls = [NSGDictionary class]; IDCls = [GSDictionary class];
MDCls = [NSGMutableDictionary class]; MDCls = [GSMutableDictionary class];
USCls = [GSUnicodeString class]; USCls = [GSUnicodeString class];
CSCls = [GSCString class]; CSCls = [GSCString class];
csInitImp = [CSCls instanceMethodForSelector: csInitSel]; csInitImp = [CSCls instanceMethodForSelector: csInitSel];

View file

@ -77,7 +77,7 @@
@class GSMutableString; @class GSMutableString;
@class GSPlaceholderString; @class GSPlaceholderString;
@class GSMutableArray; @class GSMutableArray;
@class NSGMutableDictionary; @class GSMutableDictionary;
/* /*
@ -4029,7 +4029,7 @@ setupPl()
plAdd = (id (*)(id, SEL, id)) plAdd = (id (*)(id, SEL, id))
[plArray instanceMethodForSelector: @selector(addObject:)]; [plArray instanceMethodForSelector: @selector(addObject:)];
plDictionary = [NSGMutableDictionary class]; plDictionary = [GSMutableDictionary class];
plSet = (id (*)(id, SEL, id, id)) plSet = (id (*)(id, SEL, id, id))
[plDictionary instanceMethodForSelector: @selector(setObject:forKey:)]; [plDictionary instanceMethodForSelector: @selector(setObject:forKey:)];