CDEF handling #define, #ifdef and #include for easier conversion of header files to cdefs

125 views
Skip to first unread message

Sarvi Shanmugham

unread,
Oct 2, 2012, 2:48:48 AM10/2/12
to pytho...@googlegroups.com


So far my experience with CFFI and the conversion of header files to cdefs() has been very pleasant.

I was thinking of ways this could be easier, potentially completely automatic, which could be greatly simpler.

The main things I have had to do bring in header files into cdefs are

1. copy over the complete header file itself
2. comment out #include lines within them that bring in other include files.
3. potentially copy/bring in some of these header files in 2 above, before 1 above, if 1 above needs those definitions.
4. define some typedefs before 1 and 3 above, those needed for 1 and 3 above to work
5. Comment out #ifdefs as well as complex #defines that define complex mappings/translations
6. Convert simple #defines and their values to "..." notation

If I am not mistaken a lot of these can be automatically right?
1 and 3 could be allowing cdef() to read its string from a text file
2. have cdef automatically ignore #include macros
3. Have cdef ignore complex #defines and treat the rest of them automatically as if they were using the "..." notation
4. have cdef handle #ifdef/#else/#endif macros

I understand this might take a bit of work, that I might be able to contribute after I am done selling CFFI within my extended team, which I am working on currently.

Does this seem reasonable and simple enough to do?  Or is it more complex than I am imagining it?


Thx,
sarvi
Reply all
Reply to author
Forward
0 new messages