A JNA Structure is automatically passed by reference when used as an
argument, unless you explicitly tell it to pass by value
(https://jna.dev.java.net/
#structures).
Whether or not you actually define the structure, you still have to
allocate the space passed to compute_score. You can allocate a chunk
of memory with com.sun.jna.Memory, but then you'll need to access the
structure fields via hard-coded offsets.
On Sep 5, 2008, at 10:17 AM, amina guermouche wrote:
Hie,
I have these C functions: compute_score(mesh_t * mesh) where mesh_t
is a structure
It's called in the main function this way:
compute_score(mesh) //mesh is declared as a mesh_t *
The function compute_score modifies (initializes) the variable mesh.
I need to access to an attribute of the structure and read its
value, for example:
filename = mesh->data[SPARSE]->filename[0];
I've tried to do this this way (like for a char *):
PointerByReference meshRef=new PointerByReference();
Pointer meshPtr=meshRef.getPointer();
mesh_t mesh=new mesh();
///////////////////////////
compute_score(meshRef);
////////////////////////////
Pointer=meshPtr.getPointer();
And here, I don't know what to to (if it was an int, I'd have done:
mesh=meshPtr.getInt(0));
Thanks.