Serialize the factory info

This commit is contained in:
Robbert van der Helm
2020-12-05 13:49:38 +01:00
parent fa10600114
commit 79df8fecc2
2 changed files with 34 additions and 4 deletions
@@ -26,6 +26,10 @@ YaPluginFactory::YaPluginFactory(
// 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);
if (Steinberg::PFactoryInfo info;
factory->getFactoryInfo(&info) == Steinberg::kResultOk) {
factory_info = info;
}
auto factory2 = Steinberg::FUnknownPtr<Steinberg::IPluginFactory2>(factory);
if (!factory2) {
@@ -75,9 +79,13 @@ tresult PLUGIN_API YaPluginFactory::queryInterface(Steinberg::FIDString _iid,
}
tresult PLUGIN_API
YaPluginFactory::getFactoryInfo(Steinberg::PFactoryInfo* /*info*/) {
// TODO: Implement
return 0;
YaPluginFactory::getFactoryInfo(Steinberg::PFactoryInfo* info) {
if (info && factory_info) {
*info = *factory_info;
return Steinberg::kResultOk;
} else {
return Steinberg::kNotInitialized;
}
}
int32 PLUGIN_API YaPluginFactory::countClasses() {
@@ -126,6 +134,7 @@ YaPluginFactory::getClassInfoUnicode(int32 /*index*/,
tresult PLUGIN_API
YaPluginFactory::setHostContext(Steinberg::FUnknown* /*context*/) {
// TODO: Implement
// TODO: I guess this should do a callback and set the Wine host's host
// context, right?
return 0;
}
@@ -18,7 +18,9 @@
#include <set>
#include <bitsery/ext/std_optional.h>
#include <bitsery/ext/std_set.h>
#include <bitsery/traits/string.h>
#include <pluginterfaces/base/ipluginbase.h>
#include "../../bitsery/ext/vst3.h"
@@ -29,6 +31,8 @@ using Steinberg::int32, Steinberg::tresult;
// TODO: After implementing one or two more of these, abstract away some of the
// nasty bits
// TODO: Should we have some clearer way to indicate to us which fields are
// going to return copied results directly and which make a callback?
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
@@ -82,13 +86,30 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
*/
std::set<Steinberg::FUID> known_iids;
// For `IPluginFactory::getFactoryInfo`
std::optional<Steinberg::PFactoryInfo> factory_info;
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.ext(factory_info, bitsery::ext::StdOptional{},
[](S& s, Steinberg::PFactoryInfo& info) { s.object(info); });
}
};
#pragma GCC diagnostic pop
// Serialization functions have to live in the same namespace as the objects
// they're serializing
namespace Steinberg {
template <typename S>
void serialize(S& s, PFactoryInfo& factory_info) {
s.text1b(factory_info.vendor);
s.text1b(factory_info.url);
s.text1b(factory_info.email);
s.value4b(factory_info.flags);
}
} // namespace Steinberg