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