Hello all, here's my first weekly-ish progress update.
I've made a start on wrapping SDL. Most of SDL_video.h, SDL_error.h,
SDL_rwops.h, SDL_timer.h, SDL_version.h, and all the #defines have been
wrapped. Things that work:
* I've ported test/testvidinfo.c to Python with only minor changes and
it works perfectly, and fast.
* I've changed the signature of some functions so that instead of
passing by reference, they return the value directly; for example, see
SDL_GetClipRect.
* Functions that take or return an array, I've modified to take or
return a Python list.
* RWops work both as an opaque type (e.g., as a value to pass from
SDL_Load* to SDL_CreateSurface*), and as a wrapper around any Python
file-type object (only tested reading a bitmap so far).
* There's a couple of unit tests written also, but not many.
Things that don't work yet:
* Haven't wrapped any of the enums yet -- I will do these the same as
constants for now, unless someone has a better idea.
* SDL_VideoInfo has bitfields... these are problematic, since compilers
are allowed to do anything they like with them. At the moment I have
them reading correctly for my AMD64/gcc system, but there's no guarantee
it will work for any other combination.
* The GL_* constants should probably be stripped out (there is a script
that generates these constants)
Things that need thinking about:
* I'm not doing anything useful with SDL_Surface.pixels yet, which is a
void *. There are also a couple of functions that take arrays of ints
that I'm ignoring for now. I guess here is where we think about doing
conversions to/from strings, lists, numarray, numpy, numeric etc a la
PyOpenGL-ctypes.
* I want to be able to autogenerate documentation. Epydoc doesn't pick
up the docstrings on most of my wrapper functions though... does anyone
know of a tool that might work, or an easy way to patch epydoc?
Otherwise I'm willing to spend a couple of days writing/modifying
something with docutils to do it, rather than writing all the
documentation by hand.
I'm using a SVN repository on my home computer at the moment, let me
know when the pygame one starts existing, or if I should just use CVS on
pygame.
I've put a snapshot of the code at
http://www.pygame.org/ctypes/SDL-ctypes-0.01.tar.gz. It _requires_ SDL
1.2.10 (I was erroneously using 1.2.8 earlier and some structs are
actually defined differently... this could be a problem in the future, I
suspect). The test/testvidinfo.py script is probably the most
interesting thing to run.
Cheers
Alex.