

![]() | 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: |
3 messages in net.java.dev.jna.usersRe: [jna-users] how to represent int**| From | Sent On | Attachments |
|---|---|---|
| Travis Banks | Feb 3, 2009 10:24 am | |
| Timothy Wall | Feb 3, 2009 11:42 am | |
| Travis Banks | Feb 3, 2009 1:56 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] how to represent int** | Actions... |
|---|---|---|
| From: | Travis Banks (trav...@gmail.com) | |
| Date: | Feb 3, 2009 1:56:35 pm | |
| List: | net.java.dev.jna.users | |
Your advice was correct! I was able to pass a Pointer[]. Thanks
For others who search the message, here's my solution:
int[][] origData=getOrigData(); //assume origData is populated with ints Pointer[] passData=new Pointer[origData.length]; // I know there are 4 elements for(int i=0;i<origData.length;i++) { int[] raw=origData[i]; Memory m=new Memory(4L*(long)raw.length); m.write(0L,raw,0,raw.length); passData[i]=m; }
- Travis
On Tue, Feb 3, 2009 at 1:42 PM, Timothy Wall <twal...@dev.java.net> wrote:
If the argument is intended to be an array of arrays, then the layout in memory looks like this:
If your argument is Pointer with value x: x+0: ptr to first array x+4: ptr to next array x+8: ptr to next array ...
In which case you need to pass in Pointer[]. You should be able to initialize the elements with com.sun.jna.Memory, allocating blocks of appropriate size.
On Feb 3, 2009, at 1:24 PM, Travis Banks wrote:
Hello All,
I'm having trouble representing the type int** in Java and could use some assistance. The function I want to call has the following signature;
do_iteration(int **data, int num_datapoints, Options *options, Message *message)
I know that 'data' is processed in the function as an int[][] and that 'data' is passed to other functions (where it is modified) from within do_iterations. 'data' is not empty when I call the argument from Java but must be populated. I've tried the following things but have had not luck;
do_iteration(IntBuffer[] data, int num_datapoints, Options options, Message message) - Exception in thread "main" java.lang.IllegalArgumentException: Unsupported array argument type: class java.nio.IntBuffer
do_iteration(Pointer[] data, int num_datapoints, Options options, Message message) - I use Native.getDirectBufferPointer() to get the pointers but I get; 'Exception in thread "main" java.lang.IllegalArgumentException: Non-direct Buffer is not supported'
do_iteration(int[][] data,int num_datapoints, Options options, Message message) - Exception in thread "main" java.lang.IllegalArgumentException: Unsupported array argument type: class [I
Thanks for any help you can give me.
- Travis







