[Development] Extending moc to generate easily accessible metatype descriptions
olivier at woboq.com
Mon Sep 16 17:28:29 CEST 2019
On 16.09.19 12:32, Ulf Hermann wrote:
> The place where all the metatypes are known at compile time is inside
Well, unfortunetely, even moc doesn't know about all the metatypes.
Many types don't need registration, and moc is not always aware of the
Q_DECLARE_METATYPE declaration (but it actually should still work for most types)
There are also all the custom QMetaObject (thinking of stuff like DBus,
ActiveQt or other language bindings, or the ones created by Verdigris)
> Therefore I propose an additional parameter "--json" for moc that would
> generate just such files, in JSON format, to be processed by further
Sounds like a good idea.
> In addition, moc should also gain the ability to collect multiple
> such per-C++-file JSON files into one per-module JSON file. The latter
> is a pure JSON transformation and doesn't require any insight about the
> actual types.
But this post-processing of the .json files is not necessarily something for
moc. It could be in a separate tool. (But I realize that you can just add the
option to the moc binary to avoid creating another small tool just for that.)
> The proposed change to moc is
> https://codereview.qt-project.org/c/qt/qtbase/+/248470 and a proposed
> qmltyperegistrar which would use the metatype information to generate
> plugins.qmltypes files at compile time can be seen at
> https://codereview.qt-project.org/c/qt/qtdeclarative/+/248471 (mind the
> dependency chain).
The question is also how does it fits in the build system? How do you know
which .json to collect and at what stage do you do that?
Is this going to add some burden for people using custom build systems?
And how mandatory will it be? Is it ok if this does not work?
Also I would need to find a solution for Verdigris. (Was thinking about
generating the json at compile time in a constexpr string put in a specific
section of the binary, but how does it ends up in a qmltypes then?)
More information about the Development