Change encoding/decoding to protect against differences in integer size.

This commit is contained in:
fredkiefer 2021-01-08 17:18:36 +01:00
parent 05572b2d01
commit 35698d41b6
12 changed files with 233 additions and 163 deletions

View file

@ -1,3 +1,18 @@
2021-01-08 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSActionCell.m,
* Source/NSButtonCell.m,
* Source/NSCell.m,
* Source/NSComboBoxCell.m,
* Source/NSImageCell.m,
* Source/NSLevelIndicatorCell.m,
* Source/NSPathCell.m,
* Source/NSPopUpButtonCell.m,
* Source/NSSearchFieldCell.m,
* Source/NSSliderCell.m,
* Source/NSStepperCell.m: Change encoding/decoding to protect
against differences in integer size.
2020-12-13 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSSearchFieldCell.m: Use GSTheme to display the popup.

View file

@ -386,7 +386,10 @@ static Class controlClass;
}
else
{
[aCoder encodeValueOfObjCType: @encode(NSInteger) at: &_tag];
int32_t tmp;
tmp = _tag;
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &tmp];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
// This is only encoded for backward compatibility and won't be decoded.
@ -419,12 +422,15 @@ static Class controlClass;
else
{
id dummy;
int32_t tmp;
[aDecoder decodeValueOfObjCType: @encode(NSInteger) at: &_tag];
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &tmp];
_tag = tmp;
_target = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_action];
// Don't decode _control_view, as this may no longer be valid.
dummy = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(id) at: &dummy];
RELEASE(dummy);
}
return self;

View file

@ -1579,9 +1579,8 @@
*/
- (void) encodeWithCoder: (NSCoder*)aCoder
{
BOOL tmp;
[super encodeWithCoder: aCoder];
if ([aCoder allowsKeyedCoding])
{
GSButtonCellFlags buttonCellFlags;
@ -1695,6 +1694,9 @@
}
else
{
BOOL tmp;
uint32_t tmp2;
[aCoder encodeObject: _keyEquivalent];
[aCoder encodeObject: _keyEquivalentFont];
[aCoder encodeObject: _altContents];
@ -1703,42 +1705,35 @@
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &tmp];
if([NSButtonCell version] <= 2)
{
unsigned int ke = _keyEquivalentModifierMask << 16;
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &ke];
}
else
{
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_keyEquivalentModifierMask];
}
tmp2 = _keyEquivalentModifierMask;
[aCoder encodeValueOfObjCType: @encode(uint32_t)
at: &tmp2];
tmp2 = _highlightsByMask;
[aCoder encodeValueOfObjCType: @encode(uint32_t)
at: &tmp2];
tmp2 = _showAltStateMask;
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_highlightsByMask];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_showAltStateMask];
at: &tmp2];
if([NSButtonCell version] >= 2)
{
[aCoder encodeObject: _sound];
[aCoder encodeObject: _backgroundColor];
[aCoder encodeValueOfObjCType: @encode(float)
at: &_delayInterval];
[aCoder encodeValueOfObjCType: @encode(float)
at: &_repeatInterval];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_bezel_style];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_gradient_type];
tmp = _image_dims_when_disabled;
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &tmp];
tmp = _shows_border_only_while_mouse_inside;
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &tmp];
}
[aCoder encodeObject: _sound];
[aCoder encodeObject: _backgroundColor];
[aCoder encodeValueOfObjCType: @encode(float)
at: &_delayInterval];
[aCoder encodeValueOfObjCType: @encode(float)
at: &_repeatInterval];
tmp2 = _bezel_style;
[aCoder encodeValueOfObjCType: @encode(uint32_t)
at: &tmp2];
tmp2 = _gradient_type;
[aCoder encodeValueOfObjCType: @encode(uint32_t)
at: &tmp2];
tmp = _image_dims_when_disabled;
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &tmp];
tmp = _shows_border_only_while_mouse_inside;
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &tmp];
}
}
@ -1885,27 +1880,36 @@
else
{
BOOL tmp;
uint32_t tmp2;
int version = [aDecoder versionForClassName: @"NSButtonCell"];
NSString *key = nil;
[aDecoder decodeValueOfObjCType: @encode(id) at: &key];
[self setKeyEquivalent: key]; // Set the key equivalent...
// Hack to correct a Gorm problem, there "\n" is used instead of "\r".
if ([key isEqualToString: @"\n" ])
{
key = @"\r";
}
[self setKeyEquivalent: key];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_keyEquivalentFont];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_altContents];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_altImage];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
_buttoncell_is_transparent = tmp;
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_keyEquivalentModifierMask];
[aDecoder decodeValueOfObjCType: @encode(uint32_t)
at: &tmp2];
_keyEquivalentModifierMask = (NSUInteger)tmp2;
if (version <= 2)
{
_keyEquivalentModifierMask = _keyEquivalentModifierMask << 16;
}
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_highlightsByMask];
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_showAltStateMask];
[aDecoder decodeValueOfObjCType: @encode(uint32_t)
at: &tmp2];
_highlightsByMask = (NSInteger)tmp2;
[aDecoder decodeValueOfObjCType: @encode(uint32_t)
at: &tmp2];
_showAltStateMask = (NSInteger)tmp2;
if (version >= 2)
{
@ -1913,10 +1917,12 @@
[aDecoder decodeValueOfObjCType: @encode(id) at: &_backgroundColor];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_delayInterval];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_repeatInterval];
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_bezel_style];
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_gradient_type];
[aDecoder decodeValueOfObjCType: @encode(uint32_t)
at: &tmp2];
_bezel_style = (NSBezelStyle)tmp2;
[aDecoder decodeValueOfObjCType: @encode(uint32_t)
at: &tmp2];
_gradient_type = (NSGradientType)tmp2;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
_image_dims_when_disabled = tmp;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
@ -1926,12 +1932,6 @@
_imageScaling = NSImageScaleNone;
}
// Hack to correct a Gorm problem, there "\n" is used instead of "\r".
if ([_keyEquivalent isEqualToString: @"\n" ])
{
[self setKeyEquivalent: @"\r"];
}
return self;
}

