|
From: Philip J. <pj...@gr...> - 2007-09-04 17:48:59
|
On Sep 3, 2007, at 10:34 AM, Frank Wierzbicki wrote: > On 9/3/07, Wayne Meissner <wme...@gm...> wrote: >> >> >> Frank Wierzbicki wrote: >>> On 9/3/07, Frank Wierzbicki <fwi...@gm...> wrote: >> JNA supports and comes with binaries for most of the operating >> systems >> the Sun JDK supports - linux/i386, linux/amd64, win32, macosx/ppc, >> macosx/i386, solaris/x86, solaris/sparc, solaris/sparc64, freebsd/ >> i386. >> Windows/amd64 and solaris/amd64 are the only exceptions I can >> think of. >> >> But regardless of that, you probably still want to make it >> pluggable so >> when something better comes along (which always happens in software >> development) you can switch to that. >> >> Other options are using C/Invoke >> http://www.nongnu.org/cinvoke/index.html or libffi and writing enough >> java/JNI to interface with it. >> >> When called from jython, the JNA API is pretty narrow - only a >> handful >> of methods. You could abstract them, use a JNA backend initially, >> then >> switch to a BSD-licensed backend when you have one ready. > Thanks for the extra information -- this convinces me more that this > should be written in a plugin style. > > Philip: does any of this deter you from giving it a try? I would love > to see better support for os calls in Jython -- and JRuby can be a > nice prototype for us in these areas... Nope, making it pluggable sounds like a good idea anyway. To define "native" methods in JNA, you write an interface defining all the method prototypes, and your interface has to subclass their Library interface. We can define those "native" methods in our own Interface that doesn't subclass JNA's Library interface, which I believe a cinvoke version, for example, could also utilize. Then our actual JNA Library interface would extend their Library and our own: interface PosixModule { int chmod(String filename, int mask); } interface JNAPosixModule extends PosixModule, com.sun.jna.Library { // The super interfaces provide all that's needed } PosixModule posix = (PosixModule)com.sun.jna.Native.loadLibrary("c", JNAPosixModule.class); -- Philip Jenvey |