On 22 Nov 2007, at 21:01, Timothy Wall wrote:
The return value part of the cast ensures that the compiler
properly handles the value returned. Defining your JNA method
interface is equivalent to doing the cast; all type information is
passed to the libffi layer, which handles stack setup and capture
of the return value. Currently all returned structures are assumed
to be as pointers by JNA; you might write up some simple tests with
a custom shared lib to see if small structs are handled properly as
an argument and/or return value. libffi for powerpc looks like it
handles small structs, as does x86; JNA may need to be tweaked a
bit to pass structure size information down to libffi, though.
So fighting my way down through libffi, I'd pass the instance of the
Structure in along with an ffi_type describing it, pass that to
ffi_prep_cif, let the invoke happen giving it the pointer to the
structure as the return value, as currently happens.
So I guess that libffi uses the contents of the ffi_type to work out
how to copy the value to the buffer?
I'm in so deep I can't even see the bottom any more.
Given that Structure results are currently return by pointer, how
would you signal that you wanted return by value? It would seem
logical to make that the default, but would break current code.
Duncan