Binding of C code

Hans Aschauer Hans.Aschauer at Physik.uni-muenchen.de
Fri Jun 20 07:50:24 EDT 2003


Roberto Cavada wrote:

> Hi all,
> 
>     I need to bind C code written with a object-oriented style.
> For example suppose you need to bind this two "classes" (sorry, it's a
> bit long, but easy to read):

[... code snipped...] 


> How can I bind these structures into two equivalent python classes?
> The idea here is that I can use Class A methods on instances of Class B.
> 
> I know the gobject library, but I'd like to avoid to depend on it.
> I think that SWIG cannot handle this stuff, am I wrong?
> Is there a tool that can generate the correct binding? If there is
> not, how would it be possible to write one?


I guess that Pyrex does what you want. It allows you essentially to create
Glue-Code which calls C functions (and knows C-structs etc), which in turn
can be called by Python. The Glue-Code is written in a very Python-like
language, which compiles into plain C code.

For more information:

www.cosc.canterbury.ac.nz/~greg/python/Pyrex/

Hans




More information about the Python-list mailing list