Host Get Extension and Meson#77
Conversation
| virtual void requestCallback() noexcept = 0; | ||
|
|
||
| virtual bool enableDraftExtensions() const noexcept { return false; } | ||
| virtual const void* getExtension (std::string_view extensionId) const noexcept { return nullptr; } |
There was a problem hiding this comment.
| virtual const void* getExtension (std::string_view extensionId) const noexcept { return nullptr; } | |
| virtual const void *extension(const char *id) const noexcept { return nullptr; } |
- rename for consistency with
clap::helpers::Plugin::extension - just pass on the
const char *-> let it up to the implementation to usestd::string_view - format:
void *extension(instead ofvoid* extension (seems more consistent with the rest to me
There was a problem hiding this comment.
rename for consistency with clap::helpers::Plugin::extension
Plugin uses clapExtension and extension, but Host uses clapGetExtension so the corresponding method would be getExtension. However, the parameter type and name should be changed to const char *extension_id to match Host::clapGetExtension.
There was a problem hiding this comment.
Should I change it back... probably should have looked here first. :)
There was a problem hiding this comment.
Yeah, I actually think messmerd is more right than me :D
So maybe it would be ok for you to change the name back to getExtension...?
There was a problem hiding this comment.
would be OK for me to add this. What do you think, @abique ?
There was a problem hiding this comment.
My comment in discord was: if we add it we should add a ci test since it needs to work and most of us don’t use it ever.
There was a problem hiding this comment.
I turned on ci here and it failed alas
There was a problem hiding this comment.
Just for cmakr not even for meson
There was a problem hiding this comment.
I've never used meson.
I'm not going to maintain it myself.
So as long as it is maintained by someone I don't mind.
There was a problem hiding this comment.
I went ahead and made another branch ...
https://github.com/mfisher31/clap-helpers/tree/host-ext-access
... that has cherry-pick'd the extension access changes only.
There was a problem hiding this comment.
My two cents is that a
meson.buildaddition was a workaround anyway. If there was acmakeoption, or something, to stop the download of clap without erroring then the cmake could be used directly as a cmake-subproject. (assuming the dev also handles the clap dependency on their own).
but the cmake already does that. The download is wrapped in if (NOT TARGET clap)
Line 11 in 8558641
There was a problem hiding this comment.
Hmmm, my guess is that TARGET clap does not get registered when runs the checks and what not.
There was a problem hiding this comment.
What does that mean?
when ci runs target clap is false so it downloads
you can see in the pr I pushed that the next main thing also gets fixed - if I merge that and you rebase your code should work. Just waiting for @abique to review
my comment was addressing yours about meson needing an if (which my pr also addresses)
I guess “what is the problem which requires a meson build file here and nowhere else”
There was a problem hiding this comment.
Sorry I only really use cmake in passing. I just meant from my own perspective: If I used meson to subproject(...) in clap, then TARGET clap still returns false (not regisered in cmake). I'll do the rebase, kill the meson.build???, and also change back to getExtension() as @messmerd suggested?. Sorry this one went kind of haywire :)
|
I've started addressing the identified cmake problems #78
|
386ee7c to
15a450c
Compare
| } | ||
| return nullptr; | ||
|
|
||
| return self.getExtension(extension_id); |
There was a problem hiding this comment.
This would need to be called first and if that returns a valid ext pointer then return it.
There was a problem hiding this comment.
hm, in clap::helpers::Plugin::clapExtension self.extension isn't called first. Should that be changed as well then?
There was a problem hiding this comment.
Ahh yeah, didn't think about that. Doing so enables client code to override the default impl. I'll get it done.
There was a problem hiding this comment.
Ok. I did a few things:
- Squash all previous commits.
- Rebase on
next& force push - check overriden
extension(...)andgetExtension(...)before built-in implementations - remove the meson.build
- remove
#include <string_view>fromhost.hh
Turns out next works perfectly fine when using the cmake options: something like this:
https://github.com/kushview/element/blob/4d3d97114680a3312f1eddcf39b68e0ddcbdf845/meson/deps/meson.build#L5
# ...
cmake = import ('cmake')
clap_proj = cmake.subproject ('clap')
clap_helpers_opts = cmake.subproject_options()
clap_helpers_opts.add_cmake_defines ({
'CLAP_HELPERS_DOWNLOAD_DEPENDENCIES': false,
'CLAP_HELPERS_NO_CLAP_IS_FATAL': false })
clap_helpers_proj = cmake.subproject ('clap-helpers', options: clap_helpers_opts)
clap_dep = [ clap_proj.dependency('clap'),
clap_helpers_proj.dependency ('clap-helpers') ]
# ...|
Sorry for the delay on this. I just pushed the change to revert to All of the above is being worked out here: |
* Ignore generated files when used as a meson subproject
a8b6a9d to
f8c8a51
Compare
|
Maybe split the assignment from the if and it'll compile :) |
Whoops. probably should have checked one of the plugin (not host), projects I have on the side. 😎 |
|
Thanks 👍 |
| @@ -163,7 +165,7 @@ namespace clap { namespace helpers { | |||
| // put draft ext here | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
Am I reading this wrong or is it a pretty big change?
if I request host.get extension I no longer get the extension which routes to my internal virtual method for one of the mapped extensions?
There was a problem hiding this comment.
It allows the host to shortcut the clap helper for a specific extension.
I think it makes sense.
There was a problem hiding this comment.
Maybe I merged this too quickly, do you see a big issue with this change?
There was a problem hiding this comment.
Maybe we could have two methods to make it clearer if that you're concern:
getExtension()which would be the fallback if the clap-helper didn't provide itshortcutExtension()which would let the subclass provide the extension to use before the helper layer.
Would that make sense?
There was a problem hiding this comment.
It allows the host to shortcut the clap helper for a specific extension. I think it makes sense.
but what if that extension is CLAP_EXT_GUI was my thinking. Then you get nullptr if you call get extension.
I definitely mix-and-match hostProxy.paramFoo and p = hostProxy.getExtension(PARAMS); p->foo(hostProxy->_host) in my code and expect both to kinda give the same function point.
The perhaps yeah 'underlyingExtension' or 'shortcutExtension' makes sense but I think this change will break some of my code.
There was a problem hiding this comment.
This doesn't touch the PluginProxy or HostProxy.
It is only for the Plugin and Host.
There was a problem hiding this comment.
Are you saying that you are using plugin-proxy to talk to your own plugin instance within itself?
There was a problem hiding this comment.
ahhh did i misread?
i definitely use raw extensions from the host and the host proxy interchangeably.
let me check if i do the same with plugins. i think that's less likely.
* * Add host getExtension() handler * Ignore generated files when used as a meson subproject * host/plugin: check overriden extension access before built-ins * host.hh: remove string_view include; not used. * plugin: call extension on the 'self' object
* * Add host getExtension() handler * Ignore generated files when used as a meson subproject * host/plugin: check overriden extension access before built-ins * host.hh: remove string_view include; not used. * plugin: call extension on the 'self' object
No description provided.