Parsing C header files with python

Ville Vainio ville at spammers.com
Sat Aug 21 12:06:41 EDT 2004


>>>>> "Ian" == Ian McConnell <ian at emit.demon.co.uk> writes:

    Ian> I've got a header file which lists a whole load of C functions of the form
    Ian> int func1(float *arr, int len, double arg1);
    Ian> int func2(float **arr, float *arr2, int len, double arg1, double arg2);

    Ian> It's a numerical library so all functions return an int and
    Ian> accept varying combinations of float pointers, ints and
    Ian> doubles.

    Ian> What's the easiest way breaking down this header file into a
    Ian> list of functions and their argument using python? Is there

Well, what comes immediately to mind (I might be overlooking
something) is that the function name is immediately before '(', and
arguments come after it separated by ','. Start with regexps and work
from there...  


-- 
Ville Vainio   http://tinyurl.com/2prnb



More information about the Python-list mailing list