code tidyup and c-99ism fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25341 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rmottola 2007-07-19 21:38:14 +00:00
parent 89a0cb9080
commit 324432d9d1
3 changed files with 24 additions and 9 deletions

View file

@ -1,3 +1,9 @@
2007-07-19 Riccardo Mottola <riccardo@kaffe.org>
* Source/NSKeyValueCoding.m:
* Source/NSKeyValueMutableSet.m:
Code cleanup and C99-ism fixes
2007-07-14 Richard Frith-Macdonald <rfm@gnu.org> 2007-07-14 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSKeyValueCoding.m: * Source/NSKeyValueCoding.m:

View file

@ -871,6 +871,7 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
NSDictionary *dict; NSDictionary *dict;
NSException *exp; NSException *exp;
static IMP o = 0; static IMP o = 0;
NSString *reason;
/* Backward compatibility hack */ /* Backward compatibility hack */
if (o == 0) if (o == 0)
@ -886,7 +887,7 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
self, @"NSTargetObjectUserInfoKey", self, @"NSTargetObjectUserInfoKey",
(aKey ? (id)aKey : (id)@"(nil)"), @"NSUnknownUserInfoKey", (aKey ? (id)aKey : (id)@"(nil)"), @"NSUnknownUserInfoKey",
nil]; nil];
NSString * reason = [NSString stringWithFormat: reason = [NSString stringWithFormat:
@"Unable to find value for key \"%@\" of object %@ (%@)", @"Unable to find value for key \"%@\" of object %@ (%@)",
aKey, self, [self class]]; aKey, self, [self class]];
exp = [NSException exceptionWithName: NSUndefinedKeyException exp = [NSException exceptionWithName: NSUndefinedKeyException

View file

@ -88,6 +88,7 @@
+ (NSKeyValueMutableSet *) setForKey: (NSString *)aKey ofObject: (id)anObject + (NSKeyValueMutableSet *) setForKey: (NSString *)aKey ofObject: (id)anObject
{ {
NSKeyValueMutableSet *proxy;
unsigned size = [aKey maximumLengthOfBytesUsingEncoding: unsigned size = [aKey maximumLengthOfBytesUsingEncoding:
NSUTF8StringEncoding]; NSUTF8StringEncoding];
char key[size + 1]; char key[size + 1];
@ -100,7 +101,6 @@
*key = toupper(*key); *key = toupper(*key);
} }
NSKeyValueMutableSet *proxy;
proxy = [NSKeyValueFastMutableSet setForKey: aKey proxy = [NSKeyValueFastMutableSet setForKey: aKey
ofObject: anObject ofObject: anObject
@ -454,11 +454,12 @@
- (void) removeAllObjects - (void) removeAllObjects
{ {
NSSet *nothing;
NSSet *theSet = [NSSet setWithSet: [object valueForKey: key]]; NSSet *theSet = [NSSet setWithSet: [object valueForKey: key]];
[object willChangeValueForKey: key [object willChangeValueForKey: key
withSetMutation: NSKeyValueMinusSetMutation withSetMutation: NSKeyValueMinusSetMutation
usingObjects: theSet]; usingObjects: theSet];
NSSet *nothing = [NSSet set]; nothing = [NSSet set];
[setSetInvocation setArgument: &nothing atIndex: 2]; [setSetInvocation setArgument: &nothing atIndex: 2];
[setSetInvocation invoke]; [setSetInvocation invoke];
[object didChangeValueForKey: key [object didChangeValueForKey: key
@ -468,11 +469,14 @@
- (void) addObject: (id)anObject - (void) addObject: (id)anObject
{ {
NSSet *unionSet = [NSSet setWithObject: anObject]; NSMutableSet *temp;
NSSet *unionSet;
unionSet = [NSSet setWithObject: anObject];
[object willChangeValueForKey: key [object willChangeValueForKey: key
withSetMutation: NSKeyValueUnionSetMutation withSetMutation: NSKeyValueUnionSetMutation
usingObjects: unionSet]; usingObjects: unionSet];
NSMutableSet *temp = [NSMutableSet setWithSet: [object valueForKey: key]]; temp = [NSMutableSet setWithSet: [object valueForKey: key]];
[temp addObject: anObject]; [temp addObject: anObject];
[setSetInvocation setArgument: &temp atIndex: 2]; [setSetInvocation setArgument: &temp atIndex: 2];
[setSetInvocation invoke]; [setSetInvocation invoke];
@ -483,11 +487,12 @@
- (void) removeObject: (id)anObject - (void) removeObject: (id)anObject
{ {
NSMutableSet *temp;
NSSet *minusSet = [NSSet setWithObject: anObject]; NSSet *minusSet = [NSSet setWithObject: anObject];
[object willChangeValueForKey: key [object willChangeValueForKey: key
withSetMutation: NSKeyValueMinusSetMutation withSetMutation: NSKeyValueMinusSetMutation
usingObjects: minusSet]; usingObjects: minusSet];
NSMutableSet *temp = [NSMutableSet setWithSet: [object valueForKey: key]]; temp = [NSMutableSet setWithSet: [object valueForKey: key]];
[temp removeObject: anObject]; [temp removeObject: anObject];
[setSetInvocation setArgument: &temp atIndex: 2]; [setSetInvocation setArgument: &temp atIndex: 2];
[setSetInvocation invoke]; [setSetInvocation invoke];
@ -498,10 +503,11 @@
- (void) unionSet: (id)anObject - (void) unionSet: (id)anObject
{ {
NSMutableSet *temp;
[object willChangeValueForKey: key [object willChangeValueForKey: key
withSetMutation: NSKeyValueUnionSetMutation withSetMutation: NSKeyValueUnionSetMutation
usingObjects: anObject]; usingObjects: anObject];
NSMutableSet *temp = [NSMutableSet setWithSet: [object valueForKey: key]]; temp = [NSMutableSet setWithSet: [object valueForKey: key]];
[temp unionSet: anObject]; [temp unionSet: anObject];
[setSetInvocation setArgument: &temp atIndex: 2]; [setSetInvocation setArgument: &temp atIndex: 2];
[setSetInvocation invoke]; [setSetInvocation invoke];
@ -512,10 +518,11 @@
- (void) minusSet: (id)anObject - (void) minusSet: (id)anObject
{ {
NSMutableSet *temp;
[object willChangeValueForKey: key [object willChangeValueForKey: key
withSetMutation: NSKeyValueMinusSetMutation withSetMutation: NSKeyValueMinusSetMutation
usingObjects: anObject]; usingObjects: anObject];
NSMutableSet *temp = [NSMutableSet setWithSet: [object valueForKey: key]]; temp = [NSMutableSet setWithSet: [object valueForKey: key]];
[temp minusSet: anObject]; [temp minusSet: anObject];
[setSetInvocation setArgument: &temp atIndex: 2]; [setSetInvocation setArgument: &temp atIndex: 2];
[setSetInvocation invoke]; [setSetInvocation invoke];
@ -526,10 +533,11 @@
- (void) intersectSet: (id)anObject - (void) intersectSet: (id)anObject
{ {
NSMutableSet *temp;
[object willChangeValueForKey: key [object willChangeValueForKey: key
withSetMutation: NSKeyValueIntersectSetMutation withSetMutation: NSKeyValueIntersectSetMutation
usingObjects: anObject]; usingObjects: anObject];
NSMutableSet *temp = [NSMutableSet setWithSet: [object valueForKey: key]]; temp = [NSMutableSet setWithSet: [object valueForKey: key]];
[temp intersectSet: anObject]; [temp intersectSet: anObject];
[setSetInvocation setArgument: &temp atIndex: 2]; [setSetInvocation setArgument: &temp atIndex: 2];
[setSetInvocation invoke]; [setSetInvocation invoke];