7 messages in net.java.dev.jna.users[jna-users] Problems with Unions
FromSent OnAttachments
Hendrik SalyFeb 11, 2009 10:27 am 
Timothy WallFeb 11, 2009 12:41 pm 
Hendrik SalyFeb 11, 2009 1:19 pm 
Timothy WallFeb 11, 2009 2:16 pm 
Hendrik SalyFeb 11, 2009 10:35 pm 
Timothy WallFeb 12, 2009 7:53 am 
Hendrik SalyFeb 12, 2009 12:14 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:[jna-users] Problems with UnionsActions...
From:Hendrik Saly (hend@gmx.de)
Date:Feb 11, 2009 10:27:17 am
List:net.java.dev.jna.users

Hello again,

is it correct to map a C Union

C:

typedef struct test_callback_data { unsigned int type;

union specific_data {

test__DATA *test_data; test_XX_DATA *data; } callback_data;

} test_CALLBACK_DATA;

to Java using JNA in that way:

Java:

public static class test_callback_data extends Structure { public int type; public UNION_callback_data callback_data; }

public static class UNION_callback_data extends Union {

public test__DATA test_data; public test_XX_DATA data;

}

public interface CALLBACK extends com.sun.jna.Callback { int callback(test_callback_data data); }

The Union is filled by a callback function. The instance fields are then always
0 or null, so i guess they get not properly initialised. How to use the setType(Class clazz) method in/with the Union? Should i use or
override the method?

Environment: Linux i386, JNA 3.0.5, Sun JDK 1.5

Thanks Hendrik