diff --git a/Foundation/CPException.j b/Foundation/CPException.j index feac9eb6d..68b0d4279 100755 --- a/Foundation/CPException.j +++ b/Foundation/CPException.j @@ -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]])); } diff --git a/Foundation/CPKeyValueCoding.j b/Foundation/CPKeyValueCoding.j index d530e4e3b..a4b02c50d 100644 --- a/Foundation/CPKeyValueCoding.j +++ b/Foundation/CPKeyValueCoding.j @@ -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]; diff --git a/Foundation/CPKeyValueObserving.j b/Foundation/CPKeyValueObserving.j index fc9deadea..8fc5ca9ac 100644 --- a/Foundation/CPKeyValueObserving.j +++ b/Foundation/CPKeyValueObserving.j @@ -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; diff --git a/Foundation/CPKeyedUnarchiver.j b/Foundation/CPKeyedUnarchiver.j index e5c0823f5..a98853038 100644 --- a/Foundation/CPKeyedUnarchiver.j +++ b/Foundation/CPKeyedUnarchiver.j @@ -39,7 +39,7 @@ var _CPKeyedUnarchiverCannotDecodeObjectOfClassNameOriginalClassesSelector _CPKeyedUnarchiverDidFinishSelector = 1 << 4, CPKeyedUnarchiverDelegate_unarchiver_cannotDecodeObjectOfClassName_originalClasses_ = 1 << 5; -var _CPKeyedArchiverNullString = "$null" +var _CPKeyedArchiverNullString = "$null", _CPKeyedArchiverUIDKey = "CP$UID",