Invocation fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15873 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-02-04 18:18:47 +00:00
parent 391078933d
commit 382a204d75
5 changed files with 66 additions and 5 deletions

View file

@ -1,3 +1,23 @@
2003-02-04 Willem Rein Oudshoorn <woudshoo@xs4all.nl>
* Headers/gnustep/base/GSInvocation.h (CLEAR_RETURN_VALUE_IF_OBJECT):
* New macro, if invocation returns object release it.
(RETAIN_RETURN_VALUE): New macro, if invocation returns object
release it.
* Source/NSInvocation.m ([NSInvocation -dealloc]): Implement RELEASE
* return object
([NSInvocation -setReturnValue:]) Implement RETAIN/RELEASE on return
object ([NSInvocation -invokeWithTarget:]): Implement RETAIN/RELEASE
on return object,
fixed _validReturn flag setting
* Source/GSFFIInvocation.m ([GSFFIInvocation -invokeWithTarget:]):
Fix _validReturn flag setting, Implement RETAIN/RELEASE on return
object.
* Source/GSFFCallInvocation.m ([GSFFCallInvocation
* -invokeWithTarget:]):
Fix _validReturn flag setting. Implement RETAIN/RELEASE on return
object.
2003-02-04 Adam Fedor <fedor@Eldorado.local.>
* Headers/gnustep/base/.cvsignore: Don't include config.h.in

View file

@ -51,4 +51,14 @@ GSFFCallInvokeWithTargetAndImp(NSInvocation *inv, id anObject, IMP imp);
extern void
GSFFIInvokeWithTargetAndImp(NSInvocation *inv, id anObject, IMP imp);
#define CLEAR_RETURN_VALUE_IF_OBJECT do { if (_validReturn && *_info[0].type == _C_ID) \
{ \
RELEASE (*(id*) _retval); \
*(id*) _retval = nil; \
_validReturn = NO; \
}\
} while (0)
#define RETAIN_RETURN_VALUE do { if (*_info[0].type == _C_ID) RETAIN (*(id*) _retval);} while (0)
#endif

View file

@ -645,15 +645,23 @@ GSFFCallInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp)
id old_target;
IMP imp;
CLEAR_RETURN_VALUE_IF_OBJECT;
_validReturn = NO;
/*
* A message to a nil object returns nil.
*/
if (anObject == nil)
{
memset(_retval, '\0', _info[0].size); /* Clear return value */
if (*_info[0].type != _C_VOID)
{
_validReturn = YES;
}
return;
}
NSAssert(_selector != 0, @"you must set the selector before invoking");
/*
@ -697,6 +705,8 @@ GSFFCallInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp)
RELEASE(old_target);
GSFFCallInvokeWithTargetAndImp(self, anObject, imp);
RETAIN_RETURN_VALUE;
_validReturn = YES;
}

View file

@ -278,13 +278,17 @@ GSFFIInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp)
id old_target;
IMP imp;
CLEAR_RETURN_VALUE_IF_OBJECT;
_validReturn = NO;
/*
* A message to a nil object returns nil.
*/
if (anObject == nil)
{
if (_retval)
memset(_retval, '\0', _info[0].size); /* Clear return value */
memset(_retval, '\0', _info[0].size); /* Clear return value */
_validReturn = YES;
return;
}
@ -335,6 +339,8 @@ GSFFIInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp)
/* Decode the return value */
if (*_info[0].type != _C_VOID)
cifframe_decode_arg(_info[0].type, _retval);
RETAIN_RETURN_VALUE;
_validReturn = YES;
}

View file

@ -167,6 +167,10 @@ _arg_addr(NSInvocation *inv, int index)
}
}
}
CLEAR_RETURN_VALUE_IF_OBJECT;
#if defined(USE_LIBFFI)
if (_cframe)
{
@ -319,6 +323,8 @@ _arg_addr(NSInvocation *inv, int index)
type = _info[0].type;
CLEAR_RETURN_VALUE_IF_OBJECT;
if (*type != _C_VOID)
{
int length = _info[0].size;
@ -329,6 +335,8 @@ _arg_addr(NSInvocation *inv, int index)
#endif
memcpy(_retval, buffer, length);
}
RETAIN_RETURN_VALUE;
_validReturn = YES;
}
@ -425,11 +433,16 @@ _arg_addr(NSInvocation *inv, int index)
IMP imp;
int stack_argsize;
CLEAR_RETURN_VALUE_IF_OBJECT;
_validReturn = NO;
/*
* A message to a nil object returns nil.
*/
if (anObject == nil)
{
_validReturn = YES;
memset(_retval, '\0', _info[0].size); /* Clear return value */
return;
}
@ -485,6 +498,8 @@ _arg_addr(NSInvocation *inv, int index)
{
mframe_decode_return(_info[0].type, _retval, returned);
}
RETAIN_RETURN_VALUE;
_validReturn = YES;
}
@ -568,7 +583,7 @@ _arg_addr(NSInvocation *inv, int index)
const char *types;
void *datum;
unsigned int i;
[aCoder decodeValueOfObjCType: @encode(char*) at: &types];
newSig = [NSMethodSignature signatureWithObjCTypes: types];
NSZoneFree(NSDefaultMallocZone(), (void*)types);
@ -603,9 +618,9 @@ _arg_addr(NSInvocation *inv, int index)
{
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &_validReturn];
if (_validReturn)
{
[aCoder decodeValueOfObjCType: _info[0].type at: _retval];
}
{
[aCoder decodeValueOfObjCType: _info[0].type at: _retval];
}
}
return self;
}