Generating Python bindings with the Clang cindex.py API

Hello,

I'm working together with another KDE contributor on automated python
binding generation by using cindex.py to parse the headers.

Generating Python Bindings with Clang | Steveire's Blog

I've encountered a limitation of the cindex.py API while attempting to parse
default values of method parameters. Because I am focusing on Qt libraries,
it is necessary to be able to parse

Type match(..., Qt::MatchFlags flags =
     Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap));

as found in QAbstractItemModel subclasses, and

void foo(QString const& input = QStringLiteral("Foo"));

where the QStringLiteral expands to a lambda which gets called like:

#define STRINGLITERAL(STR) (() -> String { return String("" STR ""); }())

The attached patch to the cindex-dump.py and the sample header file,
executed with

python2 cindex-dump.py testfile.h

shows that the expression for the flags is omitted entirely, and I have no
idea where to start with the STRINGLITERAL example.

Can anyone help with this?

Thanks,

Steve.

patch (1.95 KB)

testfile.h (555 Bytes)