Such a callback is problematic because there is no way for the native
callback stub to generically the types of the varargs parameters in
order to convert them into java objects or primitives. The type
information is (presumably) embedded in the format string, rather than
in the objects themselves, and that information isn't available to JNA.
Mapping the second arg to Pointer is actually more accurate, since it
represents the position of the arguments on the stack. Since your
application knows how to parse the format string, it can walk the
argument stack and extract each value appropriately using
Pointer.getXXX functions with appropriate offsets. Not particularly
elegant, but it should work.
On Aug 23, 2008, at 6:18 AM, Alex Lam S.L. wrote:
Hi there,
For dll functions which have "char *" or "...", I can use String and
Java Varargs as method parameters and it works like a charm.
However, when I tried to do the same with Callback:
typedef int (*PFKT) (char *format, ...);
public interface PFKT extends Callback {
int callback(String format, Object ... parameters);
}
JNA claims that it cannot find the right conversion to "parameters".
It would run if I declare "parameters" as Pointer instead, but it is
evidently not the best solution.
Any pointers on the issue?