[IronPython] ctypes for IronPython (preliminary)

Sanghyeon Seo 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.

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.

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')


Seo Sanghyeon

More information about the Ironpython-users mailing list