[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] ODE-ctpyes binding



Simon Wittber wrote:

I want an ODE ctypes binding. I dont want to use the Pyrex PyODE.

I've started some work, which you can see here.

http://svn.xerian.net/xerian.net/ode/

I've looked at Alex Holkners works on pygame-ctypes.

Being the lazy programmer I am, I've taken a few shortcuts.

I've written a set of functions which grab the ctypes function pointer
from the dll, add the restype and argtypes attributes, and magically
insert the (possibly) mangled (into a more pep 8 style) name into the
module namespace via globals(). A function needs to be explicitly
dereferenced if it returns a pointer.

I'd like to be more lazy, and parse the .h files for ODE_API
functions, but I havent worked out how to do that yet, other than
using grep and cut + paste ;-)

Before I continue with this approach, I'm looking for some feedback.
Does this style smell bad? Am I going to run into problems using magic
globals() insertion? Does anyone want to help :-)

-Sw.

If you're going the generated approach, have a look at ctypes-codegen, which is distributed with ctypes. It doesn't parse header files directly, going through gcc-xml instead.


The common approach among ctypes wrappers seems to be fully generating standalone Python modules, rather than modules which rely on the header file being present. Presumably this is for the benefit of Windows users, but I've not put too much thought into the pros and cons.

Alex.