5 messages in net.java.dev.jna.usersRe: [jna-users] some tip for mapping
FromSent OnAttachments
Daniele DellafioreFeb 18, 2008 12:58 pm.html
Timothy WallFeb 18, 2008 7:24 pm 
Daniele DellafioreFeb 19, 2008 12:40 am 
Timothy WallFeb 20, 2008 4:34 am 
Daniele DellafioreFeb 20, 2008 5:26 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] some tip for mappingActions...
From:Timothy Wall (twal@dev.java.net)
Date:Feb 18, 2008 7:24:57 pm
List:net.java.dev.jna.users

On Feb 18, 2008, at 3:59 PM, Daniele Dellafiore wrote:

Hi.

It is the very first time I use jna, I would like to ask some tip to start writing.

I have made a test like this:

Gpod gpod = (Gpod) Native.loadLibrary("libgpod.so.3.0.0", Gpod.class);

You can simply use "gpod" as the library name. JNA will figure out the rest and use the most recent version available.

assertNotNull(gpod);

and it passes so I am able to load the library and map it in a interface that extends Library. That interface class is empty. As you can see I Am trying to map libgpod library. I cannot find online doc, I'll attach to this email.

I need some tip on how to create the Java class, for example the native method:

Itdb_iTunesDB* itdb_new (void);

how should be mapped? And there is the structure, Itdb_iTunesDB, should I map it in:

class Itdb_iTunesDB extends Structure { ... }

and that structure should be in Gpod.class? Or where?

If you don't need to access the contents of the structure, just declare it as a PointerType or Pointer. If you *do* need to access structure fields, simply declare structure fields of the same order and size as the native declaration. The Javadoc overview page details many specifics of JNA usage.