Changes to refactor storyboard loader

This commit is contained in:
Gregory John Casamento 2025-05-12 08:25:13 -04:00
parent e8d5653e47
commit 0ded1feee0
6 changed files with 37 additions and 33 deletions

View file

@ -33,6 +33,7 @@
#import <Foundation/NSObject.h> #import <Foundation/NSObject.h>
#import <Foundation/NSKeyedArchiver.h> #import <Foundation/NSKeyedArchiver.h>
#import "GNUstepGUI/GSXibKeyedUnarchiver.h" #import "GNUstepGUI/GSXibKeyedUnarchiver.h"
@class NSString, NSDictionary, NSArray, NSMutableDictionary, NSMutableArray; @class NSString, NSDictionary, NSArray, NSMutableDictionary, NSMutableArray;
@ -42,11 +43,13 @@
// Hack: This allows the class name FirstResponder in NSCustomObject and // Hack: This allows the class name FirstResponder in NSCustomObject and
// correctly returns nil as the corresponding object. // correctly returns nil as the corresponding object.
APPKIT_EXPORT_CLASS
@interface FirstResponder: NSObject @interface FirstResponder: NSObject
{ {
} }
@end @end
APPKIT_EXPORT_CLASS
@interface IBClassDescriptionSource: NSObject @interface IBClassDescriptionSource: NSObject
{ {
NSString *majorKey; NSString *majorKey;
@ -54,6 +57,7 @@
} }
@end @end
APPKIT_EXPORT_CLASS
@interface IBPartialClassDescription: NSObject @interface IBPartialClassDescription: NSObject
{ {
NSString *className; NSString *className;
@ -70,6 +74,7 @@
} }
@end @end
APPKIT_EXPORT_CLASS
@interface IBConnection: NSObject <NSCoding> @interface IBConnection: NSObject <NSCoding>
{ {
NSString *label; NSString *label;
@ -84,23 +89,27 @@
- (void) establishConnection; - (void) establishConnection;
@end @end
APPKIT_EXPORT_CLASS
@interface IBActionConnection: IBConnection @interface IBActionConnection: IBConnection
{ {
NSString *trigger; NSString *trigger;
} }
@end @end
APPKIT_EXPORT_CLASS
@interface IBOutletConnection: IBConnection @interface IBOutletConnection: IBConnection
{ {
} }
@end @end
APPKIT_EXPORT_CLASS
@interface IBBindingConnection: IBConnection @interface IBBindingConnection: IBConnection
{ {
NSNibBindingConnector *connector; NSNibBindingConnector *connector;
} }
@end @end
APPKIT_EXPORT_CLASS
@interface IBConnectionRecord: NSObject @interface IBConnectionRecord: NSObject
{ {
IBConnection *connection; IBConnection *connection;
@ -109,6 +118,7 @@
- (IBConnection *) connection; - (IBConnection *) connection;
@end @end
APPKIT_EXPORT_CLASS
@interface IBToolTipAttribute: NSObject @interface IBToolTipAttribute: NSObject
{ {
NSString *name; NSString *name;
@ -117,6 +127,7 @@
} }
@end @end
APPKIT_EXPORT_CLASS
@interface IBInitialTabViewItemAttribute: NSObject @interface IBInitialTabViewItemAttribute: NSObject
{ {
NSString *name; NSString *name;
@ -125,6 +136,7 @@
} }
@end @end
APPKIT_EXPORT_CLASS
@interface IBObjectRecord: NSObject @interface IBObjectRecord: NSObject
{ {
id objectID; id objectID;
@ -137,6 +149,7 @@
- (id) objectID; - (id) objectID;
@end @end
APPKIT_EXPORT_CLASS
@interface IBMutableOrderedSet: NSObject @interface IBMutableOrderedSet: NSObject
{ {
NSArray *orderedObjects; NSArray *orderedObjects;
@ -145,6 +158,7 @@
- (id) objectWithObjectID: (id)objID; - (id) objectWithObjectID: (id)objID;
@end @end
APPKIT_EXPORT_CLASS
@interface IBObjectContainer: NSObject <NSCoding> @interface IBObjectContainer: NSObject <NSCoding>
{ {
NSMutableArray *connectionRecords; NSMutableArray *connectionRecords;

View file

@ -34,6 +34,7 @@ extern "C" {
#endif #endif
@class NSBundle; @class NSBundle;
@class NSData;
@class NSMutableDictionary; @class NSMutableDictionary;
@class NSString; @class NSString;
@ -45,6 +46,7 @@ DEFINE_BLOCK_TYPE(NSStoryboardControllerCreator, NSCoder*, id);
APPKIT_EXPORT_CLASS APPKIT_EXPORT_CLASS
@interface NSStoryboard : NSObject @interface NSStoryboard : NSObject
{ {
NSData *_data;
NSMutableDictionary *_scenes; NSMutableDictionary *_scenes;
} }

View file

@ -39,6 +39,7 @@
#import "AppKit/NSApplication.h" #import "AppKit/NSApplication.h"
#import "AppKit/NSMenu.h" #import "AppKit/NSMenu.h"
#import "AppKit/NSNib.h" #import "AppKit/NSNib.h"
#import "GNUstepGUI/GSModelLoaderFactory.h" #import "GNUstepGUI/GSModelLoaderFactory.h"
#import "GNUstepGUI/GSNibLoading.h" #import "GNUstepGUI/GSNibLoading.h"
#import "GNUstepGUI/GSXibLoading.h" #import "GNUstepGUI/GSXibLoading.h"
@ -122,9 +123,9 @@
return; return;
} }
NSDebugLLog(@"XIB", @"First object %@", [rootObjects objectAtIndex: 0]); NSDebugLLog(@"Storyboard", @"First object %@", [rootObjects objectAtIndex: 0]);
NSDebugLLog(@"XIB", @"Second object %@", [rootObjects objectAtIndex: 1]); NSDebugLLog(@"Storyboard", @"Second object %@", [rootObjects objectAtIndex: 1]);
NSDebugLLog(@"XIB", @"Third object %@", [rootObjects objectAtIndex: 2]); NSDebugLLog(@"Storyboard", @"Third object %@", [rootObjects objectAtIndex: 2]);
// Use the owner as first root object // Use the owner as first root object
[(NSCustomObject*)[rootObjects objectAtIndex: 0] setRealObject: owner]; [(NSCustomObject*)[rootObjects objectAtIndex: 0] setRealObject: owner];
@ -187,7 +188,7 @@
NSArray *rootObjects; NSArray *rootObjects;
IBObjectContainer *objects; IBObjectContainer *objects;
NSDebugLLog(@"XIB", @"Invoking unarchiver"); NSDebugLLog(@"Storyboard", @"Invoking unarchiver");
[unarchiver setObjectZone: zone]; [unarchiver setObjectZone: zone];
rootObjects = [unarchiver decodeObjectForKey: @"IBDocument.RootObjects"]; rootObjects = [unarchiver decodeObjectForKey: @"IBDocument.RootObjects"];
objects = [unarchiver decodeObjectForKey: @"IBDocument.Objects"]; objects = [unarchiver decodeObjectForKey: @"IBDocument.Objects"];
@ -231,7 +232,7 @@
NSFileManager *mgr = [NSFileManager defaultManager]; NSFileManager *mgr = [NSFileManager defaultManager];
BOOL isDir = NO; BOOL isDir = NO;
NSDebugLLog(@"XIB", @"Loading Storyboard `%@'...\n", fileName); NSDebugLLog(@"Storyboard", @"Loading Storyboard `%@'...\n", fileName);
if ([mgr fileExistsAtPath: fileName isDirectory: &isDir]) if ([mgr fileExistsAtPath: fileName isDirectory: &isDir])
{ {
if (isDir == NO) if (isDir == NO)
@ -247,6 +248,7 @@
{ {
NSLog(@"Storyboard file specified %@, could not be found.", fileName); NSLog(@"Storyboard file specified %@, could not be found.", fileName);
} }
return nil; return nil;
} }

View file

@ -233,7 +233,7 @@ static NSArray *XmlBoolDefaultYes = nil;
@"NSStackViewContainer", @"middleViews", @"NSStackViewContainer", @"middleViews",
@"NSStackViewContainer", @"endViews", @"NSStackViewContainer", @"endViews",
// @"GSScene", @"scene", // @"GSScene", @"scene",
// @"NSMutableArray", @"scenes", @"NSMutableArray", @"scenes",
nil]; nil];
RETAIN(XmlTagToObjectClassMap); RETAIN(XmlTagToObjectClassMap);
@ -704,7 +704,7 @@ static NSArray *XmlBoolDefaultYes = nil;
// Parse the XML data // Parse the XML data
[theParser parse]; [theParser parse];
// Decode optional resources // Decode optional resourcess
_resources = RETAIN([self decodeObjectForKey: @"resources"]); _resources = RETAIN([self decodeObjectForKey: @"resources"]);
} }
NS_HANDLER NS_HANDLER

View file

@ -98,11 +98,12 @@
{ {
NSKeyedUnarchiver *unarchiver = nil; NSKeyedUnarchiver *unarchiver = nil;
if ([self checkStoryboard: data]) // if ([self checkStoryboard: data])
{ // {
unarchiver = [[GSStoryboardKeyedUnarchiver alloc] initForReadingWithData: data]; // unarchiver = [[GSStoryboardKeyedUnarchiver alloc] initForReadingWithData: data];
} // }
else if ([self checkXib5: data]) // else
if ([self checkXib5: data])
{ {
unarchiver = [[GSXib5KeyedUnarchiver alloc] initForReadingWithData: data]; unarchiver = [[GSXib5KeyedUnarchiver alloc] initForReadingWithData: data];
} }

View file

@ -111,32 +111,17 @@ static NSStoryboard *__mainStoryboard = nil;
self = [super init]; self = [super init];
if (self != nil) if (self != nil)
{ {
BOOL success = NO; NSString *path = [bundle pathForResource: name
ofType: @"storyboard"];
success = [bundle loadNibFile: name _data = [NSData dataWithContentsOfFile: path];
externalNameTable: nil
withZone: NSDefaultMallocZone()];
if (success) if (_data != nil)
{ {
} }
/* else
if (unarchiver != nil)
{ {
NSArray *rootObjects; NSLog(@"Failed to load storyboard with name \"%@\" at \"%@.\"", name, path);
IBObjectContainer *objects;
NSDebugLLog(@"XIB", @"Invoking unarchiver");
[unarchiver setObjectZone: zone];
rootObjects = [unarchiver decodeObjectForKey: @"IBDocument.RootObjects"];
objects = [unarchiver decodeObjectForKey: @"IBDocument.Objects"];
NSDebugLLog(@"XIB", @"rootObjects %@", rootObjects);
[self awake: rootObjects
inContainer: objects
withContext: context];
loaded = YES;
} }
*/
} }
return self; return self;
} }