💥 Rework Vst3MessageHandler

- Now allows direct deserialization into existing objects. This will be
  necessary for our VST3 implementations since the interface instances
  we'll deserialize into will not be trivially constructable because
  they have to be able to do callbacks.
- `ControlResponse` and `CallbackResponse` were dropped. These response
  enums are not necessary because of the `T::Response` associated type
  and returning the types directly makes the direct deserialization
  possible.
This commit is contained in:
Robbert van der Helm
2020-12-06 12:21:37 +01:00
parent 5423950a8a
commit d5374e4540
3 changed files with 27 additions and 65 deletions
+2 -35
View File
@@ -48,10 +48,7 @@ struct WantsConfiguration {
/**
* When we send a control message from the plugin to the Wine VST host, this
* encodes the information we request or the operation we want to perform. A
* request of type `T` should send back a `CallbackResponse` containing
* `T::Reponse`.
*
* @relates ControlResponse
* request of type `ControlRequest(T)` should send back a `T::Reponse`.
*/
using ControlRequest = std::variant<>;
@@ -60,26 +57,10 @@ void serialize(S& s, ControlRequest& payload) {
s.ext(payload, bitsery::ext::StdVariant{});
}
/**
* A response to a control message. Tee `T::Reponse` for the correct type to
* return here.
*
* @relates ControlRrequest
*/
using ControlResponse = std::variant<>;
// TODO: Uncomment when this is no longer empty
// template <typename S>
// void serialize(S& s, ControlResponse& payload) {
// s.ext(payload, bitsery::ext::StdVariant{});
// }
/**
* When we do a callback from the Wine VST host to the plugin, this encodes the
* information we want or the operation we want to perform. A request of type
* `T` should send back a `CallbackResponse` containing `T::Reponse`.
*
* @relates CallbackResponse
* `CallbackRequest(T)` should send back a `T::Reponse`.
*/
using CallbackRequest = std::variant<WantsConfiguration>;
@@ -87,17 +68,3 @@ template <typename S>
void serialize(S& s, CallbackRequest& payload) {
s.ext(payload, bitsery::ext::StdVariant{[](S&, WantsConfiguration&) {}});
}
/**
* A response to a callback. Tee `T::Reponse` for the correct type to return
* here.
*
* @relates CallbackRrequest
*/
using CallbackResponse = std::variant<Configuration>;
template <typename S>
void serialize(S& s, CallbackResponse& payload) {
s.ext(payload, bitsery::ext::StdVariant{
[](S& s, Configuration& config) { s.object(config); }});
}