From b854f2da8a831514dad7ddaa4900b6cfdcad7a28 Mon Sep 17 00:00:00 2001 From: nicola Date: Mon, 27 Dec 2010 11:57:04 +0000 Subject: [PATCH] Explicitly encode/decode enumerated types as 'int' which is what all the existing archives use (even if it is incorrect as in many cases the types are actually 'unsigned int') git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31785 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 27 +++++++++++++++++++++++++++ Source/NSBezierPath.m | 4 ++-- Source/NSBox.m | 8 ++++---- Source/NSEvent.m | 4 ++-- Source/NSFileWrapper.m | 4 ++-- Source/NSImageCell.m | 12 ++++++------ Source/NSParagraphStyle.m | 14 ++++++-------- Source/NSResponder.m | 6 ++---- Source/NSScrollView.m | 4 ++-- Source/NSTabView.m | 4 ++-- Source/NSTabViewItem.m | 4 ++-- Source/NSWindow.m | 4 ++-- 12 files changed, 59 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1d16ca36..e03976552 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2010-12-27 Nicola Pero + + * Source/NSBezierPath.m ([-encodeWithCoder:], [-initWithCoder:]): + Explicitly encode/decode NSBezierPathElement as 'int' to work + across compiler versions. + * Source/NSBox.m ([-encodeWithCoder:], [-initWithCoder:]): Same + for NSBorderType and NSTitlePosition. + * Source/NSEvent.m ([-encodeWithCoder:], [-initWithCoder:]): Same + for NSEventType. + * Source/NSFileWrapper.m ([-encodeWithCoder:], [-initWithCoder:]): + Same for GSFileWrapperType. + * Source/NSImageCell.m ([-encodeWithCoder:], [-initWithCoder:]): + Same for NSImageAlignment, NSImageFrameStyle, NSImageScaling, + * Source/NSParagraphStyle.m ([-initWithCoder:], + [-encodeWithCoder:]): Same for NSTextAlignment, NSLineBreakMode + and NSTextTabType. + * Source/NSResponder.m ([-encodeWithCoder:], [-initWithCoder:]): + Same for NSInterfaceStyle. + * Source/NSScrollView.m ([-encodeWithCoder:], [-initWithCoder:]): + Same for NSBorderType. + * Source/NSTabView.m ([-encodeWithCoder:], [-initWithCoder:]): + Same for NSTabViewType. + * Source/NSTabViewItem.m ([-encodeWithCoder:], [-initWithCoder:]): + Same for NSTabState. + * Source/NSWindow.m ([-encodeWithCoder:], [-initWithCoder:]): Same + for NSBackingStoreType. + 2010-12-27 02:12-EST Gregory John Casamento * Source/GSThemeMenu.m: Added implementation for diff --git a/Source/NSBezierPath.m b/Source/NSBezierPath.m index 81a65d68b..46fde85a8 100644 --- a/Source/NSBezierPath.m +++ b/Source/NSBezierPath.m @@ -1628,7 +1628,7 @@ static int winding_curve(double_point from, double_point to, double_point c1, for (i = 0; i < count; i++) { type = [self elementAtIndex: i associatedPoints: pts]; - [aCoder encodeValueOfObjCType: @encode(NSBezierPathElement) at: &type]; + [aCoder encodeValueOfObjCType: @encode(int) at: &type]; switch(type) { case NSMoveToBezierPathElement: @@ -1674,7 +1674,7 @@ static int winding_curve(double_point from, double_point to, double_point c1, for (i = 0; i < count; i++) { - [aCoder decodeValueOfObjCType: @encode(NSBezierPathElement) at: &type]; + [aCoder decodeValueOfObjCType: @encode(int) at: &type]; switch(type) { case NSMoveToBezierPathElement: diff --git a/Source/NSBox.m b/Source/NSBox.m index 175ca8886..da858b766 100644 --- a/Source/NSBox.m +++ b/Source/NSBox.m @@ -514,8 +514,8 @@ { [aCoder encodeObject: _cell]; [aCoder encodeSize: _offsets]; - [aCoder encodeValueOfObjCType: @encode(NSBorderType) at: &_border_type]; - [aCoder encodeValueOfObjCType: @encode(NSTitlePosition) at: &_title_position]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_border_type]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_title_position]; // NB: the content view is our (only) subview, so it is already // encoded by NSView. } @@ -564,9 +564,9 @@ { [aDecoder decodeValueOfObjCType: @encode(id) at: &_cell]; _offsets = [aDecoder decodeSize]; - [aDecoder decodeValueOfObjCType: @encode(NSBorderType) + [aDecoder decodeValueOfObjCType: @encode(int) at: &_border_type]; - [aDecoder decodeValueOfObjCType: @encode(NSTitlePosition) + [aDecoder decodeValueOfObjCType: @encode(int) at: &_title_position]; // The content view is our only sub_view diff --git a/Source/NSEvent.m b/Source/NSEvent.m index 9c3a3f741..db7798e62 100644 --- a/Source/NSEvent.m +++ b/Source/NSEvent.m @@ -696,7 +696,7 @@ static const char *eventTypes[] = { - (void) encodeWithCoder: (NSCoder*)aCoder { - [aCoder encodeValueOfObjCType: @encode(NSEventType) at: &event_type]; + [aCoder encodeValueOfObjCType: @encode(int) at: &event_type]; [aCoder encodePoint: location_point]; [aCoder encodeValueOfObjCType: @encode(unsigned) at: &modifier_flags]; [aCoder encodeValueOfObjCType: @encode(NSTimeInterval) at: &event_time]; @@ -779,7 +779,7 @@ static const char *eventTypes[] = { { int version = [aDecoder versionForClassName: @"NSEvent"]; - [aDecoder decodeValueOfObjCType: @encode(NSEventType) at: &event_type]; + [aDecoder decodeValueOfObjCType: @encode(int) at: &event_type]; location_point = [aDecoder decodePoint]; [aDecoder decodeValueOfObjCType: @encode(unsigned) at: &modifier_flags]; [aDecoder decodeValueOfObjCType: @encode(NSTimeInterval) at: &event_time]; diff --git a/Source/NSFileWrapper.m b/Source/NSFileWrapper.m index b6a3f9247..e4e9feba2 100644 --- a/Source/NSFileWrapper.m +++ b/Source/NSFileWrapper.m @@ -579,7 +579,7 @@ - (void) encodeWithCoder: (NSCoder*)aCoder { - [aCoder encodeValueOfObjCType: @encode(GSFileWrapperType) at: &_wrapperType]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_wrapperType]; // Dont store the file name [aCoder encodeObject: _preferredFilename]; [aCoder encodeObject: _fileAttributes]; @@ -595,7 +595,7 @@ id wrapperData; NSImage *iconImage; - [aDecoder decodeValueOfObjCType: @encode(GSFileWrapperType) at: &wrapperType]; + [aDecoder decodeValueOfObjCType: @encode(int) at: &wrapperType]; // Dont restore the file name preferredFilename = [aDecoder decodeObject]; fileAttributes = [aDecoder decodeObject]; diff --git a/Source/NSImageCell.m b/Source/NSImageCell.m index 7b13d5508..0fc0626f8 100644 --- a/Source/NSImageCell.m +++ b/Source/NSImageCell.m @@ -340,9 +340,9 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect) } else { - [aCoder encodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment]; - [aCoder encodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle]; - [aCoder encodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_imageAlignment]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_frameStyle]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_imageScaling]; [aCoder encodeSize: _original_image_size]; } } @@ -372,9 +372,9 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect) } else { - [aDecoder decodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment]; - [aDecoder decodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle]; - [aDecoder decodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling]; + [aDecoder decodeValueOfObjCType: @encode(int) at: &_imageAlignment]; + [aDecoder decodeValueOfObjCType: @encode(int) at: &_frameStyle]; + [aDecoder decodeValueOfObjCType: @encode(int) at: &_imageScaling]; _original_image_size = [aDecoder decodeSize]; } } diff --git a/Source/NSParagraphStyle.m b/Source/NSParagraphStyle.m index 8925d85be..b23dcd37b 100644 --- a/Source/NSParagraphStyle.m +++ b/Source/NSParagraphStyle.m @@ -473,9 +473,8 @@ static NSParagraphStyle *defaultStyle = nil; { unsigned count; - [aCoder decodeValueOfObjCType: @encode(NSTextAlignment) at: &_alignment]; - [aCoder decodeValueOfObjCType: @encode(NSLineBreakMode) - at: &_lineBreakMode]; + [aCoder decodeValueOfObjCType: @encode(int) at: &_alignment]; + [aCoder decodeValueOfObjCType: @encode(int) at: &_lineBreakMode]; [aCoder decodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent]; [aCoder decodeValueOfObjCType: @encode(float) at: &_headIndent]; [aCoder decodeValueOfObjCType: @encode(float) at: &_lineSpacing]; @@ -498,7 +497,7 @@ static NSParagraphStyle *defaultStyle = nil; [aCoder decodeArrayOfObjCType: @encode(float) count: count at: locations]; - [aCoder decodeArrayOfObjCType: @encode(NSTextTabType) + [aCoder decodeArrayOfObjCType: @encode(int) count: count at: types]; for (i = 0; i < count; i++) @@ -531,9 +530,8 @@ static NSParagraphStyle *defaultStyle = nil; { unsigned count; - [aCoder encodeValueOfObjCType: @encode(NSTextAlignment) at: &_alignment]; - [aCoder encodeValueOfObjCType: @encode(NSLineBreakMode) - at: &_lineBreakMode]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_alignment]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_lineBreakMode]; [aCoder encodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent]; [aCoder encodeValueOfObjCType: @encode(float) at: &_headIndent]; [aCoder encodeValueOfObjCType: @encode(float) at: &_lineSpacing]; @@ -563,7 +561,7 @@ static NSParagraphStyle *defaultStyle = nil; [aCoder encodeArrayOfObjCType: @encode(float) count: count at: locations]; - [aCoder encodeArrayOfObjCType: @encode(NSTextTabType) + [aCoder encodeArrayOfObjCType: @encode(int) count: count at: types]; } diff --git a/Source/NSResponder.m b/Source/NSResponder.m index d6b813ab5..936f76160 100644 --- a/Source/NSResponder.m +++ b/Source/NSResponder.m @@ -357,8 +357,7 @@ } else { - [aCoder encodeValueOfObjCType: @encode(NSInterfaceStyle) - at: &_interface_style]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_interface_style]; [aCoder encodeObject: _menu]; } } @@ -386,8 +385,7 @@ } else { - [aDecoder decodeValueOfObjCType: @encode(NSInterfaceStyle) - at: &_interface_style]; + [aDecoder decodeValueOfObjCType: @encode(int) at: &_interface_style]; obj = [aDecoder decodeObject]; } diff --git a/Source/NSScrollView.m b/Source/NSScrollView.m index 161651424..076cb1cc5 100644 --- a/Source/NSScrollView.m +++ b/Source/NSScrollView.m @@ -1478,7 +1478,7 @@ static float scrollerWidth; else { [aCoder encodeObject: _contentView]; - [aCoder encodeValueOfObjCType: @encode(NSBorderType) at: &_borderType]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_borderType]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_scrollsDynamically]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_rulersVisible]; [aCoder encodeValueOfObjCType: @encode(float) at: &_hLineScroll]; @@ -1609,7 +1609,7 @@ static float scrollerWidth; int version = [aDecoder versionForClassName: @"NSScrollView"]; NSDebugLLog(@"NSScrollView", @"NSScrollView: start decoding\n"); _contentView = [aDecoder decodeObject]; - [aDecoder decodeValueOfObjCType: @encode(NSBorderType) at: &_borderType]; + [aDecoder decodeValueOfObjCType: @encode(int) at: &_borderType]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_scrollsDynamically]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_rulersVisible]; [aDecoder decodeValueOfObjCType: @encode(float) at: &_hLineScroll]; diff --git a/Source/NSTabView.m b/Source/NSTabView.m index 04062629a..a80774a1e 100644 --- a/Source/NSTabView.m +++ b/Source/NSTabView.m @@ -529,7 +529,7 @@ { [aCoder encodeObject: _items]; [aCoder encodeObject: _font]; - [aCoder encodeValueOfObjCType: @encode(NSTabViewType) at: &_type]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_type]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_draws_background]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_truncated_label]; [aCoder encodeConditionalObject: _delegate]; @@ -582,7 +582,7 @@ [aDecoder decodeValueOfObjCType: @encode(id) at: &_items]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_font]; - [aDecoder decodeValueOfObjCType: @encode(NSTabViewType) at: &_type]; + [aDecoder decodeValueOfObjCType: @encode(int) at: &_type]; if (version < 2) { switch(_type) diff --git a/Source/NSTabViewItem.m b/Source/NSTabViewItem.m index 4d1845afa..13aeded8d 100644 --- a/Source/NSTabViewItem.m +++ b/Source/NSTabViewItem.m @@ -210,7 +210,7 @@ [aCoder encodeObject:_label]; [aCoder encodeObject:_view]; [aCoder encodeObject:_color]; - [aCoder encodeValueOfObjCType: @encode(NSTabState) at: &_state]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_state]; [aCoder encodeObject:_first_responder]; [aCoder encodeObject:_tabview]; } @@ -234,7 +234,7 @@ [aDecoder decodeValueOfObjCType: @encode(id) at: &_label]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_view]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_color]; - [aDecoder decodeValueOfObjCType: @encode(NSTabState) at:&_state]; + [aDecoder decodeValueOfObjCType: @encode(int) at:&_state]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_first_responder]; AUTORELEASE(_first_responder); [aDecoder decodeValueOfObjCType: @encode(id) at: &_tabview]; diff --git a/Source/NSWindow.m b/Source/NSWindow.m index dd930a17b..1fa3b2117 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -5124,7 +5124,7 @@ current key view.
[aCoder encodeRect: [[self contentView] frame]]; [aCoder encodeValueOfObjCType: @encode(unsigned) at: &_styleMask]; - [aCoder encodeValueOfObjCType: @encode(NSBackingStoreType) at: &_backingType]; + [aCoder encodeValueOfObjCType: @encode(int) at: &_backingType]; [aCoder encodePoint: NSMakePoint(NSMinX([self frame]), NSMaxY([self frame]))]; [aCoder encodeObject: _contentView]; @@ -5191,7 +5191,7 @@ current key view.
aRect = [aDecoder decodeRect]; [aDecoder decodeValueOfObjCType: @encode(unsigned) at: &aStyle]; - [aDecoder decodeValueOfObjCType: @encode(NSBackingStoreType) + [aDecoder decodeValueOfObjCType: @encode(int) at: &aBacking]; // call the designated initializer....