29 messages in net.java.dev.jna.usersRe: AW: [jna-users] Struct with Union...
FromSent OnAttachments
Wolfgang PichlerMar 25, 2009 5:58 am 
Timothy WallMar 25, 2009 7:02 am 
Timothy WallMar 25, 2009 7:06 am 
Wolfgang PichlerMar 25, 2009 7:21 am 
Timothy WallMar 25, 2009 7:24 am 
Wolfgang PichlerMar 25, 2009 8:11 am 
Wolfgang PichlerMar 25, 2009 8:20 am 
Novatchkov HristoMar 25, 2009 8:41 am 
Timothy WallMar 25, 2009 9:59 am 
Timothy WallMar 25, 2009 10:28 am 
Timothy WallMar 25, 2009 10:38 am 
Hristo NovatchkovMar 25, 2009 11:40 am 
Wolfgang PichlerMar 25, 2009 12:02 pm 
LYou...@gkservices.comMar 25, 2009 12:11 pm 
Timothy WallMar 25, 2009 12:52 pm 
Wolfgang PichlerMar 26, 2009 12:22 am 
Timothy WallMar 26, 2009 4:46 am 
Wolfgang PichlerMar 26, 2009 5:23 am 
Timothy WallMar 26, 2009 6:09 am 
Wolfgang PichlerMar 26, 2009 6:13 am 
Wolfgang PichlerMar 26, 2009 6:26 am 
Timothy WallMar 26, 2009 6:40 am 
Wolfgang PichlerMar 26, 2009 12:22 pm 
Timothy WallMar 26, 2009 1:00 pm 
Wolfgang PichlerMar 26, 2009 3:15 pm 
Timothy WallMar 30, 2009 6:06 am 
Wolfgang PichlerMar 30, 2009 11:55 am 
Timothy WallMar 30, 2009 12:14 pm 
Wolfgang PichlerMar 31, 2009 12:35 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: AW: [jna-users] Struct with Union with Structs...Actions...
From:Timothy Wall (twal@dev.java.net)
Date:Mar 25, 2009 7:24:05 am
List:net.java.dev.jna.users

Check to see that the union field has the proper base address, which should be some offset from the enclosing structure's base address. All union field members will have the same base address as the union.

On Mar 25, 2009, at 10:21 AM, Wolfgang Pichler wrote:

The code does not produce an exception or a crash... - but it does return wrong values.

I will return nulled values - but there are real values - as I have seen when I do directly use the registration structure instead of the union. It does look like it does not get initialized...

Regards, Wolfgang

-----Ursprüngliche Nachricht----- Von: Timothy Wall [mailto:twal@dev.java.net] Gesendet: Mittwoch, 25. März 2009 15:07 An: use@jna.dev.java.net Betreff: Re: [jna-users] Struct with Union with Structs...

On Mar 25, 2009, at 8:59 AM, Wolfgang Pichler wrote:

Here is the callback function IAXClient.INSTANCE.iaxc_set_event_callback(new IAXClient.FUNCTION() { @Override public int invoke(iaxc_event_struct.ByValue event) { if (event==null) { return 0; } switch(event.type) { case IAXClient.IAXC_EVENT_REGISTRATION: System.out.println("Event Raw: " + event.ev.toString());

event.ev.setType(IAXClient.iaxc_ev_registration.class); event.ev.read(); IAXClient.iaxc_ev_registration reg = (iaxc_ev_registration) event.ev.getTypedValue(IAXClient.iaxc_ev_registration.class); System.out.println("Event Reg: " + reg.reply); break;

Once you've called "read", you can simply access the corresponding union field. getTypedValue is a shortcut for setType + read. How exactly does this code fail?