From be5162cd2ba63ad0e92fb11770e73569d86e7c14 Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 9 Jan 2001 09:17:31 +0000 Subject: [PATCH] More tidyups git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8534 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 10 +++- Headers/gnustep/base/NSDictionary.h | 51 ++++++++---------- Source/GNUmakefile | 2 +- Source/GSAttributedString.m | 29 ++++++++++ Source/{NSGDictionary.m => GSDictionary.m} | 61 ++++++++++++++++------ Source/NSAttributedString.m | 4 +- Source/NSDictionary.m | 55 +++++++------------ Source/NSSerializer.m | 8 +-- Source/NSString.m | 4 +- 9 files changed, 133 insertions(+), 91 deletions(-) rename Source/{NSGDictionary.m => GSDictionary.m} (82%) diff --git a/ChangeLog b/ChangeLog index 8bd3cae72..6501560ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,19 @@ 2001-01-09 Richard Frith-Macdonald + General tidyups to simplify code and to make class names + consistent with the other libraries. * Headers/Foundation/NSGAttributedString.h: removed * Source/NSGAttributedString.m: renamed to GSAttributedString.m 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/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. + * Source/NSString.m: updates for class renaming. + * Source/NSSerializer.m: ditto 2001-01-08 Adam Fedor diff --git a/Headers/gnustep/base/NSDictionary.h b/Headers/gnustep/base/NSDictionary.h index 3606fab04..f0ad6dc29 100644 --- a/Headers/gnustep/base/NSDictionary.h +++ b/Headers/gnustep/base/NSDictionary.h @@ -29,17 +29,6 @@ @class NSArray, NSString, NSEnumerator; @interface NSDictionary : NSObject -- (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) dictionaryWithContentsOfFile: (NSString*)path; + (id) dictionaryWithDictionary: (NSDictionary*)aDict; @@ -49,27 +38,34 @@ forKeys: (id*)keys count: (unsigned)count; + (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) initWithDictionary: (NSDictionary*)otherDictionary; - (id) initWithDictionary: (NSDictionary*)otherDictionary copyItems: (BOOL)shouldCopy; - (id) initWithObjects: (NSArray*)objects forKeys: (NSArray*)keys; - (id) initWithObjectsAndKeys: (id)object, ...; - +- (id) initWithObjects: (id*)objects + forKeys: (id*)keys + count: (unsigned)count; // Primitive - (BOOL) isEqualToDictionary: (NSDictionary*)other; -- (NSArray*) allKeys; -- (NSArray*) allKeysForObject: (id)anObject; -- (NSArray*) allValues; +- (NSEnumerator*) keyEnumerator; // Primitive - (NSArray*) keysSortedByValueUsingSelector: (SEL)comp; +- (NSEnumerator*) objectEnumerator; // Primitive +- (id) objectForKey: (id)aKey; // Primitive - (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; /* Accessing file attributes is a catagory declared in NSFileManager.h*/ @@ -77,18 +73,15 @@ @end @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; -- (void) removeAllObjects; -- (void) removeObjectsForKeys: (NSArray*)keyArray; - (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; @end diff --git a/Source/GNUmakefile b/Source/GNUmakefile index bcc260cfd..99007b525 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -147,6 +147,7 @@ BASE_MFILES = \ GSArray.m \ GSAttributedString.m \ GSCountedSet.m \ +GSDictionary.m \ GSHTTPURLHandle.m \ GSMime.m \ GSSet.m \ @@ -183,7 +184,6 @@ NSFileHandle.m \ NSFileManager.m \ NSFormatter.m \ NSGeometry.m \ -NSGDictionary.m \ NSHashTable.m \ NSHost.m \ NSInvocation.m \ diff --git a/Source/GSAttributedString.m b/Source/GSAttributedString.m index 89e30180a..d20b81e30 100644 --- a/Source/GSAttributedString.m +++ b/Source/GSAttributedString.m @@ -829,3 +829,32 @@ SANITY(); } @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 + diff --git a/Source/NSGDictionary.m b/Source/GSDictionary.m similarity index 82% rename from Source/NSGDictionary.m rename to Source/GSDictionary.m index 51c59420c..3c117772a 100644 --- a/Source/NSGDictionary.m +++ b/Source/GSDictionary.m @@ -49,42 +49,41 @@ @class NSDictionaryNonCore; @class NSMutableDictionaryNonCore; -@interface NSGDictionary : NSDictionary +@interface GSDictionary : NSDictionary { @public GSIMapTable_t map; } @end -@interface NSGMutableDictionary : NSMutableDictionary +@interface GSMutableDictionary : NSMutableDictionary { @public GSIMapTable_t map; } @end -@interface NSGDictionaryKeyEnumerator : NSEnumerator +@interface GSDictionaryKeyEnumerator : NSEnumerator { - NSGDictionary *dictionary; + GSDictionary *dictionary; GSIMapEnumerator_t enumerator; } @end -@interface NSGDictionaryObjectEnumerator : NSGDictionaryKeyEnumerator +@interface GSDictionaryObjectEnumerator : GSDictionaryKeyEnumerator @end -@implementation NSGDictionary +@implementation GSDictionary static SEL nxtSel; static SEL objSel; + (void) initialize { - if (self == [NSGDictionary class]) + if (self == [GSDictionary class]) { nxtSel = @selector(nextObject); objSel = @selector(objectForKey:); - behavior_class_add_class(self, [NSDictionaryNonCore class]); } } @@ -244,13 +243,13 @@ static SEL objSel; - (NSEnumerator*) keyEnumerator { - return AUTORELEASE([[NSGDictionaryKeyEnumerator allocWithZone: + return AUTORELEASE([[GSDictionaryKeyEnumerator allocWithZone: NSDefaultMallocZone()] initWithDictionary: self]); } - (NSEnumerator*) objectEnumerator { - return AUTORELEASE([[NSGDictionaryObjectEnumerator allocWithZone: + return AUTORELEASE([[GSDictionaryObjectEnumerator allocWithZone: NSDefaultMallocZone()] initWithDictionary: self]); } @@ -270,14 +269,13 @@ static SEL objSel; @end -@implementation NSGMutableDictionary +@implementation GSMutableDictionary + (void) initialize { - if (self == [NSGMutableDictionary class]) + if (self == [GSMutableDictionary class]) { - behavior_class_add_class(self, [NSMutableDictionaryNonCore class]); - behavior_class_add_class(self, [NSGDictionary class]); + behavior_class_add_class(self, [GSDictionary class]); } } @@ -332,12 +330,12 @@ static SEL objSel; @end -@implementation NSGDictionaryKeyEnumerator +@implementation GSDictionaryKeyEnumerator - (id) initWithDictionary: (NSDictionary*)d { [super init]; - dictionary = (NSGDictionary*)RETAIN(d); + dictionary = (GSDictionary*)RETAIN(d); enumerator = GSIMapEnumeratorForMap(&dictionary->map); return self; } @@ -361,7 +359,7 @@ static SEL objSel; @end -@implementation NSGDictionaryObjectEnumerator +@implementation GSDictionaryObjectEnumerator - (id) nextObject { @@ -375,3 +373,32 @@ static SEL objSel; } @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 + diff --git a/Source/NSAttributedString.m b/Source/NSAttributedString.m index 1b4d49f36..7f7b3279f 100644 --- a/Source/NSAttributedString.m +++ b/Source/NSAttributedString.m @@ -55,7 +55,7 @@ @class GSAttributedString; @class GSMutableAttributedString; -@class NSGMutableDictionary; +@class GSMutableDictionary; static Class dictionaryClass = 0; static SEL eqSel; @@ -100,7 +100,7 @@ static Class GSMutableAttributedStringClass; = [NSMutableAttributedString class]; GSMutableAttributedStringClass = [GSMutableAttributedString class]; - dictionaryClass = [NSGMutableDictionary class]; + dictionaryClass = [GSMutableDictionary class]; eqSel = @selector(isEqual:); setSel = @selector(setAttributes:range:); diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m index 3a7ccec12..227ce50f3 100644 --- a/Source/NSDictionary.m +++ b/Source/NSDictionary.m @@ -36,21 +36,16 @@ #include #include -@interface NSDictionaryNonCore : NSDictionary -@end -@interface NSMutableDictionaryNonCore: NSMutableDictionary -@end - @implementation NSDictionary -@class NSGDictionary; -@class NSGMutableDictionary; +@class GSDictionary; +@class GSMutableDictionary; static Class NSArray_class; -static Class NSDictionary_abstract_class; -static Class NSMutableDictionary_abstract_class; -static Class NSDictionary_concrete_class; -static Class NSMutableDictionary_concrete_class; +static Class NSDictionaryClass; +static Class NSMutableDictionaryClass; +static Class GSDictionaryClass; +static Class GSMutableDictionaryClass; static SEL eqSel; static SEL nxtSel; @@ -63,12 +58,11 @@ static SEL appSel; { if (self == [NSDictionary class]) { - behavior_class_add_class (self, [NSDictionaryNonCore class]); NSArray_class = [NSArray class]; - NSDictionary_abstract_class = [NSDictionary class]; - NSMutableDictionary_abstract_class = [NSMutableDictionary class]; - NSDictionary_concrete_class = [NSGDictionary class]; - NSMutableDictionary_concrete_class = [NSGMutableDictionary class]; + NSDictionaryClass = [NSDictionary class]; + NSMutableDictionaryClass = [NSMutableDictionary class]; + GSDictionaryClass = [GSDictionary class]; + GSMutableDictionaryClass = [GSMutableDictionary class]; eqSel = @selector(isEqual:); nxtSel = @selector(nextObject); @@ -81,9 +75,9 @@ static SEL appSel; + (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 { @@ -131,13 +125,13 @@ static SEL appSel; - (id) mutableCopyWithZone: (NSZone*)z { - return [[NSMutableDictionary_concrete_class allocWithZone: z] + return [[GSMutableDictionaryClass allocWithZone: z] initWithDictionary: self]; } - (Class) classForCoder { - return NSDictionary_abstract_class; + return NSDictionaryClass; } - (void) encodeWithCoder: (NSCoder*)aCoder @@ -192,9 +186,6 @@ static SEL appSel; return self; } -@end - -@implementation NSDictionaryNonCore + (id) dictionary { @@ -431,7 +422,7 @@ static SEL appSel; } NS_ENDHANDLER RELEASE(myString); - if ([result isKindOfClass: NSDictionary_abstract_class]) + if ([result isKindOfClass: NSDictionaryClass]) { [self initWithDictionary: result]; return self; @@ -453,7 +444,7 @@ static SEL appSel; if (other == self) return YES; - if ([other isKindOfClass: NSDictionary_abstract_class]) + if ([other isKindOfClass: NSDictionaryClass]) return [self isEqualToDictionary: other]; return NO; @@ -904,16 +895,14 @@ static NSString *indentStrings[] = { { if (self == [NSMutableDictionary class]) { - behavior_class_add_class (self, [NSMutableDictionaryNonCore class]); - behavior_class_add_class (self, [NSDictionaryNonCore class]); } } + (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 { @@ -940,7 +929,7 @@ static NSString *indentStrings[] = { objects[i] = (*objImp)(self, objSel, key); objects[i] = [objects[i] copyWithZone: z]; } - newDictionary = [[NSDictionary_concrete_class allocWithZone: z] + newDictionary = [[GSDictionaryClass allocWithZone: z] initWithObjects: objects forKeys: keys count: count]; @@ -955,7 +944,7 @@ static NSString *indentStrings[] = { - (Class) classForCoder { - return NSMutableDictionary_abstract_class; + return NSMutableDictionaryClass; } /* This is the designated initializer */ @@ -975,10 +964,6 @@ static NSString *indentStrings[] = { [self subclassResponsibility: _cmd]; } -@end - -@implementation NSMutableDictionaryNonCore - + (id) dictionaryWithCapacity: (unsigned)numItems { return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] diff --git a/Source/NSSerializer.m b/Source/NSSerializer.m index f6b6c1ad4..ee29ca94b 100644 --- a/Source/NSSerializer.m +++ b/Source/NSSerializer.m @@ -35,8 +35,8 @@ #include #include -@class NSGDictionary; -@class NSGMutableDictionary; +@class GSDictionary; +@class GSMutableDictionary; @class NSDataMalloc; @class GSInlineArray; @class GSMutableArray; @@ -690,8 +690,8 @@ deserializeFromInfo(_NSDeserializerInfo* info) IACls = [GSInlineArray class]; MACls = [GSMutableArray class]; DCls = [NSDataMalloc class]; - IDCls = [NSGDictionary class]; - MDCls = [NSGMutableDictionary class]; + IDCls = [GSDictionary class]; + MDCls = [GSMutableDictionary class]; USCls = [GSUnicodeString class]; CSCls = [GSCString class]; csInitImp = [CSCls instanceMethodForSelector: csInitSel]; diff --git a/Source/NSString.m b/Source/NSString.m index 48e30ed3a..fdc29f662 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -77,7 +77,7 @@ @class GSMutableString; @class GSPlaceholderString; @class GSMutableArray; -@class NSGMutableDictionary; +@class GSMutableDictionary; /* @@ -4029,7 +4029,7 @@ setupPl() plAdd = (id (*)(id, SEL, id)) [plArray instanceMethodForSelector: @selector(addObject:)]; - plDictionary = [NSGMutableDictionary class]; + plDictionary = [GSMutableDictionary class]; plSet = (id (*)(id, SEL, id, id)) [plDictionary instanceMethodForSelector: @selector(setObject:forKey:)];