53 messages in net.java.dev.jna.usersRe: [jna-users] How do I map X in C t...
FromSent OnAttachments
genc...@web.deMay 20, 2009 6:35 am 
Timothy WallMay 20, 2009 11:50 am 
Ahmet Özgür GencaslanMay 25, 2009 2:15 am 
Timothy WallMay 25, 2009 6:36 pm 
genc...@web.deMay 26, 2009 5:34 am 
genc...@web.deMay 26, 2009 5:37 am 
Timothy WallMay 26, 2009 6:16 am 
genc...@web.deMay 26, 2009 8:49 am 
Timothy WallMay 26, 2009 9:11 am 
Özgür GencaslanMay 27, 2009 12:59 am 
Timothy WallMay 27, 2009 3:52 am 
Zsolt KútiAug 21, 2009 3:00 am 
Zsolt KútiAug 21, 2009 3:32 am 
Daniel KaufmannAug 21, 2009 6:00 am 
Olivier ChafikAug 21, 2009 6:22 am 
Zsolt KútiAug 21, 2009 7:46 am 
Zsolt KútiAug 21, 2009 7:46 am 
Olivier ChafikAug 21, 2009 3:11 pm 
Zsolt KútiAug 21, 2009 11:11 pm 
Zsolt KútiAug 22, 2009 4:02 am 
Zsolt KútiAug 22, 2009 4:05 am 
Timothy WallAug 22, 2009 5:08 am 
Zsolt KútiAug 23, 2009 8:38 am 
Timothy WallAug 23, 2009 9:17 am 
Olivier ChafikAug 23, 2009 10:49 am 
Zsolt KútiAug 23, 2009 11:42 am 
Olivier ChafikAug 23, 2009 4:10 pm 
Zsolt KútiAug 24, 2009 10:17 am 
Olivier ChafikAug 24, 2009 1:56 pm 
Timothy WallAug 24, 2009 2:36 pm 
Olivier ChafikAug 24, 2009 4:17 pm 
Olivier ChafikAug 24, 2009 4:51 pm 
Timothy WallAug 25, 2009 4:43 am 
Timothy WallAug 25, 2009 4:48 am 
Olivier ChafikAug 25, 2009 7:07 am 
Timothy WallAug 25, 2009 7:37 am 
Olivier ChafikAug 25, 2009 8:49 am 
Timothy WallAug 25, 2009 10:39 am 
Olivier ChafikAug 25, 2009 3:02 pm 
Timothy WallAug 26, 2009 6:25 am 
Olivier ChafikAug 26, 2009 11:14 am 
Samuel AudetAug 27, 2009 8:14 am 
Timothy WallAug 27, 2009 8:34 am 
Timothy WallAug 27, 2009 8:42 am 
Olivier ChafikAug 27, 2009 10:02 am 
Olivier ChafikAug 27, 2009 10:08 am 
Olivier ChafikAug 27, 2009 10:13 am 
Timothy WallAug 27, 2009 10:15 am 
Samuel AudetAug 27, 2009 9:01 pm 
Olivier ChafikAug 28, 2009 9:21 am 
Samuel AudetAug 28, 2009 9:40 am 
Timothy WallAug 28, 2009 12:18 pm 
Samuel AudetAug 28, 2009 7:18 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 do I map X in C to Y in Java?Actions...
From:Timothy Wall (twal@dev.java.net)
Date:May 26, 2009 6:16:14 am
List:net.java.dev.jna.users

So the returned value was a pointer to an array of pointers, not a pointer to an array of structures.

klom_spot_result_t **spot_result_list = NULL; ... stat = klom_spot_get_result_struct(spot_id, &spot_result_list, -1);

This would be clearer with the declaration of klom_spot_get_result_struct included:

typedef klom_spot_result_t *result_list_t[]; int klom_spot_get_result_struct(void *spot_id, result_list_t *result_list_ptr, int blocking_time);

On May 26, 2009, at 8:37 AM, genc@web.de wrote:

How can i mangae this behaviour?

klom_spot_result_s s = new klom_spot_result_s(); s.useMemory(ptr.getValue(); klom_spot_result_s[] spot_result = (klom_spot_result_s[])s.toArray(LENGTH);

the following exactyl does what i wanted after a long time of trial and error. (it is not a lot documentation out there )

PointerByReference ptr = new PointerByReference();

lib.sym_spot_get_result_struct(spot_id, ptr, BLOCKING_TIME);

Pointer[] p_array = ptr.getValue().getPointerArray(0);

klom_spot_result_s[] spot_result = new klom_spot_result_s[p_array.length];

for (int i = 0; i < p_array.length; i++) { spot_result[i] = new klom_spot_result_s(p_array[i], 0); }

Is it ok doing it this way ?

Thanks for your support.

...

The constructor just does

public klom_spot_result_s(com.sun.jna.Pointer pointer, int offset) { super(); useMemory(pointer, offset); read(); }