View file

@ -2524,7 +2524,7 @@ static NSColor *dtxtCol;
else
{
BOOL flag;
unsigned int tmp_int;
uint32_t tmp_int;
[aCoder encodeObject: _contents];
[aCoder encodeObject: _cell_image];
@ -2567,38 +2567,40 @@ static NSColor *dtxtCol;
flag = [self wraps];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
tmp_int = _cell.text_align;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
tmp_int = _cell.type;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
tmp_int = _cell.image_position;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
tmp_int = _cell.entry_type;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
// FIXME: State may be -1, why do we encode it as unsigned?
tmp_int = _cell.state;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
tmp_int = _cell.mnemonic_location;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(NSUInteger) at: &_mouse_down_flags];
[aCoder encodeValueOfObjCType: @encode(NSUInteger) at: &_action_mask];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
tmp_int = _mouse_down_flags;
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_action_mask = _mouse_down_flags;
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(id) at: &_formatter];
[aCoder encodeValueOfObjCType: @encode(id) at: &_menu];
[aCoder encodeValueOfObjCType: @encode(id) at: &_represented_object];
tmp_int = _cell.allows_undo;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
tmp_int = _cell.line_break_mode;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
tmp_int = _cell.control_tint;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
tmp_int = _cell.control_size;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
tmp_int = _cell.focus_ring_type;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
tmp_int = _cell.base_writing_direction;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
tmp_int = _cell.uses_single_line_mode;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
}
}
@ -2702,7 +2704,7 @@ static NSColor *dtxtCol;
else
{
BOOL flag, wraps;
unsigned int tmp_int;
uint32_t tmp_int;
id formatter, menu;
int version = [aDecoder versionForClassName: @"NSCell"];
@ -2745,21 +2747,23 @@ static NSColor *dtxtCol;
/* The wraps attribute has been superseded by lineBreakMode. However,
we may need it to set lineBreakMode when reading old archives. */
wraps = flag;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.text_align = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.type = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.image_position = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.entry_type = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.state = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.mnemonic_location = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(NSUInteger)
at: &_mouse_down_flags];
[aDecoder decodeValueOfObjCType: @encode(NSUInteger) at: &_action_mask];
[aDecoder decodeValueOfObjCType: @encode(uint32_t)
at: &tmp_int];
_mouse_down_flags = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_action_mask = tmp_int;
if (version < 3)
{
unsigned int mask = 0;
@ -2873,17 +2877,17 @@ static NSColor *dtxtCol;
if (version >= 2)
{
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.allows_undo = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.line_break_mode = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.control_tint = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.control_size = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.focus_ring_type = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.base_writing_direction = tmp_int;
}
else
@ -2895,7 +2899,7 @@ static NSColor *dtxtCol;
if (version >= 4)
{
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &tmp_int];
_cell.uses_single_line_mode = tmp_int;
}

