mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 20:40:11 +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
|
||||
* plugin's side.
|
||||
*
|
||||
* TODO: Is it feasible to move `logging` to the constructor instead?
|
||||
*
|
||||
* @relates Vst3MessageHandler::receive_messages
|
||||
*/
|
||||
template <typename T>
|
||||
|
||||
@@ -25,7 +25,6 @@ YaPluginFactory::ConstructArgs::ConstructArgs() {}
|
||||
|
||||
YaPluginFactory::ConstructArgs::ConstructArgs(
|
||||
Steinberg::IPtr<Steinberg::IPluginFactory> factory) {
|
||||
known_iids.insert(factory->iid);
|
||||
// `IPluginFactory::getFactoryInfo`
|
||||
if (Steinberg::PFactoryInfo info;
|
||||
factory->getFactoryInfo(&info) == Steinberg::kResultOk) {
|
||||
@@ -47,7 +46,7 @@ YaPluginFactory::ConstructArgs::ConstructArgs(
|
||||
return;
|
||||
}
|
||||
|
||||
known_iids.insert(factory2->iid);
|
||||
supports_plugin_factory_2 = true;
|
||||
// `IpluginFactory2::getClassInfo2`
|
||||
class_infos_2.resize(num_classes);
|
||||
for (int i = 0; i < num_classes; i++) {
|
||||
@@ -62,7 +61,7 @@ YaPluginFactory::ConstructArgs::ConstructArgs(
|
||||
return;
|
||||
}
|
||||
|
||||
known_iids.insert(factory3->iid);
|
||||
supports_plugin_factory_3 = true;
|
||||
// `IpluginFactory3::getClassInfoUnicode`
|
||||
class_infos_unicode.resize(num_classes);
|
||||
for (int i = 0; i < num_classes; i++) {
|
||||
@@ -90,15 +89,13 @@ tresult PLUGIN_API YaPluginFactory::queryInterface(Steinberg::FIDString _iid,
|
||||
void** obj) {
|
||||
QUERY_INTERFACE(_iid, obj, Steinberg::FUnknown::iid,
|
||||
Steinberg::IPluginFactory)
|
||||
if (arguments.known_iids.contains(Steinberg::IPluginFactory::iid)) {
|
||||
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory::iid,
|
||||
Steinberg::IPluginFactory)
|
||||
}
|
||||
if (arguments.known_iids.contains(Steinberg::IPluginFactory2::iid)) {
|
||||
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory::iid,
|
||||
Steinberg::IPluginFactory)
|
||||
if (arguments.supports_plugin_factory_2) {
|
||||
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory2::iid,
|
||||
Steinberg::IPluginFactory2)
|
||||
}
|
||||
if (arguments.known_iids.contains(Steinberg::IPluginFactory3::iid)) {
|
||||
if (arguments.supports_plugin_factory_3) {
|
||||
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory3::iid,
|
||||
Steinberg::IPluginFactory3)
|
||||
}
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <bitsery/ext/std_optional.h>
|
||||
#include <bitsery/ext/std_set.h>
|
||||
#include <bitsery/traits/string.h>
|
||||
#include <pluginterfaces/base/ipluginbase.h>
|
||||
|
||||
@@ -27,15 +24,12 @@
|
||||
#include "base.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 ignored "-Wnon-virtual-dtor"
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
public:
|
||||
@@ -53,12 +47,14 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
||||
ConstructArgs(Steinberg::IPtr<Steinberg::IPluginFactory> factory);
|
||||
|
||||
/**
|
||||
* The IIDs that the interface we serialized supports.
|
||||
*
|
||||
* TODO: Replace this with a set of boolean flags, just like we're doing
|
||||
* with the other interfaces.
|
||||
* Whether `factory` supported `IPluginFactory2`.
|
||||
*/
|
||||
std::set<Steinberg::FUID> known_iids;
|
||||
bool supports_plugin_factory_2;
|
||||
|
||||
/**
|
||||
* Whether `factory` supported `IPluginFactory3`.
|
||||
*/
|
||||
bool supports_plugin_factory_3;
|
||||
|
||||
/**
|
||||
* For `IPluginFactory::getFactoryInfo`.
|
||||
@@ -92,10 +88,8 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.ext(known_iids, bitsery::ext::StdSet{32},
|
||||
[](S& s, Steinberg::FUID& iid) {
|
||||
s.ext(iid, bitsery::ext::FUID{});
|
||||
});
|
||||
s.value1b(supports_plugin_factory_2);
|
||||
s.value1b(supports_plugin_factory_3);
|
||||
s.ext(factory_info, bitsery::ext::StdOptional{});
|
||||
s.value4b(num_classes);
|
||||
s.container(class_infos_1, 2048,
|
||||
|
||||
Reference in New Issue
Block a user