Don't use ivar interconnected_stack_height.

(DOING_ROOT_OBJECT): New macro, defined based on
interconnected_stack_height.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@756 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1996-01-23 16:55:56 +00:00
parent 98ce2060ae
commit a7b5a4d193

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, 1995 Free Software Foundation, Inc. Copyright (C) 1994, 1995, 1996 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,9 +21,6 @@
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* xxx We could get rid of doing_root_object and just use
interconnected_stack_height instead. */
#include <objects/stdobjects.h> #include <objects/stdobjects.h>
#include <objects/Coder.h> #include <objects/Coder.h>
#include <objects/MemoryStream.h> #include <objects/MemoryStream.h>
@ -48,6 +45,8 @@ enum {CODER_OBJECT_NIL = 0, CODER_OBJECT, CODER_ROOT_OBJECT,
static BOOL debug_coder = NO; static BOOL debug_coder = NO;
static id defaultStreamClass; static id defaultStreamClass;
#define DOING_ROOT_OBJECT (interconnected_stack_height != 0)
/* xxx For experimentation. The function in objc-api.h doesn't always /* xxx For experimentation. The function in objc-api.h doesn't always
work for objects; it sometimes returns YES for an instance. */ work for objects; it sometimes returns YES for an instance. */
@ -156,7 +155,6 @@ my_object_is_class(id object)
- doInitOnStream: (Stream*)s isDecoding: (BOOL)f - doInitOnStream: (Stream*)s isDecoding: (BOOL)f
{ {
is_decoding = f; is_decoding = f;
doing_root_object = NO;
// [s retain]; // [s retain];
stream = s; stream = s;
object_table = nil; object_table = nil;
@ -336,7 +334,7 @@ exc_return_null(arglist_t f)
- (void) _internalCoderPutObject: anObj atReference: (unsigned)xref - (void) _internalCoderPutObject: anObj atReference: (unsigned)xref
{ {
if (doing_root_object) if (DOING_ROOT_OBJECT)
{ {
assert(![[self _coderTopRootObjectTable] includesKey:xref]); assert(![[self _coderTopRootObjectTable] includesKey:xref]);
[[self _coderTopRootObjectTable] putElement:anObj atKey:xref]; [[self _coderTopRootObjectTable] putElement:anObj atKey:xref];
@ -789,7 +787,6 @@ exc_return_null(arglist_t f)
{ {
if (interconnected_stack_height++) if (interconnected_stack_height++)
return; return;
doing_root_object = YES;
[self _coderPushRootObjectTable]; [self _coderPushRootObjectTable];
[self _coderPushForwardObjectTable]; [self _coderPushForwardObjectTable];
} }
@ -798,11 +795,11 @@ exc_return_null(arglist_t f)
{ {
/* xxx Perhaps we should look at the forward references and /* xxx Perhaps we should look at the forward references and
encode here any forward-referenced objects that haven't been encode here any forward-referenced objects that haven't been
encoded yet. */ encoded yet. No---the current behavior implements NeXT's
-encodeConditionalObject: */
assert (interconnected_stack_height); assert (interconnected_stack_height);
if (--interconnected_stack_height) if (--interconnected_stack_height)
return; return;
doing_root_object = NO;
[self _coderPopRootObjectTable]; [self _coderPopRootObjectTable];
[self _coderPopForwardObjectTable]; [self _coderPopForwardObjectTable];
} }
@ -811,7 +808,6 @@ exc_return_null(arglist_t f)
{ {
if (interconnected_stack_height++) if (interconnected_stack_height++)
return; return;
doing_root_object = YES;
[self _coderPushRootObjectTable]; [self _coderPushRootObjectTable];
[self _coderPushForwardObjectTable]; [self _coderPushForwardObjectTable];
} }
@ -856,7 +852,6 @@ exc_return_null(arglist_t f)
[[self _coderTopRootObjectTable] withElementsCall:ask_awake]; [[self _coderTopRootObjectTable] withElementsCall:ask_awake];
} }
[self _coderPopRootObjectTable]; [self _coderPopRootObjectTable];
doing_root_object = NO;
} }
/* NOTE: This *can* be called recursively */ /* NOTE: This *can* be called recursively */
@ -1037,9 +1032,7 @@ exc_return_null(arglist_t f)
} }
case CODER_ROOT_OBJECT: case CODER_ROOT_OBJECT:
{ {
doing_root_object = YES;
[self _decodeRootObjectAt:anObjPtr withName:name]; [self _decodeRootObjectAt:anObjPtr withName:name];
doing_root_object = NO;
break; break;
} }
case CODER_REPEATED_OBJECT: case CODER_REPEATED_OBJECT:
@ -1060,7 +1053,7 @@ exc_return_null(arglist_t f)
unsigned xref; unsigned xref;
struct objc_list* addr_list; struct objc_list* addr_list;
if (!doing_root_object) if (!DOING_ROOT_OBJECT)
[self error:"can't decode forward reference when not decoding " [self error:"can't decode forward reference when not decoding "
"a root object"]; "a root object"];
[self decodeValueOfSimpleType:@encode(unsigned) [self decodeValueOfSimpleType:@encode(unsigned)