11 messages in net.java.dev.jna.usersRe: [jna-users] single argument / mul...
FromSent OnAttachments
Albert KuruczJun 25, 2009 9:28 am 
Timothy WallJun 25, 2009 10:43 am 
Albert KuruczJun 25, 2009 12:01 pm 
Timothy WallJun 25, 2009 12:17 pm 
LYou...@gkservices.comJun 25, 2009 12:56 pm 
Albert KuruczJun 25, 2009 1:19 pm 
Timothy WallJun 25, 2009 2:22 pm 
Albert KuruczJun 25, 2009 2:29 pm 
LYou...@gkservices.comJun 25, 2009 2:34 pm 
LYou...@gkservices.comJun 25, 2009 2:49 pm 
Albert KuruczJun 25, 2009 3:17 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:Re: [jna-users] single argument / multiple arguments - Array or not arrayActions...
From:Albert Kurucz (albe@gmail.com)
Date:Jun 25, 2009 12:01:44 pm
List:net.java.dev.jna.users

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?