[IronPython] how to convert C# MarshalAs code to IronPython
abrahams84 at gmail.com
Mon Jun 7 09:42:43 PDT 2010
I'll try the ctypes... thanks for pointing me in the right direction and
your help is much appreciated.
On Mon, Jun 7, 2010 at 10:02 AM, Jeff Hardy <jdhardy at gmail.com> wrote:
> On Sun, Jun 6, 2010 at 8:20 PM, Ashley Abraham <abrahams84 at gmail.com>
> > Jeff,
> > I think I miss read your reply, what you are saying is that if it
> > on ctypes it will work in IronPython as well is it?? I thought you needed
> > IronClad and so on make it work.
> Yeah, with ctypes IronPython can call native code directly - it
> actually uses P/Invoke behind the scenes to do it. Python also
> implements ctypes, as do Jython and PyPy, so any code that you write
> using ctypes should work on any Python implementation.
> I haven't tested this (seeing as I don't have the exact DLL) but it
> should be pretty close:
> from ctypes import *
> vniwave = CDLL('vniwave.dll')
> cwavec = vniwave.cwavec
> cwavec.restype = c_int
> cwavec.argtypes = [c_int, c_int, POINTER(c_char_p)]
> The only part I'm not sure about is the string - I'm assuming the C
> function takes a char**.
> Alternatively, you could write the P/Invoke declarations in a C# class
> library and load that into IronPython using clr.AddReference, but I'd
> recommend using ctypes.
> - Jeff
> Users mailing list
> Users at lists.ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Users