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:
Andrew McCallum 1995-04-09 02:06:39 +00:00
parent 0dc629b0ae
commit b231a3719e
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
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>
Date: July 1994
@ -21,8 +21,8 @@
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __Coder_h
#define __Coder_h
#ifndef __Coder_h_OBJECTS_INCLUDE
#define __Coder_h_OBJECTS_INCLUDE
#include <objects/stdobjects.h>
#include <objects/Coding.h>
@ -31,7 +31,7 @@
@class Dictionary;
@class Stack;
@interface Coder : NSObject
@interface Coder : NSObject <Encoding, Decoding>
{
int format_version;
int concrete_format_version;
@ -48,102 +48,14 @@
+ defaultStreamClass;
+ 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
@interface NSObject (CoderAdditions) <Coding>
- (void) encodeWithCoder: (Coder*)anEncoder;
@interface NSObject (OptionalNewWithCoder)
+ newWithCoder: (Coder*)aDecoder;
@end
@interface NSObject (CoderAdditions)
/* <SelfCoding> not needed because of NSCoding */
/* These methods here temporarily until ObjC runtime category bug fixed */
- classForConnectedCoder:aRmc;
@ -151,4 +63,4 @@
@end
#endif /* __Coder_h */
#endif /* __Coder_h_OBJECTS_INCLUDE */

View file

@ -1,5 +1,5 @@
/* 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>
Date: May 1993
@ -36,10 +36,10 @@
- _readContents: (TypedStream*)aStream;
/* The Coding versions of the above */
- (void) _encodeCollectionWithCoder: (Coder*) aCoder;
+ _newCollectionWithCoder: (Coder*) aCoder;
- (void) _encodeContentsWithCoder: (Coder*)aCoder;
- (void) _decodeContentsWithCoder: (Coder*)aCoder;
- (void) _encodeCollectionWithCoder: (id <Encoding>)aCoder;
- _initCollectionWithCoder: (id <Decoding>)aCoder;
- (void) _encodeContentsWithCoder: (id <Encoding>)aCoder;
- (void) _decodeContentsWithCoder: (id <Decoding>)aCoder;
@end
@interface Collection (DeallocationHelpers)

View file

@ -1,5 +1,5 @@
/* 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>
Dept. of Computer Science, U. of Rochester, Rochester, NY 14627
@ -45,7 +45,7 @@
/* Archiving must mimic the above designated initializer */
- (void) encodeWithCoder: (Coder*)aCoder
- (void) encodeWithCoder: aCoder
{
const char *encoding;
@ -68,20 +68,19 @@
return &_elt_comparison_function;
}
+ newWithCoder: (Coder*)aCoder
- initWithCoder: aCoder
{
id n;
char *encoding;
n = [super newWithCoder:aCoder];
[super initWithCoder:aCoder];
[aCoder decodeValueOfType:@encode(char*)
at:&encoding
withName:NULL];
*[n _eltComparisonFunctionPtr] = elt_get_comparison_function(encoding);
*[self _eltComparisonFunctionPtr] = elt_get_comparison_function(encoding);
[aCoder decodeValueOfType:encoding
at:[n _elementDataPtr]
at:[self _elementDataPtr]
withName:NULL];
return n;
return self;
}
- (int(*)(elt,elt)) comparisonFunction

View file

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

View file

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

View file

@ -1,5 +1,5 @@
/* 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>
Date: July 1994
@ -21,8 +21,8 @@
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __Coder_h
#define __Coder_h
#ifndef __Coder_h_OBJECTS_INCLUDE
#define __Coder_h_OBJECTS_INCLUDE
#include <objects/stdobjects.h>
#include <objects/Coding.h>
@ -31,7 +31,7 @@
@class Dictionary;
@class Stack;
@interface Coder : NSObject
@interface Coder : NSObject <Encoding, Decoding>
{
int format_version;
int concrete_format_version;
@ -48,102 +48,14 @@
+ defaultStreamClass;
+ 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
@interface NSObject (CoderAdditions) <Coding>
- (void) encodeWithCoder: (Coder*)anEncoder;
@interface NSObject (OptionalNewWithCoder)
+ newWithCoder: (Coder*)aDecoder;
@end
@interface NSObject (CoderAdditions)
/* <SelfCoding> not needed because of NSCoding */
/* These methods here temporarily until ObjC runtime category bug fixed */
- classForConnectedCoder:aRmc;
@ -151,4 +63,4 @@
@end
#endif /* __Coder_h */
#endif /* __Coder_h_OBJECTS_INCLUDE */

View file

@ -1,5 +1,5 @@
/* 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>
Date: May 1993
@ -36,10 +36,10 @@
- _readContents: (TypedStream*)aStream;
/* The Coding versions of the above */
- (void) _encodeCollectionWithCoder: (Coder*) aCoder;
+ _newCollectionWithCoder: (Coder*) aCoder;
- (void) _encodeContentsWithCoder: (Coder*)aCoder;
- (void) _decodeContentsWithCoder: (Coder*)aCoder;
- (void) _encodeCollectionWithCoder: (id <Encoding>)aCoder;
- _initCollectionWithCoder: (id <Decoding>)aCoder;
- (void) _encodeContentsWithCoder: (id <Encoding>)aCoder;
- (void) _decodeContentsWithCoder: (id <Decoding>)aCoder;
@end
@interface Collection (DeallocationHelpers)

View file

@ -1,5 +1,5 @@
/* 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>
Dept. of Computer Science, U. of Rochester, Rochester, NY 14627
@ -45,7 +45,7 @@
/* Archiving must mimic the above designated initializer */
- (void) encodeWithCoder: (Coder*)aCoder
- (void) encodeWithCoder: aCoder
{
const char *encoding;
@ -68,20 +68,19 @@
return &_elt_comparison_function;
}
+ newWithCoder: (Coder*)aCoder
- initWithCoder: aCoder
{
id n;
char *encoding;
n = [super newWithCoder:aCoder];
[super initWithCoder:aCoder];
[aCoder decodeValueOfType:@encode(char*)
at:&encoding
withName:NULL];
*[n _eltComparisonFunctionPtr] = elt_get_comparison_function(encoding);
*[self _eltComparisonFunctionPtr] = elt_get_comparison_function(encoding);
[aCoder decodeValueOfType:encoding
at:[n _elementDataPtr]
at:[self _elementDataPtr]
withName:NULL];
return n;
return self;
}
- (int(*)(elt,elt)) comparisonFunction