How to deduce from NSMethodSignature
that a struct argument is passed by pointer?
Specifically on ARM.
For example if I have:
@protocol TestProtocol <NSObject>
- (void)time:(CMTime)time;
- (void)rect:(CGRect)point;
@end
And then I do:
struct objc_method_description methodDescription1 =
protocol_getMethodDescription(@protocol(TestProtocol), @selector(time:), YES, YES);
struct objc_method_description methodDescription2 =
protocol_getMethodDescription(@protocol(TestProtocol), @selector(rect:), YES, YES);
NSMethodSignature *sig1 = [NSMethodSignature signatureWithObjCTypes:methodDescription1.types];
NSMethodSignature *sig2 = [NSMethodSignature signatureWithObjCTypes:methodDescription2.types];
const char *arg1 = [sig1 getArgumentTypeAtIndex:2];
const char *arg2 = [sig2 getArgumentTypeAtIndex:2];
NSLog(@"%s %s", methodDescription1.types, arg1);
NSLog(@"%s %s", methodDescription2.types, arg2);
The output is:
v40@0:8{?=qiIq}16 {?=qiIq}
v48@0:8{CGRect={CGPoint=dd}{CGSize=dd}}16 {CGRect={CGPoint=dd}{CGSize=dd}}
Both look similar, no indication that CMTime will be actually passed as a pointer.
But when I print the debug description:
NSLog(@"%@", [sig1 debugDescription]);
NSLog(@"%@", [sig2 debugDescription]);
The first prints:
...
argument 2: -------- -------- -------- --------
type encoding (^) '^{?=qiIq}'
flags {isPointer}
...
While the second prints:
...
argument 2: -------- -------- -------- --------
type encoding ({) '{CGRect={CGPoint=dd}{CGSize=dd}}'
flags {isStruct}
...
So this information is indeed stored in the method signature, but how do I retrieve it without parsing the debug description?
Are there rules I can use to deduce this myself? I tried to experiment with different structs but it is hard to spot a pattern.