2 messages in net.java.dev.jna.userscallback funtions and Pointer
FromSent OnAttachments
Vito IngrassiaJul 12, 2007 8:56 am 
Timothy WallJul 12, 2007 11:24 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:callback funtions and PointerActions...
From:Vito Ingrassia (v.in@iwbank.it)
Date:Jul 12, 2007 8:56:51 am
List:net.java.dev.jna.users

Hello,

I'm exploiting JNA callback features and in my C library I have the following declarations:

/*data list definition*/ typedef struct _tagMyDataList { char chExchangeCode; char szExchangeName[61]; struct _tagMyDataList* pcNext;

} MyDataList;

/*callback function definition*/ typedef void (*OnDataExchanges) (int nNumExchanges, const MyDataList* pcMyDataList);

In Java the mapping I'm doing is

public class MyDataList extends Structure { public char chExchangeCode; public String szExchangeName; public MyDataList pcNext; }

public interface OnDataExchanges extends Callback { void callback(int count, Pointer list); }

My question is: is it right to declare the callback function with Pointer type instead of MyDataList type? I'd like and tried the second way but at runtime on the java side, invoking the callback function from C library and passing some dinamically created MyDataList objects, I get Pointer objects. How can I obtain Structure objects (MyDataList) from Pointer object?

thanks,

Vito