tidy a little

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34981 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2012-03-22 20:58:27 +00:00
parent d2eaeafb2a
commit c86e143298
2 changed files with 94 additions and 80 deletions

View file

@ -59,11 +59,23 @@ extern "C" {
- (NSString*) descriptionWithLocale: (id)locale
indent: (NSUInteger)level;
#if OS_API_VERSION(100600, GS_API_LATEST)
DEFINE_BLOCK_TYPE(GSKeysAndObjectsEnumeratorBlock, void, id, id, BOOL*);
- (void) enumerateKeysAndObjectsUsingBlock:
(GSKeysAndObjectsEnumeratorBlock)aBlock;
- (void) enumerateKeysAndObjectsWithOptions: (NSEnumerationOptions)opts
usingBlock: (GSKeysAndObjectsEnumeratorBlock)aBlock;
#endif
- (void) getObjects: (__unsafe_unretained id[])objects
andKeys: (__unsafe_unretained id[])keys;
- (id) init;
- (id) initWithContentsOfFile: (NSString*)path;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (id) initWithContentsOfURL: (NSURL*)aURL;
#endif
- (id) initWithDictionary: (NSDictionary*)otherDictionary;
- (id) initWithDictionary: (NSDictionary*)other copyItems: (BOOL)shouldCopy;
- (id) initWithObjects: (NSArray*)objects forKeys: (NSArray*)keys;
@ -74,30 +86,30 @@ extern "C" {
- (BOOL) isEqualToDictionary: (NSDictionary*)other;
- (NSEnumerator*) keyEnumerator; // Primitive
#if OS_API_VERSION(100600, GS_API_LATEST)
DEFINE_BLOCK_TYPE(GSKeysAndObjectsPredicateBlock, BOOL, id, id, BOOL*);
- (NSSet*) keysOfEntriesPassingTest: (GSKeysAndObjectsPredicateBlock)aPredicate;
- (NSSet*) keysOfEntriesWithOptions: (NSEnumerationOptions)opts
passingTest: (GSKeysAndObjectsPredicateBlock)aPredicate;
#endif
- (NSArray*) keysSortedByValueUsingSelector: (SEL)comp;
- (NSEnumerator*) objectEnumerator; // Primitive
- (id) objectForKey: (id)aKey; // Primitive
- (NSArray*) objectsForKeys: (NSArray*)keys notFoundMarker: (id)marker;
- (void)getObjects: (__unsafe_unretained id[])objects
andKeys: (__unsafe_unretained id[])keys;
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (id) valueForKey: (NSString*)key;
#endif
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)useAuxiliaryFile;
#endif
#if OS_API_VERSION(100600, GS_API_LATEST)
DEFINE_BLOCK_TYPE(GSKeysAndObjectsEnumeratorBlock, void, id, id, BOOL*);
DEFINE_BLOCK_TYPE(GSKeysAndObjectsPredicateBlock, BOOL, id, id, BOOL*);
- (void)enumerateKeysAndObjectsWithOptions: (NSEnumerationOptions)opts
usingBlock: (GSKeysAndObjectsEnumeratorBlock)aBlock;
- (void)enumerateKeysAndObjectsUsingBlock: (GSKeysAndObjectsEnumeratorBlock)aBlock;
- (NSSet*)keysOfEntriesWithOptions: (NSEnumerationOptions)opts
passingTest: (GSKeysAndObjectsPredicateBlock)aPredicate;
- (NSSet*)keysOfEntriesPassingTest: (GSKeysAndObjectsPredicateBlock)aPredicate;
#endif
@end
@interface NSMutableDictionary: NSDictionary
@ -112,9 +124,9 @@ DEFINE_BLOCK_TYPE(GSKeysAndObjectsPredicateBlock, BOOL, id, id, BOOL*);
- (void) setObject: (id)anObject forKey: (id)aKey; // Primitive
- (void) setDictionary: (NSDictionary*)otherDictionary;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (void) setValue: (id)value forKey: (NSString*)key;
- (void) takeStoredValue: (id)value forKey: (NSString*)key;
- (void) takeValue: (id)value forKey: (NSString*)key;
- (void) setValue: (id)value forKey: (NSString*)key;
#endif
@end

View file

@ -128,6 +128,61 @@ static SEL appSel;
}
}
/**
* Returns a new copy of the receiver.<br />
* The default abstract implementation of a copy is to use the
* -initWithDictionary:copyItems: method with the flag set to YES.<br />
* Immutable subclasses generally simply retain and return the receiver.
*/
- (id) copyWithZone: (NSZone*)z
{
NSDictionary *copy = [NSDictionaryClass allocWithZone: z];
return [copy initWithDictionary: self copyItems: NO];
}
/**
* Returns an unsigned integer which is the number of elements
* stored in the dictionary.
*/
- (NSUInteger) count
{
[self subclassResponsibility: _cmd];
return 0;
}
- (void) enumerateKeysAndObjectsUsingBlock:
(GSKeysAndObjectsEnumeratorBlock)aBlock
{
[self enumerateKeysAndObjectsWithOptions: 0
usingBlock: aBlock];
}
- (void) enumerateKeysAndObjectsWithOptions: (NSEnumerationOptions)opts
usingBlock: (GSKeysAndObjectsEnumeratorBlock)aBlock
{
/*
* NOTE: For the moment, we ignore the NSEnumerationOptions because, according
* to the Cocoa documentation, NSEnumerationReverse is undefined for
* NSDictionary and we cannot handle NSEnumerationConcurrent without
* libdispatch.
*/
id<NSFastEnumeration> enumerator = [self keyEnumerator];
SEL objectForKeySelector = @selector(objectForKey:);
IMP objectForKey = [self methodForSelector: objectForKeySelector];
BOOL shouldStop = NO;
id obj;
FOR_IN(id, key, enumerator)
obj = (*objectForKey)(self, objectForKeySelector, key);
CALL_BLOCK(aBlock, key, obj, &shouldStop);
if (YES == shouldStop)
{
break;
}
END_FOR_IN(enumerator)
}
/**
* <p>In MacOS-X class clusters do not have designated initialisers,
* and there is a general rule that -init is treated as the designated
@ -176,13 +231,12 @@ static SEL appSel;
}
/**
* Returns an unsigned integer which is the number of elements
* stored in the dictionary.
* Return an enumerator object containing all the keys of the dictionary.
*/
- (NSUInteger) count
- (NSEnumerator*) keyEnumerator
{
[self subclassResponsibility: _cmd];
return 0;
return nil;
}
/**
@ -195,15 +249,6 @@ static SEL appSel;
return 0;
}
/**
* Return an enumerator object containing all the keys of the dictionary.
*/
- (NSEnumerator*) keyEnumerator
{
[self subclassResponsibility: _cmd];
return nil;
}
/**
* Return an enumerator object containing all the objects of the dictionary.
*/
@ -213,19 +258,6 @@ static SEL appSel;
return nil;
}
/**
* Returns a new copy of the receiver.<br />
* The default abstract implementation of a copy is to use the
* -initWithDictionary:copyItems: method with the flag set to YES.<br />
* Immutable subclasses generally simply retain and return the receiver.
*/
- (id) copyWithZone: (NSZone*)z
{
NSDictionary *copy = [NSDictionaryClass allocWithZone: z];
return [copy initWithDictionary: self copyItems: NO];
}
/**
* Returns a new instance containing the same objects as
* the receiver.<br />
@ -966,37 +998,6 @@ compareIt(id o1, id o2, void* context)
}
}
#if OS_API_VERSION(100600, GS_API_LATEST)
- (void)enumerateKeysAndObjectsWithOptions: (NSEnumerationOptions)opts
usingBlock: (GSKeysAndObjectsEnumeratorBlock)aBlock
{
/*
* NOTE: For the moment, we ignore the NSEnumerationOptions because, according
* to the Cocoa documentation, NSEnumerationReverse is undefined for
* NSDictionary and we cannot handle NSEnumerationConcurrent without
* libdispatch.
*/
id<NSFastEnumeration> enumerator = [self keyEnumerator];
SEL objectForKeySelector = @selector(objectForKey:);
IMP objectForKey = [self methodForSelector: objectForKeySelector];
BOOL shouldStop = NO;
FOR_IN(id, key, enumerator)
id obj = objectForKey(self, objectForKeySelector, key);
CALL_BLOCK(aBlock, key, obj, &shouldStop);
if (YES == shouldStop)
{
break;
}
END_FOR_IN(enumerator)
}
- (void)enumerateKeysAndObjectsUsingBlock: (GSKeysAndObjectsEnumeratorBlock)aBlock
{
[self enumerateKeysAndObjectsWithOptions: 0
usingBlock: aBlock];
}
- (NSSet*)keysOfEntriesWithOptions: (NSEnumerationOptions)opts
passingTest: (GSKeysAndObjectsPredicateBlock)aPredicate;
{
@ -1012,29 +1013,30 @@ compareIt(id o1, id o2, void* context)
SEL addObjectSelector = @selector(addObject:);
IMP addObject = [buildSet methodForSelector: addObjectSelector];
NSSet *resultSet = nil;
id obj;
FOR_IN(id, key, enumerator)
id obj = objectForKey(self, objectForKeySelector, key);
obj = (*objectForKey)(self, objectForKeySelector, key);
if (CALL_BLOCK(aPredicate, key, obj, &shouldStop))
{
addObject(buildSet, addObjectSelector, key);
}
{
addObject(buildSet, addObjectSelector, key);
}
if (YES == shouldStop)
{
break;
}
{
break;
}
END_FOR_IN(enumerator)
resultSet = [NSSet setWithSet: buildSet];
[buildSet release];
return resultSet;
}
- (NSSet*)keysOfEntriesPassingTest: (GSKeysAndObjectsPredicateBlock)aPredicate
- (NSSet*) keysOfEntriesPassingTest: (GSKeysAndObjectsPredicateBlock)aPredicate
{
return [self keysOfEntriesWithOptions: 0
passingTest: aPredicate];
}
#endif //OS_API_VERSION(100600,GS_API_LATEST)
/**
* <p>Writes the contents of the dictionary to the file specified by path.
* The file contents will be in property-list format ... under GNUstep