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:LYou...@gkservices.com (LYou@gkservices.com)
Date:Jun 25, 2009 12:56:23 pm
List:net.java.dev.jna.users

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?