From 36bfc7c6759e1edcf14bb7b208b78aea5f128ac2 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Tue, 24 Apr 2012 10:15:19 +0200 Subject: [PATCH] Fixed decode methods to return the correct defaults, removed unnecessary containsValueForKey and || with defaults --- AppKit/CPButton.j | 4 +--- AppKit/CPCollectionView.j | 8 ++++---- AppKit/CPImageView.j | 2 +- AppKit/CPMenuItem/CPMenuItem.j | 23 +++++++++++------------ AppKit/CPObjectController.j | 2 +- AppKit/CPRuleEditor/CPPredicateEditor.j | 9 ++++++--- AppKit/CPScrollView.j | 4 ++-- AppKit/CPStepper.j | 8 ++++---- AppKit/CPTableView.j | 11 +++++------ AppKit/CPView.j | 8 ++------ AppKit/Cib/_CPCibWindowTemplate.j | 4 ++-- Foundation/CPKeyedUnarchiver.j | 25 ++++++++++++++++--------- Tools/nib2cib/NSBox.j | 3 ++- Tools/nib2cib/NSLevelIndicator.j | 10 +++++----- Tools/nib2cib/NSMenuItem.j | 4 ++-- Tools/nib2cib/NSProgressIndicator.j | 2 +- Tools/nib2cib/NSSearchField.j | 4 ++-- Tools/nib2cib/NSSegmentedControl.j | 8 ++++++-- Tools/nib2cib/NSSlider.j | 2 +- Tools/nib2cib/NSSplitView.j | 2 +- Tools/nib2cib/NSTableView.j | 2 +- Tools/nib2cib/NSTokenField.j | 2 +- Tools/nib2cib/NSToolbarItem.j | 4 ++-- Tools/nib2cib/NSView.j | 5 +---- 24 files changed, 80 insertions(+), 76 deletions(-) diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j index 24a758d2f..b79b72c93 100644 --- a/AppKit/CPButton.j +++ b/AppKit/CPButton.j @@ -802,9 +802,7 @@ var CPButtonImageKey = @"CPButtonImageKey", _title = [aCoder decodeObjectForKey:CPButtonTitleKey]; _alternateTitle = [aCoder decodeObjectForKey:CPButtonAlternateTitleKey]; - - if ([aCoder containsValueForKey:CPButtonAllowsMixedStateKey]) - _allowsMixedState = [aCoder decodeBoolForKey:CPButtonAllowsMixedStateKey]; + _allowsMixedState = [aCoder decodeBoolForKey:CPButtonAllowsMixedStateKey]; [self setImageDimsWhenDisabled:[aCoder decodeObjectForKey:CPButtonImageDimsWhenDisabledKey]]; diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j index 650797813..3053b67e7 100644 --- a/AppKit/CPCollectionView.j +++ b/AppKit/CPCollectionView.j @@ -1001,11 +1001,11 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeK _itemSize = CGSizeMakeZero(); - _minItemSize = [aCoder decodeSizeForKey:CPCollectionViewMinItemSizeKey] || CGSizeMakeZero(); - _maxItemSize = [aCoder decodeSizeForKey:CPCollectionViewMaxItemSizeKey] || CGSizeMakeZero(); + _minItemSize = [aCoder decodeSizeForKey:CPCollectionViewMinItemSizeKey]; + _maxItemSize = [aCoder decodeSizeForKey:CPCollectionViewMaxItemSizeKey]; - _maxNumberOfRows = [aCoder decodeIntForKey:CPCollectionViewMaxNumberOfRowsKey] || 0; - _maxNumberOfColumns = [aCoder decodeIntForKey:CPCollectionViewMaxNumberOfColumnsKey] || 0; + _maxNumberOfRows = [aCoder decodeIntForKey:CPCollectionViewMaxNumberOfRowsKey]; + _maxNumberOfColumns = [aCoder decodeIntForKey:CPCollectionViewMaxNumberOfColumnsKey]; _verticalMargin = [aCoder decodeFloatForKey:CPCollectionViewVerticalMarginKey]; diff --git a/AppKit/CPImageView.j b/AppKit/CPImageView.j index 535a7f86c..8540a9c1c 100644 --- a/AppKit/CPImageView.j +++ b/AppKit/CPImageView.j @@ -516,7 +516,7 @@ var CPImageViewImageKey = @"CPImageViewImageKey", [self setHasShadow:[aCoder decodeBoolForKey:CPImageViewHasShadowKey]]; [self setImageAlignment:[aCoder decodeIntForKey:CPImageViewImageAlignmentKey]]; - if ([aCoder decodeBoolForKey:CPImageViewIsEditableKey] || NO) + if ([aCoder decodeBoolForKey:CPImageViewIsEditableKey]) [self setEditable:YES]; [self setNeedsLayout]; diff --git a/AppKit/CPMenuItem/CPMenuItem.j b/AppKit/CPMenuItem/CPMenuItem.j index 6d70ba1b4..063fed763 100644 --- a/AppKit/CPMenuItem/CPMenuItem.j +++ b/AppKit/CPMenuItem/CPMenuItem.j @@ -932,34 +932,33 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey", _action = [aCoder decodeObjectForKey:CPMenuItemActionKey]; _isEnabled = DEFAULT_VALUE(CPMenuItemIsEnabledKey, YES); - _isHidden = DEFAULT_VALUE(CPMenuItemIsHiddenKey, NO); - _tag = DEFAULT_VALUE(CPMenuItemTagKey, 0); - _state = DEFAULT_VALUE(CPMenuItemStateKey, CPOffState); + _isHidden = [aCoder decodeBoolForKey:CPMenuItemIsHiddenKey]; + _tag = [aCoder decodeIntForKey:CPMenuItemTagKey]; + _state = [aCoder decodeIntForKey:CPMenuItemStateKey]; - _image = DEFAULT_VALUE(CPMenuItemImageKey, nil); - _alternateImage = DEFAULT_VALUE(CPMenuItemAlternateImageKey, nil); + _image = [aCoder decodeObjectForKey:CPMenuItemImageKey]; + _alternateImage = [aCoder decodeObjectForKey:CPMenuItemAlternateImageKey]; // CPImage _onStateImage; // CPImage _offStateImage; // CPImage _mixedStateImage; // This order matters because setSubmenu: needs _menu to be around. - _menu = DEFAULT_VALUE(CPMenuItemMenuKey, nil); - [self setSubmenu:DEFAULT_VALUE(CPMenuItemSubmenuKey, nil)]; + _menu = [aCoder decodeObjectForKey:CPMenuItemMenuKey]; + [self setSubmenu:[aCoder decodeObjectForKey:CPMenuItemSubmenuKey]]; _keyEquivalent = [aCoder decodeObjectForKey:CPMenuItemKeyEquivalentKey] || @""; - _keyEquivalentModifierMask = [aCoder decodeObjectForKey:CPMenuItemKeyEquivalentModifierMaskKey] || 0; + _keyEquivalentModifierMask = [aCoder decodeIntForKey:CPMenuItemKeyEquivalentModifierMaskKey]; // int _mnemonicLocation; // BOOL _isAlternate; - // Default is 0. - [self setIndentationLevel:[aCoder decodeIntForKey:CPMenuItemIndentationLevelKey] || 0]; + [self setIndentationLevel:[aCoder decodeIntForKey:CPMenuItemIndentationLevelKey]]; // CPString _toolTip; - _representedObject = DEFAULT_VALUE(CPMenuItemRepresentedObjectKey, nil); - _view = DEFAULT_VALUE(CPMenuItemViewKey, nil); + _representedObject = [aCoder decodeObjectForKey:CPMenuItemRepresentedObjectKey]; + _view = [aCoder decodeObjectForKey:CPMenuItemViewKey]; } return self; diff --git a/AppKit/CPObjectController.j b/AppKit/CPObjectController.j index 4905413e8..8999f84da 100644 --- a/AppKit/CPObjectController.j +++ b/AppKit/CPObjectController.j @@ -371,7 +371,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo [self setObjectClass:objectClass || [CPMutableDictionary class]]; [self setEditable:[aCoder decodeBoolForKey:CPObjectControllerIsEditableKey]]; - [self setAutomaticallyPreparesContent:[aCoder decodeBoolForKey:CPObjectControllerAutomaticallyPreparesContentKey] || NO]; + [self setAutomaticallyPreparesContent:[aCoder decodeBoolForKey:CPObjectControllerAutomaticallyPreparesContentKey]]; [self setContent:[aCoder decodeObjectForKey:CPObjectControllerContentKey]]; _observedKeys = [[CPCountedSet alloc] init]; diff --git a/AppKit/CPRuleEditor/CPPredicateEditor.j b/AppKit/CPRuleEditor/CPPredicateEditor.j index 5c4aadb64..ebf1985d2 100644 --- a/AppKit/CPRuleEditor/CPPredicateEditor.j +++ b/AppKit/CPRuleEditor/CPPredicateEditor.j @@ -374,12 +374,13 @@ if (rowType == CPRuleEditorRowTypeCompound) { var subrows = [rowItem valueForKey:_subrowsArrayKeyPath], - count = [subrows count]; + count = [subrows count]; for (var i = 0; i < count; i++) { - var subrow = [subrows objectAtIndex:i]; - var predicate = [self _predicateFromRowItem:subrow]; + var subrow = [subrows objectAtIndex:i], + predicate = [self _predicateFromRowItem:subrow]; + [subpredicates addObject:predicate]; } } @@ -484,9 +485,11 @@ var CPPredicateTemplatesKey = @"CPPredicateTemplates"; - (id)initWithCoder:(id)aCoder { self = [super initWithCoder:aCoder]; + if (self != nil) { var nibTemplates = [aCoder decodeObjectForKey:CPPredicateTemplatesKey]; + if (nibTemplates != nil) [self setRowTemplates:nibTemplates]; } diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j index 391389553..1d55fc2bd 100644 --- a/AppKit/CPScrollView.j +++ b/AppKit/CPScrollView.j @@ -1506,8 +1506,8 @@ var CPScrollViewContentViewKey = @"CPScrollViewContentView", _scrollTimer = nil; _implementedDelegateMethods = 0; - _scrollerStyle = [aCoder decodeIntForKey:CPScrollViewScrollerStyleKey] || CPScrollerStyleGlobal; - _scrollerKnobStyle = [aCoder decodeIntForKey:CPScrollViewScrollerKnobStyleKey] || CPScrollerKnobStyleDefault; + _scrollerStyle = [aCoder decodeObjectForKey:CPScrollViewScrollerStyleKey] || CPScrollerStyleGlobal; + _scrollerKnobStyle = [aCoder decodeObjectForKey:CPScrollViewScrollerKnobStyleKey] || CPScrollerKnobStyleDefault; [[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_didReceiveDefaultStyleChange:) diff --git a/AppKit/CPStepper.j b/AppKit/CPStepper.j index 6ad75afe1..b16833262 100644 --- a/AppKit/CPStepper.j +++ b/AppKit/CPStepper.j @@ -263,10 +263,10 @@ var CPStepperMinValue = @"CPStepperMinValue", if (self = [super initWithCoder:aCoder]) { _increment = [aCoder decodeIntForKey:CPStepperIncrement]; - _minValue = [aCoder decodeIntForKey:CPStepperMinValue] || 0; - _maxValue = [aCoder decodeIntForKey:CPStepperMaxValue] || 0; - _valueWraps = [aCoder decodeBoolForKey:CPStepperValueWraps] || NO; - _autorepeat = [aCoder decodeBoolForKey:CPStepperAutorepeat] || NO; + _minValue = [aCoder decodeIntForKey:CPStepperMinValue]; + _maxValue = [aCoder decodeIntForKey:CPStepperMaxValue]; + _valueWraps = [aCoder decodeBoolForKey:CPStepperValueWraps]; + _autorepeat = [aCoder decodeBoolForKey:CPStepperAutorepeat]; [self _init]; } diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 7fb26a8bf..38b86ff85 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -4782,15 +4782,14 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey", _tableColumns = [aCoder decodeObjectForKey:CPTableViewTableColumnsKey] || []; [_tableColumns makeObjectsPerformSelector:@selector(setTableView:) withObject:self]; - if ([aCoder containsValueForKey:CPTableViewRowHeightKey]) - _rowHeight = [aCoder decodeFloatForKey:CPTableViewRowHeightKey]; - else - _rowHeight = 23.0; + _rowHeight = [aCoder decodeFloatForKey:CPTableViewRowHeightKey] || 23.0; + _intercellSpacing = [aCoder decodeSizeForKey:CPTableViewIntercellSpacingKey]; - _intercellSpacing = [aCoder decodeSizeForKey:CPTableViewIntercellSpacingKey] || _CGSizeMake(3.0, 2.0); + if (_CGSizeEqualToSize(_intercellSpacing, _CGSizeMakeZero())) + _intercellSpacing = _CGSizeMake(3.0, 2.0); [self setGridColor:[aCoder decodeObjectForKey:CPTableViewGridColorKey]]; - _gridStyleMask = [aCoder decodeIntForKey:CPTableViewGridStyleMaskKey] || CPTableViewGridNone; + _gridStyleMask = [aCoder decodeIntForKey:CPTableViewGridStyleMaskKey]; _usesAlternatingRowBackgroundColors = [aCoder decodeObjectForKey:CPTableViewUsesAlternatingBackgroundKey]; [self setAlternatingRowBackgroundColors:[aCoder decodeObjectForKey:CPTableViewAlternatingRowColorsKey]]; diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 7129b8cad..deb71c195 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -2761,7 +2761,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", _autoresizesSubviews = ![aCoder containsValueForKey:CPViewAutoresizesSubviewsKey] || [aCoder decodeBoolForKey:CPViewAutoresizesSubviewsKey]; - _hitTests = ![aCoder containsValueForKey:CPViewHitTestsKey] || [aCoder decodeObjectForKey:CPViewHitTestsKey]; + _hitTests = ![aCoder containsValueForKey:CPViewHitTestsKey] || [aCoder decodeBoolForKey:CPViewHitTestsKey]; // DOM SETUP #if PLATFORM(DOM) @@ -2781,10 +2781,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", } #endif - if ([aCoder containsValueForKey:CPViewIsHiddenKey]) - [self setHidden:[aCoder decodeBoolForKey:CPViewIsHiddenKey]]; - else - _isHidden = NO; + [self setHidden:[aCoder decodeBoolForKey:CPViewIsHiddenKey]]; if ([aCoder containsValueForKey:CPViewOpacityKey]) [self setAlphaValue:[aCoder decodeIntForKey:CPViewOpacityKey]]; @@ -2792,7 +2789,6 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", _opacity = 1.0; [self setBackgroundColor:[aCoder decodeObjectForKey:CPViewBackgroundColorKey]]; - [self setupViewFlags]; _theme = [CPTheme defaultTheme]; diff --git a/AppKit/Cib/_CPCibWindowTemplate.j b/AppKit/Cib/_CPCibWindowTemplate.j index 6d232a76c..9ea2b4096 100644 --- a/AppKit/Cib/_CPCibWindowTemplate.j +++ b/AppKit/Cib/_CPCibWindowTemplate.j @@ -77,8 +77,8 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemp _windowTitle = [aCoder decodeObjectForKey:_CPCibWindowTemplateWindowTitleKey]; _windowView = [aCoder decodeObjectForKey:_CPCibWindowTemplateWindowViewKey]; - _windowAutorecalculatesKeyViewLoop = !![aCoder decodeObjectForKey:_CPCibWindowTemplateWindowAutorecalculatesKeyViewLoop]; - _windowIsFullPlatformWindow = !![aCoder decodeObjectForKey:_CPCibWindowTemplateWindowIsFullPlatformWindowKey]; + _windowAutorecalculatesKeyViewLoop = [aCoder decodeBoolForKey:_CPCibWindowTemplateWindowAutorecalculatesKeyViewLoop]; + _windowIsFullPlatformWindow = [aCoder decodeBoolForKey:_CPCibWindowTemplateWindowIsFullPlatformWindowKey]; } return self; diff --git a/Foundation/CPKeyedUnarchiver.j b/Foundation/CPKeyedUnarchiver.j index 22cef5289..9d5f0a3f6 100644 --- a/Foundation/CPKeyedUnarchiver.j +++ b/Foundation/CPKeyedUnarchiver.j @@ -251,7 +251,9 @@ var CPArrayClass = Ni */ - (float)decodeFloatForKey:(CPString)aKey { - return [self decodeObjectForKey:aKey]; + var f = [self decodeObjectForKey:aKey]; + + return f === nil ? 0.0 : f; } /* @@ -261,7 +263,9 @@ var CPArrayClass = Ni */ - (double)decodeDoubleForKey:(CPString)aKey { - return [self decodeObjectForKey:aKey]; + var d = [self decodeObjectForKey:aKey]; + + return d === nil ? 0.0 : d; } /* @@ -271,7 +275,9 @@ var CPArrayClass = Ni */ - (int)decodeIntForKey:(CPString)aKey { - return [self decodeObjectForKey:aKey]; + var i = [self decodeObjectForKey:aKey]; + + return i === nil ? 0 : i; } /* @@ -284,9 +290,9 @@ var CPArrayClass = Ni var object = [self decodeObjectForKey:aKey]; if (object) - return CPPointFromString(object); + return CGPointFromString(object); else - return CPPointMake(0.0, 0.0); + return CGPointMakeZero(); } /* @@ -299,9 +305,9 @@ var CPArrayClass = Ni var object = [self decodeObjectForKey:aKey]; if (object) - return CPRectFromString(object); + return CGRectFromString(object); else - return CPRectMakeZero(); + return CGRectMakeZero(); } /* @@ -314,9 +320,9 @@ var CPArrayClass = Ni var object = [self decodeObjectForKey:aKey]; if (object) - return CPSizeFromString(object); + return CGSizeFromString(object); else - return CPSizeMake(0.0, 0.0); + return CGSizeMakeZero(); } /* @@ -366,6 +372,7 @@ var CPArrayClass = Ni return nil; var objectClass = data.isa; + if (objectClass === CPDataClass) return data.bytes(); diff --git a/Tools/nib2cib/NSBox.j b/Tools/nib2cib/NSBox.j index 86e74b8c1..17ec6c6f1 100644 --- a/Tools/nib2cib/NSBox.j +++ b/Tools/nib2cib/NSBox.j @@ -36,13 +36,14 @@ _borderColor = [aCoder decodeObjectForKey:@"NSBorderColor2"] || [CPColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.42]; _fillColor = [aCoder decodeObjectForKey:@"NSFillColor2"] || [CPColor clearColor]; - _cornerRadius = [aCoder decodeFloatForKey:@"NSCornerRadius2"] || 0.0; + _cornerRadius = [aCoder decodeFloatForKey:@"NSCornerRadius2"]; _borderWidth = [aCoder decodeFloatForKey:@"NSBorderWidth2"] || 1.0; _contentMargin = [aCoder decodeSizeForKey:@"NSOffsets"]; _title = [[aCoder decodeObjectForKey:@"NSTitleCell"] objectValue] || @""; _titlePosition = [aCoder decodeObjectForKey:@"NSTitlePosition"]; + if (_titlePosition === undefined) _titlePosition = CPAtTop; } diff --git a/Tools/nib2cib/NSLevelIndicator.j b/Tools/nib2cib/NSLevelIndicator.j index 44245daec..8e936d566 100644 --- a/Tools/nib2cib/NSLevelIndicator.j +++ b/Tools/nib2cib/NSLevelIndicator.j @@ -102,17 +102,17 @@ { _objectValue = [aCoder decodeDoubleForKey:@"NSValue"]; - _minValue = [aCoder decodeDoubleForKey:@"NSMinValue"] || 0; + _minValue = [aCoder decodeDoubleForKey:@"NSMinValue"]; _maxValue = [aCoder decodeDoubleForKey:@"NSMaxValue"]; _warningValue = [aCoder decodeDoubleForKey:@"NSWarningValue"]; _criticalValue = [aCoder decodeDoubleForKey:@"NSCriticalValue"]; - _levelIndicatorStyle = [aCoder decodeIntForKey:@"NSIndicatorStyle"] || 0; + _levelIndicatorStyle = [aCoder decodeIntForKey:@"NSIndicatorStyle"]; // None of these are included in the XIB if the defaults are used. - _tickMarkPosition = [aCoder decodeIntForKey:@"NSTickMarkPosition"] || 0; - _numberOfTickMarks = [aCoder decodeIntForKey:@"NSNumberOfTickMarks"] || 0; - _numberOfTickMarks = [aCoder decodeIntForKey:@"NSNumberOfMajorTickMarks"] || 0; + _tickMarkPosition = [aCoder decodeIntForKey:@"NSTickMarkPosition"]; + _numberOfTickMarks = [aCoder decodeIntForKey:@"NSNumberOfTickMarks"]; + _numberOfTickMarks = [aCoder decodeIntForKey:@"NSNumberOfMajorTickMarks"]; } return self; diff --git a/Tools/nib2cib/NSMenuItem.j b/Tools/nib2cib/NSMenuItem.j index 5ce252950..bc7b8b740 100644 --- a/Tools/nib2cib/NSMenuItem.j +++ b/Tools/nib2cib/NSMenuItem.j @@ -34,7 +34,7 @@ if (self) { - _isSeparator = [aCoder decodeObjectForKey:@"NSIsSeparator"] || NO; + _isSeparator = [aCoder decodeBoolForKey:@"NSIsSeparator"]; _title = [aCoder decodeObjectForKey:"NSTitle"]; @@ -109,4 +109,4 @@ { } -@end \ No newline at end of file +@end diff --git a/Tools/nib2cib/NSProgressIndicator.j b/Tools/nib2cib/NSProgressIndicator.j index c3bc5505e..11d8bae12 100644 --- a/Tools/nib2cib/NSProgressIndicator.j +++ b/Tools/nib2cib/NSProgressIndicator.j @@ -34,7 +34,7 @@ var NSProgressIndicatorSpinningFlag = 1 << 12; { var NS_flags = [aCoder decodeIntForKey:@"NSpiFlags"]; - _minValue = [aCoder decodeDoubleForKey:@"NSMinValue"] || 0; + _minValue = [aCoder decodeDoubleForKey:@"NSMinValue"]; _maxValue = [aCoder decodeDoubleForKey:@"NSMaxValue"]; _style = (NS_flags & NSProgressIndicatorSpinningFlag) ? CPProgressIndicatorSpinningStyle : CPProgressIndicatorBarStyle; diff --git a/Tools/nib2cib/NSSearchField.j b/Tools/nib2cib/NSSearchField.j index d002a7d4a..ce762cc80 100644 --- a/Tools/nib2cib/NSSearchField.j +++ b/Tools/nib2cib/NSSearchField.j @@ -84,10 +84,10 @@ { _recentsAutosaveName = [aCoder decodeObjectForKey:@"NSRecentsAutosaveName"]; _maximumRecents = [aCoder decodeIntForKey:@"NSMaximumRecents"]; - _sendsWholeSearchString = [aCoder decodeBoolForKey:@"NSSendsWholeSearchString"] ? YES : NO; + _sendsWholeSearchString = [aCoder decodeBoolForKey:@"NSSendsWholeSearchString"]; // These bytes don't seem to be used for anything else but the send immediately flag - _sendsSearchStringImmediately = [aCoder decodeBytesForKey:@"NSSearchFieldFlags"] ? YES: NO; + _sendsSearchStringImmediately = [aCoder decodeBytesForKey:@"NSSearchFieldFlags"] ? YES : NO; } return self; diff --git a/Tools/nib2cib/NSSegmentedControl.j b/Tools/nib2cib/NSSegmentedControl.j index fe00f5aaf..da94613d4 100644 --- a/Tools/nib2cib/NSSegmentedControl.j +++ b/Tools/nib2cib/NSSegmentedControl.j @@ -95,9 +95,13 @@ if (self = [super initWithCoder:aCoder]) { _segments = [aCoder decodeObjectForKey:"NSSegmentImages"]; - _selectedSegment = [aCoder decodeIntForKey:"NSSelectedSegment"] || -1; + _selectedSegment = [aCoder decodeObjectForKey:"NSSelectedSegment"]; + + if (_selectedSegment === nil) + _selectedSegment = -1; + _segmentStyle = [aCoder decodeIntForKey:"NSSegmentStyle"]; - _trackingMode = [aCoder decodeIntForKey:"NSTrackingMode"] || CPSegmentSwitchTrackingSelectOne; + _trackingMode = [aCoder decodeIntForKey:"NSTrackingMode"]; if (_trackingMode == CPSegmentSwitchTrackingSelectOne && _selectedSegment == -1) _selectedSegment = 0; diff --git a/Tools/nib2cib/NSSlider.j b/Tools/nib2cib/NSSlider.j index 8e80eb887..683c10be5 100644 --- a/Tools/nib2cib/NSSlider.j +++ b/Tools/nib2cib/NSSlider.j @@ -91,7 +91,7 @@ _altIncrementValue = [aCoder decodeDoubleForKey:@"NSAltIncValue"]; _isVertical = [aCoder decodeBoolForKey:@"NSVertical"]; - _sliderType = [aCoder decodeIntForKey:@"NSSliderType"] || 0; + _sliderType = [aCoder decodeIntForKey:@"NSSliderType"]; } return self; diff --git a/Tools/nib2cib/NSSplitView.j b/Tools/nib2cib/NSSplitView.j index 7d5bc5365..6079cbd7b 100644 --- a/Tools/nib2cib/NSSplitView.j +++ b/Tools/nib2cib/NSSplitView.j @@ -30,7 +30,7 @@ if (self = [super NS_initWithCoder:aCoder]) { _isVertical = [aCoder decodeBoolForKey:@"NSIsVertical"]; - _isPaneSplitter = [aCoder decodeIntForKey:@"NSDividerStyle"] == 3 ? YES : NO; + _isPaneSplitter = [aCoder decodeIntForKey:@"NSDividerStyle"] == 3; _autosaveName = [aCoder decodeObjectForKey:@"NSAutosaveName"]; } diff --git a/Tools/nib2cib/NSTableView.j b/Tools/nib2cib/NSTableView.j index acf653ce4..b54ebb1a8 100644 --- a/Tools/nib2cib/NSTableView.j +++ b/Tools/nib2cib/NSTableView.j @@ -69,7 +69,7 @@ _usesAlternatingRowBackgroundColors = (flags & 0x00800000) ? YES : NO; _alternatingRowBackgroundColors = [[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"]]; - _selectionHighlightStyle = [aCoder decodeIntForKey:@"NSTableViewSelectionHighlightStyle"] || CPTableViewSelectionHighlightStyleRegular; + _selectionHighlightStyle = [aCoder decodeIntForKey:@"NSTableViewSelectionHighlightStyle"]; _columnAutoResizingStyle = [aCoder decodeIntForKey:@"NSColumnAutoresizingStyle"]; _allowsMultipleSelection = (flags & 0x08000000) ? YES : NO; diff --git a/Tools/nib2cib/NSTokenField.j b/Tools/nib2cib/NSTokenField.j index a03d898d8..b6216d48a 100644 --- a/Tools/nib2cib/NSTokenField.j +++ b/Tools/nib2cib/NSTokenField.j @@ -83,7 +83,7 @@ if (self) { - _tokenStyle = [aCoder decodeObjectForKey:@"NSTokenStyle"] || 0; + _tokenStyle = [aCoder decodeIntForKey:@"NSTokenStyle"]; } return self; diff --git a/Tools/nib2cib/NSToolbarItem.j b/Tools/nib2cib/NSToolbarItem.j index 33086e730..892425295 100644 --- a/Tools/nib2cib/NSToolbarItem.j +++ b/Tools/nib2cib/NSToolbarItem.j @@ -47,8 +47,8 @@ NS_CPToolbarItemIdentifierMap = _itemIdentifier = NS_CPToolbarItemIdentifierMap[NS_itemIdentifier] || NS_itemIdentifier; - _minSize = [aCoder decodeSizeForKey:@"NSToolbarItemMinSize"] || CGSizeMakeZero(); - _maxSize = [aCoder decodeSizeForKey:@"NSToolbarItemMaxSize"] || CGSizeMakeZero(); + _minSize = [aCoder decodeSizeForKey:@"NSToolbarItemMinSize"]; + _maxSize = [aCoder decodeSizeForKey:@"NSToolbarItemMaxSize"]; [self setLabel:[aCoder decodeObjectForKey:@"NSToolbarItemLabel"]]; [self setPaletteLabel:[aCoder decodeObjectForKey:@"NSToolbarItemPaletteLabel"]]; diff --git a/Tools/nib2cib/NSView.j b/Tools/nib2cib/NSView.j index 743068b30..d730f768e 100644 --- a/Tools/nib2cib/NSView.j +++ b/Tools/nib2cib/NSView.j @@ -45,10 +45,7 @@ var NSViewAutoresizingMask = 0x3F, if (self) { - _tag = 0; - - if ([aCoder containsValueForKey:@"NSTag"]) - _tag = [aCoder decodeIntForKey:@"NSTag"]; + _tag = [aCoder decodeIntForKey:@"NSTag"]; _bounds = CGRectMake(0.0, 0.0, CGRectGetWidth(_frame), CGRectGetHeight(_frame));