From 92f0d953572f38e03e0da273c7b034ed38c56c4f Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 7 May 2020 17:21:38 +0200 Subject: [PATCH] Rename EventResponsePayload to be clearer --- src/common/events.h | 24 +++++++++++------------- src/common/logging.cpp | 2 +- src/common/logging.h | 2 +- src/common/serialization.h | 27 +++++++++++++-------------- 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/common/events.h b/src/common/events.h index 9189ff06..b70598b8 100644 --- a/src/common/events.h +++ b/src/common/events.h @@ -282,8 +282,8 @@ auto passthrough_event(AEffect* plugin, F callback) { // Only write back data when needed, this depends on the event payload // type auto write_payload_fn = overload{ - [&](auto) -> EventResposnePayload { return nullptr; }, - [&](const AEffect& updated_plugin) -> EventResposnePayload { + [&](auto) -> EventResultPayload { return nullptr; }, + [&](const AEffect& updated_plugin) -> EventResultPayload { // This is a bit of a special case! Instead of writing some // return value, we will update values on the native VST // plugin's `AEffect` object. This is triggered by the @@ -308,7 +308,7 @@ auto passthrough_event(AEffect* plugin, F callback) { return nullptr; }, - [&](WantsChunkBuffer&) -> EventResposnePayload { + [&](WantsChunkBuffer&) -> EventResultPayload { // In this case the plugin will have written its data stored in // an array to which a pointer is stored in `data`, with the // return value from the event determines how much data the @@ -317,21 +317,19 @@ auto passthrough_event(AEffect* plugin, F callback) { return std::vector(chunk_data, chunk_data + return_value); }, - [&](VstIOProperties& props) -> EventResposnePayload { - return props; - }, - [&](VstMidiKeyName& key_name) -> EventResposnePayload { + [&](VstIOProperties& props) -> EventResultPayload { return props; }, + [&](VstMidiKeyName& key_name) -> EventResultPayload { return key_name; }, - [&](VstParameterProperties& props) -> EventResposnePayload { + [&](VstParameterProperties& props) -> EventResultPayload { return props; }, - [&](WantsVstRect&) -> EventResposnePayload { + [&](WantsVstRect&) -> EventResultPayload { // The plugin has written a pointer to a VstRect struct into the // data poitner return **static_cast(data); }, - [&](WantsVstTimeInfo&) -> EventResposnePayload { + [&](WantsVstTimeInfo&) -> EventResultPayload { // Not sure why the VST API has twenty different ways of // returning structs, but in this case the value returned from // the callback function is actually a pointer to a @@ -345,7 +343,7 @@ auto passthrough_event(AEffect* plugin, F callback) { return *time_info; } }, - [&](WantsString&) -> EventResposnePayload { + [&](WantsString&) -> EventResultPayload { return std::string(static_cast(data)); }}; @@ -355,9 +353,9 @@ auto passthrough_event(AEffect* plugin, F callback) { // `effGetSpeakerArrangement` expects the plugin to write its own data // to this value. Hence why we need to encode the response here // separately. - const EventResposnePayload response_data = + const EventResultPayload response_data = std::visit(write_payload_fn, event.payload); - std::optional value_response_data = std::nullopt; + std::optional value_response_data = std::nullopt; if (event.value_payload.has_value()) { value_response_data = std::visit(write_payload_fn, event.value_payload.value()); diff --git a/src/common/logging.cpp b/src/common/logging.cpp index 85dac04f..671e61aa 100644 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -210,7 +210,7 @@ void Logger::log_event(bool is_dispatch, void Logger::log_event_response(bool is_dispatch, int opcode, intptr_t return_value, - const EventResposnePayload& payload) { + const EventResultPayload& payload) { if (BOOST_UNLIKELY(verbosity >= Verbosity::most_events)) { if (should_filter_event(is_dispatch, opcode)) { return; diff --git a/src/common/logging.h b/src/common/logging.h index 803d5910..d0403d61 100644 --- a/src/common/logging.h +++ b/src/common/logging.h @@ -108,7 +108,7 @@ class Logger { void log_event_response(bool is_dispatch, int opcode, intptr_t return_value, - const EventResposnePayload& payload); + const EventResultPayload& payload); private: /** diff --git a/src/common/serialization.h b/src/common/serialization.h index 99d23703..f103a5be 100644 --- a/src/common/serialization.h +++ b/src/common/serialization.h @@ -422,19 +422,19 @@ struct Event { * `audioMasterIOChanged`. * - An X11 window pointer for the editor window. */ -using EventResposnePayload = std::variant, - AEffect, - DynamicSpeakerArrangement, - VstIOProperties, - VstMidiKeyName, - VstParameterProperties, - VstRect, - VstTimeInfo>; +using EventResultPayload = std::variant, + AEffect, + DynamicSpeakerArrangement, + VstIOProperties, + VstMidiKeyName, + VstParameterProperties, + VstRect, + VstTimeInfo>; template -void serialize(S& s, EventResposnePayload& payload) { +void serialize(S& s, EventResultPayload& payload) { s.ext(payload, bitsery::ext::StdVariant{ [](S&, std::nullptr_t&) {}, @@ -468,14 +468,13 @@ struct EventResult { * into the void pointer, but sometimes an event response should forward * some kind of special struct. */ - // TODO: Fix typo and rename to `EventResultPayload` for consistency - EventResposnePayload payload; + EventResultPayload payload; /** * The same as the above value, but for returning values written to the * `intptr_t` value parameter. This is only used during * `effGetSpeakerArrangement`. */ - std::optional value_payload; + std::optional value_payload; template void serialize(S& s) {