Convert to new Coder scheme. Use -initWithCoder instead

of +newWithCoder where appropriate.  Remove arguments typed
(Coder*).  Replace +_newCollectionWithCoder with
-_initCollectionWithCoder.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@334 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1995-04-09 02:06:39 +00:00
parent 3b43be1a80
commit 73559b8788
8 changed files with 83 additions and 263 deletions

View file

@ -1,5 +1,5 @@
/* Interface for GNU Objective-C coder object for use serializing /* Interface for GNU Objective-C coder object for use serializing
Copyright (C) 1994 Free Software Foundation, Inc. Copyright (C) 1994, 1995 Free Software Foundation, Inc.
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu> Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
Date: July 1994 Date: July 1994
@ -21,8 +21,8 @@
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef __Coder_h #ifndef __Coder_h_OBJECTS_INCLUDE
#define __Coder_h #define __Coder_h_OBJECTS_INCLUDE
#include <objects/stdobjects.h> #include <objects/stdobjects.h>
#include <objects/Coding.h> #include <objects/Coding.h>
@ -31,7 +31,7 @@
@class Dictionary; @class Dictionary;
@class Stack; @class Stack;
@interface Coder : NSObject @interface Coder : NSObject <Encoding, Decoding>
{ {
int format_version; int format_version;
int concrete_format_version; int concrete_format_version;
@ -48,102 +48,14 @@
+ defaultStreamClass; + defaultStreamClass;
+ setDebugging: (BOOL)f; + setDebugging: (BOOL)f;
- initEncodingOnStream: (Stream *)s;
- initDecodingOnStream: (Stream *)s;
- initEncoding;
- initDecoding;
- init;
- (void) dealloc;
- (BOOL) isDecoding;
- (void) encodeValueOfType: (const char*)type
at: (const void*)d
withName: (const char *)name;
- (void) decodeValueOfType: (const char*)type
at: (void*)d
withName: (const char **)namePtr;
- (void) encodeWithName: (const char *)name
valuesOfTypes: (const char *)types, ...;
- (void) decodeWithName: (const char **)name
valuesOfTypes: (const char *)types, ...;
- (void) encodeArrayOfType: (const char *)type
at: (const void *)d
count: (unsigned)c
withName: (const char *)name;
- (void) decodeArrayOfType: (const char *)type
at: (void *)d
count: (unsigned *)c
withName: (const char **)name;
- (void) encodeObject: anObj
withName: (const char *)name;
- (void) encodeObjectBycopy: anObj
withName: (const char *)name;
- (void) decodeObjectAt: (id*)anObjPtr
withName: (const char **)name;
- (void) encodeRootObject: anObj
withName: (const char *)name;
- (void) encodeObjectReference: anObj
withName: (const char *)name;
- (void) startEncodingInterconnectedObjects;
- (void) finishEncodingInterconnectedObjects;
- (void) startDecodingInterconnectedObjects;
- (void) finishDecodingInterconnectedObjects;
- (void) encodeAtomicString: (const char*)sp
withName: (const char*)name;
- (const char *) decodeAtomicStringWithName: (const char **)name;
- decodeClass;
- (void) encodeClass: aClass;
/* For inserting a name into a TextCoder stream */
- (void) encodeName: (const char*)n;
- (void) decodeName: (const char**)n;
/* For subclasses that want to keep track of recursion */
- (void) encodeIndent;
- (void) encodeUnindent;
- (void) decodeIndent;
- (void) decodeUnindent;
/* Implemented by concrete subclasses */
- (void) encodeValueOfSimpleType: (const char*)type
at: (const void*)d
withName: (const char *)name;
- (void) decodeValueOfSimpleType: (const char*)type
at: (void*)d
withName: (const char **)namePtr;
- (void) encodeBytes: (const char *)b
count: (unsigned)c
withName: (const char *)name;
- (void) decodeBytes: (char *)b
count: (unsigned*)c
withName: (const char **)name;
- (int) coderFormatVersion;
- (int) coderConcreteFormatVersion;
- (void) resetCoder; /* xxx remove this? */
- doInitOnStream: (Stream *)s isDecoding: (BOOL)f;
/* Internal designated initializer. Override it, but don't call it yourself.
This method name may change. */
+ (int) coderFormatVersion;
+ (int) coderConcreteFormatVersion;
+ (const char *) coderSignature;
@end @end
@interface NSObject (CoderAdditions) <Coding> @interface NSObject (OptionalNewWithCoder)
- (void) encodeWithCoder: (Coder*)anEncoder;
+ newWithCoder: (Coder*)aDecoder; + newWithCoder: (Coder*)aDecoder;
@end
@interface NSObject (CoderAdditions)
/* <SelfCoding> not needed because of NSCoding */
/* These methods here temporarily until ObjC runtime category bug fixed */ /* These methods here temporarily until ObjC runtime category bug fixed */
- classForConnectedCoder:aRmc; - classForConnectedCoder:aRmc;
@ -151,4 +63,4 @@
@end @end
#endif /* __Coder_h */ #endif /* __Coder_h_OBJECTS_INCLUDE */

