From 2ae0dbc0da7272c69e47d00b17f7ac33b27af0df Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Tue, 14 May 2024 13:42:13 -0400 Subject: [PATCH] Add version of GSStoryboaddKeyedUnarchiver --- Source/GNUmakefile | 1 + Source/GSStoryboardKeyedUnarchiver.h | 43 ++++++++++++++++++++++++++++ Source/GSStoryboardKeyedUnarchiver.m | 30 +++++++++++++++++++ Source/GSXib5KeyedUnarchiver.h | 1 + Source/GSXib5KeyedUnarchiver.m | 5 ++++ Source/GSXibKeyedUnarchiver.m | 13 +++++++-- 6 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 Source/GSStoryboardKeyedUnarchiver.h create mode 100644 Source/GSStoryboardKeyedUnarchiver.m diff --git a/Source/GNUmakefile b/Source/GNUmakefile index 9d4d0ad85..18eb0c31d 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -346,6 +346,7 @@ GSToolTips.m \ GSToolbarView.m \ GSToolbarCustomizationPalette.m \ GSStandardWindowDecorationView.m \ +GSStoryboardKeyedUnarchiver.m \ GSWindowDecorationView.m \ GSPrinting.m \ GSPrintOperation.m \ diff --git a/Source/GSStoryboardKeyedUnarchiver.h b/Source/GSStoryboardKeyedUnarchiver.h new file mode 100644 index 000000000..17347e1cb --- /dev/null +++ b/Source/GSStoryboardKeyedUnarchiver.h @@ -0,0 +1,43 @@ +/* Definition of class GSStoryboardKeyedUnarchiver + Copyright (C) 2024 Free Software Foundation, Inc. + + By: Gregory John Casamento + Date: 14-05-2024 + + This file is part of the GNUstep Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110 USA. +*/ + +#ifndef _GSStoryboardKeyedUnarchiver_h_GNUSTEP_GUI_INCLUDE +#define _GSStoryboardKeyedUnarchiver_h_GNUSTEP_GUI_INCLUDE + +#import "GSXib5KeyedUnarchiver.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +@interface GSStoryboardKeyedUnarchiver : GSXib5KeyedUnarchiver + +@end + +#if defined(__cplusplus) +} +#endif + +#endif /* _GSStoryboardKeyedUnarchiver_h_GNUSTEP_GUI_INCLUDE */ + diff --git a/Source/GSStoryboardKeyedUnarchiver.m b/Source/GSStoryboardKeyedUnarchiver.m new file mode 100644 index 000000000..678389338 --- /dev/null +++ b/Source/GSStoryboardKeyedUnarchiver.m @@ -0,0 +1,30 @@ +/* Implementation of class GSStoryboardKeyedUnarchiver + Copyright (C) 2024 Free Software Foundation, Inc. + + By: Gregory John Casamento + Date: 14-05-2024 + + This file is part of the GNUstep Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110 USA. +*/ + +#import "GSStoryboardKeyedUnarchiver.h" + +@implementation GSStoryboardKeyedUnarchiver + +@end + diff --git a/Source/GSXib5KeyedUnarchiver.h b/Source/GSXib5KeyedUnarchiver.h index 1ce296143..c74a3ac63 100644 --- a/Source/GSXib5KeyedUnarchiver.h +++ b/Source/GSXib5KeyedUnarchiver.h @@ -41,6 +41,7 @@ GSXibElement *_orderedObjects; GSXibElement *_flattenedProperties; GSXibElement *_runtimeAttributes; + GSXibElement *_scenes; NSMutableDictionary *_orderedObjectsDict; NSArray *_resources; } diff --git a/Source/GSXib5KeyedUnarchiver.m b/Source/GSXib5KeyedUnarchiver.m index 862fdeab7..3621ddde8 100644 --- a/Source/GSXib5KeyedUnarchiver.m +++ b/Source/GSXib5KeyedUnarchiver.m @@ -747,6 +747,11 @@ static NSArray *XmlBoolDefaultYes = nil; @"connectionRecords", @"key", nil]]; + _scenes = [[GSXibElement alloc] initWithType: @"array" + andAttributes: [NSDictionary dictionaryWithObjectsAndKeys: + @"scenes", @"key", + nil]]; + // objectRecords... [_objectRecords setElement: _orderedObjects forKey: @"orderedObjects"]; diff --git a/Source/GSXibKeyedUnarchiver.m b/Source/GSXibKeyedUnarchiver.m index 7ca9b6bc4..4bf3f5e3e 100644 --- a/Source/GSXibKeyedUnarchiver.m +++ b/Source/GSXibKeyedUnarchiver.m @@ -35,10 +35,13 @@ */ #import + #import "GNUstepGUI/GSXibKeyedUnarchiver.h" #import "GNUstepGUI/GSXibElement.h" #import "GNUstepGUI/GSNibLoading.h" + #import "GSXib5KeyedUnarchiver.h" +#import "GSStoryboardKeyedUnarchiver.h" @implementation GSXibKeyedUnarchiver @@ -49,6 +52,7 @@ NSXMLDocument *document = [[NSXMLDocument alloc] initWithData: data options: 0 error: NULL]; + if (document == nil) { return NO; @@ -63,6 +67,7 @@ return [documentNodes count] != 0; } #else + // We now default to checking XIB 5 versions return YES; #endif @@ -75,6 +80,7 @@ NSXMLDocument *document = [[NSXMLDocument alloc] initWithData: data options: 0 error: NULL]; + if (document == nil) { return NO; @@ -82,15 +88,16 @@ else { // Test to see if this is an Xcode 5 XIB... - NSArray *nodes = [document nodesForXPath: @"/scene" error: NULL]; + NSArray *nodes = [document nodesForXPath: @"/scenes" error: NULL]; // Need at LEAST ONE scene node...we should find something a bit more // specific to check here... return [nodes count] != 0; } #else + // We now default to checking XIB 5 versions - return YES; + return NO; #endif } @@ -100,7 +107,7 @@ if ([self checkStoryboard: data]) { - unarchiver = [[GSXib5KeyedUnarchiver alloc] initForReadingWithData: data]; + unarchiver = [[GSStoryboardKeyedUnarchiver alloc] initForReadingWithData: data]; } else if ([self checkXib5: data]) {