Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to convert Q_MACROS to verdigris #37

Open
jcelerier opened this issue May 12, 2018 · 2 comments
Open

Script to convert Q_MACROS to verdigris #37

jcelerier opened this issue May 12, 2018 · 2 comments

Comments

@jcelerier
Copy link
Collaborator

jcelerier commented May 12, 2018

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 :

  • something that generates a compile_commands.json, in particular I use compdb since it is able to generate a compile_commands.json which has header files.
  • python with the libclang wrapper

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
Copy link
Member

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
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants