

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
9 messages in net.java.dev.jna.usersRe: [jna-users] Re: EXC_BAD_ACCESS Ca...| From | Sent On | Attachments |
|---|---|---|
| Duncan McGregor | Nov 22, 2007 4:34 am | |
| Duncan McGregor | Nov 22, 2007 8:24 am | |
| Timothy Wall | Nov 22, 2007 8:39 am | |
| Duncan McGregor | Nov 22, 2007 10:35 am | |
| Timothy Wall | Nov 22, 2007 1:01 pm | |
| Duncan McGregor | Nov 22, 2007 1:57 pm | |
| Timothy Wall | Nov 22, 2007 3:58 pm | |
| Duncan McGregor | Nov 22, 2007 4:04 pm | |
| Wayne Meissner | Nov 26, 2007 8:07 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] Re: EXC_BAD_ACCESS Calling method with Structure on Mac (long and tortuous, sorry) | Actions... |
|---|---|---|
| From: | Wayne Meissner (wmei...@gmail.com) | |
| Date: | Nov 26, 2007 8:07:18 pm | |
| List: | net.java.dev.jna.users | |
I remember having a look at this, as ffmpeg-java also needs struct-by-value support. One simple way to pass structures by value might be to wrap them up in a StructByValue class, which stores both a pointer, and an array of classes (or FFI_TYPE_* values) that describe the fields in the structure (you just need the types, not offsets). The native side can then pull out the pointer and the member types and construct the appropriate ffi_type for that argument.
I think something similar can be done for return types.
On 23/11/2007, Duncan McGregor <dun...@oneeyedmen.com> wrote:
Unfortunately the struct in question is a QTTime, a Mac long long followed by 2 longs, so I can't fit it in a Java long.
On 22 Nov 2007, at 23:58, Timothy Wall <twal...@dev.java.net> wrote:
On Nov 22, 2007, at 4:58 PM, Duncan McGregor wrote:
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.
That's basically it, if you want to do auto-magic structure-by-value.
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.
An easier workaround would be to simply replace the structure with an int or long (depending on structure size) and provide "toInt/ fromInt" methods on the Structure definition for convenience.