View file

@ -1557,15 +1557,19 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
}
else
{
int32_t tmp;
[coder encodeValueOfObjCType: @encode(id) at: &_popUpList];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_hasVerticalScroller];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_completes];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource];
[coder encodeValueOfObjCType: @encode(int) at: &_visibleItems];
tmp = _visibleItems;
[coder encodeValueOfObjCType: @encode(int32_t) at: &tmp];
[coder encodeValueOfObjCType: @encode(NSSize) at: &_intercellSpacing];
[coder encodeValueOfObjCType: @encode(float) at: &_itemHeight];
[coder encodeValueOfObjCType: @encode(int) at: &_selectedItem];
tmp = _selectedItem;
[coder encodeValueOfObjCType: @encode(int32_t) at: &tmp];
if (_usesDataSource == YES)
[coder encodeConditionalObject: _dataSource];
@ -1635,6 +1639,7 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
else
{
BOOL dummy;
int32_t tmp;
if ([aDecoder versionForClassName: @"NSComboBoxCell"] < 2)
{
@ -1649,10 +1654,12 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasVerticalScroller];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_completes];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &dummy];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_visibleItems];
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &tmp];
_visibleItems = tmp;
[aDecoder decodeValueOfObjCType: @encode(NSSize) at: &_intercellSpacing];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_itemHeight];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_selectedItem];
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &tmp];
_selectedItem = tmp;
if (_usesDataSource == YES)
[self setDataSource: [aDecoder decodeObject]];

View file

@ -306,9 +306,14 @@ yBottomInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
}
else
{
[aCoder encodeValueOfObjCType: @encode(int) at: &_imageAlignment];
[aCoder encodeValueOfObjCType: @encode(int) at: &_frameStyle];
[aCoder encodeValueOfObjCType: @encode(int) at: &_imageScaling];
int32_t tmp;
tmp = _imageAlignment;
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &tmp];
tmp = _frameStyle;
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &tmp];
tmp = _imageScaling;
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &tmp];
[aCoder encodeSize: _original_image_size];
}
}
@ -338,9 +343,14 @@ yBottomInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
}
else
{
[aDecoder decodeValueOfObjCType: @encode(int) at: &_imageAlignment];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_frameStyle];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_imageScaling];
int32_t tmp;
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &tmp];
_imageAlignment = tmp;
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &tmp];
_frameStyle = tmp;
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &tmp];
_imageScaling = tmp;
_original_image_size = [aDecoder decodeSize];
}
}

View file

@ -501,14 +501,20 @@
}
else
{
int32_t tmp;
[aCoder encodeValueOfObjCType: @encode(double) at: &_minValue];
[aCoder encodeValueOfObjCType: @encode(double) at: &_maxValue];
[aCoder encodeValueOfObjCType: @encode(double) at: &_warningValue];
[aCoder encodeValueOfObjCType: @encode(double) at: &_criticalValue];
[aCoder encodeValueOfObjCType: @encode(int) at: &_style];
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfMajorTickMarks];
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfTickMarks];
[aCoder encodeValueOfObjCType: @encode(int) at: &_tickMarkPosition];
tmp = _style;
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &tmp];
tmp = _numberOfMajorTickMarks;
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &tmp];
tmp = _numberOfTickMarks;
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &tmp];
tmp = _tickMarkPosition;
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &tmp];
}
}
@ -556,15 +562,21 @@
}
}
else
{
{
int32_t tmp;
[aDecoder decodeValueOfObjCType: @encode(double) at: &_minValue];
[aDecoder decodeValueOfObjCType: @encode(double) at: &_maxValue];
[aDecoder decodeValueOfObjCType: @encode(double) at: &_warningValue];
[aDecoder decodeValueOfObjCType: @encode(double) at: &_criticalValue];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_style];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfMajorTickMarks];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfTickMarks];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_tickMarkPosition];
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &tmp];
_style = tmp;
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &tmp];
_numberOfMajorTickMarks = tmp;
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &tmp];
_numberOfTickMarks = tmp;
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &tmp];
_tickMarkPosition = tmp;
}
return self;

View file

