2 messages in net.java.dev.jna.usersRe: [jna-users] output structure as p...
FromSent OnAttachments
amina guermoucheSep 5, 2008 7:17 am 
Timothy WallSep 5, 2008 10:59 am 
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] output structure as parameterActions...
From:Timothy Wall (twal@dev.java.net)
Date:Sep 5, 2008 10:59:40 am
List:net.java.dev.jna.users

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.