[Kde-bindings] smokegen on clang

Chris Burel chrisburel at gmail.com
Sun Sep 6 23:51:04 UTC 2015


2015-09-06 6:04 GMT-07:00 Arno Rehn <arno at arnorehn.de>:

> Second, I don't know how to handle the Qt macros like "signals", "slots",
> etc. which expand to basic C++ (or even nothing at all). Maybe a proper
> handling would need some extensions to the parser itself.



This blog post [1] may provide some help.  His general approach is to use
the clang PPCallbacks class to detect whenever qobjectdefs.h has just been
read (which defines the initial version of the signals and slots macros),
and then redefine these macros so that each method is annotated as being a
signal or slot:

#define Q_SIGNAL __attribute__((annotate("qt_signal")))
#define Q_SLOT __attribute__((annotate("qt_slot")))

Now the information is stored in the AST as metadata on the associated
method.

I'm not sure of the details, I'm sure in practice it gets more complicated.

[1] http://woboq.com/blog/moc-with-clang.html

-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20150906/633b4e35/attachment.html>


More information about the Kde-bindings mailing list