@ -250,8 +250,11 @@ static Class pathComponentCellClass;
}
else
{
[coder decodeValueOfObjCType: @encode(NSUInteger)
at: &_pathStyle];
uint32_t tmp;
[coder decodeValueOfObjCType: @encode(uint32_t)
at: &tmp];
_pathStyle = tmp;
[self setPathComponentCells: [coder decodeObject]];
}
@ -270,8 +273,11 @@ static Class pathComponentCellClass;
}
else
{
[coder encodeValueOfObjCType: @encode(NSUInteger)
at: &_pathStyle];
uint32_t tmp;
tmp = _pathStyle;
[coder encodeValueOfObjCType: @encode(uint32_t)
at: &tmp];
[coder encodeObject: [self pathComponentCells]];
}
}

View file

@ -1207,19 +1207,20 @@ static NSImage *_pbc_image[5];
}
else
{
int flag;
int32_t flag;
[aCoder encodeObject: _menu];
[aCoder encodeConditionalObject: [self selectedItem]];
flag = _pbcFlags.pullsDown;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &flag];
flag = _pbcFlags.preferredEdge;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &flag];
flag = _pbcFlags.usesItemFromMenu;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &flag];
flag = _pbcFlags.altersStateOfSelectedItem;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &flag];
flag = _pbcFlags.arrowPosition;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &flag];
}
}
@ -1305,7 +1306,7 @@ static NSImage *_pbc_image[5];
}
else
{
int flag;
int32_t flag;
id<NSMenuItem> selectedItem;
int version = [aDecoder versionForClassName:
@"NSPopUpButtonCell"];
@ -1320,15 +1321,15 @@ static NSImage *_pbc_image[5];
[self setMenu: nil];
[self setMenu: menu];
selectedItem = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(int) at: &flag];
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &flag];
_pbcFlags.pullsDown = flag;
[aDecoder decodeValueOfObjCType: @encode(int) at: &flag];
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &flag];
_pbcFlags.preferredEdge = flag;
[aDecoder decodeValueOfObjCType: @encode(int) at: &flag];
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &flag];
_pbcFlags.usesItemFromMenu = flag;
[aDecoder decodeValueOfObjCType: @encode(int) at: &flag];
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &flag];
_pbcFlags.altersStateOfSelectedItem = flag;
[aDecoder decodeValueOfObjCType: @encode(int) at: &flag];
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &flag];
_pbcFlags.arrowPosition = flag;
if (version < 2)

View file

@ -481,12 +481,12 @@
//
- (void) encodeWithCoder: (NSCoder*)aCoder
{
NSInteger max = [self maximumRecents];
[super encodeWithCoder: aCoder];
if ([aCoder allowsKeyedCoding])
{
int max = [self maximumRecents];
[aCoder encodeObject: _search_button_cell forKey: @"NSSearchButtonCell"];
[aCoder encodeObject: _cancel_button_cell forKey: @"NSCancelButtonCell"];
[aCoder encodeObject: _recents_autosave_name forKey: @"NSRecentsAutosaveName"];
@ -495,12 +495,14 @@
}
else
{
uint32_t max = [self maximumRecents];
[aCoder encodeObject: _search_button_cell];
[aCoder encodeObject: _cancel_button_cell];
[aCoder encodeObject: _recents_autosave_name];
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &_sends_whole_search_string];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
[aCoder encodeValueOfObjCType: @encode(uint32_t)
at: &max];
}
}
@ -521,13 +523,13 @@
}
else
{
NSInteger max;
uint32_t max;
[self setSearchButtonCell: [aDecoder decodeObject]];
[self setCancelButtonCell: [aDecoder decodeObject]];
[self setRecentsAutosaveName: [aDecoder decodeObject]];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_sends_whole_search_string];
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &max];
[aDecoder decodeValueOfObjCType: @encode(uint32_t) at: &max];
[self setMaximumRecents: max];
}

View file

