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

时间秒杀一切 提交于 2019-12-21 03:42:45

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3334170/is-there-python-clang-wrapper-in-the-vein-of-pygccxml-which-wraps-gcc-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!