Introduce K_PLUGIN_CLASS_WITH_JSON
ClosedPublic

Authored by aacid on Feb 5 2018, 11:48 PM.

Details

Summary

Does the same as K_PLUGIN_FACTORY_WITH_JSON but saves you typing the class name twice.

If you look at lxr.kde.org you can see our codebase is full of stuff like

K_PLUGIN_FACTORY_WITH_JSON(NinjaBuilderFactory, "kdevninja.json", registerPlugin<NinjaBuilder>(); )

where we repeat NinjaBuilder twice, so add a nice macro so that we only have to write it once

Diff Detail

Repository
R244 KCoreAddons
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
aacid created this revision.Feb 5 2018, 11:48 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptFeb 5 2018, 11:48 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
aacid requested review of this revision.Feb 5 2018, 11:48 PM
apol added a subscriber: apol.Feb 5 2018, 11:55 PM

+1
I'd welcome that. I always found odd to have to invent a name that wouldn't be required on the rest of the program.

Makes sense to me to have a shorter version for the common case of just one registered plugin. Less boilerplate :)

Please add a note in the API dox that this macro is for the case of just one plugin class, and link to K_PLUGIN_FACTORY_WITH_JSON for the case someone wants multiple plugins (yes, there are some use-cases for that).

Please also add K_PLUGIN_CLASS_WITH_JSON (or whatever name it will be in the end) to the list KCoreAddons_AUTOMOC_MACRO_NAMES in the toplevel CMakeLists.txt.

aacid updated this revision to Diff 26729.Feb 7 2018, 10:31 PM

add macro to KCoreAddons_AUTOMOC_MACRO_NAMES

aacid added a comment.Feb 7 2018, 10:32 PM

Makes sense to me to have a shorter version for the common case of just one registered plugin. Less boilerplate :)

Please add a note in the API dox that this macro is for the case of just one plugin class, and link to K_PLUGIN_FACTORY_WITH_JSON for the case someone wants multiple plugins (yes, there are some use-cases for that).

Hmm, i already have a \see K_PLUGIN_FACTORY_WITH_JSON my guess is that people that find out that this doesn't do what they want, they'll go there?

Please also add K_PLUGIN_CLASS_WITH_JSON (or whatever name it will be in the end) to the list KCoreAddons_AUTOMOC_MACRO_NAMES in the toplevel CMakeLists.txt.

Done, thanks.

And yes, I'm open for better naming, not totally happy with it to be honest.

dfaure accepted this revision.Feb 7 2018, 11:05 PM
This revision is now accepted and ready to land.Feb 7 2018, 11:05 PM
mlaurent requested changes to this revision.Feb 8 2018, 6:30 AM
mlaurent added a subscriber: mlaurent.
mlaurent added inline comments.
src/lib/plugin/kpluginfactory.h
211 ↗(On Diff #26729)

it's doesn't work. jsonFile in all macro or json only
otherwise it's not defined.

This revision now requires changes to proceed.Feb 8 2018, 6:30 AM
This revision was not accepted when it landed; it landed in state Needs Revision.Feb 9 2018, 11:23 PM
This revision was automatically updated to reflect the committed changes.