View file

@ -1,5 +1,5 @@
/* Collection definitions for the use of subclass implementations only /* Collection definitions for the use of subclass implementations only
Copyright (C) 1993,1994 Free Software Foundation, Inc. Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc.
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu> Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
Date: May 1993 Date: May 1993
@ -36,10 +36,10 @@
- _readContents: (TypedStream*)aStream; - _readContents: (TypedStream*)aStream;
/* The Coding versions of the above */ /* The Coding versions of the above */
- (void) _encodeCollectionWithCoder: (Coder*) aCoder; - (void) _encodeCollectionWithCoder: (id <Encoding>)aCoder;
+ _newCollectionWithCoder: (Coder*) aCoder; - _initCollectionWithCoder: (id <Decoding>)aCoder;
- (void) _encodeContentsWithCoder: (Coder*)aCoder; - (void) _encodeContentsWithCoder: (id <Encoding>)aCoder;
- (void) _decodeContentsWithCoder: (Coder*)aCoder; - (void) _decodeContentsWithCoder: (id <Decoding>)aCoder;
@end @end
@interface Collection (DeallocationHelpers) @interface Collection (DeallocationHelpers)

View file

@ -1,5 +1,5 @@
/* Code for implementation for Objective-C EltNode objects /* Code for implementation for Objective-C EltNode objects
Copyright (C) 1993 Free Software Foundation, Inc. Copyright (C) 1993, 1995 Free Software Foundation, Inc.
Written by: R. Andrew McCallum <mccallum@cs.rochester.edu> Written by: R. Andrew McCallum <mccallum@cs.rochester.edu>
Dept. of Computer Science, U. of Rochester, Rochester, NY 14627 Dept. of Computer Science, U. of Rochester, Rochester, NY 14627
@ -45,7 +45,7 @@
/* Archiving must mimic the above designated initializer */ /* Archiving must mimic the above designated initializer */
- (void) encodeWithCoder: (Coder*)aCoder - (void) encodeWithCoder: aCoder
{ {
const char *encoding; const char *encoding;
@ -68,20 +68,19 @@
return &_elt_comparison_function; return &_elt_comparison_function;
} }
+ newWithCoder: (Coder*)aCoder - initWithCoder: aCoder
{ {
id n;
char *encoding; char *encoding;
n = [super newWithCoder:aCoder]; [super initWithCoder:aCoder];
[aCoder decodeValueOfType:@encode(char*) [aCoder decodeValueOfType:@encode(char*)
at:&encoding at:&encoding
withName:NULL]; withName:NULL];
*[n _eltComparisonFunctionPtr] = elt_get_comparison_function(encoding); *[self _eltComparisonFunctionPtr] = elt_get_comparison_function(encoding);
[aCoder decodeValueOfType:encoding [aCoder decodeValueOfType:encoding
at:[n _elementDataPtr] at:[self _elementDataPtr]
withName:NULL]; withName:NULL];
return n; return self;
} }
- (int(*)(elt,elt)) comparisonFunction - (int(*)(elt,elt)) comparisonFunction

View file

