(connectionForward,connectionPerformAndDismissCoder): Removed old

#if'ed-out versions.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1994-11-21 00:19:10 +00:00
parent 09c06010a6
commit 0ae4349f26

View file

@ -225,7 +225,6 @@ static int messagesReceivedCount;
#define FLT_AND_DBL_RETFRAME_OFFSET 8
#if 1
- (retval_t) connectionForward: (Proxy*)object : (SEL)sel : (arglist_t)argframe
{
ConnectedCoder *op;
@ -307,272 +306,6 @@ static int messagesReceivedCount;
}
}
#else
- (retval_t) connectionForward: (SEL)sel : (arglist_t)argframe
{
id op;
id ip;
retval_t* retframe = NULL; /* NULL just to avoid uninitialized warning */
const char *type;
const char *tmptype;
unsigned flags;
int retsize;
char *datum;
BOOL out_parameters = NO;
int argnum; /* for debugging */
char argname[16]; /* for debugging */
op = [self newSendingRequestRmc];
/* get the method types from the selector */
type = sel_get_type(sel);
assert(type);
assert(*type);
/* Send the types that we're using, so that the performer knows
exactly what qualifiers we're using.
If all selectors included qualifiers and I could make sel_types_match()
work the way I wanted, we wouldn't need to do this. */
[op encodeValueOfSimpleType:@encode(char*)
at:&type
withName:"selector type"];
/* encode arguments */
tmptype = type;
datum = my_method_get_next_argument(argframe, &tmptype);
assert(datum);
assert(*tmptype == _C_ID);
if (![*(id*)datum isProxy])
[self error:"Asking connection to forward to a non-Proxy object"];
#if 0
if (![*(id*)datum proxyIsRemote])
[self error:"Asking connection to forward to non-remote Proxy"];
#endif
if ([*(id*)datum connectionForProxy] != self)
[self error:"Asking connection to forward to a Proxy it doesn't own"];
[op encodeValueOfType:tmptype
at:datum
withName:"arg1 receiver"];
datum = my_method_get_next_argument(argframe, &tmptype);
assert(datum);
assert(*tmptype == _C_SEL);
[op encodeValueOfType:tmptype
at:datum
withName:"arg2 selector"];
for (datum = my_method_get_next_argument(argframe, &tmptype), argnum=3;
datum;
datum = my_method_get_next_argument(argframe, &tmptype), argnum++)
{
flags = objc_get_type_qualifiers(tmptype);
tmptype = objc_skip_type_qualifiers(tmptype);
sprintf(argname, "arg%d", argnum); /* too expensive? */
if (*tmptype == _C_ID)
{
if (flags & _F_BYCOPY)
[op encodeObjectBycopy:*(id*)datum withName:argname];
else
[op encodeObject:*(id*)datum withName:argname];
}
else if (*tmptype == _C_CHARPTR)
{
if ((flags & _F_OUT) || !(flags & _F_IN))
out_parameters = YES;
if ((flags & _F_IN) || !(flags & _F_OUT))
[op encodeValueOfType:tmptype
at:datum
withName:argname];
}
else if (*tmptype == _C_PTR)
{
tmptype++;
if ((flags & _F_OUT) || !(flags & _F_IN))
out_parameters = YES;
/* xxx These two cases currently the same */
if (*tmptype == _C_STRUCT_B || *tmptype == _C_ARY_B)
{
if ((flags & _F_IN) || !(flags & _F_OUT))
[op encodeValueOfType:tmptype
at:*(void**)datum
withName:argname];
}
else
{
if ((flags & _F_IN) || !(flags & _F_OUT))
[op encodeValueOfType:tmptype
at:*(void**)datum
withName:argname];
}
}
else if (*tmptype == _C_STRUCT_B || *tmptype == _C_ARY_B)
{
#if CONNECTION_STRUCTURES_PASSED_BY_REFERENCE
[op encodeValueOfType:tmptype
at:*(void**)datum
withName:argname];
#else
[op encodeValueOfType:tmptype
at:datum
withName:argname];
#endif
}
else
{
[op encodeValueOfType:tmptype
at:datum
withName:argname];
}
}
[op dismiss];
/* get return values, if necessary */
flags = objc_get_type_qualifiers(type);
tmptype = objc_skip_type_qualifiers(type);
/* xxx What happens with method declared "- (oneway) foo: (out int*)ip;" */
/* xxx What happens with method declared "- (in char *) bar;" */
/* Is this right? Do we also have to check _F_ONEWAY? */
if (out_parameters || *tmptype != _C_VOID)
{
ip = [self newReceivedReplyRmcWithSequenceNumber:
[op sequenceNumber]];
if (*tmptype != _C_VOID)
{
/* decode return value */
retsize = objc_sizeof_type(tmptype);
/* xxx We need to test retsize's less than 4 Also note that
if we return structures using a structure-value-address, we
are potentially alloca'ing much more than we need here. */
/* xxx Find out about returning structures by reference
on non--structure-value-address machines, and potentially
just always alloca(RETFRAME_SIZE == sizeof(void*)*4) */
retframe = alloca(MAX(retsize, sizeof(void*)*4));
/* xxx change this to a switch (*tmptype) */
if (*tmptype == _C_PTR)
{
tmptype++;
/* xxx these two cases are the same */
if (*tmptype == _C_STRUCT_B || *tmptype == _C_ARY_B)
{
*(void**)retframe =
(*objc_malloc)(objc_sizeof_type(tmptype));
[ip decodeValueOfType:tmptype
at:*(void**)retframe
withName:NULL];
}
else
{
*(void**)retframe =
(*objc_malloc)(objc_sizeof_type(tmptype));
[ip decodeValueOfType:tmptype
at:*(void**)retframe
withName:NULL];
}
}
else if (*tmptype == _C_STRUCT_B || *tmptype == _C_ARY_B)
{
/* xxx These two cases currently the same */
#if CONNECTION_STRUCTURES_PASSED_BY_REFERENCE
*(void**)retframe = alloca(objc_sizeof_type(tmptype));
[ip decodeValueOfType:tmptype
at:*(void**)retframe
withName:NULL];
#else
*(void**)retframe = alloca(objc_sizeof_type(tmptype));
[ip decodeValueOfType:tmptype
at:*(void**)retframe
withName:NULL];
#endif
}
else if (*tmptype == _C_FLT || *tmptype == _C_DBL)
{
[ip decodeValueOfType:tmptype
at:((char*)retframe) + FLT_AND_DBL_RETFRAME_OFFSET
withName:NULL];
}
else /* Among other things, _C_CHARPTR is handled here */
{
/* int typesize; xxx Use retsize instead! */
/* xxx was: (typesize = objc_sizeof_type(tmptype)) */
/* Special case BOOL (and other types smaller than int)
because retframe doesn't actually point to the char */
/* xxx What about structures smaller than int's that
are passed by reference on true structure reference-
passing architectures? */
/* xxx Is this the right test? Use sizeof(int*) instead? */
if (retsize < sizeof(void*))
{
*(void**)retframe = 0;
[ip decodeValueOfType:tmptype
at:((char*)retframe)+sizeof(void*)-retsize
withName:NULL];
}
else
{
[ip decodeValueOfType:tmptype
at:retframe
withName:NULL];
}
}
}
/* decode values returned by reference */
if (out_parameters)
{
for (datum = my_method_get_next_argument(argframe, &tmptype);
datum;
(datum = my_method_get_next_argument(argframe, &tmptype)))
{
flags = objc_get_type_qualifiers(tmptype);
tmptype = objc_skip_type_qualifiers(tmptype);
if (*tmptype == _C_PTR
&& ((flags & _F_OUT) || !(flags & _F_IN)))
{
tmptype++;
/* xxx Note that a (char**) is malloc'ed anew here.
Yucky, or worse than yucky. If the returned string
is smaller than the original, we should just put it
there; if the returned string is bigger, I don't know
what to do. */
/* xxx These two cases are the same */
if (*tmptype == _C_STRUCT_B || *tmptype == _C_ARY_B)
{
[ip decodeValueOfType:tmptype
at:*(void**)datum
withName:NULL];
}
else
{
[ip decodeValueOfType:tmptype
at:*(void**)datum
withName:NULL];
}
}
/* __builtin_return can't return structures by value */
else if (*tmptype == _C_CHARPTR
&& ((flags & _F_OUT) || !(flags & _F_IN)))
{
[ip decodeValueOfType:tmptype
at:datum
withName:NULL];
}
}
}
[ip dismiss];
}
else /* void return value */
{
retframe = alloca(sizeof(void*));
}
return retframe;
}
#endif /* 1 */
#if 1
- connectionPerformAndDismissCoder: aRmc
{
char *forward_type;
@ -629,280 +362,6 @@ static int messagesReceivedCount;
return self;
}
#else
- connectionPerformAndDismissCoder: aRmc
{
const char *type, *tmptype;
char *forward_type;
const char *ftmptype;
id object;
SEL selector;
IMP imp;
void *retframe;
arglist_t argframe;
int stack_argsize;
int reg_argsize;
char *datum;
id op;
unsigned flags;
BOOL out_parameters = NO;
int reply_sequence_number;
char argname[16]; /* for debugging with TextCoder */
int argnum; /* for debugging with TextCoder */
/* Save this for later */
reply_sequence_number = [aRmc sequenceNumber];
/* Get the types that we're using, so that we know
exactly what qualifiers the forwarder used.
If all selectors included qualifiers and I could make sel_types_match()
work the way I wanted, we wouldn't need to do this. */
[aRmc decodeValueOfSimpleType:@encode(char*)
at:&forward_type
withName:NULL];
/* get object and selector */
[aRmc decodeValueOfType:@encode(id)
at:&object
withName:NULL];
/* @encode(SEL) produces "^v" in gcc 2.5.8. It should be ":" */
[aRmc decodeValueOfType:":"
at:&selector
withName:NULL];
assert(selector);
type = sel_get_type(selector);
assert(type);
/* Set up argframe */
stack_argsize = types_get_size_of_stack_arguments(type);
reg_argsize = types_get_size_of_register_arguments(type);
argframe = (arglist_t) alloca(sizeof(char*) + reg_argsize);
if (stack_argsize)
argframe->arg_ptr = alloca(stack_argsize);
else
argframe->arg_ptr = 0;
/* decode rest of arguments */
tmptype = type;
ftmptype = objc_skip_argspec(forward_type);
datum = my_method_get_next_argument(argframe, &tmptype);
assert(datum);
assert(*tmptype == _C_ID);
*(id*)datum = object;
assert(object);
ftmptype = objc_skip_argspec(ftmptype);
datum = my_method_get_next_argument(argframe, &tmptype);
assert(datum);
assert(*tmptype == _C_SEL);
*(SEL*)datum = selector;
assert(selector);
for (datum = my_method_get_next_argument(argframe, &tmptype),
ftmptype = objc_skip_argspec(ftmptype);
datum;
datum = my_method_get_next_argument(argframe, &tmptype),
ftmptype = objc_skip_argspec(ftmptype))
{
flags = objc_get_type_qualifiers(ftmptype);
tmptype = objc_skip_type_qualifiers(tmptype);
if (*tmptype == _C_CHARPTR)
{
if ((flags & _F_OUT) || !(flags & _F_IN))
out_parameters = YES;
if ((flags & _F_IN) || !(flags & _F_OUT))
[aRmc decodeValueOfType:tmptype
at:datum
withName:NULL];
}
else if (*tmptype == _C_PTR)
{
tmptype++;
if ((flags & _F_OUT) || !(flags & _F_IN))
out_parameters = YES;
/* xxx These two cases currently the same */
if (*tmptype == _C_STRUCT_B || *tmptype == _C_ARY_B)
{
/* *(void**)datum = alloca(sizeof(void*)); */
/* xxx or should this be alloca?!
What about inout params? Where do they get freed? */
*(void**)datum =
(*objc_malloc)(objc_sizeof_type(tmptype));
if ((flags & _F_IN) || !(flags & _F_OUT))
[aRmc decodeValueOfType:tmptype
at:*(void**)datum
withName:NULL];
}
else
{
/* xxx or should this be alloca?!
What about inout params? Where dothey get freed? */
*(char**)datum =
(*objc_malloc)(objc_sizeof_type(tmptype));
if ((flags & _F_IN) || !(flags & _F_OUT))
[aRmc decodeValueOfType:tmptype
at:*(void**)datum
withName:NULL];
}
}
else if (*tmptype == _C_STRUCT_B || *tmptype == _C_ARY_B)
{
#if CONNECTION_STRUCTURES_PASSED_BY_REFERENCE
*(void**)datum = alloca(objc_sizeof_type(tmptype));
[aRmc decodeValueOfType:tmptype
at:*(void**)datum
withName:NULL];
#else
[aRmc decodeValueOfType:tmptype
at:datum
withName:NULL];
#endif
}
else
{
[aRmc decodeValueOfType:tmptype
at:datum
withName:NULL];
}
}
/* We need this "dismiss" to happen here and not later so that Coder
"-awake..." methods will get sent before the __builtin_apply! */
[aRmc dismiss];
/* Call the method */
imp = objc_msg_lookup(object, selector);
assert(imp);
retframe = __builtin_apply((apply_t)imp,
argframe,
stack_argsize);
/* Return results, if necessary */
flags = objc_get_type_qualifiers(forward_type);
ftmptype = objc_skip_type_qualifiers(forward_type);
tmptype = objc_skip_type_qualifiers(type);
/* Is this right? Do we also have to check _F_ONEWAY? */
if (out_parameters || *tmptype != _C_VOID)
{
op = [self newSendingReplyRmcWithSequenceNumber:
reply_sequence_number];
#define ENCODE_RETNAME "return value"
if (*tmptype != _C_VOID)
{
/* encode return value */
/* xxx Change this to switch(*tmptype) */
if (*tmptype == _C_ID)
{
if (flags & _F_BYCOPY)
[op encodeObjectBycopy:*(id*)retframe withName:ENCODE_RETNAME];
else
[op encodeObject:*(id*)retframe withName:ENCODE_RETNAME];
}
else if (*tmptype == _C_PTR)
{
tmptype++;
/* xxx These two cases currently the same */
if (*tmptype == _C_STRUCT_B || *tmptype == _C_ARY_B)
[op encodeValueOfType:tmptype
at:*(void**)retframe
withName:ENCODE_RETNAME];
else
[op encodeValueOfType:tmptype
at:*(void**)retframe
withName:ENCODE_RETNAME];
}
else if (*tmptype == _C_STRUCT_B || *tmptype == _C_ARY_B)
{
/* xxx these two cases currently the same? */
#if CONNECTION_STRUCTURES_PASSED_BY_REFERENCE
[op encodeValueOfType:tmptype
at:*(void**)retframe
withName:ENCODE_RETNAME];
#else
[op encodeValueOfType:tmptype
at:*(void**)retframe
withName:ENCODE_RETNAME];
#endif
}
else if (*tmptype == _C_FLT || *tmptype == _C_DBL)
{
[op encodeValueOfType:tmptype
at:((char*)retframe) + FLT_AND_DBL_RETFRAME_OFFSET
withName:ENCODE_RETNAME];
}
else /* Among other types, _C_CHARPTR is handled here */
{
int retsize = objc_sizeof_type(tmptype);
/* Special case BOOL (and other types smaller than int)
because retframe doesn't actually point to the char */
/* xxx What about structures smaller than int's that
are passed by reference on true structure reference-
passing architectures? */
/* xxx Is this the right test? Use sizeof(int*) instead? */
if (retsize < sizeof(void*))
{
[op encodeValueOfType:tmptype
at:((char*)retframe)+sizeof(void*)-retsize
withName:ENCODE_RETNAME];
}
else
{
[op encodeValueOfType:tmptype
at:retframe
withName:ENCODE_RETNAME];
}
}
}
/* encode values returned by reference */
if (out_parameters)
{
for (datum = my_method_get_next_argument(argframe,&tmptype),
argnum = 1,
ftmptype = objc_skip_argspec(ftmptype);
datum;
datum = my_method_get_next_argument(argframe,&tmptype),
argnum++,
ftmptype = objc_skip_argspec(ftmptype))
{
flags = objc_get_type_qualifiers(ftmptype);
tmptype = objc_skip_type_qualifiers(tmptype);
sprintf(argname, "arg%d", argnum); /* too expensive? */
if ((*tmptype == _C_PTR)
&& ((flags & _F_OUT) || !(flags & _F_IN)))
{
tmptype++;
/* xxx These two cases currently the same */
if (*tmptype == _C_STRUCT_B || *tmptype == _C_ARY_B)
{
[op encodeValueOfType:tmptype
at:*(void**)datum
withName:argname];
}
else
{
[op encodeValueOfType:tmptype
at:*(void**)datum
withName:argname];
}
}
else if (*tmptype == _C_CHARPTR
&& ((flags & _F_OUT) || !(flags & _F_IN)))
{
[op encodeValueOfType:tmptype
at:datum
withName:argname];
}
}
}
[op dismiss];
}
(*objc_free)(forward_type);
return self;
}
#endif
+ (id <Collecting>) allConnections
{
return [connectionArray copy];