[IronPython] ctypes for IronPython (preliminary)

Michael Foord fuzzyman at voidspace.org.uk
Thu Jun 8 01:52:20 PDT 2006


Sanghyeon Seo wrote:
> ctypes is a popular CPython extension planned for inclusion in Python
> 2.5. It is a foreign function interface library.
>
> Homepage: http://starship.python.net/crew/theller/ctypes/
> Documentation: http://docs.python.org/dev/lib/module-ctypes.html
>
> I would like to announce a preliminary implementation of ctypes for
> IronPython using .NET's P/Invoke machinery.
>
> Code is here: http://sparcs.kaist.ac.kr/~tinuviel/fepy/lib/ctypes.py
> Example is here: http://sparcs.kaist.ac.kr/~tinuviel/fepy/example/ctypes_test.py
>
> The example can be run on IronPython as well as on CPython.
>
>   
Wow. Given that one of the google SoC projects is to implement some of 
the Python C extensions for PyPy using ctypes, this opens new possibilities.

Great.

Michael Foord
http://www.voidspace.org.uk/python/index.shtml
http://www.resolversystems.com

> What's missing:
> * Many primitive types
> * .value on primitive types
> * Buffers and .raw
> * Pointer and .contents
> * Reference
> * Array
> * Structure and union and .offset
> * Recursive type
> * Callback
> * External value
> * Windows goodies
>
> In short, everything except those needed to demo anything interesting.
> :-) But you can do this now:
>
> IronPython 1.0.60523 (Beta) on .NET 2.0.50727.42
> Copyright (c) Microsoft Corporation. All rights reserved.
>   
>>>> from ctypes import *
>>>> print cdll.msvcrt.strlen('hello')
>>>>         
> 5
>   
>
> Enjoy!
>
> Seo Sanghyeon
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>   



More information about the users mailing list