Move GMArchiver files so gui doesnt depend on extenions

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3614 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 1999-01-28 18:34:31 +00:00
parent 68b1bc9a05
commit ec6158f0bb
13 changed files with 1488 additions and 12 deletions

168
Model/GMArchiveObjects.m Normal file
View file

@ -0,0 +1,168 @@
/*
GMArchiveObjects.m
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: October 1997
Copyright (C) 1997 Free Software Foundation, Inc.
All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* This file declares categories to various OpenStep classes so they get
archived correctly by GMArchiver. The main things deal with encoding in
place of some objects like imutable strings, arrays, dictionaries and
data objects (basically the property list classes).
This file is included by GMArchiver rather than compiled as a separate file
because of the linking problems with categories (they are not linked into
the executable even if you refer a method from category; you should refer a
symbol from the category's file in order to force it link.
*/
#import <Foundation/NSData.h>
@implementation NSObject (ModelArchivingMethods)
- (id)replacementObjectForModelArchiver:(GMArchiver*)archiver
{
return [self replacementObjectForCoder:nil];
}
- (Class)classForModelArchiver
{
return [self classForCoder];
}
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
return [[[self allocWithZone:[unarchiver objectZone]] init] autorelease];
}
@end
@implementation NSString (ModelArchivingMethods)
- (void)encodeWithModelArchiver:(id)archiver
{
[archiver encodeString:self withName:@"string"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
return [unarchiver decodeStringWithName:@"string"];
}
- (Class)classForModelArchiver
{
return [NSString class];
}
@end
@implementation NSMutableString (ModelArchivingMethods)
- (Class)classForModelArchiver
{
return [NSMutableString class];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
return [[[unarchiver decodeStringWithName:@"string"] mutableCopy]
autorelease];
}
@end
@implementation NSArray (ModelArchivingMethods)
- (void)encodeWithModelArchiver:(id)archiver
{
[archiver encodeArray:self withName:@"elements"];
}
- (Class)classForModelArchiver
{
return [NSMutableArray class];
}
@end
@implementation NSMutableArray (ModelArchivingMethods)
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
id array = [unarchiver decodeArrayWithName:@"elements"];
int i, count;
for (i = 0, count = [array count]; i < count; i++)
[self addObject:[array objectAtIndex:i]];
return self;
}
@end
@implementation NSDictionary (ModelArchivingMethods)
- (void)encodeWithModelArchiver:(id)archiver
{
[archiver encodeDictionary:self withName:@"elements"];
}
- (Class)classForModelArchiver
{
return [NSMutableDictionary class];
}
@end
@implementation NSMutableDictionary (ModelArchivingMethods)
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
id dictionary = [unarchiver decodeDictionaryWithName:@"elements"];
id enumerator = [dictionary keyEnumerator];
id key, value;
while ((key = [enumerator nextObject])) {
value = [dictionary objectForKey:key];
[self setObject:value forKey:key];
}
return self;
}
@end
@implementation NSData (ModelArchivingMethods)
- (void)encodeWithModelArchiver:(id)archiver
{
[archiver encodeData:self withName:@"data"];
}
- (Class)classForModelArchiver
{
return [NSMutableData class];
}
@end
@implementation NSMutableData (ModelArchivingMethods)
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
id data = [unarchiver decodeDataWithName:@"data"];
[self appendData:data];
return self;
}
@end

1096
Model/GMArchiver.m Normal file

File diff suppressed because it is too large Load diff

View file

@ -37,7 +37,8 @@ endif
#APP_NAME = test
libgmodel_OBJC_FILES = IMCustomObject.m IMConnectors.m IMLoading.m GMAppKit.m
libgmodel_OBJC_FILES = IMCustomObject.m IMConnectors.m IMLoading.m GMAppKit.m \
GMArchiver.m
libgmodel_HEADER_FILES_DIR = ../Headers/AppKit
libgmodel_HEADER_FILES_INSTALL_DIR = /gnustep/gui/AppKit
libgmodel_HEADER_FILES = IMConnectors.h IMCustomObject.h IMLoading.h GMAppKit.h
@ -59,7 +60,7 @@ ADDITIONAL_CPPFLAGS += $(RUNTIME_DEFINE) $(GUI_DEFINE) $(BACKEND_DEFINE)
ADDITIONAL_LIB_DIRS += -L$(GNUSTEP_OBJ_DIR)
ADDITIONAL_TOOL_LIBS += -lgmodel -lFoundationExt
ADDITIONAL_TOOL_LIBS += -lgmodel
ADDITIONAL_OBJC_FLAGS += $(BACKEND_DEFINE)
# Additional include directories the compiler should search
@ -69,7 +70,7 @@ ADDITIONAL_INCLUDE_DIRS = -I../Headers -I../Headers/gnustep
# systems where building a shared library requires to pass to the linker
# all the libraries the target library depends upon.
LIBRARIES_DEPEND_UPON = -lFoundationExt $(FND_LIBS) $(GUI_LIBS) \
LIBRARIES_DEPEND_UPON = $(FND_LIBS) $(GUI_LIBS) \
$(BACKEND_LIBS) $(SYSTEM_LIBS)
-include GNUmakefile.local

View file

@ -27,3 +27,6 @@ before-libgmodel-all:: \
../Headers/gnustep/gui/%.h: %.h
cp $^ $@
# Additional dependencies
$(GNUSTEP_OBJ_DIR)/GMArchiver.o: GMArchiveObjects.m

View file

@ -28,7 +28,7 @@
#import <Foundation/NSCoder.h>
#import <Foundation/NSString.h>
#import <Foundation/NSArray.h>
#import <extensions/GMArchiver.h>
#import <AppKit/GMArchiver.h>
#import "IBClasses.h"
#import "Translator.h"
#import "IMConnectors.h"

View file

@ -26,11 +26,23 @@
#include <string.h>
#import <AppKit/NSActionCell.h>
#include <extensions/GMArchiver.h>
#include <extensions/objc-runtime.h>
#include <AppKit/GMArchiver.h>
#include "AppKit/IMCustomObject.h"
#include "IMConnectors.h"
#if GNU_RUNTIME
#include <objc/objc-api.h>
#include <objc/Protocol.h>
#include <objc/encoding.h>
#else /* NeXT_RUNTIME */
#include <objc/objc-class.h>
#include <extensions/objc-api.h>
#include <extensions/encoding.h>
#endif
static void
object_set_instance_variable (id anObject,
const char* variableName,

View file

@ -24,7 +24,7 @@
*/
#import <Foundation/NSObjCRuntime.h>
#include <extensions/GMArchiver.h>
#include <AppKit/GMArchiver.h>
#include "AppKit/IMCustomObject.h"
@implementation NSObject(ModelUnarchiving)

View file

@ -28,7 +28,7 @@
#import <Foundation/NSFileManager.h>
#import <Foundation/NSPathUtilities.h>
#include <extensions/GMArchiver.h>
#include <AppKit/GMArchiver.h>
#include "AppKit/IMLoading.h"
#include "AppKit/IMCustomObject.h"

View file

@ -32,7 +32,7 @@
#import <Foundation/NSNotification.h>
#import <AppKit/AppKit.h>
#import <extensions/GMArchiver.h>
#import <AppKit/GMArchiver.h>
#import "AppKit/IMLoading.h"
#import "IBClasses.h"
#import "Translator.h"