Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there Python Clang wrapper in the vein of pygccxml which wraps GCC-XML?

For a long time now I've been using pygccxml to parse and introspect my C++ source code: it helps me to do some clever code-generation during our build process.

Recently I've read a lot about the benefits of the LLVM stack, and especially the benefits that the LLVM Clang parser brings to C++ compilation. I am now wondering if there is any Python interface to Clang such that I could use it as the basis for some of my existing code generation tasks?

like image 324
jkp Avatar asked Jul 26 '10 10:07

jkp


1 Answers

After further digging I found that in the LLVM 2.7 release there could be the beginings of something useful:

In the LLVM 2.7 time-frame, the Clang team has made many improvements....

CIndex API and Python bindings: Clang now includes a C API as part of the CIndex library. Although we make make some changes to the API in the future, it is intended to be stable and has been designed for use by external projects. See the Clang doxygen CIndex documentation for more details. The CIndex API also includings an preliminary set of Python bindings.

I'm not sure how useful this is in practice, certainly it looks like it could be the foundation for building a pygccxml equivalent based on LLVM but it is not in itself such a library.

like image 91
jkp Avatar answered Oct 04 '22 13:10

jkp