3 messages in net.java.dev.jna.usersRe: [jna-users] Nested structure arra...
FromSent OnAttachments
Zaharescu ValentinJan 21, 2008 4:23 am 
Timothy WallJan 21, 2008 8:16 am 
Zaharescu ValentinJan 22, 2008 9:04 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] Nested structure array problemActions...
From:Timothy Wall (twal@dev.java.net)
Date:Jan 21, 2008 8:16:24 am
List:net.java.dev.jna.users

On Jan 21, 2008, at 7:24 AM, Zaharescu Valentin wrote:

Hello,

till now I could manage well with mapping from Native C. However I reached a point where the memory is not filled correctly, it's always null for an internal list.

Here the the C code:

typedef struct MyStructList { MyStruct **list; int64_t length; } MyStructList;

Assuming your list is an array of struct contiguous in memory:

class MyStructList extends Structure { Pointer list; long length; MyStruct[] getList() { return new MyStruct(list.getPointer(0)).toArray((int)length); } }

class MyStruct extends Structure { public String name; public long index; public MyStruct() { } public MyStruct(Pointer p) { useMemory(p); } }

If your list is an array of pointers to struct contiguous in memory, then you would use Structure.ByReference[].