@ -2,7 +2,7 @@
Copyright (C) 1994 NeXT Computer, Inc. Copyright (C) 1994 NeXT Computer, Inc.
This file is part of the GNU Objective C Class Library. This file is part of the GNU Objective C Class Library.
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
@ -18,8 +18,8 @@
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef __NSCoder__include__ #ifndef __NSCoder_h_OBJECTS_INCLUDE
#define __NSCoder__include__ #define __NSCoder_h_OBJECTS_INCLUDE
#include <foundation/NSObject.h> #include <foundation/NSObject.h>
#include <foundation/NSGeometry.h> #include <foundation/NSGeometry.h>
@ -28,53 +28,50 @@
@class NSMutableData, NSData, NSString; @class NSMutableData, NSData, NSString;
@interface NSCoder : NSObject @interface NSCoder : NSObject
{
NSMutableData *_data;
}
// Encoding Data // Encoding Data
- (void)encodeArrayOfObjCType:(const char *)types - (void) encodeArrayOfObjCType: (const char*)types
count:(unsigned)count count: (unsigned)count
at:(const void *)array; at: (const void*)array;
- (void)encodeBycopyObject:(id)anObject; - (void) encodeBycopyObject: (id)anObject;
- (void)encodeConditionalObject:(id)anObject; - (void) encodeConditionalObject: (id)anObject;
- (void)encodeDataObject:(NSData *)data; - (void) encodeDataObject: (NSData*)data;
- (void)encodeObject:(id)anObject; - (void) encodeObject: (id)anObject;
- (void)encodePropertyList:(id)plist; - (void) encodePropertyList: (id)plist;
- (void)encodePoint:(NSPoint)point; - (void) encodePoint: (NSPoint)point;
- (void)encodeRect:(NSRect)rect; - (void) encodeRect: (NSRect)rect;
- (void)encodeRootObject:(id)rootObject; - (void) encodeRootObject: (id)rootObject;
- (void)encodeSize:(NSSize)size; - (void) encodeSize: (NSSize)size;
- (void)encodeValueOfObjCType:(const char *)type - (void) encodeValueOfObjCType: (const char*)type
at:(const void *)address; at: (const void*)address;
- (void)encodeValuesOfObjCTypes:(const char *)types,...; - (void) encodeValuesOfObjCTypes: (const char*)types,...;
// Decoding Data // Decoding Data
- (void)decodeArrayOfObjCType:(const char *)types - (void) decodeArrayOfObjCType: (const char*)types
count:(unsigned)count count: (unsigned)count
at:(void *)address; at: (void*)address;
- (NSData *)decodeDataObject; - (NSData*) decodeDataObject;
- (id)decodeObject; - (id) decodeObject;
- (id)decodePropertyList; - (id) decodePropertyList;
- (NSPoint)decodePoint; - (NSPoint) decodePoint;
- (NSRect)decodeRect; - (NSRect) decodeRect;
- (NSSize)decodeSize; - (NSSize) decodeSize;
- (void)decodeValueOfObjCType:(const char *)type - (void) decodeValueOfObjCType: (const char*)type
at:(void *)address; at: (void*)address;
- (void)decodeValuesOfObjCTypes:(const char *)types,...; - (void) decodeValuesOfObjCTypes: (const char*)types,...;
// Managing Zones // Managing Zones
- (NSZone *)objectZone; - (NSZone*) objectZone;
- (void)setObjectZone:(NSZone *)zone; - (void) setObjectZone: (NSZone*)zone;
// Getting a Version // Getting a Version
- (unsigned int)systemVersion; - (unsigned int) systemVersion;
- (unsigned int)versionForClassName:(NSString *)className; - (unsigned int) versionForClassName: (NSString*)className;
@end @end
#endif /* __NSCoder__include__ */ #endif /* __NSCoder_h_OBJECTS_INCLUDE */

View file

