From 7927ecefc29dae25f601d77449ea9a3a4a1fc208 Mon Sep 17 00:00:00 2001 From: mccallum Date: Thu, 22 Feb 1996 15:51:05 +0000 Subject: [PATCH] Declare classes Encoder and Decoder; extensive rearrangement of ivars, method names and protocols. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@955 72102866-910b-0410-8b05-ffd578937521 --- Headers/gnustep/base/Coder.h | 89 ++++++++++++++++++++++++------------ Source/objects/Coder.h | 89 ++++++++++++++++++++++++------------ 2 files changed, 118 insertions(+), 60 deletions(-) diff --git a/Headers/gnustep/base/Coder.h b/Headers/gnustep/base/Coder.h index b35f32ee7..320ddb9dd 100644 --- a/Headers/gnustep/base/Coder.h +++ b/Headers/gnustep/base/Coder.h @@ -28,30 +28,38 @@ #include #include #include +#include +#include @class CStream; -@class Dictionary; -@class Stack; -@class Array; /* xxx Change this to "Set" */ -/* xxx Should I split this into Encoder and Decoder classes? */ + +/* The root abstract class for archiving */ -@interface Coder : NSObject +@interface Coder : NSObject { int format_version; CStream *cstream; - BOOL is_decoding; - Dictionary *classname_map; /* for changing class names on r/w */ - Dictionary *object_table; /* read/written objects */ - Dictionary *const_ptr_table; /* read/written const *'s */ - Dictionary *root_object_table; /* table of interconnected objects */ - Dictionary *forward_object_table; /* table of forward references */ - Array *in_progress_table; /* objects started r/w, but !finished */ - int interconnected_stack_height; /* number of nested root objects */ - NSZone *zone; + NSMapTable *classname_2_classname; /* for changing class names on r/w */ + int interconnect_stack_height; /* number of nested root objects */ } -/* Encoding */ ++ setDebugging: (BOOL)f; + +@end + + +/* An abstract class for writing an archive */ + +@interface Encoder : Coder +{ + /* xxx in_progress_table should actually be an NSHashTable, + but we are working around a bug right now. */ + NSMapTable *in_progress_table; /* objects begun writing, but !finished */ + NSMapTable *object_2_xref; /* objects already written */ + NSMapTable *object_2_fref; /* table of forward references */ + NSMapTable *const_ptr_2_xref; /* const pointers already written */ +} - initForWritingToFile: (id ) filename; - initForWritingToFile: (id ) filename @@ -76,9 +84,34 @@ withName: (id ) name toStream: (id )stream; -/* Decoding */ -/* These are class methods because the header of the file or stream - determines which (sub)class of Coder is created. */ +/* Defaults */ ++ (void) setDefaultStreamClass: sc; ++ defaultStreamClass; ++ (void) setDefaultFormatVersion: (int)fv; ++ (int) defaultFormatVersion; + +@end + +@interface Encoder (Encoding) +@end + + + +/* An abstract class for reading an archive. */ + +@interface Decoder : Coder +{ + NSZone *zone; /* zone in which to create objects */ + id xref_2_object; /* objects already read */ + id xref_2_object_root; /* objs read since last -startDecodoingI.. */ + NSMapTable *xref_2_const_ptr; /* const pointers already written */ + NSMapTable *fref_2_object; /* table of forward references */ + NSMapTable *address_2_fref; /* table of forward references */ +} + +/* These are class methods (and not instance methods) because the + header of the file or stream determines which subclass of Decoder + is created. */ + newReadingFromFile: (id ) filename; + newReadingFromStream: (id )stream; @@ -88,29 +121,25 @@ + decodeObjectWithName: (id *) name fromStream: (id )stream; - -/* Querying */ - -+ (void) setDefaultStreamClass: sc; -+ defaultStreamClass; -+ (int) defaultFormatVersion; - - -+ setDebugging: (BOOL)f; - @end +@interface Decoder (Decoding) +@end + + +/* Extensions to NSObject for encoding and decoding. */ + @interface NSObject (OptionalNewWithCoder) + newWithCoder: (Coder*)aDecoder; @end @interface NSObject (CoderAdditions) /* not needed because of NSCoding */ - /* These methods here temporarily until ObjC runtime category bug fixed */ - classForConnectedCoder:aRmc; + (void) encodeObject: anObject withConnectedCoder: aRmc; - @end +extern id CoderSignatureMalformedException; + #endif /* __Coder_h_OBJECTS_INCLUDE */ diff --git a/Source/objects/Coder.h b/Source/objects/Coder.h index b35f32ee7..320ddb9dd 100644 --- a/Source/objects/Coder.h +++ b/Source/objects/Coder.h @@ -28,30 +28,38 @@ #include #include #include +#include +#include @class CStream; -@class Dictionary; -@class Stack; -@class Array; /* xxx Change this to "Set" */ -/* xxx Should I split this into Encoder and Decoder classes? */ + +/* The root abstract class for archiving */ -@interface Coder : NSObject +@interface Coder : NSObject { int format_version; CStream *cstream; - BOOL is_decoding; - Dictionary *classname_map; /* for changing class names on r/w */ - Dictionary *object_table; /* read/written objects */ - Dictionary *const_ptr_table; /* read/written const *'s */ - Dictionary *root_object_table; /* table of interconnected objects */ - Dictionary *forward_object_table; /* table of forward references */ - Array *in_progress_table; /* objects started r/w, but !finished */ - int interconnected_stack_height; /* number of nested root objects */ - NSZone *zone; + NSMapTable *classname_2_classname; /* for changing class names on r/w */ + int interconnect_stack_height; /* number of nested root objects */ } -/* Encoding */ ++ setDebugging: (BOOL)f; + +@end + + +/* An abstract class for writing an archive */ + +@interface Encoder : Coder +{ + /* xxx in_progress_table should actually be an NSHashTable, + but we are working around a bug right now. */ + NSMapTable *in_progress_table; /* objects begun writing, but !finished */ + NSMapTable *object_2_xref; /* objects already written */ + NSMapTable *object_2_fref; /* table of forward references */ + NSMapTable *const_ptr_2_xref; /* const pointers already written */ +} - initForWritingToFile: (id ) filename; - initForWritingToFile: (id ) filename @@ -76,9 +84,34 @@ withName: (id ) name toStream: (id )stream; -/* Decoding */ -/* These are class methods because the header of the file or stream - determines which (sub)class of Coder is created. */ +/* Defaults */ ++ (void) setDefaultStreamClass: sc; ++ defaultStreamClass; ++ (void) setDefaultFormatVersion: (int)fv; ++ (int) defaultFormatVersion; + +@end + +@interface Encoder (Encoding) +@end + + + +/* An abstract class for reading an archive. */ + +@interface Decoder : Coder +{ + NSZone *zone; /* zone in which to create objects */ + id xref_2_object; /* objects already read */ + id xref_2_object_root; /* objs read since last -startDecodoingI.. */ + NSMapTable *xref_2_const_ptr; /* const pointers already written */ + NSMapTable *fref_2_object; /* table of forward references */ + NSMapTable *address_2_fref; /* table of forward references */ +} + +/* These are class methods (and not instance methods) because the + header of the file or stream determines which subclass of Decoder + is created. */ + newReadingFromFile: (id ) filename; + newReadingFromStream: (id )stream; @@ -88,29 +121,25 @@ + decodeObjectWithName: (id *) name fromStream: (id )stream; - -/* Querying */ - -+ (void) setDefaultStreamClass: sc; -+ defaultStreamClass; -+ (int) defaultFormatVersion; - - -+ setDebugging: (BOOL)f; - @end +@interface Decoder (Decoding) +@end + + +/* Extensions to NSObject for encoding and decoding. */ + @interface NSObject (OptionalNewWithCoder) + newWithCoder: (Coder*)aDecoder; @end @interface NSObject (CoderAdditions) /* not needed because of NSCoding */ - /* These methods here temporarily until ObjC runtime category bug fixed */ - classForConnectedCoder:aRmc; + (void) encodeObject: anObject withConnectedCoder: aRmc; - @end +extern id CoderSignatureMalformedException; + #endif /* __Coder_h_OBJECTS_INCLUDE */