I'm confused, you say groovy has no interface, but I think it is you who
would make the interface right? yes...
In other words, groovy likely has nothing in the interference set.
Levi Yourchuck
Senior Programmer Analyst
G&K Services
Phone: 952 912 5828
www.gkservices.com
Enhancing Image & Safety Through Innovation
This e-mail and any attachments may contain confidential and privileged
information. If you are not the intended recipient, please notify the
sender immediately by return e-mail, delete this e-mail and destroy any
copies. Any dissemination or use of this information by a person other
than the intended recipient is unauthorized and may be illegal.
Albert Kurucz <albe...@gmail.com>
06/25/2009 02:02 PM
Please respond to
use...@jna.dev.java.net
To
use...@jna.dev.java.net
cc
Subject
Re: [jna-users] single argument / multiple arguments - Array or not array
Your recommended solution, using interface mapping does not work with
Groovy, because Groovy has no Interface.
My Groovy solution so far is:
import com.sun.jna.NativeLibrary
import com.sun.jna.Platform
public class Clib {
private static def libc =
NativeLibrary.getInstance(Platform.isWindows() ? "msvcrt" : "c")
def methodMissing(String name, args) {
def method = libc.getFunction(name)
if (method) {
if (args.getClass().isArray()) {
return method.invokeInt(args)
} else {
return method.invokeInt([args] as Object[])
}
} else {
throw new MissingMethodException(name, getClass(), args)
}
}
}
Groovy calls automatically the methodMissing with single Object args
or array Object[], depending the number of args.
What shall I use if not com.sun.jna.Function, in this case?