Initial checkin.
5 // Created by Jens Alfke on 2/11/08.
6 // Copyright 2008 Jens Alfke. All rights reserved.
12 NSInvocation* _mktarget( id rcvr, SEL action )
14 NSMethodSignature *sig = [rcvr methodSignatureForSelector: action];
15 CAssert(sig,@"%@<%p> does not respond to %@",[rcvr class],rcvr,NSStringFromSelector(action));
16 CAssert(sig.numberOfArguments==3,
17 @"-[%@ %@] can't be used as a target because it takes >1 param",
18 [rcvr class],NSStringFromSelector(action));
19 CAssert(0==strcmp([sig getArgumentTypeAtIndex: 2],"@"),
20 @"-[%@ %@] can't be used as a target because it takes a non-object param",
21 [rcvr class],NSStringFromSelector(action));
22 NSInvocation *inv = [NSInvocation invocationWithMethodSignature: sig];
24 inv.selector = action;
29 id $calltarget( NSInvocation *target, id param )
31 if( target && target.target ) {
32 [target setArgument: ¶m atIndex: 2];
35 NSMethodSignature *sig = target.methodSignature;
36 NSUInteger returnLength = sig.methodReturnLength;
40 const char *returnType = sig.methodReturnType;
41 if( returnType[0]=='@' ) {
43 [target getReturnValue: &returnObject];
46 UInt8 returnBuffer[returnLength];
47 [target getReturnValue: &returnBuffer];
48 return [NSValue valueWithBytes: &returnBuffer objCType: returnType];