2 messages in net.java.dev.jna.usersUsing NativeLong in Structures?
FromSent OnAttachments
Andrew ThompsonMay 25, 2008 11:52 am 
Andrew ThompsonMay 25, 2008 11:59 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:Using NativeLong in Structures?Actions...
From:Andrew Thompson (lord@mac.com)
Date:May 25, 2008 11:52:23 am
List:net.java.dev.jna.users

Hi all,

Is using NativeLong in structures supported? I have a structure:

public class CFRange extends Structure implements Structure.ByValue { public CFIndex location; public CFIndex length; public CFRange() { } public CFRange(final CFIndex location, final CFIndex length) { this.location = location; this.length = length; }

public CFIndex getLength() { return length; }

public CFIndex getLocation() { return location; } }

Where CFIndex is

public class CFIndex extends NativeLong { private static final long serialVersionUID = 0; }

But I'm getting this error:

Caused by: java.lang.IllegalArgumentException: Unsupported structure field type class org.rococoa.CFIndex at com.sun.jna.Structure$FFIType.get(Structure.java:1199) at com.sun.jna.Structure$FFIType.<init>(Structure.java:1140) at com.sun.jna.Structure$FFIType.get(Structure.java:1189) at com.sun.jna.Structure$FFIType.get(Structure.java:1163) at com.sun.jna.Structure.getTypeInfo(Structure.java:1034) at com.sun.jna.Structure.getTypeInfo(Structure.java:1027) at com.sun.jna.Structure.allocateMemory(Structure.java:217) at com.sun.jna.Structure.<init>(Structure.java:126) at com.sun.jna.Structure.<init>(Structure.java:120) at com.sun.jna.Structure.<init>(Structure.java:116) at org.rococoa.CFRange.<init>(CFRange.java:18)

Is it really true that NativeLong types don't work in Structures? If so, how to handle 32/64 bit Structures.

Could I add this to Structure myself reasonably easily or are there deep and evil reasons why it is hard?

AndyT (lordpixel - the cat who walks through walls) A little bigger on the inside

(see you later space cowboy, you can't take the sky from me)