[cfe-dev] Generating Python bindings with the Clang cindex.py API

Stephen Kelly via cfe-dev cfe-dev at lists.llvm.org
Wed May 18 14:48:00 PDT 2016


Hello,

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

 https://steveire.wordpress.com/2016/05/18/generating-python-bindings-with-clang/

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.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160518/12c4d9ef/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testfile.h
Type: text/x-chdr
Size: 527 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160518/12c4d9ef/attachment.h>


More information about the cfe-dev mailing list