I thought that the Python binding to libclang could use some love, so
I've been working on a number of enhancements to it.
You can find my work at . Changes can be seen at . Things are
still a work in progress and there are a number of outstanding issues
I'd like to address before I formally submit a patch. But, I think
things are ready for critique.
* Enumerations split out into clang.cindex.enumerations module
* Objects hold references to parent (i.e. worry-free memory management)
* Support for Token API
* More APIs supported around the board. Pretty much everything from
libclang is supported except the high-level Indexing component.
* Python style improvements. pylint and pyflakes output is now
tolerable and the code mostly follows Python best practices.
* Improved documentation
* Increased test coverage
* Added test to ensure enumerations are up-to-date with Index.h (uses
* Introduced decorator to cache/lazy load properties. This should cut
down on C function calls.
Despite the major changes, API compatibility is mostly preserved. I did
break APIs. However, I actively tried to only break things that I
thought were internal to the module. If external consumers were using
the things that changed, IMO they deserved to break because they weren't
using things in an intended manner. This is my intent anyway. I haven't
thoroughly audited to ensure I stuck to this principle. If the lack of
changes to the existing tests is any indication, I think I did a good
That said, there are numerous API breaking changes I would like to make.
Here are some examples:
* Various APIs are using camel case instead of underscores for method
names, breaking the Python convention.
* Diagnostic exposes iterable structures as properties. IMO properties
should return the same object every call. Currently, they return
different instances. This is confusing, IMO.
* Code completion has a different style from the rest of the module.
If someone gives me a green light, I'd love to have a go at it and
produce a consistent API.
The remaining content in this message is essentially my developer notes
and explains why I did what I did. If you will be commenting, please
read it first.