Hi, I'm still pursuing my Cocoa bridge, now onto calling methods which
return struct, in particular QTTime
I'm calling objc_msgSend_stret(void* stretAddr, id self, SEL op, ...)
via my own function to let me debug, viz
OBJC_EXPORT void DELMEobjc_msgSend_stret(void * stretAddr, id self,
SEL op, ...) {
NSLog(@"DELMEobjc_msgSend_stret function with %p", stretAddr);
objc_msgSend_stret(stretAddr, self, op, 0);
NSLog(@"exit DELMEobjc_msgSend_stret function with %p", stretAddr);
}
In Java I'm mapping this as
private interface RococoaLibrary extends Library {
void DELMEobjc_msgSend_stret(Pointer stretAddr, ID receiver,
ID selector, Object... args);
}
and calling with
public static <T extends Structure> T sendReturnsStructure(ID
receiver, ID selector, Class<T> returnedType, Object... args) {
try {
T result = returnedType.newInstance();
rococoaLibrary.DELMEobjc_msgSend_stret(result.getPointer(),
receiver, selector, args);
return result;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
and
sendReturnsStructure(movie.id(), selector("currentTime"), QTTime.class);
Debugging in XCode the invocation of objc_msgSend_stret succeeds, the
struct is populated with plausible values as the current time of the
movie, the exit log succeeds, but stepping out of the function fails
with
2007-11-22 12:13:56.698 java[17539] DELMEobjc_msgSend_stret function
with 0x36a560
Current language: auto; currently objective-c
2007-11-22 12:14:02.951 java[17539] exit DELMEobjc_msgSend_stret
function with 0x36a560
Invalid memory access of location 00000002 eip=0036a560
Program received signal: "EXC_BAD_ACCESS".
Previous frame inner to this frame (corrupt stack?)
Previous frame inner to this frame (corrupt stack?)
(out of the debugger the location is 0).
I've built jna with debug, and even though I can see .LCFI1, ffi_call
and dispatch on the stack, stepping out blows, suggesting the stack
has been corrupted as GDB suggests.
I'm obviously doing something silly on the Java side, please put me
out of my misery
Thanks in anticipation
Duncan