mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Varous tidyups
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25330 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6848cb6de9
commit
f6a57d5fba
7 changed files with 329 additions and 284 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2007-07-14 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSKeyValueCoding.m:
|
||||
* Source/NSKeyValueMutableSet.m:
|
||||
* Source/NSArray.m:
|
||||
* Source/NSKeyValueMutableArray.m:
|
||||
Whitespace and initialisation tidyups.
|
||||
|
||||
2007-07-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSString.m: For MacOS-X compatibility, alter -propertyList
|
||||
to have the undocumented behavior of parsing strings file format
|
||||
too.
|
||||
|
||||
2007-07-10 Chris Farber <chris@chrisfarber.net>
|
||||
|
||||
* Source/NSArray.m ([NSArray -objectsAtIndexes:]): New method.
|
||||
|
|
|
@ -839,7 +839,7 @@ static SEL rlSel;
|
|||
- (NSArray *) objectsAtIndexes: (NSIndexSet *)indexes
|
||||
{
|
||||
//FIXME: probably slow!
|
||||
NSMutableArray * group = [NSMutableArray arrayWithCapacity: [indexes count]];
|
||||
NSMutableArray *group = [NSMutableArray arrayWithCapacity: [indexes count]];
|
||||
|
||||
unsigned i = [indexes firstIndex];
|
||||
while (i != NSNotFound)
|
||||
|
@ -1732,7 +1732,7 @@ compare(id elem1, id elem2, void* context)
|
|||
unsigned indexArray[count];
|
||||
|
||||
[indexes getIndexes: indexArray
|
||||
maxCount:count
|
||||
maxCount: count
|
||||
inIndexRange: NULL];
|
||||
|
||||
[self removeObjectsFromIndices: indexArray
|
||||
|
|
|
@ -255,7 +255,7 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
|
|||
|
||||
- (NSMutableSet*) mutableSetValueForKey: (NSString*)aKey
|
||||
{
|
||||
return [NSKeyValueMutableSet setForKey:aKey ofObject:self];
|
||||
return [NSKeyValueMutableSet setForKey: aKey ofObject: self];
|
||||
}
|
||||
|
||||
- (NSMutableSet*) mutableSetValueForKeyPath: (NSString*)aKey
|
||||
|
@ -292,7 +292,7 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
|
|||
|
||||
- (NSMutableArray*) mutableArrayValueForKey: (NSString*)aKey
|
||||
{
|
||||
return [NSKeyValueMutableArray arrayForKey:aKey ofObject:self];
|
||||
return [NSKeyValueMutableArray arrayForKey: aKey ofObject: self];
|
||||
}
|
||||
|
||||
- (NSMutableArray*) mutableArrayValueForKeyPath: (NSString*)aKey
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
$Date: 2007-06-08 04:04:14 -0400 (Fri, 08 Jun 2007) $ $Revision: 25230 $
|
||||
$Date: 2007-06-08 04: 04: 14 -0400 (Fri, 08 Jun 2007) $ $Revision: 25230 $
|
||||
*/
|
||||
|
||||
#import "Foundation/NSInvocation.h"
|
||||
|
@ -31,22 +31,22 @@
|
|||
{
|
||||
@protected
|
||||
id object;
|
||||
NSString * key;
|
||||
NSMutableArray * array;
|
||||
NSString *key;
|
||||
NSMutableArray *array;
|
||||
BOOL otherChangeInProgress;
|
||||
}
|
||||
|
||||
+ (NSKeyValueMutableArray *)arrayForKey:(NSString *)aKey ofObject:(id)anObject;
|
||||
- (id) initWithKey:(NSString *)aKey ofObject:(id)anObject;
|
||||
+ (NSKeyValueMutableArray *) arrayForKey: (NSString *)aKey ofObject: (id)anObject;
|
||||
- (id) initWithKey: (NSString *)aKey ofObject: (id)anObject;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSKeyValueFastMutableArray : NSKeyValueMutableArray
|
||||
{
|
||||
@private
|
||||
NSInvocation * insertObjectInvocation;
|
||||
NSInvocation * removeObjectInvocation;
|
||||
NSInvocation * replaceObjectInvocation;
|
||||
NSInvocation *insertObjectInvocation;
|
||||
NSInvocation *removeObjectInvocation;
|
||||
NSInvocation *replaceObjectInvocation;
|
||||
}
|
||||
|
||||
+ (id) arrayForKey: (NSString *)aKey ofObject: (id)anObject
|
||||
|
@ -60,7 +60,7 @@
|
|||
@interface NSKeyValueSlowMutableArray : NSKeyValueMutableArray
|
||||
{
|
||||
@private
|
||||
NSInvocation * setArrayInvocation;
|
||||
NSInvocation *setArrayInvocation;
|
||||
}
|
||||
|
||||
+ (id) arrayForKey: (NSString *)aKey ofObject: (id)anObject
|
||||
|
@ -85,15 +85,16 @@
|
|||
|
||||
@implementation NSKeyValueMutableArray
|
||||
|
||||
+ (NSKeyValueMutableArray *)arrayForKey:(NSString *)aKey ofObject:(id)anObject;
|
||||
+ (NSKeyValueMutableArray *) arrayForKey: (NSString *)aKey
|
||||
ofObject: (id)anObject
|
||||
{
|
||||
NSKeyValueMutableArray * proxy;
|
||||
unsigned size = [aKey maximumLengthOfBytesUsingEncoding:
|
||||
NSASCIIStringEncoding];
|
||||
NSKeyValueMutableArray *proxy;
|
||||
unsigned size = [aKey maximumLengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding];
|
||||
char key[size + 1];
|
||||
[aKey getCString: key
|
||||
maxLength: size + 1
|
||||
encoding: NSASCIIStringEncoding];
|
||||
encoding: NSUTF8StringEncoding];
|
||||
if (islower(*key))
|
||||
{
|
||||
*key = toupper(*key);
|
||||
|
@ -117,14 +118,14 @@
|
|||
return proxy;
|
||||
}
|
||||
|
||||
- (id) initWithKey:(NSString *)aKey ofObject:(id)anObject
|
||||
- (id) initWithKey: (NSString *)aKey ofObject: (id)anObject
|
||||
{
|
||||
[super init];
|
||||
|
||||
object = anObject;
|
||||
key = [aKey copy];
|
||||
otherChangeInProgress = NO;
|
||||
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
object = anObject;
|
||||
key = [aKey copy];
|
||||
otherChangeInProgress = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -151,7 +152,7 @@
|
|||
[self insertObject: anObject atIndex: [self count]];
|
||||
}
|
||||
|
||||
- (void)removeLastObject
|
||||
- (void) removeLastObject
|
||||
{
|
||||
[self removeObjectAtIndex: ([self count] - 1)];
|
||||
}
|
||||
|
@ -163,8 +164,8 @@
|
|||
+ (id) arrayForKey: (NSString *)aKey ofObject: (id)anObject
|
||||
withCapitalizedKey: (char *)capitalized
|
||||
{
|
||||
return [[[self alloc] initWithKey:aKey ofObject:anObject
|
||||
withCapitalizedKey:capitalized] autorelease];
|
||||
return [[[self alloc] initWithKey: aKey ofObject: anObject
|
||||
withCapitalizedKey: capitalized] autorelease];
|
||||
}
|
||||
|
||||
- (id) initWithKey: (NSString *)aKey ofObject: (id)anObject
|
||||
|
@ -174,42 +175,43 @@
|
|||
SEL remove;
|
||||
SEL replace;
|
||||
|
||||
|
||||
insert = NSSelectorFromString
|
||||
([NSString stringWithFormat: @"insertObject:in%sAtIndex:", capitalized]);
|
||||
remove = NSSelectorFromString
|
||||
([NSString stringWithFormat: @"removeObjectFrom%sAtIndex:", capitalized]);
|
||||
if (!([anObject respondsToSelector:insert] &&
|
||||
[anObject respondsToSelector:remove]))
|
||||
if (!([anObject respondsToSelector: insert]
|
||||
&& [anObject respondsToSelector: remove]))
|
||||
{
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
replace = NSSelectorFromString
|
||||
([NSString stringWithFormat: @"replaceObjectIn%sAtIndex:withObject:", capitalized]);
|
||||
([NSString stringWithFormat: @"replaceObjectIn%sAtIndex:withObject:",
|
||||
capitalized]);
|
||||
|
||||
[super initWithKey:aKey ofObject:anObject];
|
||||
|
||||
insertObjectInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector:insert]] retain];
|
||||
[insertObjectInvocation setTarget: anObject];
|
||||
[insertObjectInvocation setSelector:insert];
|
||||
removeObjectInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector:remove]] retain];
|
||||
[removeObjectInvocation setTarget: anObject];
|
||||
[removeObjectInvocation setSelector:remove];
|
||||
if ([anObject respondsToSelector:replace])
|
||||
if ((self = [super initWithKey: aKey ofObject: anObject]) != nil)
|
||||
{
|
||||
replaceObjectInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector:replace]] retain];
|
||||
[replaceObjectInvocation setTarget: anObject];
|
||||
[replaceObjectInvocation setSelector:replace];
|
||||
insertObjectInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector: insert]] retain];
|
||||
[insertObjectInvocation setTarget: anObject];
|
||||
[insertObjectInvocation setSelector: insert];
|
||||
removeObjectInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector: remove]] retain];
|
||||
[removeObjectInvocation setTarget: anObject];
|
||||
[removeObjectInvocation setSelector: remove];
|
||||
if ([anObject respondsToSelector: replace])
|
||||
{
|
||||
replaceObjectInvocation
|
||||
= [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector: replace]] retain];
|
||||
[replaceObjectInvocation setTarget: anObject];
|
||||
[replaceObjectInvocation setSelector: replace];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
- (void) dealloc
|
||||
{
|
||||
[insertObjectInvocation release];
|
||||
[removeObjectInvocation release];
|
||||
|
@ -219,7 +221,8 @@
|
|||
|
||||
- (void) removeObjectAtIndex: (unsigned)index
|
||||
{
|
||||
NSIndexSet * indexes;
|
||||
NSIndexSet *indexes;
|
||||
|
||||
if (!otherChangeInProgress)
|
||||
{
|
||||
indexes = [NSIndexSet indexSetWithIndex: index];
|
||||
|
@ -227,7 +230,7 @@
|
|||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
}
|
||||
[removeObjectInvocation setArgument:&index atIndex:2];
|
||||
[removeObjectInvocation setArgument: &index atIndex: 2];
|
||||
[removeObjectInvocation invoke];
|
||||
if (!otherChangeInProgress)
|
||||
{
|
||||
|
@ -239,7 +242,8 @@
|
|||
|
||||
- (void) insertObject: (id)anObject atIndex: (unsigned)index
|
||||
{
|
||||
NSIndexSet * indexes;
|
||||
NSIndexSet *indexes;
|
||||
|
||||
if (!otherChangeInProgress)
|
||||
{
|
||||
indexes = [NSIndexSet indexSetWithIndex: index];
|
||||
|
@ -247,8 +251,8 @@
|
|||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
}
|
||||
[insertObjectInvocation setArgument:&anObject atIndex:2];
|
||||
[insertObjectInvocation setArgument:&index atIndex:3];
|
||||
[insertObjectInvocation setArgument: &anObject atIndex: 2];
|
||||
[insertObjectInvocation setArgument: &index atIndex: 3];
|
||||
[insertObjectInvocation invoke];
|
||||
if (!otherChangeInProgress)
|
||||
{
|
||||
|
@ -260,8 +264,9 @@
|
|||
|
||||
- (void) replaceObjectAtIndex: (unsigned)index withObject: (id)anObject
|
||||
{
|
||||
NSIndexSet * indexes;
|
||||
NSIndexSet *indexes;
|
||||
BOOL triggerNotifications = !otherChangeInProgress;
|
||||
|
||||
if (triggerNotifications)
|
||||
{
|
||||
otherChangeInProgress = YES;
|
||||
|
@ -272,14 +277,14 @@
|
|||
}
|
||||
if (replaceObjectInvocation)
|
||||
{
|
||||
[replaceObjectInvocation setArgument:&index atIndex:2];
|
||||
[replaceObjectInvocation setArgument:&anObject atIndex:3];
|
||||
[replaceObjectInvocation setArgument: &index atIndex: 2];
|
||||
[replaceObjectInvocation setArgument: &anObject atIndex: 3];
|
||||
[replaceObjectInvocation invoke];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self removeObjectAtIndex:index];
|
||||
[self insertObject:anObject atIndex:index];
|
||||
[self removeObjectAtIndex: index];
|
||||
[self insertObject: anObject atIndex: index];
|
||||
}
|
||||
if (triggerNotifications)
|
||||
{
|
||||
|
@ -298,15 +303,15 @@
|
|||
+ (id) arrayForKey: (NSString *)aKey ofObject: (id)anObject
|
||||
withCapitalizedKey: (const char *)capitalized
|
||||
{
|
||||
return [[[self alloc] initWithKey:aKey ofObject:anObject
|
||||
withCapitalizedKey:capitalized] autorelease];
|
||||
return [[[self alloc] initWithKey: aKey ofObject: anObject
|
||||
withCapitalizedKey: capitalized] autorelease];
|
||||
}
|
||||
|
||||
- (id) initWithKey: (NSString *)aKey ofObject: (id)anObject
|
||||
withCapitalizedKey: (const char *)capitalized;
|
||||
|
||||
{
|
||||
SEL set = NSSelectorFromString([NSString stringWithFormat:
|
||||
SEL set = NSSelectorFromString([NSString stringWithFormat:
|
||||
@"set%s:", capitalized]);
|
||||
|
||||
if (![anObject respondsToSelector: set])
|
||||
|
@ -315,20 +320,20 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
[super initWithKey:aKey ofObject:anObject];
|
||||
|
||||
setArrayInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector:set]] retain];
|
||||
[setArrayInvocation setSelector:set];
|
||||
[setArrayInvocation setTarget:anObject];
|
||||
|
||||
if ((self = [super initWithKey: aKey ofObject: anObject]) != nil)
|
||||
{
|
||||
setArrayInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector: set]] retain];
|
||||
[setArrayInvocation setSelector: set];
|
||||
[setArrayInvocation setTarget: anObject];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) removeObjectAtIndex: (unsigned)index
|
||||
{
|
||||
NSIndexSet * indexes;
|
||||
NSMutableArray * temp;
|
||||
NSIndexSet *indexes;
|
||||
NSMutableArray *temp;
|
||||
|
||||
if (!otherChangeInProgress)
|
||||
{
|
||||
|
@ -338,10 +343,10 @@
|
|||
forKey: key];
|
||||
}
|
||||
|
||||
temp = [NSMutableArray arrayWithArray:[object valueForKey:key]];
|
||||
[temp removeObjectAtIndex:index];
|
||||
temp = [NSMutableArray arrayWithArray: [object valueForKey: key]];
|
||||
[temp removeObjectAtIndex: index];
|
||||
|
||||
[setArrayInvocation setArgument:&temp atIndex:2];
|
||||
[setArrayInvocation setArgument: &temp atIndex: 2];
|
||||
[setArrayInvocation invoke];
|
||||
|
||||
if (!otherChangeInProgress)
|
||||
|
@ -354,8 +359,8 @@
|
|||
|
||||
- (void) insertObject: (id)anObject atIndex: (unsigned)index
|
||||
{
|
||||
NSIndexSet * indexes;
|
||||
NSMutableArray * temp;
|
||||
NSIndexSet *indexes;
|
||||
NSMutableArray *temp;
|
||||
|
||||
if (!otherChangeInProgress)
|
||||
{
|
||||
|
@ -365,10 +370,10 @@
|
|||
forKey: key];
|
||||
}
|
||||
|
||||
temp = [NSMutableArray arrayWithArray:[object valueForKey:key]];
|
||||
[temp insertObject:anObject atIndex:index];
|
||||
temp = [NSMutableArray arrayWithArray: [object valueForKey: key]];
|
||||
[temp insertObject: anObject atIndex: index];
|
||||
|
||||
[setArrayInvocation setArgument:&temp atIndex:2];
|
||||
[setArrayInvocation setArgument: &temp atIndex: 2];
|
||||
[setArrayInvocation invoke];
|
||||
|
||||
if (!otherChangeInProgress)
|
||||
|
@ -381,8 +386,8 @@
|
|||
|
||||
- (void) replaceObjectAtIndex: (unsigned)index withObject: (id)anObject
|
||||
{
|
||||
NSIndexSet * indexes;
|
||||
NSMutableArray * temp;
|
||||
NSIndexSet *indexes;
|
||||
NSMutableArray *temp;
|
||||
|
||||
if (!otherChangeInProgress)
|
||||
{
|
||||
|
@ -392,11 +397,11 @@
|
|||
forKey: key];
|
||||
}
|
||||
|
||||
temp = [NSMutableArray arrayWithArray:[object valueForKey:key]];
|
||||
[temp removeObjectAtIndex:index];
|
||||
[temp insertObject:anObject atIndex:index];
|
||||
temp = [NSMutableArray arrayWithArray: [object valueForKey: key]];
|
||||
[temp removeObjectAtIndex: index];
|
||||
[temp insertObject: anObject atIndex: index];
|
||||
|
||||
[setArrayInvocation setArgument:&temp atIndex:2];
|
||||
[setArrayInvocation setArgument: &temp atIndex: 2];
|
||||
[setArrayInvocation invoke];
|
||||
|
||||
if (!otherChangeInProgress)
|
||||
|
@ -413,101 +418,106 @@
|
|||
|
||||
@implementation NSKeyValueIvarMutableArray
|
||||
|
||||
+ (id)arrayForKey: (NSString *)key ofObject: (id)anObject
|
||||
+ (id) arrayForKey: (NSString *)key ofObject: (id)anObject
|
||||
{
|
||||
return [[[self alloc] initWithKey:key ofObject:anObject] autorelease];
|
||||
return [[[self alloc] initWithKey: key ofObject: anObject] autorelease];
|
||||
}
|
||||
|
||||
- (id) initWithKey: (NSString *)aKey ofObject: (id)anObject
|
||||
{
|
||||
[super initWithKey: aKey ofObject: anObject];
|
||||
|
||||
{
|
||||
unsigned size = [aKey maximumLengthOfBytesUsingEncoding:NSASCIIStringEncoding];
|
||||
char cKey[size + 2];
|
||||
char *cKeyPtr = &cKey[0];
|
||||
const char *type = 0;
|
||||
BOOL found;
|
||||
int offset;
|
||||
|
||||
cKey[0] = '_';
|
||||
[aKey getCString:cKeyPtr + 1
|
||||
maxLength:size + 1
|
||||
encoding:NSASCIIStringEncoding];
|
||||
|
||||
if (!GSObjCFindVariable (anObject, cKeyPtr, &type, &size, &offset))
|
||||
found = GSObjCFindVariable (anObject, ++cKeyPtr, &type, &size, &offset);
|
||||
if (found)
|
||||
{
|
||||
array = GSObjCGetVal (anObject, cKeyPtr, NULL, type, size, offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
array = [object valueForKey: key];
|
||||
}
|
||||
}
|
||||
if ((self = [super initWithKey: aKey ofObject: anObject]) != nil)
|
||||
{
|
||||
unsigned size = [aKey maximumLengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding];
|
||||
char cKey[size + 2];
|
||||
char *cKeyPtr = &cKey[0];
|
||||
const char *type = 0;
|
||||
BOOL found;
|
||||
int offset;
|
||||
|
||||
cKey[0] = '_';
|
||||
[aKey getCString: cKeyPtr + 1
|
||||
maxLength: size + 1
|
||||
encoding: NSUTF8StringEncoding];
|
||||
|
||||
if (!GSObjCFindVariable (anObject, cKeyPtr, &type, &size, &offset))
|
||||
found = GSObjCFindVariable (anObject, ++cKeyPtr, &type, &size, &offset);
|
||||
if (found)
|
||||
{
|
||||
array = GSObjCGetVal (anObject, cKeyPtr, NULL, type, size, offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
array = [object valueForKey: key];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) addObject: (id)anObject
|
||||
{
|
||||
NSIndexSet * indexes = [NSIndexSet indexSetWithIndex: [array count]];
|
||||
NSIndexSet *indexes = [NSIndexSet indexSetWithIndex: [array count]];
|
||||
|
||||
[object willChange: NSKeyValueChangeInsertion
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
[array addObject:anObject];
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
[array addObject: anObject];
|
||||
[object didChange: NSKeyValueChangeInsertion
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
}
|
||||
|
||||
- (void) removeObjectAtIndex: (unsigned)index
|
||||
{
|
||||
NSIndexSet * indexes = [NSIndexSet indexSetWithIndex: index];
|
||||
NSIndexSet *indexes = [NSIndexSet indexSetWithIndex: index];
|
||||
|
||||
[object willChange: NSKeyValueChangeRemoval
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
[array removeObjectAtIndex:index];
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
[array removeObjectAtIndex: index];
|
||||
[object didChange: NSKeyValueChangeRemoval
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
}
|
||||
|
||||
- (void) insertObject: (id)anObject atIndex: (unsigned)index
|
||||
{
|
||||
NSIndexSet * indexes = [NSIndexSet indexSetWithIndex: index];
|
||||
NSIndexSet *indexes = [NSIndexSet indexSetWithIndex: index];
|
||||
|
||||
[object willChange: NSKeyValueChangeInsertion
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
[array insertObject: anObject atIndex: index];
|
||||
[object didChange: NSKeyValueChangeInsertion
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
}
|
||||
|
||||
- (void) removeLastObject
|
||||
{
|
||||
NSIndexSet * indexes = [NSIndexSet indexSetWithIndex: [array count] - 1];
|
||||
NSIndexSet *indexes = [NSIndexSet indexSetWithIndex: [array count] - 1];
|
||||
|
||||
[object willChange: NSKeyValueChangeRemoval
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
[array removeObjectAtIndex: [indexes firstIndex]];
|
||||
[object didChange: NSKeyValueChangeRemoval
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
}
|
||||
|
||||
- (void) replaceObjectAtIndex: (unsigned)index withObject: (id)anObject
|
||||
{
|
||||
NSIndexSet * indexes = [NSIndexSet indexSetWithIndex: index];
|
||||
NSIndexSet *indexes = [NSIndexSet indexSetWithIndex: index];
|
||||
|
||||
[object willChange: NSKeyValueChangeReplacement
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
[array replaceObjectAtIndex: index withObject: anObject];
|
||||
[object didChange: NSKeyValueChangeReplacement
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
valuesAtIndexes: indexes
|
||||
forKey: key];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,28 +29,28 @@
|
|||
{
|
||||
@protected
|
||||
id object;
|
||||
NSString * key;
|
||||
NSMutableSet * set;
|
||||
NSString *key;
|
||||
NSMutableSet *set;
|
||||
BOOL changeInProgress;
|
||||
}
|
||||
|
||||
+ (NSKeyValueMutableSet *)setForKey:(NSString *)aKey ofObject:(id)anObject;
|
||||
- (id) initWithKey:(NSString *)aKey ofObject:(id)anObject;
|
||||
+ (NSKeyValueMutableSet*) setForKey: (NSString*)aKey ofObject: (id)anObject;
|
||||
- (id) initWithKey: (NSString*)aKey ofObject: (id)anObject;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSKeyValueFastMutableSet : NSKeyValueMutableSet
|
||||
{
|
||||
@private
|
||||
NSInvocation * addObjectInvocation;
|
||||
NSInvocation * removeObjectInvocation;
|
||||
NSInvocation * addSetInvocation;
|
||||
NSInvocation * removeSetInvocation;
|
||||
NSInvocation * intersectInvocation;
|
||||
NSInvocation * setSetInvocation;
|
||||
NSInvocation *addObjectInvocation;
|
||||
NSInvocation *removeObjectInvocation;
|
||||
NSInvocation *addSetInvocation;
|
||||
NSInvocation *removeSetInvocation;
|
||||
NSInvocation *intersectInvocation;
|
||||
NSInvocation *setSetInvocation;
|
||||
}
|
||||
|
||||
+ (id) setForKey: (NSString *)aKey ofObject: (id)anObject
|
||||
+ (id) setForKey: (NSString*)aKey ofObject: (id)anObject
|
||||
withCapitalizedKey: (const char *)capitalized;
|
||||
|
||||
- (id) initWithKey: (NSString *)aKey ofObject: (id)anObject
|
||||
|
@ -61,7 +61,7 @@
|
|||
@interface NSKeyValueSlowMutableSet : NSKeyValueMutableSet
|
||||
{
|
||||
@private
|
||||
NSInvocation * setSetInvocation;
|
||||
NSInvocation *setSetInvocation;
|
||||
}
|
||||
|
||||
+ (id) setForKey: (NSString *)aKey ofObject: (id)anObject
|
||||
|
@ -86,48 +86,48 @@
|
|||
|
||||
@implementation NSKeyValueMutableSet
|
||||
|
||||
+ (NSKeyValueMutableSet *)setForKey:(NSString *)aKey ofObject:(id)anObject;
|
||||
+ (NSKeyValueMutableSet *) setForKey: (NSString *)aKey ofObject: (id)anObject
|
||||
{
|
||||
unsigned size = [aKey maximumLengthOfBytesUsingEncoding:
|
||||
NSASCIIStringEncoding];
|
||||
NSUTF8StringEncoding];
|
||||
char key[size + 1];
|
||||
|
||||
[aKey getCString: key
|
||||
maxLength: size + 1
|
||||
encoding: NSASCIIStringEncoding];
|
||||
encoding: NSUTF8StringEncoding];
|
||||
if (islower(*key))
|
||||
{
|
||||
*key = toupper(*key);
|
||||
}
|
||||
|
||||
NSKeyValueMutableSet * proxy;
|
||||
NSKeyValueMutableSet *proxy;
|
||||
|
||||
proxy = [NSKeyValueFastMutableSet setForKey:aKey
|
||||
ofObject:anObject
|
||||
withCapitalizedKey:key];
|
||||
proxy = [NSKeyValueFastMutableSet setForKey: aKey
|
||||
ofObject: anObject
|
||||
withCapitalizedKey: key];
|
||||
if (proxy == nil)
|
||||
{
|
||||
proxy = [NSKeyValueSlowMutableSet setForKey:aKey
|
||||
ofObject:anObject
|
||||
withCapitalizedKey:key];
|
||||
proxy = [NSKeyValueSlowMutableSet setForKey: aKey
|
||||
ofObject: anObject
|
||||
withCapitalizedKey: key];
|
||||
|
||||
if (proxy == nil)
|
||||
{
|
||||
proxy = [NSKeyValueIvarMutableSet setForKey:aKey
|
||||
ofObject:anObject];
|
||||
proxy = [NSKeyValueIvarMutableSet setForKey: aKey
|
||||
ofObject: anObject];
|
||||
}
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
- (id) initWithKey:(NSString *)aKey ofObject:(id)anObject
|
||||
- (id) initWithKey: (NSString *)aKey ofObject: (id)anObject
|
||||
{
|
||||
[super init];
|
||||
|
||||
object = anObject;
|
||||
key = [aKey copy];
|
||||
changeInProgress = NO;
|
||||
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
object = anObject;
|
||||
key = [aKey copy];
|
||||
changeInProgress = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -175,8 +175,8 @@
|
|||
withCapitalizedKey: (char *)capitalized
|
||||
{
|
||||
return [[[self alloc] initWithKey: aKey
|
||||
ofObject: anObject
|
||||
withCapitalizedKey: capitalized] autorelease];
|
||||
ofObject: anObject
|
||||
withCapitalizedKey: capitalized] autorelease];
|
||||
}
|
||||
|
||||
- (id) initWithKey: (NSString *)aKey ofObject: (id)anObject
|
||||
|
@ -201,7 +201,7 @@
|
|||
removeSet = NSSelectorFromString
|
||||
([NSString stringWithFormat: @"remove%s:", capitalized]);
|
||||
|
||||
if ([anObject respondsToSelector:addObject])
|
||||
if ([anObject respondsToSelector: addObject])
|
||||
{
|
||||
canAdd = YES;
|
||||
addObjectInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
|
@ -209,7 +209,7 @@
|
|||
[addObjectInvocation setTarget: anObject];
|
||||
[addObjectInvocation setSelector: addObject];
|
||||
}
|
||||
if ([anObject respondsToSelector:removeObject])
|
||||
if ([anObject respondsToSelector: removeObject])
|
||||
{
|
||||
canRemove = YES;
|
||||
removeObjectInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
|
@ -217,7 +217,7 @@
|
|||
[removeObjectInvocation setTarget: anObject];
|
||||
[removeObjectInvocation setSelector: removeObject];
|
||||
}
|
||||
if ([anObject respondsToSelector:addSet])
|
||||
if ([anObject respondsToSelector: addSet])
|
||||
{
|
||||
canAdd = YES;
|
||||
addSetInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
|
@ -225,7 +225,7 @@
|
|||
[addSetInvocation setTarget: anObject];
|
||||
[addSetInvocation setSelector: addSet];
|
||||
}
|
||||
if ([anObject respondsToSelector:removeSet])
|
||||
if ([anObject respondsToSelector: removeSet])
|
||||
{
|
||||
canRemove = YES;
|
||||
removeSetInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
|
@ -240,32 +240,32 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
[super initWithKey: aKey ofObject: anObject];
|
||||
|
||||
intersect = NSSelectorFromString
|
||||
([NSString stringWithFormat: @"intersect%s:", capitalized]);
|
||||
setSet = NSSelectorFromString
|
||||
([NSString stringWithFormat: @"set%s:", capitalized]);
|
||||
|
||||
if ([anObject respondsToSelector: intersect])
|
||||
if ((self = [super initWithKey: aKey ofObject: anObject]) != nil)
|
||||
{
|
||||
intersectInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector: intersect]] retain];
|
||||
[intersectInvocation setTarget: anObject];
|
||||
[intersectInvocation setSelector: intersect];
|
||||
}
|
||||
if ([anObject respondsToSelector: setSet])
|
||||
{
|
||||
setSetInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector: setSet]] retain];
|
||||
[setSetInvocation setTarget: anObject];
|
||||
[setSetInvocation setSelector: setSet];
|
||||
}
|
||||
intersect = NSSelectorFromString
|
||||
([NSString stringWithFormat: @"intersect%s:", capitalized]);
|
||||
setSet = NSSelectorFromString
|
||||
([NSString stringWithFormat: @"set%s:", capitalized]);
|
||||
|
||||
if ([anObject respondsToSelector: intersect])
|
||||
{
|
||||
intersectInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector: intersect]] retain];
|
||||
[intersectInvocation setTarget: anObject];
|
||||
[intersectInvocation setSelector: intersect];
|
||||
}
|
||||
if ([anObject respondsToSelector: setSet])
|
||||
{
|
||||
setSetInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector: setSet]] retain];
|
||||
[setSetInvocation setTarget: anObject];
|
||||
[setSetInvocation setSelector: setSet];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
- (void) dealloc
|
||||
{
|
||||
[setSetInvocation release];
|
||||
[intersectInvocation release];
|
||||
|
@ -284,7 +284,7 @@
|
|||
{
|
||||
[object willChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueUnionSetMutation
|
||||
usingObjects: [NSSet setWithObject:anObject]];
|
||||
usingObjects: [NSSet setWithObject: anObject]];
|
||||
}
|
||||
[addObjectInvocation setArgument: &anObject atIndex: 2];
|
||||
[addObjectInvocation invoke];
|
||||
|
@ -292,7 +292,7 @@
|
|||
{
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueUnionSetMutation
|
||||
usingObjects: [NSSet setWithObject:anObject]];
|
||||
usingObjects: [NSSet setWithObject: anObject]];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -313,7 +313,7 @@
|
|||
[addSetInvocation invoke];
|
||||
}
|
||||
else
|
||||
[super unionSet:aSet];
|
||||
[super unionSet: aSet];
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueUnionSetMutation
|
||||
usingObjects: aSet];
|
||||
|
@ -340,7 +340,7 @@
|
|||
}
|
||||
}
|
||||
else
|
||||
[self minusSet:[NSSet setWithObject:anObject]];
|
||||
[self minusSet: [NSSet setWithObject: anObject]];
|
||||
}
|
||||
|
||||
- (void) minusSet: (NSSet *)aSet
|
||||
|
@ -413,8 +413,8 @@
|
|||
+ (id) setForKey: (NSString *)aKey ofObject: (id)anObject
|
||||
withCapitalizedKey: (const char *)capitalized
|
||||
{
|
||||
return [[[self alloc] initWithKey:aKey ofObject:anObject
|
||||
withCapitalizedKey:capitalized] autorelease];
|
||||
return [[[self alloc] initWithKey: aKey ofObject: anObject
|
||||
withCapitalizedKey: capitalized] autorelease];
|
||||
}
|
||||
|
||||
- (id) initWithKey: (NSString *)aKey ofObject: (id)anObject
|
||||
|
@ -424,19 +424,19 @@
|
|||
SEL setSelector = NSSelectorFromString([NSString stringWithFormat:
|
||||
@"set%s:", capitalized]);
|
||||
|
||||
if (![anObject respondsToSelector:setSelector])
|
||||
if (![anObject respondsToSelector: setSelector])
|
||||
{
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
[super initWithKey:aKey ofObject:anObject];
|
||||
|
||||
setSetInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector:setSelector]] retain];
|
||||
[setSetInvocation setSelector:setSelector];
|
||||
[setSetInvocation setTarget:anObject];
|
||||
|
||||
if ((self = [super initWithKey: aKey ofObject: anObject]) != nil)
|
||||
{
|
||||
setSetInvocation = [[NSInvocation invocationWithMethodSignature:
|
||||
[anObject methodSignatureForSelector: setSelector]] retain];
|
||||
[setSetInvocation setSelector: setSelector];
|
||||
[setSetInvocation setTarget: anObject];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -448,52 +448,52 @@
|
|||
[setSetInvocation setArgument: &aSet atIndex: 2];
|
||||
[setSetInvocation invoke];
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueSetSetMutation
|
||||
usingObjects: aSet];
|
||||
withSetMutation: NSKeyValueSetSetMutation
|
||||
usingObjects: aSet];
|
||||
}
|
||||
|
||||
- (void) removeAllObjects
|
||||
{
|
||||
NSSet * theSet = [NSSet setWithSet: [object valueForKey: key]];
|
||||
NSSet *theSet = [NSSet setWithSet: [object valueForKey: key]];
|
||||
[object willChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: theSet];
|
||||
NSSet * nothing = [NSSet set];
|
||||
NSSet *nothing = [NSSet set];
|
||||
[setSetInvocation setArgument: ¬hing atIndex: 2];
|
||||
[setSetInvocation invoke];
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: theSet];
|
||||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: theSet];
|
||||
}
|
||||
|
||||
- (void) addObject: (id)anObject
|
||||
{
|
||||
NSSet * unionSet = [NSSet setWithObject:anObject];
|
||||
NSSet *unionSet = [NSSet setWithObject: anObject];
|
||||
[object willChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueUnionSetMutation
|
||||
usingObjects: unionSet];
|
||||
NSMutableSet * temp = [NSMutableSet setWithSet:[object valueForKey:key]];
|
||||
[temp addObject:anObject];
|
||||
NSMutableSet *temp = [NSMutableSet setWithSet: [object valueForKey: key]];
|
||||
[temp addObject: anObject];
|
||||
[setSetInvocation setArgument: &temp atIndex: 2];
|
||||
[setSetInvocation invoke];
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueUnionSetMutation
|
||||
usingObjects: unionSet];
|
||||
withSetMutation: NSKeyValueUnionSetMutation
|
||||
usingObjects: unionSet];
|
||||
}
|
||||
|
||||
- (void) removeObject: (id)anObject
|
||||
{
|
||||
NSSet * minusSet = [NSSet setWithObject:anObject];
|
||||
NSSet *minusSet = [NSSet setWithObject: anObject];
|
||||
[object willChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: minusSet];
|
||||
NSMutableSet * temp = [NSMutableSet setWithSet: [object valueForKey: key]];
|
||||
[temp removeObject:anObject];
|
||||
NSMutableSet *temp = [NSMutableSet setWithSet: [object valueForKey: key]];
|
||||
[temp removeObject: anObject];
|
||||
[setSetInvocation setArgument: &temp atIndex: 2];
|
||||
[setSetInvocation invoke];
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: minusSet];
|
||||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: minusSet];
|
||||
}
|
||||
|
||||
- (void) unionSet: (id)anObject
|
||||
|
@ -501,13 +501,13 @@
|
|||
[object willChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueUnionSetMutation
|
||||
usingObjects: anObject];
|
||||
NSMutableSet * temp = [NSMutableSet setWithSet: [object valueForKey: key]];
|
||||
[temp unionSet:anObject];
|
||||
NSMutableSet *temp = [NSMutableSet setWithSet: [object valueForKey: key]];
|
||||
[temp unionSet: anObject];
|
||||
[setSetInvocation setArgument: &temp atIndex: 2];
|
||||
[setSetInvocation invoke];
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueUnionSetMutation
|
||||
usingObjects: anObject];
|
||||
withSetMutation: NSKeyValueUnionSetMutation
|
||||
usingObjects: anObject];
|
||||
}
|
||||
|
||||
- (void) minusSet: (id)anObject
|
||||
|
@ -515,13 +515,13 @@
|
|||
[object willChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: anObject];
|
||||
NSMutableSet * temp = [NSMutableSet setWithSet: [object valueForKey: key]];
|
||||
[temp minusSet:anObject];
|
||||
NSMutableSet *temp = [NSMutableSet setWithSet: [object valueForKey: key]];
|
||||
[temp minusSet: anObject];
|
||||
[setSetInvocation setArgument: &temp atIndex: 2];
|
||||
[setSetInvocation invoke];
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: anObject];
|
||||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: anObject];
|
||||
}
|
||||
|
||||
- (void) intersectSet: (id)anObject
|
||||
|
@ -529,13 +529,13 @@
|
|||
[object willChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueIntersectSetMutation
|
||||
usingObjects: anObject];
|
||||
NSMutableSet * temp = [NSMutableSet setWithSet: [object valueForKey: key]];
|
||||
[temp intersectSet:anObject];
|
||||
NSMutableSet *temp = [NSMutableSet setWithSet: [object valueForKey: key]];
|
||||
[temp intersectSet: anObject];
|
||||
[setSetInvocation setArgument: &temp atIndex: 2];
|
||||
[setSetInvocation invoke];
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueIntersectSetMutation
|
||||
usingObjects: anObject];
|
||||
withSetMutation: NSKeyValueIntersectSetMutation
|
||||
usingObjects: anObject];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -543,33 +543,34 @@
|
|||
|
||||
@implementation NSKeyValueIvarMutableSet
|
||||
|
||||
+ (id)setForKey: (NSString *)key ofObject: (id)anObject
|
||||
+ (id) setForKey: (NSString *)key ofObject: (id)anObject
|
||||
{
|
||||
return [[[self alloc] initWithKey:key ofObject:anObject] autorelease];
|
||||
return [[[self alloc] initWithKey: key ofObject: anObject] autorelease];
|
||||
}
|
||||
|
||||
- (id) initWithKey: (NSString *)aKey ofObject: (id)anObject
|
||||
{
|
||||
[super initWithKey: aKey ofObject: anObject];
|
||||
|
||||
unsigned size = [aKey maximumLengthOfBytesUsingEncoding: NSASCIIStringEncoding];
|
||||
char cKey[size + 2];
|
||||
char *cKeyPtr = &cKey[0];
|
||||
const char *type = 0;
|
||||
|
||||
int offset;
|
||||
|
||||
|
||||
cKey[0] = '_';
|
||||
[aKey getCString: cKeyPtr + 1
|
||||
maxLength: size + 1
|
||||
encoding: NSASCIIStringEncoding];
|
||||
if (!GSObjCFindVariable (anObject, cKeyPtr, &type, &size, &offset))
|
||||
if ((self = [super initWithKey: aKey ofObject: anObject]) != nil)
|
||||
{
|
||||
GSObjCFindVariable (anObject, ++cKeyPtr, &type, &size, &offset);
|
||||
}
|
||||
set = GSObjCGetVal (anObject, cKeyPtr, NULL, type, size, offset);
|
||||
unsigned size = [aKey maximumLengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding];
|
||||
char cKey[size + 2];
|
||||
char *cKeyPtr = &cKey[0];
|
||||
const char *type = 0;
|
||||
|
||||
int offset;
|
||||
|
||||
|
||||
cKey[0] = '_';
|
||||
[aKey getCString: cKeyPtr + 1
|
||||
maxLength: size + 1
|
||||
encoding: NSUTF8StringEncoding];
|
||||
if (!GSObjCFindVariable (anObject, cKeyPtr, &type, &size, &offset))
|
||||
{
|
||||
GSObjCFindVariable (anObject, ++cKeyPtr, &type, &size, &offset);
|
||||
}
|
||||
set = GSObjCGetVal (anObject, cKeyPtr, NULL, type, size, offset);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -599,9 +600,9 @@
|
|||
{
|
||||
[object willChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueUnionSetMutation
|
||||
usingObjects: [NSSet setWithObject:anObject]];
|
||||
usingObjects: [NSSet setWithObject: anObject]];
|
||||
}
|
||||
[set addObject:anObject];
|
||||
[set addObject: anObject];
|
||||
if (!changeInProgress)
|
||||
{
|
||||
[object didChangeValueForKey: key
|
||||
|
@ -610,7 +611,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)removeObject: (id)anObject
|
||||
- (void) removeObject: (id)anObject
|
||||
{
|
||||
if (!changeInProgress)
|
||||
{
|
||||
|
@ -618,24 +619,24 @@
|
|||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: [NSSet setWithObject:anObject]];
|
||||
}
|
||||
[set removeObject:anObject];
|
||||
[set removeObject: anObject];
|
||||
if (!changeInProgress)
|
||||
{
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: [NSSet setWithObject:anObject]];
|
||||
usingObjects: [NSSet setWithObject: anObject]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)unionSet: (id)anObject
|
||||
- (void) unionSet: (id)anObject
|
||||
{
|
||||
if (!changeInProgress)
|
||||
{
|
||||
[object willChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueUnionSetMutation
|
||||
usingObjects: [NSSet setWithObject:anObject]];
|
||||
usingObjects: [NSSet setWithObject: anObject]];
|
||||
}
|
||||
[set unionSet:anObject];
|
||||
[set unionSet: anObject];
|
||||
if (!changeInProgress)
|
||||
{
|
||||
[object didChangeValueForKey: key
|
||||
|
@ -644,54 +645,54 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)minusSet: (id)anObject
|
||||
- (void) minusSet: (id)anObject
|
||||
{
|
||||
if (!changeInProgress)
|
||||
{
|
||||
[object willChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: [NSSet setWithObject:anObject]];
|
||||
usingObjects: [NSSet setWithObject: anObject]];
|
||||
}
|
||||
[set minusSet:anObject];
|
||||
[set minusSet: anObject];
|
||||
if (!changeInProgress)
|
||||
{
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueMinusSetMutation
|
||||
usingObjects: [NSSet setWithObject:anObject]];
|
||||
usingObjects: [NSSet setWithObject: anObject]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)intersectSet: (id)anObject
|
||||
- (void) intersectSet: (id)anObject
|
||||
{
|
||||
if (!changeInProgress)
|
||||
{
|
||||
[object willChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueIntersectSetMutation
|
||||
usingObjects: [NSSet setWithObject:anObject]];
|
||||
usingObjects: [NSSet setWithObject: anObject]];
|
||||
}
|
||||
[set intersectSet:anObject];
|
||||
[set intersectSet: anObject];
|
||||
if (!changeInProgress)
|
||||
{
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueIntersectSetMutation
|
||||
usingObjects: [NSSet setWithObject:anObject]];
|
||||
usingObjects: [NSSet setWithObject: anObject]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setSet: (id)anObject
|
||||
- (void) setSet: (id)anObject
|
||||
{
|
||||
if (!changeInProgress)
|
||||
{
|
||||
[object willChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueSetSetMutation
|
||||
usingObjects: [NSSet setWithObject:anObject]];
|
||||
usingObjects: [NSSet setWithObject: anObject]];
|
||||
}
|
||||
[set setSet:anObject];
|
||||
[set setSet: anObject];
|
||||
if (!changeInProgress)
|
||||
{
|
||||
[object didChangeValueForKey: key
|
||||
withSetMutation: NSKeyValueSetSetMutation
|
||||
usingObjects: [NSSet setWithObject:anObject]];
|
||||
usingObjects: [NSSet setWithObject: anObject]];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -4472,7 +4472,12 @@ static NSFileManager *fm = nil;
|
|||
* in XML format, the standard SGML comment sequences are used.
|
||||
* </p>
|
||||
* <p>See the documentation for [NSPropertyListSerialization] for more
|
||||
* information on what a property list is.</p>
|
||||
* information on what a property list is.
|
||||
* </p>
|
||||
* <p>If the string cannot be parsed as a normal property list format,
|
||||
* this method also tries to parse it as 'strings file' format (see the
|
||||
* -propertyListFromStringsFileFormat method).
|
||||
* </p>
|
||||
*/
|
||||
- (id) propertyList
|
||||
{
|
||||
|
@ -4496,8 +4501,22 @@ static NSFileManager *fm = nil;
|
|||
|
||||
if (result == nil)
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"Parse failed - %@", error];
|
||||
extern id GSPropertyListFromStringsFormat(NSString *string);
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
result = GSPropertyListFromStringsFormat(self);
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
result = nil;
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
if (result == nil)
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"Parse failed - %@", error];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,8 @@ main(int argc, char** argv, char **env)
|
|||
if (result == nil)
|
||||
GSPrintf(stderr, @"Parsing '%@' - nil property list\n", file);
|
||||
else if ([result isKindOfClass: [NSDictionary class]] == YES)
|
||||
GSPrintf(stderr, @"Parsing '%@' - seems ok\n", file);
|
||||
GSPrintf(stderr, @"Parsing '%@' - seems ok (%d entries)\n",
|
||||
file, [result count]);
|
||||
else
|
||||
GSPrintf(stderr, @"Parsing '%@' - unexpected class - %@\n",
|
||||
file, [[result class] description]);
|
||||
|
|
Loading…
Reference in a new issue