mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Rename Create/Destroy to Construct/Destruct
This is less likely to clash with names used by interfaces and it's a bit clearer what's going on (since they are basically proxies for constructors and destructors).
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
Vst3Logger::Vst3Logger(Logger& generic_logger) : logger(generic_logger) {}
|
||||
|
||||
void Vst3Logger::log_request(bool is_host_vst, const YaComponent::Create&) {
|
||||
void Vst3Logger::log_request(bool is_host_vst, const YaComponent::Construct&) {
|
||||
log_request_base(is_host_vst, [](auto& message) {
|
||||
// TODO: Log the cid in some readable way, if possible
|
||||
message << "IPluginFactory::createComponent(cid, IComponent::iid, "
|
||||
@@ -31,7 +31,7 @@ void Vst3Logger::log_request(bool is_host_vst, const YaComponent::Create&) {
|
||||
}
|
||||
|
||||
void Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaComponent::Destroy& request) {
|
||||
const YaComponent::Destruct& request) {
|
||||
log_request_base(is_host_vst, [&](auto& message) {
|
||||
message << "<IComponent* #" << request.instance_id
|
||||
<< ">::~IComponent()";
|
||||
@@ -63,9 +63,9 @@ void Vst3Logger::log_response(bool is_host_vst, const Ack&) {
|
||||
|
||||
void Vst3Logger::log_response(
|
||||
bool is_host_vst,
|
||||
const std::variant<YaComponent::CreateArgs, UniversalTResult>& result) {
|
||||
const std::variant<YaComponent::ConstructArgs, UniversalTResult>& result) {
|
||||
log_response_base(is_host_vst, [&](auto& message) {
|
||||
std::visit(overload{[&](const YaComponent::CreateArgs& args) {
|
||||
std::visit(overload{[&](const YaComponent::ConstructArgs& args) {
|
||||
message << "<IComponent* #" << args.instance_id
|
||||
<< ">";
|
||||
},
|
||||
|
||||
@@ -47,8 +47,8 @@ class Vst3Logger {
|
||||
// flag here indicates whether the request was initiated on the host side
|
||||
// (what we'll call a control message).
|
||||
|
||||
void log_request(bool is_host_vst, const YaComponent::Create&);
|
||||
void log_request(bool is_host_vst, const YaComponent::Destroy&);
|
||||
void log_request(bool is_host_vst, const YaComponent::Construct&);
|
||||
void log_request(bool is_host_vst, const YaComponent::Destruct&);
|
||||
void log_request(bool is_host_vst, const YaComponent::Terminate&);
|
||||
void log_request(bool is_host_vst, const WantsConfiguration&);
|
||||
void log_request(bool is_host_vst, const WantsPluginFactory&);
|
||||
@@ -56,7 +56,7 @@ class Vst3Logger {
|
||||
void log_response(bool is_host_vst, const Ack&);
|
||||
void log_response(
|
||||
bool is_host_vst,
|
||||
const std::variant<YaComponent::CreateArgs, UniversalTResult>&);
|
||||
const std::variant<YaComponent::ConstructArgs, UniversalTResult>&);
|
||||
void log_response(bool is_host_vst, const Configuration&);
|
||||
void log_response(bool is_host_vst, const YaPluginFactory&);
|
||||
|
||||
|
||||
@@ -68,8 +68,8 @@ struct WantsPluginFactory {
|
||||
* encodes the information we request or the operation we want to perform. A
|
||||
* request of type `ControlRequest(T)` should send back a `T::Response`.
|
||||
*/
|
||||
using ControlRequest = std::variant<YaComponent::Create,
|
||||
YaComponent::Destroy,
|
||||
using ControlRequest = std::variant<YaComponent::Construct,
|
||||
YaComponent::Destruct,
|
||||
YaComponent::Terminate,
|
||||
WantsPluginFactory>;
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
#include "component.h"
|
||||
|
||||
YaComponent::CreateArgs::CreateArgs() {}
|
||||
YaComponent::ConstructArgs::ConstructArgs() {}
|
||||
|
||||
YaComponent::CreateArgs::CreateArgs(
|
||||
YaComponent::ConstructArgs::ConstructArgs(
|
||||
Steinberg::IPtr<Steinberg::Vst::IComponent> component,
|
||||
size_t instance_id)
|
||||
: instance_id(instance_id) {
|
||||
@@ -29,7 +29,7 @@ YaComponent::CreateArgs::CreateArgs(
|
||||
}
|
||||
}
|
||||
|
||||
YaComponent::YaComponent(const CreateArgs&& args) : arguments(std::move(args)) {
|
||||
YaComponent::YaComponent(const ConstructArgs&& args) : arguments(std::move(args)) {
|
||||
FUNKNOWN_CTOR
|
||||
|
||||
// Everything else is handled directly through callbacks to minimize the
|
||||
|
||||
@@ -49,14 +49,14 @@ class YaComponent : public Steinberg::Vst::IComponent {
|
||||
/**
|
||||
* These are the arguments for creating a `YaComponentPluginImpl`.
|
||||
*/
|
||||
struct CreateArgs {
|
||||
CreateArgs();
|
||||
struct ConstructArgs {
|
||||
ConstructArgs();
|
||||
|
||||
/**
|
||||
* Read arguments from an existing implementation.
|
||||
*/
|
||||
CreateArgs(Steinberg::IPtr<Steinberg::Vst::IComponent> component,
|
||||
size_t isntance_id);
|
||||
ConstructArgs(Steinberg::IPtr<Steinberg::Vst::IComponent> component,
|
||||
size_t isntance_id);
|
||||
|
||||
/**
|
||||
* The unique identifier for this specific instance.
|
||||
@@ -83,8 +83,8 @@ class YaComponent : public Steinberg::Vst::IComponent {
|
||||
* IComponent::iid,
|
||||
* ...)`.
|
||||
*/
|
||||
struct Create {
|
||||
using Response = std::variant<CreateArgs, UniversalTResult>;
|
||||
struct Construct {
|
||||
using Response = std::variant<ConstructArgs, UniversalTResult>;
|
||||
|
||||
ArrayUID cid;
|
||||
|
||||
@@ -98,14 +98,14 @@ class YaComponent : public Steinberg::Vst::IComponent {
|
||||
* Instantiate this instance with arguments read from another interface
|
||||
* implementation.
|
||||
*/
|
||||
YaComponent(const CreateArgs&& args);
|
||||
YaComponent(const ConstructArgs&& args);
|
||||
|
||||
/**
|
||||
* Message to request the Wine plugin host to destroy the IComponent
|
||||
* instance with the given instance ID. Sent from the destructor of
|
||||
* `YaComponentPluginImpl`.
|
||||
*/
|
||||
struct Destroy {
|
||||
struct Destruct {
|
||||
using Response = Ack;
|
||||
|
||||
native_size_t instance_id;
|
||||
@@ -170,7 +170,7 @@ class YaComponent : public Steinberg::Vst::IComponent {
|
||||
getState(Steinberg::IBStream* state) override = 0;
|
||||
|
||||
protected:
|
||||
CreateArgs arguments;
|
||||
ConstructArgs arguments;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -178,6 +178,6 @@ class YaComponent : public Steinberg::Vst::IComponent {
|
||||
template <typename S>
|
||||
void serialize(
|
||||
S& s,
|
||||
std::variant<YaComponent::CreateArgs, UniversalTResult>& result) {
|
||||
std::variant<YaComponent::ConstructArgs, UniversalTResult>& result) {
|
||||
s.ext(result, bitsery::ext::StdVariant{});
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
#include "component.h"
|
||||
|
||||
YaComponentPluginImpl::YaComponentPluginImpl(Vst3PluginBridge& bridge,
|
||||
YaComponent::CreateArgs&& args)
|
||||
YaComponent::ConstructArgs&& args)
|
||||
: YaComponent(std::move(args)), bridge(bridge) {}
|
||||
|
||||
YaComponentPluginImpl::~YaComponentPluginImpl() {
|
||||
bridge.send_message(
|
||||
YaComponent::Destroy{.instance_id = arguments.instance_id});
|
||||
YaComponent::Destruct{.instance_id = arguments.instance_id});
|
||||
}
|
||||
|
||||
tresult PLUGIN_API
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
class YaComponentPluginImpl : public YaComponent {
|
||||
public:
|
||||
YaComponentPluginImpl(Vst3PluginBridge& bridge,
|
||||
YaComponent::CreateArgs&& args);
|
||||
YaComponent::ConstructArgs&& args);
|
||||
|
||||
/**
|
||||
* When the reference count reaches zero and this destructor is called,
|
||||
|
||||
@@ -31,11 +31,11 @@ YaPluginFactoryPluginImpl::createInstance(Steinberg::FIDString cid,
|
||||
ArrayUID cid_array;
|
||||
std::copy(cid, cid + sizeof(Steinberg::TUID), cid_array.begin());
|
||||
if (Steinberg::FIDStringsEqual(_iid, Steinberg::Vst::IComponent::iid)) {
|
||||
std::variant<YaComponent::CreateArgs, UniversalTResult> result =
|
||||
bridge.send_message(YaComponent::Create{.cid = cid_array});
|
||||
std::variant<YaComponent::ConstructArgs, UniversalTResult> result =
|
||||
bridge.send_message(YaComponent::Construct{.cid = cid_array});
|
||||
return std::visit(
|
||||
overload{
|
||||
[&](YaComponent::CreateArgs&& args) -> tresult {
|
||||
[&](YaComponent::ConstructArgs&& args) -> tresult {
|
||||
// I find all of these raw pointers scary
|
||||
*obj = new YaComponentPluginImpl(bridge, std::move(args));
|
||||
return Steinberg::kResultOk;
|
||||
|
||||
@@ -51,8 +51,8 @@ void Vst3Bridge::run() {
|
||||
sockets.host_vst_control.receive_messages(
|
||||
std::nullopt,
|
||||
overload{
|
||||
[&](const YaComponent::Create& args)
|
||||
-> YaComponent::Create::Response {
|
||||
[&](const YaComponent::Construct& args)
|
||||
-> YaComponent::Construct::Response {
|
||||
Steinberg::TUID cid;
|
||||
std::copy(args.cid.begin(), args.cid.end(), cid);
|
||||
Steinberg::IPtr<Steinberg::Vst::IComponent> component =
|
||||
@@ -64,15 +64,15 @@ void Vst3Bridge::run() {
|
||||
const size_t instance_id = generate_instance_id();
|
||||
component_instances[instance_id] = std::move(component);
|
||||
|
||||
return YaComponent::CreateArgs(
|
||||
return YaComponent::ConstructArgs(
|
||||
component_instances[instance_id], instance_id);
|
||||
} else {
|
||||
// The actual result is lost here
|
||||
return UniversalTResult(Steinberg::kNotImplemented);
|
||||
}
|
||||
},
|
||||
[&](const YaComponent::Destroy& request)
|
||||
-> YaComponent::Destroy::Response {
|
||||
[&](const YaComponent::Destruct& request)
|
||||
-> YaComponent::Destruct::Response {
|
||||
std::lock_guard lock(component_instances_mutex);
|
||||
component_instances.erase(request.instance_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user