Several changes to support porting of an OPENSTEP application to GNUstep.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2689 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Ovidiu Predescu 1998-01-09 22:28:14 +00:00
parent 298d5644e0
commit 83942f9a80
26 changed files with 365 additions and 29 deletions

View file

@ -44,6 +44,9 @@
@interface NSControl (GMArchiverMethods) <ModelCoding>
@end
@interface NSCStringText (GMArchiverMethods) <ModelCoding>
@end
@interface NSFont (GMArchiverMethods) <ModelCoding>
@end
@ -56,6 +59,9 @@
@interface NSMenu (GMArchiverMethods) <ModelCoding>
@end
@interface NSPopUpButton (GMArchiverMethods) <ModelCoding>
@end
@interface NSResponder (GMArchiverMethods) <ModelCoding>
@end

View file

@ -345,6 +345,26 @@ void __dummy_GMAppKit_functionForLinking() {}
@end /* NSControl (GMArchiverMethods) */
@implementation NSCStringText (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
return [super initWithModelUnarchiver:unarchiver];
}
- (Class)classForModelArchiver
{
return [NSCStringText class];
}
@end /* NSCStringText (GMArchiverMethods) */
@implementation NSFont (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
@ -382,7 +402,11 @@ void __dummy_GMAppKit_functionForLinking() {}
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
return [NSImage imageNamed:[unarchiver decodeStringWithName:@"name"]];
id image = [NSImage imageNamed:[unarchiver decodeStringWithName:@"name"]];
if (!image)
image = [NSImage imageNamed:@"NSRadioButton"];
return image;
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
@ -499,6 +523,27 @@ void __dummy_GMAppKit_functionForLinking() {}
@end /* NSMenu (GMArchiverMethods) */
@implementation NSPopUpButton (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
// [super encodeWithModelArchiver:archiver];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
// return [super initWithModelUnarchiver:unarchiver];
return self;
}
- (Class)classForModelArchiver
{
return [NSPopUpButton class];
}
@end /* NSPopUpButton (GMArchiverMethods) */
@implementation NSResponder (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver

View file

@ -22,6 +22,8 @@
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make
LIBRARY_NAME = libgmodel
@ -33,6 +35,9 @@ endif
APP_NAME = test
libgmodel_OBJC_FILES = IMCustomObject.m IMConnectors.m IMLoading.m GMAppKit.m
libgmodel_HEADER_FILES_DIR = .
libgmodel_HEADER_FILES_INSTALL_DIR = /gnustep/gui/AppKit
libgmodel_HEADER_FILES = IMConnectors.h IMCustomObject.h IMLoading.h GMAppKit.h
test_OBJC_FILES = test.m Controller.m

View file

@ -56,4 +56,23 @@
@interface NSIBControlConnector : NSIBConnector
@end
/* Classes used internally by NeXT's AppKit we don't want to appear in the
model file */
@interface NSWindowTemplate : NSObject
{
NSRect windowRect;
int windowStyleMask;
int windowBacking;
id windowTitle;
id viewClass;
id windowClass;
id windowView;
id realObject;
id extension;
NSSize minSize;
BOOL _wtFlags; /* Don't know the type of this ivar */
NSRect screenRect;
}
@end
#endif /* _GNUstep_H_IBClasses */

View file

@ -127,3 +127,25 @@
return [IMControlConnector class];
}
@end /* NSIBControlConnector */
@implementation NSWindowTemplate (GMArchiverMethods)
#ifdef DEBUG
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
NSLog (@"%@: %@", NSStringFromClass (isa), NSStringFromSelector (_cmd));
[super encodeWithModelArchiver:archiver];
}
#endif
- (id)replacementObjectForModelArchiver:(GMArchiver*)archiver
{
#ifdef DEBUG
NSLog (@"realObject = %@", realObject);
#endif
return realObject;
}
@end

View file

@ -54,7 +54,7 @@ object_set_instance_variable (id anObject,
if (ivar.ivar_name && !strcmp (ivar.ivar_name, variableName)) {
/* We found it! */
*((id*)(((char*)anObject) + ivar.ivar_offset)) = value;
*((void**)(((char*)anObject) + ivar.ivar_offset)) = value;
break;
}
}
@ -97,7 +97,7 @@ object_set_instance_variable (id anObject,
[_source setTarget:_destination];
}
else
object_set_instance_variable (_source, "target", _destination);
object_set_instance_variable (_source, "target", [_destination retain]);
if ([_source respondsToSelector:@selector(setAction:)]) {
// NSLog (@"%@: setting action to %@",
@ -124,7 +124,7 @@ object_set_instance_variable (id anObject,
if (setSelector && [_source respondsToSelector:setSelector])
[_source performSelector:setSelector withObject:_destination];
else
object_set_instance_variable(_source, [label cString], _destination);
object_set_instance_variable(_source, [label cString], [_destination retain]);
}
@end /* IMOutletConnector */

View file

@ -25,6 +25,7 @@
#import <Foundation/NSDictionary.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSFileManager.h>
#include <extensions/GMArchiver.h>
#include "IMLoading.h"
#include "IMCustomObject.h"
@ -58,10 +59,21 @@ BOOL _fileOwnerDecoded = NO;
+ (BOOL)loadIMFile:(NSString*)path owner:(id)owner
{
GMUnarchiver* unarchiver = [GMUnarchiver unarchiverWithContentsOfFile:path];
NSBundle* mainBundle = [NSBundle mainBundle];
NSString* resourcePath = [mainBundle resourcePath];
GMUnarchiver* unarchiver;
id previousNibOwner = _nibOwner;
GMModel* decoded;
if (![path hasSuffix:@".gmodel"])
path = [path stringByAppendingPathExtension:@"gmodel"];
path = [resourcePath stringByAppendingPathComponent:path];
if (![[NSFileManager defaultManager] fileExistsAtPath:path])
return NO;
NSLog (@"loading model file %@...", path);
unarchiver = [GMUnarchiver unarchiverWithContentsOfFile:path];
if (!unarchiver)
return NO;