3 messages in net.java.dev.jna.usersRe: [jna-users] how to represent int**
FromSent OnAttachments
Travis BanksFeb 3, 2009 10:24 am 
Timothy WallFeb 3, 2009 11:42 am 
Travis BanksFeb 3, 2009 1:56 pm 
Actions with this message:
Paste this link in email or IM:
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:Timothy Wall (twal@dev.java.net)
Date:Feb 3, 2009 11:42:33 am
List:net.java.dev.jna.users

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