@ -63,8 +63,8 @@
@end @end
@protocol NSCoding @protocol NSCoding
// - (void)encodeWithCoder:(NSCoder *)aCoder; /* xxx Fix this! */ - (void) encodeWithCoder: (NSCoder*)aCoder;
// - initWithCoder:(NSCoder *)aDecoder; - (id) initWithCoder: (NSCoder*)aDecoder;
@end @end
@ -111,6 +111,7 @@
NSObject *NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone); NSObject *NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone);
void NSDeallocateObject(NSObject *anObject); void NSDeallocateObject(NSObject *anObject);
NSObject *NSCopyObject(NSObject *anObject, unsigned extraBytes, NSZone *zone); NSObject *NSCopyObject(NSObject *anObject, unsigned extraBytes, NSZone *zone);
BOOL NSShouldRetainWithZone(NSObject *anObject, NSZone *requestedZone); BOOL NSShouldRetainWithZone(NSObject *anObject, NSZone *requestedZone);
void NSIncrementExtraRefCount(id anObject); void NSIncrementExtraRefCount(id anObject);
BOOL NSDecrementExtraRefCountWasZero(id anObject); BOOL NSDecrementExtraRefCountWasZero(id anObject);

View file

@ -1,5 +1,5 @@
/* Interface for GNU Objective-C coder object for use serializing /* Interface for GNU Objective-C coder object for use serializing
Copyright (C) 1994 Free Software Foundation, Inc. Copyright (C) 1994, 1995 Free Software Foundation, Inc.
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu> Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
Date: July 1994 Date: July 1994
@ -21,8 +21,8 @@
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef __Coder_h #ifndef __Coder_h_OBJECTS_INCLUDE
#define __Coder_h #define __Coder_h_OBJECTS_INCLUDE
#include <objects/stdobjects.h> #include <objects/stdobjects.h>
#include <objects/Coding.h> #include <objects/Coding.h>
@ -31,7 +31,7 @@
@class Dictionary; @class Dictionary;
@class Stack; @class Stack;
@interface Coder : NSObject @interface Coder : NSObject <Encoding, Decoding>
{ {
int format_version; int format_version;
int concrete_format_version; int concrete_format_version;
@ -48,102 +48,14 @@
+ defaultStreamClass; + defaultStreamClass;
+ setDebugging: (BOOL)f; + setDebugging: (BOOL)f;
- initEncodingOnStream: (Stream *)s;
- initDecodingOnStream: (Stream *)s;
- initEncoding;
- initDecoding;
- init;
- (void) dealloc;
- (BOOL) isDecoding;
- (void) encodeValueOfType: (const char*)type
at: (const void*)d
withName: (const char *)name;
- (void) decodeValueOfType: (const char*)type
at: (void*)d
withName: (const char **)namePtr;
- (void) encodeWithName: (const char *)name
valuesOfTypes: (const char *)types, ...;
- (void) decodeWithName: (const char **)name
valuesOfTypes: (const char *)types, ...;
- (void) encodeArrayOfType: (const char *)type
at: (const void *)d
count: (unsigned)c
withName: (const char *)name;
- (void) decodeArrayOfType: (const char *)type
at: (void *)d
count: (unsigned *)c
withName: (const char **)name;
- (void) encodeObject: anObj
withName: (const char *)name;
- (void) encodeObjectBycopy: anObj
withName: (const char *)name;
- (void) decodeObjectAt: (id*)anObjPtr
withName: (const char **)name;
- (void) encodeRootObject: anObj
withName: (const char *)name;
- (void) encodeObjectReference: anObj
withName: (const char *)name;
- (void) startEncodingInterconnectedObjects;
- (void) finishEncodingInterconnectedObjects;
- (void) startDecodingInterconnectedObjects;
- (void) finishDecodingInterconnectedObjects;
- (void) encodeAtomicString: (const char*)sp
withName: (const char*)name;
- (const char *) decodeAtomicStringWithName: (const char **)name;
- decodeClass;
- (void) encodeClass: aClass;
/* For inserting a name into a TextCoder stream */
- (void) encodeName: (const char*)n;
- (void) decodeName: (const char**)n;
/* For subclasses that want to keep track of recursion */
- (void) encodeIndent;
- (void) encodeUnindent;
- (void) decodeIndent;
- (void) decodeUnindent;
/* Implemented by concrete subclasses */
- (void) encodeValueOfSimpleType: (const char*)type
at: (const void*)d
withName: (const char *)name;
- (void) decodeValueOfSimpleType: (const char*)type
at: (void*)d
withName: (const char **)namePtr;
- (void) encodeBytes: (const char *)b
count: (unsigned)c
withName: (const char *)name;
- (void) decodeBytes: (char *)b
count: (unsigned*)c
withName: (const char **)name;
- (int) coderFormatVersion;
- (int) coderConcreteFormatVersion;
- (void) resetCoder; /* xxx remove this? */
- doInitOnStream: (Stream *)s isDecoding: (BOOL)f;
/* Internal designated initializer. Override it, but don't call it yourself.
This method name may change. */
+ (int) coderFormatVersion;
+ (int) coderConcreteFormatVersion;
+ (const char *) coderSignature;
@end @end
@interface NSObject (CoderAdditions) <Coding> @interface NSObject (OptionalNewWithCoder)
- (void) encodeWithCoder: (Coder*)anEncoder;
+ newWithCoder: (Coder*)aDecoder; + newWithCoder: (Coder*)aDecoder;
@end
@interface NSObject (CoderAdditions)
/* <SelfCoding> not needed because of NSCoding */
/* These methods here temporarily until ObjC runtime category bug fixed */ /* These methods here temporarily until ObjC runtime category bug fixed */
- classForConnectedCoder:aRmc; - classForConnectedCoder:aRmc;
@ -151,4 +63,4 @@
@end @end
#endif /* __Coder_h */ #endif /* __Coder_h_OBJECTS_INCLUDE */

