woboq / verdigris

Qt without moc: set of macros to use Qt without needing moc
https://woboq.com/blog/verdigris-qt-without-moc.html
GNU Lesser General Public License v3.0
643 stars 60 forks source link

Script to convert Q_MACROS to verdigris #37

Open jcelerier opened 6 years ago

jcelerier commented 6 years ago

Hello, I've been working on a python script that leverages libclang to port my codebase to verdigris. Since it may be useful to others, here it is : https://github.com/OSSIA/score/blob/master/tools/to_verdigris.py

It requires :

Usage :

 $ to_verdigris.py path/to/a/folder/with/compile_commands.json

There is a bunch of stuff to improve - in particular a pass of clang-format will certainly be required afterwards - but overall it is able to go through most Qt code with Q_OBJECT, Q_PROPERTY, Q_SIGNAL, Q_SLOT, etc etc. It does not yet add W_OBJECT_IMPL to cpp files however - I guess some heuristic could be used for this but for now...

ogoffart commented 6 years ago

Thanks for your script. Perhaps you could make a merge request that adds it to a tools or contrib subdirectory. Otherwise I guess i could put a link from the readme to your repository.

(Please add license header to your file, and short documentation in comments)

Also, if you wish to improve it, this might help you: http://code.qt.io/cgit/qt/qtbase.git/commit/?id=6c54e10144e7af02f4c35e20e5f375a0cf280b8b By setting some defines you can probably detect the signals/slots and other qt meta macro with more accuracy.

jcelerier commented 6 years ago

thanks ! yes, I will just work on it a bit more before making a pull request- ideally, a good test would be to be able to convert qt itself for instance.