mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Implement IpluginFactory2::getClassInfo2
This commit is contained in:
@@ -22,18 +22,15 @@ YaPluginFactory::YaPluginFactory(
|
|||||||
Steinberg::IPtr<Steinberg::IPluginFactory> factory) {
|
Steinberg::IPtr<Steinberg::IPluginFactory> factory) {
|
||||||
FUNKNOWN_CTOR
|
FUNKNOWN_CTOR
|
||||||
|
|
||||||
// TODO: Copy data from `IPluginFactory`
|
|
||||||
// TODO: We should only copy the interfaces that we support. This should use
|
|
||||||
// the same list as that used in `createInstance()`.
|
|
||||||
known_iids.insert(factory->iid);
|
known_iids.insert(factory->iid);
|
||||||
|
// `IPluginFactory::getFactoryInfo`
|
||||||
if (Steinberg::PFactoryInfo info;
|
if (Steinberg::PFactoryInfo info;
|
||||||
factory->getFactoryInfo(&info) == Steinberg::kResultOk) {
|
factory->getFactoryInfo(&info) == Steinberg::kResultOk) {
|
||||||
factory_info = info;
|
factory_info = info;
|
||||||
}
|
}
|
||||||
|
// `IPluginFactory::countClasses`
|
||||||
num_classes = factory->countClasses();
|
num_classes = factory->countClasses();
|
||||||
|
// `IPluginFactory::getClassInfo`
|
||||||
// TODO: At this point we don't know what this class is and thus we can't
|
// TODO: At this point we don't know what this class is and thus we can't
|
||||||
// filter unsupported classes, right?
|
// filter unsupported classes, right?
|
||||||
class_infos_1.resize(num_classes);
|
class_infos_1.resize(num_classes);
|
||||||
@@ -49,8 +46,14 @@ YaPluginFactory::YaPluginFactory(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Copy data from `IPluginFactory2`
|
|
||||||
known_iids.insert(factory2->iid);
|
known_iids.insert(factory2->iid);
|
||||||
|
// `IpluginFactory2::getClassInfo2`
|
||||||
|
for (int i = 0; i < num_classes; i++) {
|
||||||
|
Steinberg::PClassInfo2 info;
|
||||||
|
if (factory2->getClassInfo2(i, &info) == Steinberg::kResultOk) {
|
||||||
|
class_infos_2[i] = info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto factory3 = Steinberg::FUnknownPtr<Steinberg::IPluginFactory3>(factory);
|
auto factory3 = Steinberg::FUnknownPtr<Steinberg::IPluginFactory3>(factory);
|
||||||
if (!factory3) {
|
if (!factory3) {
|
||||||
@@ -120,10 +123,17 @@ tresult PLUGIN_API YaPluginFactory::getClassInfo(Steinberg::int32 index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API
|
tresult PLUGIN_API
|
||||||
YaPluginFactory::getClassInfo2(int32 /*index*/,
|
YaPluginFactory::getClassInfo2(int32 index, Steinberg::PClassInfo2* info) {
|
||||||
Steinberg::PClassInfo2* /*info*/) {
|
if (index >= static_cast<int32>(class_infos_1.size())) {
|
||||||
// TODO: Implement
|
return Steinberg::kInvalidArgument;
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
if (class_infos_2[index]) {
|
||||||
|
*info = *class_infos_2[index];
|
||||||
|
return Steinberg::kResultOk;
|
||||||
|
} else {
|
||||||
|
return Steinberg::kResultFalse;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API
|
tresult PLUGIN_API
|
||||||
|
|||||||
@@ -25,9 +25,7 @@
|
|||||||
|
|
||||||
#include "../../bitsery/ext/vst3.h"
|
#include "../../bitsery/ext/vst3.h"
|
||||||
|
|
||||||
namespace {
|
|
||||||
using Steinberg::int32, Steinberg::tresult;
|
using Steinberg::int32, Steinberg::tresult;
|
||||||
} // namespace
|
|
||||||
|
|
||||||
// TODO: After implementing one or two more of these, abstract away some of the
|
// TODO: After implementing one or two more of these, abstract away some of the
|
||||||
// nasty bits
|
// nasty bits
|
||||||
@@ -43,14 +41,6 @@ using Steinberg::int32, Steinberg::tresult;
|
|||||||
*/
|
*/
|
||||||
class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* TODO: Instead of a having a default constructor, we should probably be
|
|
||||||
* passing a callback to this constructor that lets us communicate
|
|
||||||
* with the Wine plugin host.
|
|
||||||
* TODO: Alternative to requiring a bunch of `fu::unique_function<>`
|
|
||||||
* callbacks would be to make the callback functions pure virtual, and
|
|
||||||
* then implement those functions directly using `Vst3MessageHandler`.
|
|
||||||
*/
|
|
||||||
YaPluginFactory();
|
YaPluginFactory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,7 +106,10 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
|||||||
* doesn't return a class info.
|
* doesn't return a class info.
|
||||||
*/
|
*/
|
||||||
std::vector<std::optional<Steinberg::PClassInfo>> class_infos_1;
|
std::vector<std::optional<Steinberg::PClassInfo>> class_infos_1;
|
||||||
// TODO: Callback interface for `createInstance()`
|
/**
|
||||||
|
* For `IPluginFactory2::getClassInfo2`, works the same way as the above.
|
||||||
|
*/
|
||||||
|
std::vector<std::optional<Steinberg::PClassInfo2>> class_infos_2;
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s) {
|
void serialize(S& s) {
|
||||||
@@ -130,6 +123,10 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
|||||||
[](S& s, std::optional<Steinberg::PClassInfo>& info) {
|
[](S& s, std::optional<Steinberg::PClassInfo>& info) {
|
||||||
s.ext(info, bitsery::ext::StdOptional{});
|
s.ext(info, bitsery::ext::StdOptional{});
|
||||||
});
|
});
|
||||||
|
s.container(class_infos_2, 2048,
|
||||||
|
[](S& s, std::optional<Steinberg::PClassInfo2>& info) {
|
||||||
|
s.ext(info, bitsery::ext::StdOptional{});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -146,6 +143,19 @@ void serialize(S& s, PClassInfo& class_info) {
|
|||||||
s.text1b(class_info.name);
|
s.text1b(class_info.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s, PClassInfo2& class_info) {
|
||||||
|
s.container1b(class_info.cid);
|
||||||
|
s.value4b(class_info.cardinality);
|
||||||
|
s.text1b(class_info.category);
|
||||||
|
s.text1b(class_info.name);
|
||||||
|
s.value4b(class_info.classFlags);
|
||||||
|
s.text1b(class_info.subCategories);
|
||||||
|
s.text1b(class_info.vendor);
|
||||||
|
s.text1b(class_info.version);
|
||||||
|
s.text1b(class_info.sdkVersion);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s, PFactoryInfo& factory_info) {
|
void serialize(S& s, PFactoryInfo& factory_info) {
|
||||||
s.text1b(factory_info.vendor);
|
s.text1b(factory_info.vendor);
|
||||||
|
|||||||
Reference in New Issue
Block a user