View file

@ -1,5 +1,5 @@
/* Collection definitions for the use of subclass implementations only /* Collection definitions for the use of subclass implementations only
Copyright (C) 1993,1994 Free Software Foundation, Inc. Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc.
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu> Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
Date: May 1993 Date: May 1993
@ -36,10 +36,10 @@
- _readContents: (TypedStream*)aStream; - _readContents: (TypedStream*)aStream;
/* The Coding versions of the above */ /* The Coding versions of the above */
- (void) _encodeCollectionWithCoder: (Coder*) aCoder; - (void) _encodeCollectionWithCoder: (id <Encoding>)aCoder;
+ _newCollectionWithCoder: (Coder*) aCoder; - _initCollectionWithCoder: (id <Decoding>)aCoder;
- (void) _encodeContentsWithCoder: (Coder*)aCoder; - (void) _encodeContentsWithCoder: (id <Encoding>)aCoder;
- (void) _decodeContentsWithCoder: (Coder*)aCoder; - (void) _decodeContentsWithCoder: (id <Decoding>)aCoder;
@end @end
@interface Collection (DeallocationHelpers) @interface Collection (DeallocationHelpers)

View file

@ -1,5 +1,5 @@
/* Code for implementation for Objective-C EltNode objects /* Code for implementation for Objective-C EltNode objects
Copyright (C) 1993 Free Software Foundation, Inc. Copyright (C) 1993, 1995 Free Software Foundation, Inc.
Written by: R. Andrew McCallum <mccallum@cs.rochester.edu> Written by: R. Andrew McCallum <mccallum@cs.rochester.edu>
Dept. of Computer Science, U. of Rochester, Rochester, NY 14627 Dept. of Computer Science, U. of Rochester, Rochester, NY 14627
@ -45,7 +45,7 @@
/* Archiving must mimic the above designated initializer */ /* Archiving must mimic the above designated initializer */
- (void) encodeWithCoder: (Coder*)aCoder - (void) encodeWithCoder: aCoder
{ {
const char *encoding; const char *encoding;
@ -68,20 +68,19 @@
return &_elt_comparison_function; return &_elt_comparison_function;
} }
+ newWithCoder: (Coder*)aCoder - initWithCoder: aCoder
{ {
id n;
char *encoding; char *encoding;
n = [super newWithCoder:aCoder]; [super initWithCoder:aCoder];
[aCoder decodeValueOfType:@encode(char*) [aCoder decodeValueOfType:@encode(char*)
at:&encoding at:&encoding
withName:NULL]; withName:NULL];
*[n _eltComparisonFunctionPtr] = elt_get_comparison_function(encoding); *[self _eltComparisonFunctionPtr] = elt_get_comparison_function(encoding);
[aCoder decodeValueOfType:encoding [aCoder decodeValueOfType:encoding
at:[n _elementDataPtr] at:[self _elementDataPtr]
withName:NULL]; withName:NULL];
return n; return self;
} }
- (int(*)(elt,elt)) comparisonFunction - (int(*)(elt,elt)) comparisonFunction