mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-02 11:12:58 +00:00
Merge branch 'refs/heads/CPDictionary_deprecate_nil'
This commit is contained in:
commit
7461407140
7 files changed
+103
-18
No files matched your search
@@ -208,7 +208,8 @@ var CPSharedFontManager = nil,
|
||||
|
||||
- (@action)addFontTrait:(id)sender
|
||||
{
|
||||
_activeChange = @{ @"addTraits": [sender tag] };
|
||||
var tag = [sender tag];
|
||||
_activeChange = tag === nil ? @{} : @{ @"addTraits": tag };
|
||||
|
||||
[self sendAction];
|
||||
}
|
||||
|
||||
+14
-7
@@ -148,6 +148,13 @@ var _CPMenuBarVisible = NO,
|
||||
return _CPMenuBarImage;
|
||||
}
|
||||
|
||||
+ (void)_setOrRemoveMenuBarAttribute:(id)aValue forKey:(id)aKey
|
||||
{
|
||||
if (aValue === nil)
|
||||
[_CPMenuBarAttributes removeObjectForKey:aKey];
|
||||
else
|
||||
[_CPMenuBarAttributes setObject:aValue forKey:aKey];
|
||||
}
|
||||
|
||||
+ (void)setMenuBarAttributes:(CPDictionary)attributes
|
||||
{
|
||||
@@ -172,8 +179,8 @@ var _CPMenuBarVisible = NO,
|
||||
|
||||
else if (!textColor && !titleColor)
|
||||
{
|
||||
[_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-text-color" forClass:_CPMenuView] forKey:@"CPMenuBarTextColor"];
|
||||
[_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-title-color" forClass:_CPMenuView] forKey:@"CPMenuBarTitleColor"];
|
||||
[self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-text-color" forClass:_CPMenuView] forKey:@"CPMenuBarTextColor"];
|
||||
[self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-title-color" forClass:_CPMenuView] forKey:@"CPMenuBarTitleColor"];
|
||||
}
|
||||
|
||||
if (!textShadowColor && titleShadowColor)
|
||||
@@ -184,18 +191,18 @@ var _CPMenuBarVisible = NO,
|
||||
|
||||
else if (!textShadowColor && !titleShadowColor)
|
||||
{
|
||||
[_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-text-shadow-color" forClass:_CPMenuView] forKey:@"CPMenuBarTextShadowColor"];
|
||||
[_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-title-shadow-color" forClass:_CPMenuView] forKey:@"CPMenuBarTitleShadowColor"];
|
||||
[self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-text-shadow-color" forClass:_CPMenuView] forKey:@"CPMenuBarTextShadowColor"];
|
||||
[self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-title-shadow-color" forClass:_CPMenuView] forKey:@"CPMenuBarTitleShadowColor"];
|
||||
}
|
||||
|
||||
if (!highlightColor)
|
||||
[_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-color" forClass:_CPMenuView] forKey:@"CPMenuBarHighlightColor"];
|
||||
[self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-color" forClass:_CPMenuView] forKey:@"CPMenuBarHighlightColor"];
|
||||
|
||||
if (!highlightTextColor)
|
||||
[_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-text-color" forClass:_CPMenuView] forKey:@"CPMenuBarHighlightTextColor"];
|
||||
[self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-text-color" forClass:_CPMenuView] forKey:@"CPMenuBarHighlightTextColor"];
|
||||
|
||||
if (!highlightTextShadowColor)
|
||||
[_CPMenuBarAttributes setObject:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-text-shadow-color" forClass:_CPMenuView] forKey:@"CPMenuBarHighlightTextShadowColor"];
|
||||
[self _setOrRemoveMenuBarAttribute:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-highlight-text-shadow-color" forClass:_CPMenuView] forKey:@"CPMenuBarHighlightTextShadowColor"];
|
||||
|
||||
if (_CPMenuBarSharedWindow)
|
||||
{
|
||||
|
||||
@@ -1157,7 +1157,14 @@ The sum of the views and the sum of the dividers should be equal to the size of
|
||||
_preCollapsePositions = [CPMutableDictionary new];
|
||||
|
||||
for (var i = 0, count = [preCollapseArray count]; i < count; i++)
|
||||
[_preCollapsePositions setObject:preCollapseArray[i] forKey:i + ""];
|
||||
{
|
||||
var item = preCollapseArray[i];
|
||||
|
||||
if (item === nil)
|
||||
[_preCollapsePositions removeObjectForKey:String(i)];
|
||||
else
|
||||
[_preCollapsePositions setObject:item forKey:String(i)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
@import "CPObject.j"
|
||||
#import "Ref.h"
|
||||
|
||||
//FIXME: After release of 0.9.7 remove below variable
|
||||
var CPDictionaryShowNilDeprecationMessage = YES;
|
||||
|
||||
/* @ignore */
|
||||
@implementation _CPDictionaryValueEnumerator : CPEnumerator
|
||||
{
|
||||
@@ -254,14 +257,37 @@
|
||||
self = [super init];
|
||||
|
||||
if ([objects count] != [keyArray count])
|
||||
[CPException raise:CPInvalidArgumentException reason:"Counts are different.(" + [objects count] + "!=" + [keyArray count] + ")"];
|
||||
[CPException raise:CPInvalidArgumentException reason:[CPString stringWithFormat:@"Counts are different.(%d != %d)", [objects count], [keyArray count]]];
|
||||
|
||||
if (self)
|
||||
{
|
||||
var i = [keyArray count];
|
||||
|
||||
while (i--)
|
||||
[self setObject:objects[i] forKey:keyArray[i]];
|
||||
{
|
||||
var value = objects[i],
|
||||
key = keyArray[i];
|
||||
|
||||
if (value === nil)
|
||||
{
|
||||
CPDictionaryShowNilDeprecationMessage = NO;
|
||||
CPLog.warn([CPString stringWithFormat:@"[%s %s] DEPRECATED: Attempt to insert nil object from objects[%d]", [self className], _cmd, i]);
|
||||
objj_backtrace_print(CPLog.warn);
|
||||
// FIXME: After release of 0.9.7 change 3 lines above to this:
|
||||
// [CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil object from objects[" + i + @"]"];
|
||||
}
|
||||
|
||||
if (key === nil)
|
||||
{
|
||||
CPDictionaryShowNilDeprecationMessage = NO;
|
||||
CPLog.warn([CPString stringWithFormat:@"[%s %s] DEPRECATED: Attempt to insert nil key from keys[%d]", [self className], _cmd, i]);
|
||||
objj_backtrace_print(CPLog.warn);
|
||||
// FIXME: After release of 0.9.7 change 3 lines above to this:
|
||||
// [CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil key from keys[" + i + @"]"];
|
||||
}
|
||||
|
||||
[self setObject:value forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -297,12 +323,28 @@
|
||||
|
||||
for (; index < argCount; index += 2)
|
||||
{
|
||||
var value = arguments[index];
|
||||
var value = arguments[index],
|
||||
key = arguments[index + 1];
|
||||
|
||||
if (value === nil)
|
||||
continue;
|
||||
{
|
||||
CPDictionaryShowNilDeprecationMessage = NO;
|
||||
CPLog.warn([CPString stringWithFormat:@"[%s %s] DEPRECATED: Attempt to insert nil object from objects[%d]", [self className], _cmd, (index / 2) - 1]);
|
||||
objj_backtrace_print(CPLog.warn);
|
||||
// FIXME: After release of 0.9.7 change 3 lines above to this:
|
||||
// [CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil object from objects[" + ((index / 2) - 1) + @"]"];
|
||||
}
|
||||
|
||||
[self setObject:value forKey:arguments[index + 1]];
|
||||
if (key === nil)
|
||||
{
|
||||
CPDictionaryShowNilDeprecationMessage = NO;
|
||||
CPLog.warn([CPString stringWithFormat:@"[%s %s] DEPRECATED: Attempt to insert nil key from keys[%d]", [self className], _cmd, (index / 2) - 1]);
|
||||
objj_backtrace_print(CPLog.warn);
|
||||
// FIXME: After release of 0.9.7 change 3 lines above to this:
|
||||
// [CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil key from keys[" + ((index / 2) - 1) + @"]"];
|
||||
}
|
||||
|
||||
[self setObject:value forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,6 +653,29 @@
|
||||
*/
|
||||
- (void)setObject:(id)anObject forKey:(id)aKey
|
||||
{
|
||||
// FIXME: After release of 0.9.7, remove this test and leave the contents of its block
|
||||
if (CPDictionaryShowNilDeprecationMessage)
|
||||
{
|
||||
if (aKey === nil)
|
||||
{
|
||||
CPLog.warn([CPString stringWithFormat:@"[%s %s] DEPRECATED: key cannot be nil", [self className], _cmd]);
|
||||
objj_backtrace_print(CPLog.warn);
|
||||
// FIXME: After release of 0.9.7 change 2 lines above to this:
|
||||
// [CPException raise:CPInvalidArgumentException reason:@"key cannot be nil"];
|
||||
}
|
||||
|
||||
if (anObject === nil)
|
||||
{
|
||||
CPLog.warn([CPString stringWithFormat:@"[%s %s] DEPRECATED: object cannot be nil (key: %s)", [self className], _cmd, aKey]);
|
||||
objj_backtrace_print(CPLog.warn);
|
||||
// FIXME: After release of 0.9.7 change 2 lines above to this:
|
||||
// [CPException raise:CPInvalidArgumentException reason:@"object cannot be nil (key: " + aKey + @")"];
|
||||
}
|
||||
}
|
||||
// FIXME: After release of 0.9.7 remove 2 lines below.
|
||||
else
|
||||
CPDictionaryShowNilDeprecationMessage = YES;
|
||||
|
||||
self.setValueForKey(aKey, anObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -503,7 +503,8 @@ var _CPKeyedArchiverEncodeObject = function(self, anObject, isConditional)
|
||||
}
|
||||
}
|
||||
|
||||
[self._replacementObjects setObject:object forKey:GUID];
|
||||
if (object != nil && GUID != nil)
|
||||
[self._replacementObjects setObject:object forKey:GUID];
|
||||
}
|
||||
|
||||
// If we still don't have an object by this point, then return a
|
||||
|
||||
@@ -342,7 +342,10 @@ var StandardUserDefaults;
|
||||
var data = [[self persistentStoreForDomain:aDomain] data],
|
||||
domain = data ? [CPKeyedUnarchiver unarchiveObjectWithData:data] : nil;
|
||||
|
||||
[_domains setObject:domain forKey:aDomain];
|
||||
if (domain === nil)
|
||||
[_domains removeObjectForKey:aDomain];
|
||||
else
|
||||
[_domains setObject:domain forKey:aDomain];
|
||||
|
||||
_searchListNeedsReload = YES;
|
||||
}
|
||||
|
||||
@@ -200,13 +200,14 @@
|
||||
[self assertFalse:[dict containsKey:"4"]];
|
||||
}
|
||||
|
||||
// FIXME: When CPDictionary will throw exception on nil value the following test case can be turn on again
|
||||
/*
|
||||
- (void)testThrowsOnNilValue
|
||||
{
|
||||
[self assertThrows:function(){
|
||||
var dict = [[CPDictionary alloc] initWithObjects:[1, nil] forKeys:["1", "2"]];
|
||||
[self assertFalse:dict];
|
||||
}];
|
||||
}
|
||||
}*/
|
||||
|
||||
- (void)testKeysOfEntriesPassingTest
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user