(-decodeObjectAt:withName:): Create the instance and send

-initWithCoder if the object doesn't respond to +newWithCoder.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@324 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1995-04-08 18:44:45 +00:00
parent 025a41bf53
commit 83e9bab0ae

View file

@ -1,5 +1,5 @@
/* Implementation of GNU Objective-C coder object for use serializing /* Implementation of 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
@ -982,7 +982,7 @@ exc_return_null(arglist_t f)
case CODER_OBJECT: case CODER_OBJECT:
{ {
unsigned xref; unsigned xref;
SEL decode_sel = sel_get_any_uid("newWithCoder:"); SEL new_sel = sel_get_any_uid("newWithCoder:");
Class object_class; Class object_class;
IMP imp; IMP imp;
@ -991,10 +991,17 @@ exc_return_null(arglist_t f)
withName:NULL]; withName:NULL];
[self decodeIndent]; [self decodeIndent];
object_class = [self decodeClass]; object_class = [self decodeClass];
if ((imp = objc_msg_lookup(object_class, decode_sel))) if ((imp = objc_msg_lookup(object_class, new_sel)))
*anObjPtr = (*imp)(object_class, decode_sel, self); *anObjPtr = (*imp)(object_class, new_sel, self);
else else
*anObjPtr = class_create_instance(object_class); {
SEL init_sel = sel_get_any_uid("initWithCoder:");
IMP imp = objc_msg_lookup(object_class, init_sel);
*anObjPtr = class_create_instance(object_class);
if (imp)
*anObjPtr = (*imp)(*anObjPtr, init_sel, self);
/* xxx else, error? */
}
/* Would get error here with Connection-wide object references /* Would get error here with Connection-wide object references
because addProxy gets called in +newRemote:connection: */ because addProxy gets called in +newRemote:connection: */
if ([self _coderHasObjectReference:xref]) if ([self _coderHasObjectReference:xref])
@ -1233,14 +1240,19 @@ exc_return_null(arglist_t f)
@implementation NSObject (CoderAdditions) @implementation NSObject (CoderAdditions)
- (void) encodeWithCoder: (Coder*)anEncoder - (void) encodeWithCoder: (id <Encoding>)anEncoder
{ {
return; return;
} }
+ newWithCoder: (Coder*)aDecoder - initWithCoder: (id <Decoding>)aDecoder
{ {
return NSAllocateObject(self, 0, NULL); return self;
}
+ newWithCoder: (id <Decoding>)aDecoder
{
return NSAllocateObject(self, 0, NULL); /* xxx Fix this NULL */
} }