Split YaEditController into YaEditController{,2}

Since even though the title would make you assume it's a versioned
interface, it's not.
This commit is contained in:
Robbert van der Helm
2020-12-19 14:18:57 +01:00
parent 9bca4796a5
commit 54e73d2d19
8 changed files with 124 additions and 41 deletions
@@ -0,0 +1,27 @@
// yabridge: a Wine VST bridge
// Copyright (C) 2020 Robbert van der Helm
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "edit-controller-2.h"
YaEditController2::ConstructArgs::ConstructArgs() {}
YaEditController2::ConstructArgs::ConstructArgs(
Steinberg::IPtr<Steinberg::FUnknown> object)
: supported(
Steinberg::FUnknownPtr<Steinberg::Vst::IEditController2>(object)) {}
YaEditController2::YaEditController2(const ConstructArgs&& args)
: arguments(std::move(args)) {}
@@ -0,0 +1,73 @@
// yabridge: a Wine VST bridge
// Copyright (C) 2020 Robbert van der Helm
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <pluginterfaces/vst/ivsteditcontroller.h>
#include "../../common.h"
#include "../base.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
/**
* Wraps around `IEditController2` for serialization purposes. This is
* instantiated as part of `Vst3PluginProxy`.
*/
class YaEditController2 : public Steinberg::Vst::IEditController2 {
public:
/**
* These are the arguments for creating a `YaEditController2`.
*/
struct ConstructArgs {
ConstructArgs();
/**
* Check whether an existing implementation implements
* `IEditController2` and read arguments from it.
*/
ConstructArgs(Steinberg::IPtr<Steinberg::FUnknown> object);
/**
* Whether the object supported this interface.
*/
bool supported;
template <typename S>
void serialize(S& s) {
s.value1b(supported);
}
};
/**
* Instantiate this instance with arguments read from another interface
* implementation.
*/
YaEditController2(const ConstructArgs&& args);
inline bool supported() const { return arguments.supported; }
virtual tresult PLUGIN_API
setKnobMode(Steinberg::Vst::KnobMode mode) override = 0;
virtual tresult PLUGIN_API openHelp(TBool onlyCheck) override = 0;
virtual tresult PLUGIN_API openAboutBox(TBool onlyCheck) override = 0;
protected:
ConstructArgs arguments;
};
#pragma GCC diagnostic pop
@@ -20,10 +20,8 @@ YaEditController::ConstructArgs::ConstructArgs() {}
YaEditController::ConstructArgs::ConstructArgs(
Steinberg::IPtr<Steinberg::FUnknown> object)
: supported_version_1(
Steinberg::FUnknownPtr<Steinberg::Vst::IEditController>(object)),
supported_version_2(
Steinberg::FUnknownPtr<Steinberg::Vst::IEditController2>(object)) {}
: supported(
Steinberg::FUnknownPtr<Steinberg::Vst::IEditController>(object)) {}
YaEditController::YaEditController(const ConstructArgs&& args)
: arguments(std::move(args)) {}
@@ -25,14 +25,10 @@
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
/**
* Wraps around `IEditController{,2}` for serialization purposes. This is
* Wraps around `IEditController` for serialization purposes. This is
* instantiated as part of `Vst3PluginProxy`.
*
* Steinberg forgot to inherit `IEditController2` from `IEditController` event
* if it says it does in the docs, so we'll pretend they just that.
*/
class YaEditController : public Steinberg::Vst::IEditController,
public Steinberg::Vst::IEditController2 {
class YaEditController : public Steinberg::Vst::IEditController {
public:
/**
* These are the arguments for creating a `YaEditController`.
@@ -41,25 +37,19 @@ class YaEditController : public Steinberg::Vst::IEditController,
ConstructArgs();
/**
* Check whether an existing implementation implements `IEditController`
* and `IEditController2` and read arguments from it.
* Check whether an existing implementation implements
* `IEditController` and read arguments from it.
*/
ConstructArgs(Steinberg::IPtr<Steinberg::FUnknown> object);
/**
* Whether the object supported `IEditController`.
* Whether the object supported this interface.
*/
bool supported_version_1;
/**
* Whether the object supported `IEditController2`.
*/
bool supported_version_2;
bool supported;
template <typename S>
void serialize(S& s) {
s.value1b(supported_version_1);
s.value1b(supported_version_2);
s.value1b(supported);
}
};
@@ -69,14 +59,7 @@ class YaEditController : public Steinberg::Vst::IEditController,
*/
YaEditController(const ConstructArgs&& args);
inline bool supported_version_1() const {
return arguments.supported_version_1;
}
inline bool supported_version_2() const {
return arguments.supported_version_2;
}
// From `IEditController`
inline bool supported() const { return arguments.supported; }
/**
* Message to pass through a call to
@@ -350,13 +333,6 @@ class YaEditController : public Steinberg::Vst::IEditController,
virtual Steinberg::IPlugView* PLUGIN_API
createView(Steinberg::FIDString name) override = 0;
// From `IEditController2`
virtual tresult PLUGIN_API
setKnobMode(Steinberg::Vst::KnobMode mode) override = 0;
virtual tresult PLUGIN_API openHelp(TBool onlyCheck) override = 0;
virtual tresult PLUGIN_API openAboutBox(TBool onlyCheck) override = 0;
protected:
ConstructArgs arguments;
};