Fix accidental globals, cleanup.

This commit is contained in:
Alexander Ljungberg
2010-12-15 16:02:50 +01:00
parent 251ba407be
commit 8edee4e755
4 changed files with 29 additions and 24 deletions
+2 -2
View File
@@ -145,8 +145,8 @@ if (input == nil)
if (!anObject || !anObject.isa)
return NO;
return [anObject isKindOfClass:CPException] &&
name === [anObject name] &&
return [anObject isKindOfClass:CPException] &&
name === [anObject name] &&
message === [anObject message] &&
(_userInfo === [anObject userInfo] || ([_userInfo isEqual:[anObject userInfo]]));
}
+7 -4
View File
@@ -252,11 +252,14 @@ var _ivarForKey = function(theObject, aKey)
- (void)setValuesForKeysWithDictionary:(CPDictionary)keyedValues
{
var value, key, keyEnumerator = [keyedValues keyEnumerator];
while(key = [keyEnumerator nextObject])
var value,
key,
keyEnumerator = [keyedValues keyEnumerator];
while (key = [keyEnumerator nextObject])
{
value = [keyedValues objectForKey: key];
if(value === [CPNull null])
if (value === [CPNull null])
[self setValue: nil forKey: key];
else
[self setValue: value forKey: key];
@@ -284,7 +287,7 @@ var _ivarForKey = function(theObject, aKey)
- (void)setValue:(id)aValue forKey:(CPString)aKey
{
if(aValue)
if (aValue)
[self setObject:aValue forKey:aKey];
else
[self removeObjectForKey: aKey];
+19 -17
View File
@@ -92,7 +92,7 @@
newValue = [aChange objectForKey:CPKeyValueChangeNewKey],
indexes = [aChange objectForKey:CPKeyValueChangeIndexesKey];
if(newValue === [CPNull null])
if (newValue === [CPNull null])
newValue = nil;
if (changeKind === CPKeyValueChangeSetting)
@@ -102,7 +102,7 @@
}
//decide if this is a unordered or ordered to-many relationship
if([newValue isKindOfClass: [CPSet class]] || [oldValue isKindOfClass: [CPSet class]])
if ([newValue isKindOfClass: [CPSet class]] || [oldValue isKindOfClass: [CPSet class]])
{
if (changeKind === CPKeyValueChangeInsertion)
[[self mutableSetValueForKeyPath:aKeyPath] unionSet:newValue];
@@ -205,7 +205,7 @@ _CPKeyValueChangeSetMutationNewValueKey = @"_CPKeyValueChangeSetMutationNewValue
var _changeKindForSetMutationKind = function(mutationKind)
{
switch(mutationKind)
switch (mutationKind)
{
case CPKeyValueUnionSetMutation:
return CPKeyValueChangeInsertion;
@@ -247,7 +247,7 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld,
- (id)initWithTarget:(id)aTarget
{
if(self = [super init])
if (self = [super init])
{
_targetObject = aTarget;
_nativeClass = [aTarget class];
@@ -460,14 +460,15 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld,
{
changes = changeOptions;
var indexes = [changes objectForKey:CPKeyValueChangeIndexesKey];
var setMutationKind = changes[_CPKeyValueChangeSetMutationKindKey];
var indexes = [changes objectForKey:CPKeyValueChangeIndexesKey],
setMutationKind = changes[_CPKeyValueChangeSetMutationKindKey];
if(setMutationKind)
if (setMutationKind)
{
var setMutationObjects = [changes[_CPKeyValueChangeSetMutationObjectsKey] copy];
var setExistingObjects = [[_targetObject valueForKey: aKey] copy];
if(setMutationKind == CPKeyValueMinusSetMutation)
var setMutationObjects = [changes[_CPKeyValueChangeSetMutationObjectsKey] copy],
setExistingObjects = [[_targetObject valueForKey: aKey] copy];
if (setMutationKind == CPKeyValueMinusSetMutation)
{
[setExistingObjects intersectSet: setMutationObjects];
[changes setValue:setExistingObjects forKey:CPKeyValueChangeOldKey];
@@ -477,13 +478,13 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld,
[setExistingObjects minusSet: setMutationObjects];
[changes setValue:setExistingObjects forKey:CPKeyValueChangeOldKey];
}
//for unordered to-many relationships (CPSet) even new values can only be calculated before!!!
if (setMutationKind === CPKeyValueUnionSetMutation || setMutationKind === CPKeyValueSetSetMutation)
{
[setMutationObjects minusSet: setExistingObjects];
//hide new value (for CPKeyValueObservingOptionPrior messages)
//as long as "didChangeValue..." is not yet called!
//as long as "didChangeValue..." is not yet called!
changes[_CPKeyValueChangeSetMutationNewValueKey] = setMutationObjects;
}
}
@@ -519,10 +520,10 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld,
[changes removeObjectForKey:CPKeyValueChangeNotificationIsPriorKey];
var indexes = [changes objectForKey:CPKeyValueChangeIndexesKey];
var setMutationKind = changes[_CPKeyValueChangeSetMutationKindKey];
var indexes = [changes objectForKey:CPKeyValueChangeIndexesKey],
setMutationKind = changes[_CPKeyValueChangeSetMutationKindKey];
if(setMutationKind)
if (setMutationKind)
{
//old and new values for unordered to-many relationships can only be calculated before
//set precalculated hidden new value as soon as "didChangeValue..." is called!
@@ -668,8 +669,9 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld,
if (!aKey)
return;
var changeKind = _changeKindForSetMutationKind(mutationKind);
var changeOptions = [CPDictionary dictionaryWithObject:changeKind forKey:CPKeyValueChangeKindKey];
var changeKind = _changeKindForSetMutationKind(mutationKind),
changeOptions = [CPDictionary dictionaryWithObject:changeKind forKey:CPKeyValueChangeKindKey];
//set hidden change-dict ivars to support unordered to-many relationships
changeOptions[_CPKeyValueChangeSetMutationObjectsKey] = objects;
changeOptions[_CPKeyValueChangeSetMutationKindKey] = mutationKind;
+1 -1
View File
@@ -39,7 +39,7 @@ var _CPKeyedUnarchiverCannotDecodeObjectOfClassNameOriginalClassesSelector
_CPKeyedUnarchiverDidFinishSelector = 1 << 4,
CPKeyedUnarchiverDelegate_unarchiver_cannotDecodeObjectOfClassName_originalClasses_ = 1 << 5;
var _CPKeyedArchiverNullString = "$null"
var _CPKeyedArchiverNullString = "$null",
_CPKeyedArchiverUIDKey = "CP$UID",