Introducing Python Bindings for LibTooling

Hi,

I am working on python bindings for LibTooling right now - see https://github.com/firolino/python-clang-tooling. So, one can use pretty things such as

recordDecl(hasDescendant(
ifStmt(hasTrueExpression(
expr(hasDescendant(
ifStmt()))))))

in python as well.

I am almost finished. Just a few things are left:

  • Include all narrowing and traverse AST matchers
  • Fix CMakeLists.txt for other python versions
  • Transform clang AST matcher unit tests to python version and use it
  • Provide pip packages
  • Provide Rewriter
  • Clean the code

Unfortunately, the resulting python module is already 190 MB big. Since most of the matcher stuff are templates, I need to instantiate everything in any possible combination to make them exposable to python. If you have suggestions or improvements regarding the bindings, please let me know.

Interesting work. It would be easier to just process a clang-query string, but I guess you benefit from error messages in the python code instead of in a string.

Do you have further plans for this library once it's clean and you have a pip package etc done?

I already wrote a generator for javascript bindings for AST nodes to expose the various SourceLocations and SourceRanges and strings exposed from AST node classes. That's probably something you will also need eventually?

Thanks,

Stephen.