mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Use the new simple supports flags for the factory
This is both more type safe and as it turns out much more manageable.
This commit is contained in:
@@ -77,8 +77,6 @@ class Vst3MessageHandler : public AdHocSocketHandler<Thread> {
|
|||||||
* -> host callbacks isntead. Optional since it only has to be set on the
|
* -> host callbacks isntead. Optional since it only has to be set on the
|
||||||
* plugin's side.
|
* plugin's side.
|
||||||
*
|
*
|
||||||
* TODO: Is it feasible to move `logging` to the constructor instead?
|
|
||||||
*
|
|
||||||
* @relates Vst3MessageHandler::receive_messages
|
* @relates Vst3MessageHandler::receive_messages
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ YaPluginFactory::ConstructArgs::ConstructArgs() {}
|
|||||||
|
|
||||||
YaPluginFactory::ConstructArgs::ConstructArgs(
|
YaPluginFactory::ConstructArgs::ConstructArgs(
|
||||||
Steinberg::IPtr<Steinberg::IPluginFactory> factory) {
|
Steinberg::IPtr<Steinberg::IPluginFactory> factory) {
|
||||||
known_iids.insert(factory->iid);
|
|
||||||
// `IPluginFactory::getFactoryInfo`
|
// `IPluginFactory::getFactoryInfo`
|
||||||
if (Steinberg::PFactoryInfo info;
|
if (Steinberg::PFactoryInfo info;
|
||||||
factory->getFactoryInfo(&info) == Steinberg::kResultOk) {
|
factory->getFactoryInfo(&info) == Steinberg::kResultOk) {
|
||||||
@@ -47,7 +46,7 @@ YaPluginFactory::ConstructArgs::ConstructArgs(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
known_iids.insert(factory2->iid);
|
supports_plugin_factory_2 = true;
|
||||||
// `IpluginFactory2::getClassInfo2`
|
// `IpluginFactory2::getClassInfo2`
|
||||||
class_infos_2.resize(num_classes);
|
class_infos_2.resize(num_classes);
|
||||||
for (int i = 0; i < num_classes; i++) {
|
for (int i = 0; i < num_classes; i++) {
|
||||||
@@ -62,7 +61,7 @@ YaPluginFactory::ConstructArgs::ConstructArgs(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
known_iids.insert(factory3->iid);
|
supports_plugin_factory_3 = true;
|
||||||
// `IpluginFactory3::getClassInfoUnicode`
|
// `IpluginFactory3::getClassInfoUnicode`
|
||||||
class_infos_unicode.resize(num_classes);
|
class_infos_unicode.resize(num_classes);
|
||||||
for (int i = 0; i < num_classes; i++) {
|
for (int i = 0; i < num_classes; i++) {
|
||||||
@@ -90,15 +89,13 @@ tresult PLUGIN_API YaPluginFactory::queryInterface(Steinberg::FIDString _iid,
|
|||||||
void** obj) {
|
void** obj) {
|
||||||
QUERY_INTERFACE(_iid, obj, Steinberg::FUnknown::iid,
|
QUERY_INTERFACE(_iid, obj, Steinberg::FUnknown::iid,
|
||||||
Steinberg::IPluginFactory)
|
Steinberg::IPluginFactory)
|
||||||
if (arguments.known_iids.contains(Steinberg::IPluginFactory::iid)) {
|
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory::iid,
|
||||||
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory::iid,
|
Steinberg::IPluginFactory)
|
||||||
Steinberg::IPluginFactory)
|
if (arguments.supports_plugin_factory_2) {
|
||||||
}
|
|
||||||
if (arguments.known_iids.contains(Steinberg::IPluginFactory2::iid)) {
|
|
||||||
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory2::iid,
|
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory2::iid,
|
||||||
Steinberg::IPluginFactory2)
|
Steinberg::IPluginFactory2)
|
||||||
}
|
}
|
||||||
if (arguments.known_iids.contains(Steinberg::IPluginFactory3::iid)) {
|
if (arguments.supports_plugin_factory_3) {
|
||||||
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory3::iid,
|
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory3::iid,
|
||||||
Steinberg::IPluginFactory3)
|
Steinberg::IPluginFactory3)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include <bitsery/ext/std_optional.h>
|
#include <bitsery/ext/std_optional.h>
|
||||||
#include <bitsery/ext/std_set.h>
|
|
||||||
#include <bitsery/traits/string.h>
|
#include <bitsery/traits/string.h>
|
||||||
#include <pluginterfaces/base/ipluginbase.h>
|
#include <pluginterfaces/base/ipluginbase.h>
|
||||||
|
|
||||||
@@ -27,15 +24,12 @@
|
|||||||
#include "base.h"
|
#include "base.h"
|
||||||
#include "host-application.h"
|
#include "host-application.h"
|
||||||
|
|
||||||
// TODO: After implementing one or two more of these, abstract away some of the
|
|
||||||
// nasty bits
|
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps around `IPluginFactory{1,2,3}` for serialization purposes. See
|
* Wraps around `IPluginFactory{1,2,3}` for serialization purposes. See
|
||||||
* `README.md` for more information on how this works.
|
* `docs/vst3.md` for more information on how this works.
|
||||||
*/
|
*/
|
||||||
class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
||||||
public:
|
public:
|
||||||
@@ -53,12 +47,14 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
|||||||
ConstructArgs(Steinberg::IPtr<Steinberg::IPluginFactory> factory);
|
ConstructArgs(Steinberg::IPtr<Steinberg::IPluginFactory> factory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The IIDs that the interface we serialized supports.
|
* Whether `factory` supported `IPluginFactory2`.
|
||||||
*
|
|
||||||
* TODO: Replace this with a set of boolean flags, just like we're doing
|
|
||||||
* with the other interfaces.
|
|
||||||
*/
|
*/
|
||||||
std::set<Steinberg::FUID> known_iids;
|
bool supports_plugin_factory_2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether `factory` supported `IPluginFactory3`.
|
||||||
|
*/
|
||||||
|
bool supports_plugin_factory_3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For `IPluginFactory::getFactoryInfo`.
|
* For `IPluginFactory::getFactoryInfo`.
|
||||||
@@ -92,10 +88,8 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
|||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s) {
|
void serialize(S& s) {
|
||||||
s.ext(known_iids, bitsery::ext::StdSet{32},
|
s.value1b(supports_plugin_factory_2);
|
||||||
[](S& s, Steinberg::FUID& iid) {
|
s.value1b(supports_plugin_factory_3);
|
||||||
s.ext(iid, bitsery::ext::FUID{});
|
|
||||||
});
|
|
||||||
s.ext(factory_info, bitsery::ext::StdOptional{});
|
s.ext(factory_info, bitsery::ext::StdOptional{});
|
||||||
s.value4b(num_classes);
|
s.value4b(num_classes);
|
||||||
s.container(class_infos_1, 2048,
|
s.container(class_infos_1, 2048,
|
||||||
|
|||||||
Reference in New Issue
Block a user