[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bindings
Subject:    Re: [Kde-bindings] smokegen on clang
From:       Chris Burel <chrisburel () gmail ! com>
Date:       2015-09-06 23:51:04
Message-ID: CAPOisTt+WuaoEzTgQa7FXEXfzLyfZ5mJNkQ-22dfMWWzdwoMzg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


2015-09-06 6:04 GMT-07:00 Arno Rehn <arno@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

[Attachment #5 (text/html)]

<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">2015-09-06 6:04 \
GMT-07:00 Arno Rehn <span dir="ltr">&lt;<a href="mailto:arno@arnorehn.de" \
target="_blank">arno@arnorehn.de</a>&gt;</span>:<br><blockquote class="gmail_quote" \
style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"> Second, I don&#39;t know how to handle the Qt \
macros like &quot;signals&quot;, &quot;slots&quot;, etc. which expand to basic C++ \
(or even nothing at all). Maybe a proper handling would need some extensions to the \
parser itself.</blockquote></div><br><br></div><div class="gmail_extra">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:<br><br>#define Q_SIGNAL \
__attribute__((annotate(&quot;qt_signal&quot;)))<br>#define Q_SLOT \
__attribute__((annotate(&quot;qt_slot&quot;)))<br><br>Now the information is stored \
in the AST as metadata on the associated method.<br><br></div><div \
class="gmail_extra">I&#39;m not sure of the details, I&#39;m sure in practice it gets \
more complicated.<br></div><div class="gmail_extra"><br></div><div \
class="gmail_extra"></div><div class="gmail_extra">[1] <a \
href="http://woboq.com/blog/moc-with-clang.html" \
target="_blank">http://woboq.com/blog/moc-with-clang.html</a><br><br>-Chris<br><br></div></div>



[Attachment #6 (text/plain)]

_______________________________________________
Kde-bindings mailing list
Kde-bindings@kde.org
https://mail.kde.org/mailman/listinfo/kde-bindings


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic