From 225056bcff771ab7399cb1983a317f326307a381 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 8 Dec 2020 23:02:49 +0100 Subject: [PATCH] Allow instantiating IComponents --- src/common/serialization/vst3/component.cpp | 2 ++ src/common/serialization/vst3/component.h | 2 ++ src/plugin/bridges/vst3-impls.cpp | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/common/serialization/vst3/component.cpp b/src/common/serialization/vst3/component.cpp index 9e521646..1db52fcf 100644 --- a/src/common/serialization/vst3/component.cpp +++ b/src/common/serialization/vst3/component.cpp @@ -16,6 +16,8 @@ #include "component.h" +YaComponent::Arguments::Arguments() {} + YaComponent::Arguments::Arguments( Steinberg::IPtr component, size_t instance_id) diff --git a/src/common/serialization/vst3/component.h b/src/common/serialization/vst3/component.h index 3be2f83e..b025a785 100644 --- a/src/common/serialization/vst3/component.h +++ b/src/common/serialization/vst3/component.h @@ -48,6 +48,8 @@ class YaComponent : public Steinberg::Vst::IComponent { * These are the arguments for creating a `YaComponentPluginImpl`. */ struct Arguments { + Arguments(); + /** * Read arguments from an existing implementation. */ diff --git a/src/plugin/bridges/vst3-impls.cpp b/src/plugin/bridges/vst3-impls.cpp index 9a99b254..fd0d683e 100644 --- a/src/plugin/bridges/vst3-impls.cpp +++ b/src/plugin/bridges/vst3-impls.cpp @@ -25,10 +25,19 @@ tresult PLUGIN_API YaPluginFactoryPluginImpl::createInstance(Steinberg::FIDString cid, Steinberg::FIDString _iid, void** obj) { - // TODO: Implement as specified in `src/common/serialization/vst3/README.md` + // TODO: Do the same thing for other types + ArrayUID cid_array; + std::copy(cid, cid + sizeof(Steinberg::TUID), cid_array.begin()); if (Steinberg::FIDStringsEqual(_iid, Steinberg::Vst::IComponent::iid)) { - // TODO: Instantiate an IComponent as described above - return Steinberg::kNotImplemented; + std::optional args = + bridge.send_message(YaComponent::Create{.cid = cid_array}); + if (args) { + // I find all of these raw pointers scary + *obj = new YaComponentPluginImpl(bridge, std::move(*args)); + return Steinberg::kResultOk; + } else { + return Steinberg::kNotImplemented; + } } else { // When the host requests an interface we do not (yet) implement, we'll // print a recognizable log message. I don't think they include a safe