Implement IComponent::setState()

This commit is contained in:
Robbert van der Helm
2020-12-14 12:09:47 +01:00
parent c463543ac9
commit 816d1c1501
10 changed files with 56 additions and 6 deletions
+4 -3
View File
@@ -141,9 +141,10 @@ tresult PLUGIN_API YaComponentPluginImpl::setActive(TBool state) {
}
tresult PLUGIN_API YaComponentPluginImpl::setState(Steinberg::IBStream* state) {
// TODO: Implement
bridge.logger.log("TODO: IComponent::setState()");
return Steinberg::kNotImplemented;
return bridge
.send_message(YaComponent::SetState{
.instance_id = arguments.instance_id, .state = state})
.native();
}
tresult PLUGIN_API YaComponentPluginImpl::getState(Steinberg::IBStream* state) {
@@ -30,6 +30,11 @@ YaPluginFactoryPluginImpl::createInstance(Steinberg::FIDString cid,
Steinberg::FIDString _iid,
void** obj) {
// TODO: Do the same thing for other types
// These arw pointers are scary. The idea here is that we return a newly
// initialized object (that initializes itself with a reference count of 1),
// and then the receiving side will use `Steinberg::owned()` to adopt it to
// an `IPtr<T>`.
ArrayUID cid_array;
std::copy(cid, cid + sizeof(Steinberg::TUID), cid_array.begin());
if (Steinberg::FIDStringsEqual(_iid, Steinberg::Vst::IComponent::iid)) {
@@ -38,8 +43,8 @@ YaPluginFactoryPluginImpl::createInstance(Steinberg::FIDString cid,
return std::visit(
overload{
[&](YaComponent::ConstructArgs&& args) -> tresult {
// I find all of these raw pointers scary
*obj = new YaComponentPluginImpl(bridge, std::move(args));
*obj = static_cast<Steinberg::Vst::IComponent*>(
new YaComponentPluginImpl(bridge, std::move(args)));
return Steinberg::kResultOk;
},
[&](const UniversalTResult& code) { return code.native(); }},