mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
Bugfix update
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2885 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8dde889542
commit
d987db52d2
6 changed files with 114 additions and 65 deletions
|
@ -111,6 +111,63 @@ static Class NSMutableDictionary_concrete_class;
|
|||
return nil;
|
||||
}
|
||||
|
||||
- copyWithZone: (NSZone*)z
|
||||
{
|
||||
/* a deep copy */
|
||||
unsigned count = [self count];
|
||||
id oldKeys[count];
|
||||
id newKeys[count];
|
||||
id oldObjects[count];
|
||||
id newObjects[count];
|
||||
id newDictionary;
|
||||
unsigned i;
|
||||
id key;
|
||||
NSEnumerator *enumerator = [self keyEnumerator];
|
||||
BOOL needCopy = [self isKindOfClass: [NSMutableDictionary class]];
|
||||
|
||||
if (NSShouldRetainWithZone(self, z) == NO)
|
||||
needCopy = YES;
|
||||
for (i = 0; (key = [enumerator nextObject]); i++)
|
||||
{
|
||||
oldKeys[i] = key;
|
||||
oldObjects[i] = [self objectForKey:key];
|
||||
newKeys[i] = [oldKeys[i] copyWithZone:z];
|
||||
newObjects[i] = [oldObjects[i] copyWithZone:z];
|
||||
if (oldKeys[i] != newKeys[i] || oldObjects[i] != newObjects[i])
|
||||
needCopy = YES;
|
||||
}
|
||||
if (needCopy)
|
||||
newDictionary = [[[[self class] _concreteClass] alloc]
|
||||
initWithObjects:newObjects
|
||||
forKeys:newKeys
|
||||
count:count];
|
||||
else
|
||||
newDictionary = [self retain];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
[newKeys[i] release];
|
||||
[newObjects[i] release];
|
||||
}
|
||||
return newDictionary;
|
||||
}
|
||||
|
||||
- mutableCopyWithZone: (NSZone*)z
|
||||
{
|
||||
/* a shallow copy */
|
||||
return [[[[[self class] _mutableConcreteClass] _mutableConcreteClass] alloc]
|
||||
initWithDictionary:self];
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return nil;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSDictionaryNonCore
|
||||
|
@ -203,6 +260,12 @@ static Class NSMutableDictionary_concrete_class;
|
|||
autorelease];
|
||||
}
|
||||
|
||||
+ dictionaryWithObject: (id)object forKey: (id)key
|
||||
{
|
||||
return [[[self alloc] initWithObjects: &object forKeys: &key count: 1]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
/* Override superclass's designated initializer */
|
||||
- init
|
||||
{
|
||||
|
@ -365,53 +428,6 @@ compareIt(id o1, id o2, void* context)
|
|||
return [[self description] writeToFile:path atomically:useAuxiliaryFile];
|
||||
}
|
||||
|
||||
- copyWithZone: (NSZone*)z
|
||||
{
|
||||
/* a deep copy */
|
||||
unsigned count = [self count];
|
||||
id oldKeys[count];
|
||||
id newKeys[count];
|
||||
id oldObjects[count];
|
||||
id newObjects[count];
|
||||
id newDictionary;
|
||||
unsigned i;
|
||||
id key;
|
||||
NSEnumerator *enumerator = [self keyEnumerator];
|
||||
BOOL needCopy = [self isKindOfClass: [NSMutableDictionary class]];
|
||||
|
||||
if (NSShouldRetainWithZone(self, z) == NO)
|
||||
needCopy = YES;
|
||||
for (i = 0; (key = [enumerator nextObject]); i++)
|
||||
{
|
||||
oldKeys[i] = key;
|
||||
oldObjects[i] = [self objectForKey:key];
|
||||
newKeys[i] = [oldKeys[i] copyWithZone:z];
|
||||
newObjects[i] = [oldObjects[i] copyWithZone:z];
|
||||
if (oldKeys[i] != newKeys[i] || oldObjects[i] != newObjects[i])
|
||||
needCopy = YES;
|
||||
}
|
||||
if (needCopy)
|
||||
newDictionary = [[[[self class] _concreteClass] alloc]
|
||||
initWithObjects:newObjects
|
||||
forKeys:newKeys
|
||||
count:count];
|
||||
else
|
||||
newDictionary = [self retain];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
[newKeys[i] release];
|
||||
[newObjects[i] release];
|
||||
}
|
||||
return newDictionary;
|
||||
}
|
||||
|
||||
- mutableCopyWithZone: (NSZone*)z
|
||||
{
|
||||
/* a shallow copy */
|
||||
return [[[[[self class] _mutableConcreteClass] _mutableConcreteClass] alloc]
|
||||
initWithDictionary:self];
|
||||
}
|
||||
|
||||
- (NSString*) description
|
||||
{
|
||||
return [self descriptionWithLocale: nil];
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
[super init];
|
||||
bag = d;
|
||||
[bag retain];
|
||||
enum_state = 0;
|
||||
enum_state = [bag newEnumState];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
[bag freeEnumState: &enum_state];
|
||||
[bag release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -74,12 +75,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
- initWithCapacity: (unsigned)numItems
|
||||
{
|
||||
return [self initWithType:@encode(id)
|
||||
capacity:numItems];
|
||||
}
|
||||
|
||||
- (NSEnumerator*) objectEnumerator
|
||||
{
|
||||
return [[[NSGCountedSetEnumerator alloc] initWithCountedSet:self]
|
||||
|
|
|
@ -314,14 +314,12 @@ static Class NSMutableSet_concrete_class;
|
|||
|
||||
- (NSString*) description
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
return 0;
|
||||
return [self descriptionWithLocale: nil];
|
||||
}
|
||||
|
||||
- (NSString*) descriptionWithLocale: (NSDictionary*)ld;
|
||||
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
return nil;
|
||||
return [[self allObjects] descriptionWithLocale: locale];
|
||||
}
|
||||
|
||||
- copyWithZone: (NSZone*)z
|
||||
|
@ -331,13 +329,28 @@ static Class NSMutableSet_concrete_class;
|
|||
id objects[count];
|
||||
id enumerator = [self objectEnumerator];
|
||||
id o;
|
||||
NSSet *newSet;
|
||||
int i;
|
||||
BOOL needCopy = [self isKindOfClass: [NSMutableSet class]];
|
||||
|
||||
if (NSShouldRetainWithZone(self, z) == NO)
|
||||
needCopy = YES;
|
||||
|
||||
for (i = 0; (o = [enumerator nextObject]); i++)
|
||||
objects[i] = [o copyWithZone:z];
|
||||
return [[[[self class] _concreteClass] alloc]
|
||||
{
|
||||
objects[i] = [o copyWithZone:z];
|
||||
if (objects[i] != o)
|
||||
needCopy = YES;
|
||||
}
|
||||
if (needCopy)
|
||||
newSet = [[[[self class] _concreteClass] alloc]
|
||||
initWithObjects:objects
|
||||
count:count];
|
||||
else
|
||||
newSet = [self retain];
|
||||
for (i = 0; i < count; i++)
|
||||
[objects[i] release];
|
||||
return newSet;
|
||||
}
|
||||
|
||||
- mutableCopyWithZone: (NSZone*)z
|
||||
|
@ -347,6 +360,17 @@ static Class NSMutableSet_concrete_class;
|
|||
initWithSet:self];
|
||||
}
|
||||
|
||||
- initWithCoder: aCoder
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: aCoder
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSMutableSet
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue