use int/integer/uinteger coder convenience methods

This commit is contained in:
Riccardo Mottola 2021-01-09 00:01:14 +01:00
parent 05572b2d01
commit ff39391740

View file

@ -1579,8 +1579,6 @@
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL tmp;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if ([aCoder allowsKeyedCoding]) if ([aCoder allowsKeyedCoding])
{ {
@ -1699,26 +1697,20 @@
[aCoder encodeObject: _keyEquivalentFont]; [aCoder encodeObject: _keyEquivalentFont];
[aCoder encodeObject: _altContents]; [aCoder encodeObject: _altContents];
[aCoder encodeObject: _altImage]; [aCoder encodeObject: _altImage];
tmp = _buttoncell_is_transparent; [aCoder encodeBool: _buttoncell_is_transparent];
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &tmp];
if([NSButtonCell version] <= 2) if([NSButtonCell version] <= 2)
{ {
unsigned int ke = _keyEquivalentModifierMask << 16; unsigned int ke = _keyEquivalentModifierMask << 16;
[aCoder encodeValueOfObjCType: @encode(unsigned int) [aCoder encodeUInteger: ke];
at: &ke];
} }
else else
{ {
[aCoder encodeValueOfObjCType: @encode(unsigned int) [aCoder encodeUInteger: _keyEquivalentModifierMask];
at: &_keyEquivalentModifierMask];
} }
[aCoder encodeValueOfObjCType: @encode(unsigned int) [aCoder encodeUInteger: _highlightsByMask];
at: &_highlightsByMask]; [aCoder encodeUInteger: _showAltStateMask];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_showAltStateMask];
if([NSButtonCell version] >= 2) if([NSButtonCell version] >= 2)
{ {
@ -1728,16 +1720,10 @@
at: &_delayInterval]; at: &_delayInterval];
[aCoder encodeValueOfObjCType: @encode(float) [aCoder encodeValueOfObjCType: @encode(float)
at: &_repeatInterval]; at: &_repeatInterval];
[aCoder encodeValueOfObjCType: @encode(unsigned int) [aCoder encodeUInteger: _bezel_style];
at: &_bezel_style]; [aCoder encodeUInteger: _gradient_type];
[aCoder encodeValueOfObjCType: @encode(unsigned int) [aCoder encodeBool: _image_dims_when_disabled];
at: &_gradient_type]; [aCoder encodeBool: _shows_border_only_while_mouse_inside];
tmp = _image_dims_when_disabled;
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &tmp];
tmp = _shows_border_only_while_mouse_inside;
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &tmp];
} }
} }
} }
@ -1884,7 +1870,6 @@
} }
else else
{ {
BOOL tmp;
int version = [aDecoder versionForClassName: @"NSButtonCell"]; int version = [aDecoder versionForClassName: @"NSButtonCell"];
NSString *key = nil; NSString *key = nil;
@ -1894,18 +1879,16 @@
[aDecoder decodeValueOfObjCType: @encode(id) at: &_keyEquivalentFont]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_keyEquivalentFont];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_altContents]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_altContents];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_altImage]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_altImage];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp]; _buttoncell_is_transparent = [aDecoder decodeBool];
_buttoncell_is_transparent = tmp; _keyEquivalentModifierMask = [aDecoder decodeUInteger];
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_keyEquivalentModifierMask];
if (version <= 2) if (version <= 2)
{ {
_keyEquivalentModifierMask = _keyEquivalentModifierMask << 16; _keyEquivalentModifierMask = _keyEquivalentModifierMask << 16;
} }
[aDecoder decodeValueOfObjCType: @encode(unsigned int) // we need to cast because the encoded value is unisgned
at: &_highlightsByMask]; _highlightsByMask = (NSInteger)[aDecoder decodeUInteger];
[aDecoder decodeValueOfObjCType: @encode(unsigned int) _showAltStateMask = (NSInteger)[aDecoder decodeUInteger];
at: &_showAltStateMask];
if (version >= 2) if (version >= 2)
{ {
@ -1913,14 +1896,10 @@
[aDecoder decodeValueOfObjCType: @encode(id) at: &_backgroundColor]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_backgroundColor];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_delayInterval]; [aDecoder decodeValueOfObjCType: @encode(float) at: &_delayInterval];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_repeatInterval]; [aDecoder decodeValueOfObjCType: @encode(float) at: &_repeatInterval];
[aDecoder decodeValueOfObjCType: @encode(unsigned int) _bezel_style = (NSBezelStyle)[aDecoder decodeUInteger];
at: &_bezel_style]; _gradient_type = (NSGradientType)[aDecoder decodeUInteger];
[aDecoder decodeValueOfObjCType: @encode(unsigned int) _image_dims_when_disabled = [aDecoder decodeBool];
at: &_gradient_type]; _shows_border_only_while_mouse_inside = [aDecoder decodeBool];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
_image_dims_when_disabled = tmp;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
_shows_border_only_while_mouse_inside = tmp;
} }
// Not encoded in non-keyed archive // Not encoded in non-keyed archive
_imageScaling = NSImageScaleNone; _imageScaling = NSImageScaleNone;