2 messages in net.java.dev.jna.usersByReference types in callback functions
FromSent OnAttachments
James WayOct 24, 2007 11:25 am 
Timothy WallOct 24, 2007 12:04 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:ByReference types in callback functionsActions...
From:James Way (jame@us.army.mil)
Date:Oct 24, 2007 11:25:08 am
List:net.java.dev.jna.users

I can use the Pointer type as an argument to a callback function, but I cannot use an IntByReference argument. Is this the way it has to be, an error on my part, or has it just not been implemented yet?

// This code does not work unless I replace IntByReference with Pointer public interface FbarJavaLib extends Library { static FbarJavaLib INSTANCE = (FbarJavaLib)Native.loadLibrary("FbarJava", FbarJavaLib.class); public interface DATAINFUNCTION extends Callback { public void callback(IntByReference iref); } public void fbar504t(String inputText, String outputText, DATAINFUNCTION datain); }

lib.fbar504t(inputText, outputText, new FbarJavaLib.DATAINFUNCTION() { public void callback(IntByReference iref) { System.out.println("hello from callback: iref = " + iref.getInt(0)); iref.setInt(0, 1111); System.out.println("callback: " + iref.getInt(0)); } } );