pypdfium2-team / ctypesgen

Wrapper generator for Python ctypes
BSD 2-Clause "Simplified" License
1 stars 1 forks source link

Include statements parsing draft (capture 2) #10

Closed mara004 closed 8 months ago

mara004 commented 8 months ago

Reland of https://github.com/pypdfium2-team/ctypesgen/pull/9

A fun side project showing how to parse out include statements in python. Might be useful in the future for --deepen-inclusion 1 (rather than --all-headers), or for a wrapper to write individual outputs per header.

However, there might be some more elegant pre-processor mechanism to handle these cases. See also this thread: https://stackoverflow.com/questions/5834778/how-to-tell-where-a-header-file-is-included-from

mara004 commented 8 months ago

CC #7: this also uses the assignment expression, in a way that is hard to avoid.

mara004 commented 8 months ago

Yeah I guess gcc -M / -MM would indeed be the more straightforward approach. It also implements the recursion which we haven't got here yet, and it can expand system includes.