Python bindings and status of clang-c API

Hi all,

I notice the cindex module is very outdated, so I decided to have a play last night and added a significant amount of the missing CursorKind statics as well as the start of exposing CXType. In my experimentation, I’ve noticed is that there appears to be many missing CXCursorKind enums in the clang-c/Index.h header. As an example, I declared a small function in a test file:

void f0(int a0, int a1) {
start_over:
f1();
}

There are 3 children of f0, kinds being CXCursor_ParmDecl, CXCursor_ParmDecl, CXCursor_UnexposedStatement. I assume the 3rd node is the function body. I don’t think the python code is doing anything wrong when visiting the children. I looked at MakeCSCursor(Stmt *S, …) in CXCursor.cpp (libclang) and noticed that the function is are largely un-implemented. I can walk down and find the CallExpr (f1();).

Is this an area I could do some work in? Having complete python bindings for the entire AST would be a great way to learn clang…

Cheers,

Stu

Stuart Carnie, CTO
manomio | in retro we trust!

I have made similar experiences. I'm right now working on using libclang as C/C++ parser for Synopsis (http://synopsis.fresco.org), and I hit similar limitations as the ones you mention.

I expect to have to make a couple of additions to the libclang API to support my needs (such as a more complete type system representation, but also some other queries that aren't possibly yet.)

FWIW,
         Stefan

Hi Stuart,

Most of the CXCursor kinds have been demand added. Feel free to flesh out additional ones as needed, and submit patches for review.

Ted

Sounds good!

Cheers,

Stu

Stuart Carnie, CTO
manomio | in retro we trust!

Success! I am now stepping into C++ libclang.dylib source via python test script in Xcode :slight_smile: Makes it a lot easier to understand what is going on - hopefully can contribute in the future.

Cheers,

Stu

Stuart Carnie, CTO
manomio | in retro we trust!