reinstate deleted code (bug #42405)

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37904 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2014-05-22 16:55:18 +00:00
parent 2a7fa54019
commit 43f07926da
5 changed files with 122 additions and 12 deletions

View file

@ -1,3 +1,11 @@
2014-05-22 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSInvocation.h:
* Source/NSInvocation.m:
* Headers/Foundation/NSInvocation.h:
* Tests/base/NSInvocation/test02.m:
Reinstate lost code for NS_MESSAGE and NS_INVOCATION macros
2014-05-20 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSHTTPURLHandle.m:

View file

@ -121,6 +121,14 @@ extern "C" {
@end
#endif
/** For use by macros only.
*/
@interface NSInvocation (MacroSetup)
- (id) initWithMethodSignature: (NSMethodSignature*)aSignature;
+ (id) _newProxyForInvocation: (id)target;
+ (id) _newProxyForMessage: (id)target;
+ (NSInvocation*) _returnInvocationAndDestroyProxy: (id)proxy;
@end
/**
* Creates and returns an autoreleased invocation containing a
* message to an instance of the class. The 'message' consists

View file

@ -39,10 +39,6 @@ typedef struct {
BOOL isReg;
} NSArgumentInfo;
@interface NSInvocation (MacroSetup)
- (id) initWithMethodSignature: (NSMethodSignature*)aSignature;
@end
@interface GSFFIInvocation : NSInvocation
{
@ -77,13 +73,15 @@ 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 && *_inf[0].type == _C_ID) \
{ \
RELEASE (*(id*) _retval); \
*(id*) _retval = nil; \
_validReturn = NO; \
}\
} while (0)
#define CLEAR_RETURN_VALUE_IF_OBJECT \
do {\
if (_validReturn && *_inf[0].type == _C_ID) \
{ \
RELEASE (*(id*) _retval); \
*(id*) _retval = nil; \
_validReturn = NO; \
}\
} while (0)
#define RETAIN_RETURN_VALUE IF_NO_GC(do { if (*_inf[0].type == _C_ID) RETAIN (*(id*) _retval);} while (0))

View file

@ -186,6 +186,22 @@ static Class NSInvocation_concrete_class;
GS_ROOT_CLASS
@interface GSInvocationProxy
{
@public
Class isa;
id target;
NSInvocation *invocation;
}
+ (id) _newWithTarget: (id)t;
- (NSInvocation*) _invocation;
- (void) forwardInvocation: (NSInvocation*)anInvocation;
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector;
@end
@interface GSMessageProxy : GSInvocationProxy
@end
#define _inf ((NSArgumentInfo*)_info)
/**
@ -804,6 +820,23 @@ _arg_addr(NSInvocation *inv, int index)
return nil;
}
/**
* Internal use.
*/
+ (id) _newProxyForInvocation: (id)target
{
return (id)[GSInvocationProxy _newWithTarget: target];
}
+ (id) _newProxyForMessage: (id)target
{
return (id)[GSMessageProxy _newWithTarget: target];
}
+ (NSInvocation*) _returnInvocationAndDestroyProxy: (id)proxy
{
NSInvocation *inv = [proxy _invocation];
NSDeallocateObject(proxy);
return inv;
}
@end
@implementation NSInvocation (BackwardCompatibility)
@ -819,7 +852,6 @@ _arg_addr(NSInvocation *inv, int index)
#warning Using dummy NSInvocation implementation. It is strongly recommended that you use libffi.
@implementation GSDummyInvocation
/*
* This is the de_signated initialiser.
*/
@ -845,3 +877,33 @@ _arg_addr(NSInvocation *inv, int index)
@end
#endif
@implementation GSInvocationProxy
+ (id) _newWithTarget: (id)t
{
GSInvocationProxy *o;
o = (GSInvocationProxy*) NSAllocateObject(self, 0, NSDefaultMallocZone());
o->target = RETAIN(t);
return o;
}
- (NSInvocation*) _invocation
{
return invocation;
}
- (void) forwardInvocation: (NSInvocation*)anInvocation
{
invocation = anInvocation;
}
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector
{
return [target methodSignatureForSelector: aSelector];
}
@end
@implementation GSMessageProxy
- (NSInvocation*) _invocation
{
[invocation setTarget: target];
return invocation;
}
@end

View file

@ -0,0 +1,34 @@
#import <Foundation/Foundation.h>
#import "Testing.h"
static int called = 0;
@interface NSMessageTest : NSObject
@end
@implementation NSMessageTest
- (void) methodToCall
{
called++;
}
@end
int main(void)
{
NSAutoreleasePool* pool = [NSAutoreleasePool new];
NSMessageTest* test = [NSMessageTest new];
[NS_MESSAGE(test, methodToCall) invoke];
PASS(called > 0, "NS_MESSAGE worked");
[pool release];
return 0;
}