[Development] Changing definition of Qt meta macro to allow tools integration

Olivier Goffart olivier at woboq.com
Wed Mar 30 16:08:52 CEST 2016


Hi,

As I am working on porting qdoc using clang, this is yet another time a tool is using clang to get information about Qt code and Qt meta macro (signals, slots, properties, ...)

This has been done before: qtcreator's clang code model [1], moc-ng [2], kdevelop, ...
In each case, we need to resort to hacks to redefine the macros at the right place when there should be redefined. 

Hence while doing it for qdoc, I suggest doing it in a generic way so that we 
can simplify the hacks using additional macro.

Here is the patch:  https://codereview.qt-project.org/151667

The way it works is that one can inject new macros at the begining of the
translation unit (which makes everything simpler). The macro injected are
compiler dependent. This works well with clang. I don't know if there is any
other tool or compiler that needs to be suported and that would have different
needs. And that's the reason of this mail.
This meet the needs for qdoc and moc-ng, and I guess also for QtCreator.
By this mail I'm asking if other tools author think about improvement.

I am also wondering in which branch to push this. Should it go in Qt 5.6 LTS so
newer Qt creator can benefit of it starting from Qt 5.6.1?


[1] https://code.woboq.org/qt5/qt-creator/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore/qobjectdefs.h.html
[2] https://code.woboq.org/mocng/src/qobjectdefs-injected.h.html

-- 
Olivier 

Woboq - Qt services and support - https://woboq.com - https://code.woboq.org



More information about the Development mailing list