[IronPython] ctypes for IronPython (preliminary)
sanxiyn at gmail.com
Thu Jun 8 07:00:23 CEST 2006
ctypes is a popular CPython extension planned for inclusion in Python
2.5. It is a foreign function interface library.
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.
* Many primitive types
* .value on primitive types
* Buffers and .raw
* Pointer and .contents
* Structure and union and .offset
* Recursive type
* 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')
More information about the Ironpython-users