mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Fix NSDictionary and NSMutableDictionary implementation.
NSCharacterSet searches in appropriate places for resources. NSBundle no longer supports GNUSTEP_LIBRARY_PATH variable. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2519 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
04e12e7ff5
commit
a02a4e9e88
19 changed files with 383 additions and 152 deletions
|
@ -30,6 +30,11 @@
|
|||
#include <gnustep/base/NSException.h>
|
||||
#include <assert.h>
|
||||
|
||||
@interface NSDictionaryNonCore : NSDictionary
|
||||
@end
|
||||
@interface NSMutableDictionaryNonCore: NSMutableDictionary
|
||||
@end
|
||||
|
||||
@implementation NSDictionary
|
||||
|
||||
static Class NSDictionary_concrete_class;
|
||||
|
@ -57,8 +62,12 @@ static Class NSMutableDictionary_concrete_class;
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
NSDictionary_concrete_class = [NSGDictionary class];
|
||||
NSMutableDictionary_concrete_class = [NSGMutableDictionary class];
|
||||
if (self == [NSDictionary class])
|
||||
{
|
||||
NSDictionary_concrete_class = [NSGDictionary class];
|
||||
NSMutableDictionary_concrete_class = [NSGMutableDictionary class];
|
||||
behavior_class_add_class (self, [NSDictionaryNonCore class]);
|
||||
}
|
||||
}
|
||||
|
||||
+ allocWithZone: (NSZone*)z
|
||||
|
@ -66,6 +75,43 @@ static Class NSMutableDictionary_concrete_class;
|
|||
return NSAllocateObject([self _concreteClass], 0, z);
|
||||
}
|
||||
|
||||
/* This is the designated initializer */
|
||||
- initWithObjects: (id*)objects
|
||||
forKeys: (NSObject**)keys
|
||||
count: (unsigned)count
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (unsigned) count
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return 0;
|
||||
}
|
||||
|
||||
- objectForKey: (NSObject*)aKey
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (NSEnumerator*) keyEnumerator
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSEnumerator*) objectEnumerator
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSDictionaryNonCore
|
||||
|
||||
+ dictionary
|
||||
{
|
||||
return [[[self alloc] init]
|
||||
|
@ -149,15 +195,6 @@ static Class NSMutableDictionary_concrete_class;
|
|||
autorelease];
|
||||
}
|
||||
|
||||
/* This is the designated initializer */
|
||||
- initWithObjects: (id*)objects
|
||||
forKeys: (NSObject**)keys
|
||||
count: (unsigned)count
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Override superclass's designated initializer */
|
||||
- init
|
||||
{
|
||||
|
@ -203,24 +240,6 @@ static Class NSMutableDictionary_concrete_class;
|
|||
autorelease];
|
||||
}
|
||||
|
||||
- (unsigned) count
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return 0;
|
||||
}
|
||||
|
||||
- objectForKey: (NSObject*)aKey
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (NSEnumerator*) keyEnumerator
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL) isEqual: other
|
||||
{
|
||||
if ([other isKindOfClass:[NSDictionary class]])
|
||||
|
@ -235,25 +254,20 @@ static Class NSMutableDictionary_concrete_class;
|
|||
{
|
||||
id k, e = [self keyEnumerator];
|
||||
while ((k = [e nextObject]))
|
||||
{
|
||||
id o1 = [self objectForKey: k];
|
||||
id o2 = [other objectForKey: k];
|
||||
if (![o1 isEqual: o2])
|
||||
return NO;
|
||||
/*
|
||||
if (![[self objectForKey:k] isEqual:[other objectForKey:k]])
|
||||
return NO;
|
||||
return NO; */
|
||||
}
|
||||
}
|
||||
/* xxx Recheck this. */
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSString*) description
|
||||
{
|
||||
/* This method is overridden by [Dictionary -description] */
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString*) descriptionWithIndent: (unsigned)level
|
||||
{
|
||||
/* This method is overridden by [Dictionary -descriptionWithIndent:] */
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray*) allKeys
|
||||
{
|
||||
id e = [self keyEnumerator];
|
||||
|
@ -305,12 +319,6 @@ static Class NSMutableDictionary_concrete_class;
|
|||
return 0;
|
||||
}
|
||||
|
||||
- (NSEnumerator*) objectEnumerator
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- copyWithZone: (NSZone*)z
|
||||
{
|
||||
/* a deep copy */
|
||||
|
@ -343,17 +351,20 @@ static Class NSMutableDictionary_concrete_class;
|
|||
|
||||
@implementation NSMutableDictionary
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self == [NSMutableDictionary class])
|
||||
{
|
||||
behavior_class_add_class (self, [NSMutableDictionaryNonCore class]);
|
||||
behavior_class_add_class (self, [NSDictionaryNonCore class]);
|
||||
}
|
||||
}
|
||||
|
||||
+ allocWithZone: (NSZone*)z
|
||||
{
|
||||
return NSAllocateObject([self _mutableConcreteClass], 0, z);
|
||||
}
|
||||
|
||||
+ dictionaryWithCapacity: (unsigned)numItems
|
||||
{
|
||||
return [[[self alloc] initWithCapacity:numItems]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
/* This is the designated initializer */
|
||||
- initWithCapacity: (unsigned)numItems
|
||||
{
|
||||
|
@ -361,6 +372,26 @@ static Class NSMutableDictionary_concrete_class;
|
|||
return 0;
|
||||
}
|
||||
|
||||
- (void) setObject:anObject forKey:(NSObject *)aKey
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
}
|
||||
|
||||
- (void) removeObjectForKey:(NSObject *)aKey
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSMutableDictionaryNonCore
|
||||
|
||||
+ dictionaryWithCapacity: (unsigned)numItems
|
||||
{
|
||||
return [[[self alloc] initWithCapacity:numItems]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
/* Override superclass's designated initializer */
|
||||
- initWithObjects: (id*)objects
|
||||
forKeys: (NSObject**)keys
|
||||
|
@ -372,16 +403,6 @@ static Class NSMutableDictionary_concrete_class;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) setObject:anObject forKey:(NSObject *)aKey
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
}
|
||||
|
||||
- (void) removeObjectForKey:(NSObject *)aKey
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
}
|
||||
|
||||
- (void) removeAllObjects
|
||||
{
|
||||
id k, e = [self keyEnumerator];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue