diff --git a/Source/Array.m b/Source/Array.m index b4b0690d4..1d741a8fc 100644 --- a/Source/Array.m +++ b/Source/Array.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C Array collection object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -78,23 +78,23 @@ withName:"Array Capacity"]; } -+ _newCollectionWithCoder: (Coder*)coder +- _initCollectionWithCoder: (Coder*)coder { char *encoding; - Array *n = [super _newCollectionWithCoder:coder]; + [super _initCollectionWithCoder:coder]; [coder decodeValueOfSimpleType:@encode(char*) at:&encoding withName:NULL]; - n->_comparison_function = elt_get_comparison_function(encoding); + _comparison_function = elt_get_comparison_function(encoding); [coder decodeValueOfSimpleType:@encode(unsigned) - at:&(n->_grow_factor) + at:&_grow_factor withName:NULL]; - n->_count = 0; + _count = 0; [coder decodeValueOfSimpleType:@encode(unsigned) - at:&(n->_capacity) + at:&_capacity withName:NULL]; - OBJC_MALLOC(n->_contents_array, elt, n->_capacity); - return n; + OBJC_MALLOC(_contents_array, elt, _capacity); + return self; } - _writeInit: (TypedStream*)aStream diff --git a/Source/BinaryTree.m b/Source/BinaryTree.m index b04e12add..0b53ade03 100644 --- a/Source/BinaryTree.m +++ b/Source/BinaryTree.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C BinaryTree collection object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -53,13 +53,12 @@ static id nilBinaryTreeNode; /* Archiving must mimic the above designated initializer */ -+ _newCollectionWithCoder: (Coder*)aCoder +- _initCollectionWithCoder: aCoder { - BinaryTree *n; - n = [super _newCollectionWithCoder:aCoder]; - n->_count = 0; - n->_contents_root = [self nilNode]; - return n; + [super _initCollectionWithCoder:aCoder]; + _count = 0; + _contents_root = [self nilNode]; + return self; } - (void) _encodeContentsWithCoder: (Coder*)aCoder diff --git a/Source/BinaryTreeNode.m b/Source/BinaryTreeNode.m index 24c47e0c1..4e0a1044f 100644 --- a/Source/BinaryTreeNode.m +++ b/Source/BinaryTreeNode.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C BinaryTreeNode object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -38,21 +38,21 @@ return self; } -- (void) encodeWithCoder: (Coder*)aCoder +- (void) encodeWithCoder: aCoder { - [super encodeWithCoder:aCoder]; + [super encodeWithCoder:(id)aCoder]; [aCoder encodeObjectReference:_right withName:"Right BinaryTree Node"]; [aCoder encodeObjectReference:_left withName:"Left BinaryTree Node"]; [aCoder encodeObjectReference:_parent withName:"Parent BinaryTree Node"]; } -+ newWithCoder: (Coder*)aCoder +- initWithCoder: aCoder { - BinaryTreeNode *n = [super newWithCoder:aCoder]; - [aCoder decodeObjectAt:&(n->_right) withName:NULL]; - [aCoder decodeObjectAt:&(n->_left) withName:NULL]; - [aCoder decodeObjectAt:&(n->_parent) withName:NULL]; - return n; + [super initWithCoder:aCoder]; + [aCoder decodeObjectAt:&_right withName:NULL]; + [aCoder decodeObjectAt:&_left withName:NULL]; + [aCoder decodeObjectAt:&_parent withName:NULL]; + return self; } - leftNode diff --git a/Source/CString.m b/Source/CString.m index ecf49d377..679e63b31 100644 --- a/Source/CString.m +++ b/Source/CString.m @@ -1,5 +1,5 @@ /* Implementation for GNU Objective-C CString object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: July 1994 @@ -52,13 +52,13 @@ withName:"Concrete String content_chars"]; } -+ newWithCoder: aCoder +- initWithCoder: aCoder { - CString *n = [super newWithCoder:aCoder]; - [aCoder decodeValueOfType:@encode(char*) at:&(n->_contents_chars) + [super initWithCoder:aCoder]; + [aCoder decodeValueOfType:@encode(char*) at:&_contents_chars withName:NULL]; - n->_count = strlen(n->_contents_chars); - return n; + _count = strlen(_contents_chars); + return self; } /* Empty copy must empty an allocCopy'ed version of self */ diff --git a/Source/CircularArray.m b/Source/CircularArray.m index d73c6f0b5..64ce122bc 100644 --- a/Source/CircularArray.m +++ b/Source/CircularArray.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C CircularArray collection object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -44,11 +44,11 @@ /* Archiving must mimic the above designated initializer */ -+ _newCollectionWithCoder: (Coder*)coder +- _initCollectionWithCoder: coder { - CircularArray *n = [super newWithCoder:coder]; - n->_start_index = 0; - return n; + [super _initCollectionWithCoder:coder]; + _start_index = 0; + return self; } - _readInit: (TypedStream*)aStream diff --git a/Source/Collection.m b/Source/Collection.m index d8608b509..33d00238b 100644 --- a/Source/Collection.m +++ b/Source/Collection.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C Collection object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -1218,17 +1218,17 @@ for info about latest version.", return licenseString; } -- (void) encodeWithCoder: (Coder*)aCoder +- (void) encodeWithCoder: aCoder { [self _encodeCollectionWithCoder:aCoder]; [self _encodeContentsWithCoder:aCoder]; } -+ newWithCoder: (Coder*)aCoder +- initWithCoder: aCoder { - id newCollection = [self _newCollectionWithCoder:aCoder]; - [newCollection _decodeContentsWithCoder:aCoder]; - return newCollection; + [self _initCollectionWithCoder:aCoder]; + [self _decodeContentsWithCoder:aCoder]; + return self; } @end @@ -1236,17 +1236,17 @@ for info about latest version.", @implementation Collection (ArchivingHelpers) -- (void) _encodeCollectionWithCoder: (Coder*) aCoder +- (void) _encodeCollectionWithCoder: aCoder { [super encodeWithCoder:aCoder]; // there are no instance vars; return; } -+ _newCollectionWithCoder: (Coder*) aCoder +- _initCollectionWithCoder: aCoder { // there are no instance vars; - return [super newWithCoder:aCoder]; + return [super initWithCoder:aCoder]; } - _writeInit: (TypedStream*)aStream diff --git a/Source/Connection.m b/Source/Connection.m index 0e6d898cf..96d3d3c7e 100644 --- a/Source/Connection.m +++ b/Source/Connection.m @@ -1202,12 +1202,12 @@ static int messagesReceivedCount; return self; } -- (void) encodeWithCoder: (Coder*)anEncoder +- (void) encodeWithCoder: anEncoder { [self shouldNotImplement:_cmd]; } -+ newWithCoder: (Coder*)aDecoder; ++ newWithCoder: aDecoder; { [self shouldNotImplement:_cmd]; return self; diff --git a/Source/DelegatePool.m b/Source/DelegatePool.m index b05198b36..0276880d0 100644 --- a/Source/DelegatePool.m +++ b/Source/DelegatePool.m @@ -1,5 +1,5 @@ /* Implementation of Objective-C "collection of delegates" object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -51,7 +51,7 @@ /* Archiving must mimic the above designated initializer */ -- (void) encodeWithCoder: (Coder*)anEncoder +- (void) encodeWithCoder: anEncoder { [anEncoder encodeValueOfSimpleType:@encode(unsigned char) at:&_send_behavior @@ -60,9 +60,11 @@ withName:"DelegatePool Collection of Delegates"]; } -+ newWithCoder: (Coder*)aDecoder ++ newWithCoder: aDecoder { - DelegatePool *n = class_create_instance(self); + /* xxx Should be: + DelegatePool *n = NSAllocateObject(self, 0, [aDecoder objectZone]); */ + DelegatePool *n = (id) NSAllocateObject(self, 0, NS_NOZONE); [aDecoder decodeValueOfSimpleType:@encode(unsigned char) at:&(n->_send_behavior) withName:NULL]; diff --git a/Source/Dictionary.m b/Source/Dictionary.m index c815569ba..26deb653a 100644 --- a/Source/Dictionary.m +++ b/Source/Dictionary.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C Dictionary collection object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -63,12 +63,12 @@ /* Archiving must mimic the above designated initializer */ -- (void) encodeWithCoder: (Coder*)anEncoder +- (void) encodeWithCoder: anEncoder { [self notImplemented:_cmd]; } -+ newWithCoder: (Coder*)aDecoder ++ newWithCoder: aDecoder { [self notImplemented:_cmd]; return self; diff --git a/Source/EltNodeCollector.m b/Source/EltNodeCollector.m index 8a770d89b..5ecd89c10 100644 --- a/Source/EltNodeCollector.m +++ b/Source/EltNodeCollector.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C EltNodeCollector collection object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -91,7 +91,7 @@ /* Archiving must mimic the above designated initializer */ -- (void) _encodeCollectionWithCoder: (Coder*)aCoder +- (void) _encodeCollectionWithCoder: aCoder { const char *encoding = [self contentType]; @@ -102,17 +102,16 @@ withName:"EltNodeCollector Content Node Class"]; } -+ _newCollectionWithCoder: (Coder*) aCoder +- _initCollectionWithCoder: aCoder { - EltNodeCollector *n; char *encoding; - n = [super _newCollectionWithCoder:aCoder]; + [super _initCollectionWithCoder:aCoder]; [aCoder decodeValueOfType:@encode(char*) at:&encoding withName:NULL]; - n->_comparison_function = elt_get_comparison_function(encoding); - [aCoder decodeValueOfType:"#" at:&(n->_node_class) withName:NULL]; - n->_contents_collector = nil; - return n; + _comparison_function = elt_get_comparison_function(encoding); + [aCoder decodeValueOfType:"#" at:&_node_class withName:NULL]; + _contents_collector = nil; + return self; } - (void) _encodeContentsWithCoder: (Coder*)aCoder diff --git a/Source/GapArray.m b/Source/GapArray.m index 3ab29f1e1..08be4d6b3 100644 --- a/Source/GapArray.m +++ b/Source/GapArray.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C GapArray collection object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: Kresten Krab Thorup Dept. of Mathematics and Computer Science, Aalborg U., Denmark @@ -47,12 +47,12 @@ /* Archiving must mimic the above designated initializer */ -- (void) encodeWithCoder: (Coder*)anEncoder +- (void) encodeWithCoder: anEncoder { [self notImplemented:_cmd]; } -+ newWithCoder: (Coder*)aDecoder ++ newWithCoder: aDecoder { [self notImplemented:_cmd]; return self; diff --git a/Source/LinkedList.m b/Source/LinkedList.m index 8238c4abe..79de75186 100644 --- a/Source/LinkedList.m +++ b/Source/LinkedList.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C LinkedList collection object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -44,16 +44,15 @@ /* Archiving must mimic the above designated initializer */ -+ _newCollectionWithCoder: (Coder*)aCoder +- _initCollectionWithCoder: aCoder { - LinkedList *n; - n = [super _newCollectionWithCoder:aCoder]; - n->_count = 0; - n->_first_link = nil; - return n; + [super _initCollectionWithCoder:aCoder]; + _count = 0; + _first_link = nil; + return self; } -- (void) _encodeContentsWithCoder: (Coder*)aCoder +- (void) _encodeContentsWithCoder: aCoder { [aCoder startEncodingInterconnectedObjects]; [super _encodeContentsWithCoder:aCoder]; diff --git a/Source/LinkedListNode.m b/Source/LinkedListNode.m index d4be24b50..d5b7f8110 100644 --- a/Source/LinkedListNode.m +++ b/Source/LinkedListNode.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C LinkedListNode object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -39,19 +39,19 @@ return self; } -- (void) encodeWithCoder: (Coder*)aCoder +- (void) encodeWithCoder: aCoder { [super encodeWithCoder:aCoder]; [aCoder encodeObjectReference:_next withName:"Next LinkedList Node"]; [aCoder encodeObjectReference:_prev withName:"Prev LinkedList Node"]; } -+ newWithCoder: (Coder*)aCoder +- initWithCoder: aCoder { - LinkedListNode *n = [super newWithCoder:aCoder]; - [aCoder decodeObjectAt:&(n->_next) withName:NULL]; - [aCoder decodeObjectAt:&(n->_prev) withName:NULL]; - return n; + [super initWithCoder:aCoder]; + [aCoder decodeObjectAt:&_next withName:NULL]; + [aCoder decodeObjectAt:&_prev withName:NULL]; + return self; } - (id ) nextLink diff --git a/Source/MappedCollector.m b/Source/MappedCollector.m index 2a7d365af..e02694be0 100644 --- a/Source/MappedCollector.m +++ b/Source/MappedCollector.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C MappedCollector collection object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -42,12 +42,12 @@ /* Archiving must mimic the above designated initializer */ -- (void) encodeWithCoder: (Coder*)anEncoder +- (void) encodeWithCoder: anEncoder { [self notImplemented:_cmd]; } -+ newWithCoder: (Coder*)aDecoder ++ newWithCoder: aDecoder { [self notImplemented:_cmd]; return self; diff --git a/Source/MemoryStream.m b/Source/MemoryStream.m index 24e3f3df5..75f97726f 100644 --- a/Source/MemoryStream.m +++ b/Source/MemoryStream.m @@ -1,5 +1,5 @@ /* Implementation of GNU Objective C memory stream - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: July 1994 @@ -99,12 +99,12 @@ static BOOL debug_memory_stream = YES; return [self initWithSize: DEFAULT_MEMORY_STREAM_SIZE]; } -- (void) encodeWithCoder: (Coder*)anEncoder +- (void) encodeWithCoder: anEncoder { [self notImplemented:_cmd]; } -+ newWithCoder: (Coder*)aDecoder ++ newWithCoder: aDecoder { [self notImplemented:_cmd]; return self; diff --git a/Source/MutableCString.m b/Source/MutableCString.m index c18cc1758..1c68e636d 100644 --- a/Source/MutableCString.m +++ b/Source/MutableCString.m @@ -117,17 +117,17 @@ stringDecrementCountAndFillHoleAt(MutableCStringStruct *self, withName:"String content_chars"]; } -+ newWithCoder: aCoder +- initWithCoder: aCoder { MutableCString *n; unsigned cap; [aCoder decodeValueOfType:@encode(unsigned) at:&cap withName:NULL]; - n = [[MutableCString alloc] initWithCapacity:cap]; - [aCoder decodeValueOfType:@encode(char*) at:&(n->_contents_chars) + [self initWithCapacity:cap]; + [aCoder decodeValueOfType:@encode(char*) at:_contents_chars withName:NULL]; - n->_count = strlen(n->_contents_chars); - n->_capacity = cap; + _count = strlen(_contents_chars); + _capacity = cap; return n; } diff --git a/Source/NSCoder.m b/Source/NSCoder.m index bb24e8b8a..2693a0a5c 100644 --- a/Source/NSCoder.m +++ b/Source/NSCoder.m @@ -1,7 +1,8 @@ -/* NSCoder - coder obejct for serialization and persistance. +/* NSCoder - coder object for serialization and persistance. Copyright (C) 1995 Free Software Foundation, Inc. - Written by: Adam Fedor + Written by: R. Andrew McCallum + From skeleton by: Adam Fedor Date: Mar 1995 This file is part of the GNU Objective C Class Library. @@ -21,143 +22,184 @@ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include +#include +#include @implementation NSCoder // Encoding Data -- (void)encodeArrayOfObjCType:(const char *)types - count:(unsigned)count - at:(const void *)array +- (void) encodeArrayOfObjCType: (const char*)type + count: (unsigned)count + at: (const void*)array +{ + int i, size = objc_sizeof_type(type); + const char *where = array; + + [self encodeValueOfObjCType:@encode(unsigned) + at:&count]; + for (i = 0; i < count; i++, where += size) + [self encodeValueOfObjCType:type + at:where]; +} + +- (void) encodeBycopyObject: (id)anObject; +{ + [self encodeObject:anObject]; +} + +- (void) encodeConditionalObject: (id)anObject; +{ + [self encodeObject:anObject]; +} + +- (void) encodeDataObject: (NSData*)data; { [self notImplemented:_cmd]; } -- (void)encodeBycopyObject:(id)anObject; +- (void) encodeObject: (id)anObject; { [self notImplemented:_cmd]; } -- (void)encodeConditionalObject:(id)anObject; +- (void) encodePropertyList: (id)plist; { [self notImplemented:_cmd]; } -- (void)encodeDataObject:(NSData *)data; +- (void) encodePoint: (NSPoint)point; +{ + [self encodeValueOfObjCType:@encode(NSPoint) + at:&point]; +} + +- (void) encodeRect: (NSRect)rect; +{ + [self encodeValueOfObjCType:@encode(NSRect) + at:&rect]; +} + +- (void) encodeRootObject: (id)rootObject; +{ + [self encodeObject:rootObject]; +} + +- (void) encodeSize: (NSSize)size; +{ + [self encodeValueOfObjCType:@encode(NSSize) + at:&size]; +} + +- (void) encodeValueOfObjCType: (const char*)type + at: (const void*)address; { [self notImplemented:_cmd]; } -- (void)encodeObject:(id)anObject; +- (void) encodeValuesOfObjCTypes: (const char*)types,...; { - [self notImplemented:_cmd]; -} - -- (void)encodePropertyList:(id)plist; -{ - [self notImplemented:_cmd]; -} - -- (void)encodePoint:(NSPoint)point; -{ - [self notImplemented:_cmd]; -} - -- (void)encodeRect:(NSRect)rect; -{ - [self notImplemented:_cmd]; -} - -- (void)encodeRootObject:(id)rootObject; -{ - [self notImplemented:_cmd]; -} - -- (void)encodeSize:(NSSize)size; -{ - [self notImplemented:_cmd]; -} - -- (void)encodeValueOfObjCType:(const char *)type - at:(const void *)address; -{ - [self notImplemented:_cmd]; -} - -- (void)encodeValuesOfObjCTypes:(const char *)types,...; -{ - [self notImplemented:_cmd]; + va_list ap; + va_start(ap, types); + while (*types) + { + [self encodeValueOfObjCType:types + at:va_arg(ap, void*)]; + types = objc_skip_typespec(types); + } + va_end(ap); } // Decoding Data -- (void)decodeArrayOfObjCType:(const char *)types - count:(unsigned)count - at:(void *)address; +- (void) decodeArrayOfObjCType: (const char*)type + count: (unsigned)count + at: (void*)address; { - [self notImplemented:_cmd]; + unsigned encoded_count; + int i, size = objc_sizeof_type(type); + char *where = address; + + [self decodeValueOfObjCType:@encode(unsigned) + at:&encoded_count]; + assert(encoded_count == count); /* xxx fix this */ + for (i = 0; i < count; i++, where += size) + [self decodeValueOfObjCType:type + at:where]; } -- (NSData *)decodeDataObject; +- (NSData*) decodeDataObject; { [self notImplemented:_cmd]; return nil; } -- (id)decodeObject; +- (id) decodeObject; { [self notImplemented:_cmd]; return nil; } -- (id)decodePropertyList +- (id) decodePropertyList { [self notImplemented:_cmd]; return nil; } -- (NSPoint)decodePoint +- (NSPoint) decodePoint { NSPoint point; - [self notImplemented:_cmd]; + [self decodeValueOfObjCType:@encode(NSPoint) + at:&point]; return point; } -- (NSRect)decodeRect +- (NSRect) decodeRect { NSRect rect; - [self notImplemented:_cmd]; + [self decodeValueOfObjCType:@encode(NSRect) + at:&rect]; return rect; } -- (NSSize)decodeSize +- (NSSize) decodeSize { NSSize size; - [self notImplemented:_cmd]; + [self decodeValueOfObjCType:@encode(NSSize) + at:&size]; return size; } -- (void)decodeValueOfObjCType:(const char *)type - at:(void *)address +- (void) decodeValueOfObjCType: (const char*)type + at: (void*)address { [self notImplemented:_cmd]; } -- (void)decodeValuesOfObjCTypes:(const char *)types,...; +- (void) decodeValuesOfObjCTypes: (const char*)types,...; { - [self notImplemented:_cmd]; + va_list ap; + va_start(ap, types); + while (*types) + { + [self decodeValueOfObjCType:types + at:va_arg(ap, void*)]; + types = objc_skip_typespec(types); + } + va_end(ap); } // Managing Zones -- (NSZone *)objectZone; +- (NSZone*) objectZone; { [self notImplemented:_cmd]; - return (NSZone *)0; + return (NSZone*)0; } -- (void)setObjectZone:(NSZone *)zone; +- (void) setObjectZone: (NSZone*)zone; { [self notImplemented:_cmd]; } @@ -165,13 +207,13 @@ // Getting a Version -- (unsigned int)systemVersion; +- (unsigned int) systemVersion; { [self notImplemented:_cmd]; return 0; } -- (unsigned int)versionForClassName:(NSString *)className; +- (unsigned int) versionForClassName: (NSString*)className; { [self notImplemented:_cmd]; return 0; diff --git a/Source/NSGCString.m b/Source/NSGCString.m index 68391e76b..5ff531cac 100644 --- a/Source/NSGCString.m +++ b/Source/NSGCString.m @@ -55,13 +55,13 @@ withName:"Concrete String content_chars"]; } -+ newWithCoder: aCoder +- initWithCoder: aCoder { - NSCString *n = [super newWithCoder:aCoder]; - [aCoder decodeValueOfType:@encode(char*) at:&(n->_contents_chars) + [super initWithCoder:aCoder]; + [aCoder decodeValueOfType:@encode(char*) at:&_contents_chars withName:NULL]; - n->_count = strlen(n->_contents_chars); - return n; + _count = strlen(_contents_chars); + return self; } /* Empty copy must empty an allocCopy'ed version of self */ @@ -245,18 +245,17 @@ stringDecrementCountAndFillHoleAt(NSMutableCStringStruct *self, withName:"String content_chars"]; } -+ newWithCoder: aCoder +- initWithCoder: aCoder { - NSMutableCString *n; unsigned cap; [aCoder decodeValueOfType:@encode(unsigned) at:&cap withName:NULL]; - n = [[NSMutableCString alloc] initWithCapacity:cap]; - [aCoder decodeValueOfType:@encode(char*) at:&(n->_contents_chars) + [self initWithCapacity:cap]; + [aCoder decodeValueOfType:@encode(char*) at:&_contents_chars withName:NULL]; - n->_count = strlen(n->_contents_chars); - n->_capacity = cap; - return n; + _count = strlen(_contents_chars); + _capacity = cap; + return self; } /* For IndexedCollecting protocol */ diff --git a/Source/NSObject.m b/Source/NSObject.m index 63d04481b..d072f22cb 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -408,14 +408,14 @@ BOOL NSDecrementExtraRefCountWasZero(id anObject) return NSZoneFromPtr(self); } -#if 0 /* waiting until I resolve type conflict with GNU Coding method */ -- (void)encodeWithCoder:(NSCoder *)aCoder +#if 1 /* waiting until I resolve type conflict with GNU Coding method */ +- (void) encodeWithCoder: (NSCoder*)aCoder { return; } #endif -- initWithCoder:(NSCoder *)aDecoder +- initWithCoder: (NSCoder*)aDecoder { return self; } diff --git a/Source/NSString.m b/Source/NSString.m index 7e0b9eb0b..d027788c2 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -666,6 +666,18 @@ return [[NSMutableCString allocWithZone:zone] initWithString:self]; } +/* NSCoding Protocol */ + +- (void) encodeWithCoder: anEncoder +{ + [super encodeWithCoder:anEncoder]; +} + +- initWithCoder: aDecoder +{ + return [super initWithCoder:aDecoder]; +} + @end @implementation NSString (NSCStringAccess) diff --git a/Source/Port.m b/Source/Port.m index da47fb409..c4de4d15b 100644 --- a/Source/Port.m +++ b/Source/Port.m @@ -1,5 +1,5 @@ /* Implementation of abstract superclass port for use with Connection - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: July 1994 @@ -97,9 +97,4 @@ [super encodeWithCoder:anEncoder]; } -+ newWithCoder: (Coder*)aDecoder; -{ - return [super newWithCoder:aDecoder]; -} - @end diff --git a/Source/RBTreeNode.m b/Source/RBTreeNode.m index 1bdd98587..2d52c879e 100644 --- a/Source/RBTreeNode.m +++ b/Source/RBTreeNode.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C RBTreeNode objects - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -38,17 +38,17 @@ return self; } -- (void) encodeWithCoder: (Coder*)aCoder +- (void) encodeWithCoder: aCoder { [super encodeWithCoder:aCoder]; [aCoder encodeValueOfType:@encode(BOOL) at:&_red withName:"RBTreeNode isRed"]; } -+ newWithCoder: (Coder*)aCoder +- initWithCoder: aCoder { - RBTreeNode *n = [super newWithCoder:aCoder]; - [aCoder decodeValueOfType:@encode(BOOL) at:&(n->_red) withName:NULL]; - return n; + [self initWithCoder:aCoder]; + [aCoder decodeValueOfType:@encode(BOOL) at:&_red withName:NULL]; + return self; } - write: (TypedStream*)aStream diff --git a/Source/RNGAdditiveCongruential.m b/Source/RNGAdditiveCongruential.m index b09cc4127..a5b3578d5 100644 --- a/Source/RNGAdditiveCongruential.m +++ b/Source/RNGAdditiveCongruential.m @@ -1,5 +1,5 @@ /* Implementation additive congruential pseudo-random num generating - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: July 1994 @@ -45,12 +45,12 @@ return self; } -- (void) encodeWithCoder: (Coder*)anEncoder +- (void) encodeWithCoder: anEncoder { [self notImplemented:_cmd]; } -+ newWithCoder: (Coder*)aDecoder +- initWithCoder: aDecoder { [self notImplemented:_cmd]; return self; diff --git a/Source/RNGBerkeley.m b/Source/RNGBerkeley.m index af08cadc0..c6d6961b5 100644 --- a/Source/RNGBerkeley.m +++ b/Source/RNGBerkeley.m @@ -21,7 +21,7 @@ */ /* - * Copyright (c) 1983 Regents of the University of California. + * Copyright (c) 1983, 1995 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted @@ -428,12 +428,12 @@ static long int *end_ptr = &randtbl[sizeof(randtbl) / sizeof(randtbl[0])]; } } -- (void) encodeWithCoder: (Coder*)anEncoder +- (void) encodeWithCoder: anEncoder { [self notImplemented:_cmd]; } -+ newWithCoder: (Coder*)aDecoder +- initWithCoder: aDecoder { [self notImplemented:_cmd]; return self; diff --git a/Source/Random.m b/Source/Random.m index 9f0f5f63e..12fb5b22f 100644 --- a/Source/Random.m +++ b/Source/Random.m @@ -1,5 +1,5 @@ /* Implementation Objective-C object providing randoms in uniform distribution - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: July 1994 @@ -277,12 +277,12 @@ static id defaultRNG = nil; return [self randomDouble]; } -- (void) encodeWithCoder: (Coder*)anEncoder +- (void) encodeWithCoder: anEncoder { [self notImplemented:_cmd]; } -+ newWithCoder: (Coder*)aDecoder +- initWithCoder: aDecoder { [self notImplemented:_cmd]; return self; diff --git a/Source/Set.m b/Source/Set.m index 63378cf10..3e2a33887 100644 --- a/Source/Set.m +++ b/Source/Set.m @@ -1,5 +1,5 @@ /* Implementation for Objective-C Set collection object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -75,24 +75,23 @@ return; } -+ _newCollectionWithCoder: (Coder*) aCoder +- _initCollectionWithCoder: aCoder { - Set *newColl; char *encoding; unsigned size; - newColl = [super _newCollectionWithCoder:aCoder]; + [super _initCollectionWithCoder:aCoder]; [aCoder decodeValueOfSimpleType:@encode(char*) at:&encoding withName:NULL]; [aCoder decodeValueOfSimpleType:@encode(unsigned) at:&size withName:NULL]; - newColl->_contents_hash = + _contents_hash = coll_hash_new(size, elt_get_hash_function(encoding), elt_get_comparison_function(encoding)); - return newColl; + return self; } - _writeInit: (TypedStream*)aStream diff --git a/Source/Stream.m b/Source/Stream.m index 3c7acd6d5..5d4d5743a 100644 --- a/Source/Stream.m +++ b/Source/Stream.m @@ -1,5 +1,5 @@ /* Implementation of GNU Objective C byte stream - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: July 1994 @@ -138,12 +138,12 @@ } #endif -- (void) encodeWithCoder: (Coder*)anEncoder +- (void) encodeWithCoder: anEncoder { [self notImplemented:_cmd]; } -+ newWithCoder: (Coder*)aDecoder ++ newWithCoder: aDecoder { [self notImplemented:_cmd]; return self; diff --git a/Source/TextCoder.m b/Source/TextCoder.m index 97b4364f4..97902fb1b 100644 --- a/Source/TextCoder.m +++ b/Source/TextCoder.m @@ -1,5 +1,5 @@ /* Implementation of GNU Objective-C text 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 Date: July 1994 @@ -274,12 +274,12 @@ if (debug_textcoder) \ } } -- (void) encodeWithCoder: (Coder*)anEncoder +- (void) encodeWithCoder: anEncoder { [self notImplemented:_cmd]; } -+ newWithCoder: (Coder*)aDecoder ++ newWithCoder: aDecoder { [self notImplemented:_cmd]; return self; diff --git a/Source/Time.m b/Source/Time.m index d20761cb9..664cb919e 100644 --- a/Source/Time.m +++ b/Source/Time.m @@ -1,5 +1,5 @@ /* Implementation of Objective-C Time object - Copyright (C) 1993,1994 Free Software Foundation, Inc. + Copyright (C) 1993,1994, 1995 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 @@ -359,12 +359,12 @@ id monthNames; return diff; } -- (void) encodeWithCoder: (Coder*)anEncoder +- (void) encodeWithCoder: anEncoder { [self notImplemented:_cmd]; } -+ newWithCoder: (Coder*)aDecoder ++ newWithCoder: aDecoder { [self notImplemented:_cmd]; return self;