4 messages in net.java.dev.jna.usersRe: [jna-users] Can I cast a Pointer ...
FromSent OnAttachments
Daniel NollMay 31, 2009 4:21 pm 
Timothy WallJun 1, 2009 3:36 am 
Daniel NollJun 1, 2009 5:28 pm 
Timothy WallJun 2, 2009 3:44 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] Can I cast a Pointer to int?Actions...
From:Timothy Wall (twal@dev.java.net)
Date:Jun 2, 2009 3:44:04 am
List:net.java.dev.jna.users

On Jun 1, 2009, at 8:28 PM, Daniel Noll wrote:

Timothy Wall wrote:

Use Pointer.createConstant() to compare values. BTW, the HWND type is defined in the W32APIS interface.

The copy of JNA I'm working with doesn't have this class yet... I'm using the copy included in JRuby.

You can always make your own (the original is in the examples.jar, which is probably not included with JRuby). It's just a type derived from PointerType, no special implementation.

In most cases you don't have to "cast" to an int, but if you really, really want to, you can do new PointerByReference(ptr).getPointer().getInt(0)

It looks like I will have to use this trick, it works well. Pointer doesn't have compareTo, so I can't do the logic I need, where >= 32 is success and < 32 is failure. I guess I could switch to the Ex version of the API as well, but then I would need do define a struct and more things can go wrong...

yeah, keep it simple. no need to be more complex than necessary.