mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
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:
parent
22206c66f3
commit
b30484a6c0
5 changed files with 66 additions and 5 deletions
20
ChangeLog
20
ChangeLog
|
@ -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.>
|
2003-02-04 Adam Fedor <fedor@Eldorado.local.>
|
||||||
|
|
||||||
* Headers/gnustep/base/.cvsignore: Don't include config.h.in
|
* Headers/gnustep/base/.cvsignore: Don't include config.h.in
|
||||||
|
|
|
@ -51,4 +51,14 @@ GSFFCallInvokeWithTargetAndImp(NSInvocation *inv, id anObject, IMP imp);
|
||||||
extern void
|
extern void
|
||||||
GSFFIInvokeWithTargetAndImp(NSInvocation *inv, id anObject, IMP imp);
|
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
|
#endif
|
||||||
|
|
|
@ -645,15 +645,23 @@ GSFFCallInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp)
|
||||||
id old_target;
|
id old_target;
|
||||||
IMP imp;
|
IMP imp;
|
||||||
|
|
||||||
|
CLEAR_RETURN_VALUE_IF_OBJECT;
|
||||||
|
_validReturn = NO;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A message to a nil object returns nil.
|
* A message to a nil object returns nil.
|
||||||
*/
|
*/
|
||||||
if (anObject == nil)
|
if (anObject == nil)
|
||||||
{
|
{
|
||||||
memset(_retval, '\0', _info[0].size); /* Clear return value */
|
memset(_retval, '\0', _info[0].size); /* Clear return value */
|
||||||
|
if (*_info[0].type != _C_VOID)
|
||||||
|
{
|
||||||
|
_validReturn = YES;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NSAssert(_selector != 0, @"you must set the selector before invoking");
|
NSAssert(_selector != 0, @"you must set the selector before invoking");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -697,6 +705,8 @@ GSFFCallInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp)
|
||||||
RELEASE(old_target);
|
RELEASE(old_target);
|
||||||
|
|
||||||
GSFFCallInvokeWithTargetAndImp(self, anObject, imp);
|
GSFFCallInvokeWithTargetAndImp(self, anObject, imp);
|
||||||
|
|
||||||
|
RETAIN_RETURN_VALUE;
|
||||||
_validReturn = YES;
|
_validReturn = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,13 +278,17 @@ GSFFIInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp)
|
||||||
id old_target;
|
id old_target;
|
||||||
IMP imp;
|
IMP imp;
|
||||||
|
|
||||||
|
CLEAR_RETURN_VALUE_IF_OBJECT;
|
||||||
|
_validReturn = NO;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A message to a nil object returns nil.
|
* A message to a nil object returns nil.
|
||||||
*/
|
*/
|
||||||
if (anObject == nil)
|
if (anObject == nil)
|
||||||
{
|
{
|
||||||
if (_retval)
|
if (_retval)
|
||||||
memset(_retval, '\0', _info[0].size); /* Clear return value */
|
memset(_retval, '\0', _info[0].size); /* Clear return value */
|
||||||
|
_validReturn = YES;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,6 +339,8 @@ GSFFIInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp)
|
||||||
/* Decode the return value */
|
/* Decode the return value */
|
||||||
if (*_info[0].type != _C_VOID)
|
if (*_info[0].type != _C_VOID)
|
||||||
cifframe_decode_arg(_info[0].type, _retval);
|
cifframe_decode_arg(_info[0].type, _retval);
|
||||||
|
|
||||||
|
RETAIN_RETURN_VALUE;
|
||||||
_validReturn = YES;
|
_validReturn = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,10 @@ _arg_addr(NSInvocation *inv, int index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CLEAR_RETURN_VALUE_IF_OBJECT;
|
||||||
|
|
||||||
#if defined(USE_LIBFFI)
|
#if defined(USE_LIBFFI)
|
||||||
if (_cframe)
|
if (_cframe)
|
||||||
{
|
{
|
||||||
|
@ -319,6 +323,8 @@ _arg_addr(NSInvocation *inv, int index)
|
||||||
|
|
||||||
type = _info[0].type;
|
type = _info[0].type;
|
||||||
|
|
||||||
|
CLEAR_RETURN_VALUE_IF_OBJECT;
|
||||||
|
|
||||||
if (*type != _C_VOID)
|
if (*type != _C_VOID)
|
||||||
{
|
{
|
||||||
int length = _info[0].size;
|
int length = _info[0].size;
|
||||||
|
@ -329,6 +335,8 @@ _arg_addr(NSInvocation *inv, int index)
|
||||||
#endif
|
#endif
|
||||||
memcpy(_retval, buffer, length);
|
memcpy(_retval, buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RETAIN_RETURN_VALUE;
|
||||||
_validReturn = YES;
|
_validReturn = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,11 +433,16 @@ _arg_addr(NSInvocation *inv, int index)
|
||||||
IMP imp;
|
IMP imp;
|
||||||
int stack_argsize;
|
int stack_argsize;
|
||||||
|
|
||||||
|
|
||||||
|
CLEAR_RETURN_VALUE_IF_OBJECT;
|
||||||
|
_validReturn = NO;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A message to a nil object returns nil.
|
* A message to a nil object returns nil.
|
||||||
*/
|
*/
|
||||||
if (anObject == nil)
|
if (anObject == nil)
|
||||||
{
|
{
|
||||||
|
_validReturn = YES;
|
||||||
memset(_retval, '\0', _info[0].size); /* Clear return value */
|
memset(_retval, '\0', _info[0].size); /* Clear return value */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -485,6 +498,8 @@ _arg_addr(NSInvocation *inv, int index)
|
||||||
{
|
{
|
||||||
mframe_decode_return(_info[0].type, _retval, returned);
|
mframe_decode_return(_info[0].type, _retval, returned);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RETAIN_RETURN_VALUE;
|
||||||
_validReturn = YES;
|
_validReturn = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,7 +583,7 @@ _arg_addr(NSInvocation *inv, int index)
|
||||||
const char *types;
|
const char *types;
|
||||||
void *datum;
|
void *datum;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
[aCoder decodeValueOfObjCType: @encode(char*) at: &types];
|
[aCoder decodeValueOfObjCType: @encode(char*) at: &types];
|
||||||
newSig = [NSMethodSignature signatureWithObjCTypes: types];
|
newSig = [NSMethodSignature signatureWithObjCTypes: types];
|
||||||
NSZoneFree(NSDefaultMallocZone(), (void*)types);
|
NSZoneFree(NSDefaultMallocZone(), (void*)types);
|
||||||
|
@ -603,9 +618,9 @@ _arg_addr(NSInvocation *inv, int index)
|
||||||
{
|
{
|
||||||
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &_validReturn];
|
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &_validReturn];
|
||||||
if (_validReturn)
|
if (_validReturn)
|
||||||
{
|
{
|
||||||
[aCoder decodeValueOfObjCType: _info[0].type at: _retval];
|
[aCoder decodeValueOfObjCType: _info[0].type at: _retval];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue