isolver/ioHub — pull request #16 by peteristhegreat (2012-09-17 22:28:18+00:00)
Title: QL2 header files + ctypesgen

I ran the header files for QL2 through ctypesgen.

http://code.google.com/p/ctypesgen/

And it parsed out a lot of information and converted partially it to a ctypes style wrapper.

ctypesgen can't handle bool yet, so I changed the 3 bools to longs temporarily ('Valid', 'Calibrated', and 'Found' fields). And then in the generated file, I changed them to c_bool

There is something that it doesn't like about the syntax for the function prototypes throughout QuickLink2.h. "Line 20: ... Syntax Error: '(' "

The raw output from ctypesgen is sitting in:
ioHub/devices/eyeTrackerInterface/HW/EyeTech/QuickLink/reference/pyQuickLink2.py

I copied a bunch of the generated stuff out (lines 598 to the end) and put it in qltypes.py .

For the enums and the other structs it used an odd temporary naming logic. It called them _anon_###, and set _anon_### to a c_int if it was an enum.

It also setup __slots__ for accessing the different fields. I don't exactly understand their usage yet, but here is a message someone posted about them:
http://osdir.com/ml/python.ctypes/2003-02/msg00035.html