@ -1069,24 +1069,27 @@ double _doubleValueForMousePoint (NSPoint point, NSRect knobRect,
}
else
{
float minValue, maxValue;
float altIncrementValue;
int isVertical;
float tmp_float;
int32_t tmp_int;
[decoder decodeValuesOfObjCTypes: "fffi",
&minValue, &maxValue, &altIncrementValue, &isVertical];
[self setDoubleValue: 0];
[self setMinValue: minValue];
[self setMaxValue: maxValue];
[self setAltIncrementValue: altIncrementValue];
_isVertical = isVertical;
[decoder decodeValueOfObjCType: @encode(float) at: &tmp_float];
[self setMinValue: tmp_float];
[decoder decodeValueOfObjCType: @encode(float) at: &tmp_float];
[self setMaxValue: tmp_float];
[decoder decodeValueOfObjCType: @encode(float) at: &tmp_float];
[self setAltIncrementValue: tmp_float];
[decoder decodeValueOfObjCType: @encode(int32_t) at: &tmp_int];
_isVertical = tmp_int;
[decoder decodeValueOfObjCType: @encode(id) at: &_titleCell];
[decoder decodeValueOfObjCType: @encode(id) at: &_knobCell];
if ([decoder versionForClassName: @"NSSliderCell"] >= 2)
{
[decoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsTickMarkValuesOnly];
[decoder decodeValueOfObjCType: @encode(NSInteger) at: &_numberOfTickMarks];
[decoder decodeValueOfObjCType: @encode(int) at: &_tickMarkPosition];
[decoder decodeValueOfObjCType: @encode(int32_t) at: &tmp_int];
_numberOfTickMarks = tmp_int;
[decoder decodeValueOfObjCType: @encode(int32_t) at: &tmp_int];
_tickMarkPosition = tmp_int;
}
}
return self;
@ -1108,19 +1111,25 @@ double _doubleValueForMousePoint (NSPoint point, NSRect knobRect,
}
else
{
float minValue = _minValue;
float maxValue = _maxValue;
float altIncrementValue = _altIncrementValue;
int isVertical = _isVertical;
float tmp_float;
int32_t tmp_int;
[coder encodeValuesOfObjCTypes: "fffi",
&minValue, &maxValue, &altIncrementValue, &isVertical];
tmp_float = _minValue;
[coder encodeValueOfObjCType: @encode(float) at: &tmp_float];
tmp_float = _maxValue;
[coder encodeValueOfObjCType: @encode(float) at: &tmp_float];
tmp_float = _altIncrementValue;
[coder encodeValueOfObjCType: @encode(float) at: &tmp_float];
tmp_int = _isVertical;
[coder encodeValueOfObjCType: @encode(int32_t) at: &tmp_int];
[coder encodeValueOfObjCType: @encode(id) at: &_titleCell];
[coder encodeValueOfObjCType: @encode(id) at: &_knobCell];
// New for version 2
[coder encodeValueOfObjCType: @encode(BOOL) at: &_allowsTickMarkValuesOnly];
[coder encodeValueOfObjCType: @encode(NSInteger) at: &_numberOfTickMarks];
[coder encodeValueOfObjCType: @encode(int) at: &_tickMarkPosition];
tmp_int = _numberOfTickMarks;
[coder encodeValueOfObjCType: @encode(int32_t) at: &tmp_int];
tmp_int = _tickMarkPosition;
[coder encodeValueOfObjCType: @encode(int32_t) at: &tmp_int];
}
}

View file

@ -381,21 +381,20 @@
}
else
{
int tmp1, tmp2;
int32_t tmp;
tmp1 = (int)_autorepeat;
tmp2 = (int)_valueWraps;
[aCoder encodeValueOfObjCType: @encode(double)
at: &_maxValue];
[aCoder encodeValueOfObjCType: @encode(double)
at: &_minValue];
[aCoder encodeValueOfObjCType: @encode(double)
at: &_increment];
[aCoder encodeValueOfObjCType: @encode(int)
at: &tmp1];
[aCoder encodeValueOfObjCType: @encode(int)
at: &tmp2];
tmp = (int32_t)_autorepeat;
[aCoder encodeValueOfObjCType: @encode(int32_t)
at: &tmp];
tmp = (int32_t)_valueWraps;
[aCoder encodeValueOfObjCType: @encode(int32_t)
at: &tmp];
}
}
@ -418,7 +417,7 @@
}
else
{
int tmp1, tmp2;
int32_t tmp;
[aDecoder decodeValueOfObjCType: @encode(double)
at: &_maxValue];
@ -426,13 +425,12 @@
at: &_minValue];
[aDecoder decodeValueOfObjCType: @encode(double)
at: &_increment];
[aDecoder decodeValueOfObjCType: @encode(int)
at: &tmp1];
[aDecoder decodeValueOfObjCType: @encode(int)
at: &tmp2];
_autorepeat = (BOOL)tmp1;
_valueWraps = (BOOL)tmp2;
[aDecoder decodeValueOfObjCType: @encode(int32_t)
at: &tmp];
_autorepeat = (BOOL)tmp;
[aDecoder decodeValueOfObjCType: @encode(int32_t)
at: &tmp];
_valueWraps = (BOOL)tmp;
}
return self;