From ccfda51a69b28be7390ee7c171f8721bc4bb3966 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 20 May 2021 14:36:07 +0200 Subject: [PATCH] Clarify the DefaultDataConverter method names --- src/common/communication/vst2.cpp | 14 +++++++------- src/common/communication/vst2.h | 18 +++++++++--------- src/plugin/bridges/vst2.cpp | 23 ++++++++++++----------- src/wine-host/bridges/vst2.cpp | 19 ++++++++++--------- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/common/communication/vst2.cpp b/src/common/communication/vst2.cpp index c544636c..a478094a 100644 --- a/src/common/communication/vst2.cpp +++ b/src/common/communication/vst2.cpp @@ -18,10 +18,10 @@ DefaultDataConverter::~DefaultDataConverter() noexcept {} -EventPayload DefaultDataConverter::read(const int /*opcode*/, - const int /*index*/, - const intptr_t /*value*/, - const void* data) const { +EventPayload DefaultDataConverter::read_data(const int /*opcode*/, + const int /*index*/, + const intptr_t /*value*/, + const void* data) const { if (!data) { return nullptr; } @@ -44,9 +44,9 @@ std::optional DefaultDataConverter::read_value( return std::nullopt; } -void DefaultDataConverter::write(const int /*opcode*/, - void* data, - const EventResult& response) const { +void DefaultDataConverter::write_data(const int /*opcode*/, + void* data, + const EventResult& response) const { // The default behavior is to handle this as a null terminated C-style // string std::visit(overload{[&](const auto&) {}, diff --git a/src/common/communication/vst2.h b/src/common/communication/vst2.h index 03796e73..cad92732 100644 --- a/src/common/communication/vst2.h +++ b/src/common/communication/vst2.h @@ -37,10 +37,10 @@ class DefaultDataConverter { * Read data from the `data` void pointer into a an `EventPayload` value * that can be serialized and conveys the meaning of the event. */ - virtual EventPayload read(const int opcode, - const int index, - const intptr_t value, - const void* data) const; + virtual EventPayload read_data(const int opcode, + const int index, + const intptr_t value, + const void* data) const; /** * Read data from the `value` pointer into a an `EventPayload` value that @@ -53,9 +53,9 @@ class DefaultDataConverter { /** * Write the response back to the `data` pointer. */ - virtual void write(const int opcode, - void* data, - const EventResult& response) const; + virtual void write_data(const int opcode, + void* data, + const EventResult& response) const; /** * Write the response back to the `value` pointer. This is only used during @@ -165,7 +165,7 @@ class Vst2EventHandler : public AdHocSocketHandler { // are converted to C-style data structures in `passthrough_event()` so // they can be passed to a plugin or callback function. const EventPayload payload = - data_converter.read(opcode, index, value, data); + data_converter.read_data(opcode, index, value, data); const std::optional value_payload = data_converter.read_value(opcode, value); @@ -199,7 +199,7 @@ class Vst2EventHandler : public AdHocSocketHandler { response.value_payload); } - data_converter.write(opcode, data, response); + data_converter.write_data(opcode, data, response); data_converter.write_value(opcode, value, response); return data_converter.return_value(opcode, response.return_value); diff --git a/src/plugin/bridges/vst2.cpp b/src/plugin/bridges/vst2.cpp index fea0ee1b..dc604ff5 100644 --- a/src/plugin/bridges/vst2.cpp +++ b/src/plugin/bridges/vst2.cpp @@ -190,10 +190,10 @@ class DispatchDataConverter : public DefaultDataConverter { VstRect& editor_rectangle) noexcept : chunk(chunk_data), plugin(plugin), rect(editor_rectangle) {} - EventPayload read(const int opcode, - const int index, - const intptr_t value, - const void* data) const override { + EventPayload read_data(const int opcode, + const int index, + const intptr_t value, + const void* data) const override { // There are some events that need specific structs that we can't simply // serialize as a string because they might contain null bytes switch (opcode) { @@ -243,8 +243,8 @@ class DispatchDataConverter : public DefaultDataConverter { return static_cast( reinterpret_cast(data)); } else { - return DefaultDataConverter::read(opcode, index, value, - data); + return DefaultDataConverter::read_data(opcode, index, value, + data); } break; case effGetParameterProperties: @@ -301,7 +301,8 @@ class DispatchDataConverter : public DefaultDataConverter { case effStopProcess: return nullptr; default: - return DefaultDataConverter::read(opcode, index, value, data); + return DefaultDataConverter::read_data(opcode, index, value, + data); break; } } @@ -327,9 +328,9 @@ class DispatchDataConverter : public DefaultDataConverter { } } - void write(const int opcode, - void* data, - const EventResult& response) const override { + void write_data(const int opcode, + void* data, + const EventResult& response) const override { switch (opcode) { case effOpen: { // Update our `AEffect` object one last time for improperly @@ -405,7 +406,7 @@ class DispatchDataConverter : public DefaultDataConverter { reinterpret_cast(output)); } break; default: - DefaultDataConverter::write(opcode, data, response); + DefaultDataConverter::write_data(opcode, data, response); break; } } diff --git a/src/wine-host/bridges/vst2.cpp b/src/wine-host/bridges/vst2.cpp index f76cef9c..b3ef83d2 100644 --- a/src/wine-host/bridges/vst2.cpp +++ b/src/wine-host/bridges/vst2.cpp @@ -492,10 +492,10 @@ class HostCallbackDataConverter : public DefaultDataConverter { VstTimeInfo& last_time_info) noexcept : plugin(plugin), last_time_info(last_time_info) {} - EventPayload read(const int opcode, - const int index, - const intptr_t value, - const void* data) const override { + EventPayload read_data(const int opcode, + const int index, + const intptr_t value, + const void* data) const override { switch (opcode) { case audioMasterGetTime: return WantsVstTimeInfo{}; @@ -547,7 +547,8 @@ class HostCallbackDataConverter : public DefaultDataConverter { return nullptr; break; default: - return DefaultDataConverter::read(opcode, index, value, data); + return DefaultDataConverter::read_data(opcode, index, value, + data); break; } } @@ -558,9 +559,9 @@ class HostCallbackDataConverter : public DefaultDataConverter { return DefaultDataConverter::read_value(opcode, value); } - void write(const int opcode, - void* data, - const EventResult& response) const override { + void write_data(const int opcode, + void* data, + const EventResult& response) const override { switch (opcode) { case audioMasterGetTime: // If the host returned a valid `VstTimeInfo` object, then we'll @@ -571,7 +572,7 @@ class HostCallbackDataConverter : public DefaultDataConverter { } break; default: - DefaultDataConverter::write(opcode, data, response); + DefaultDataConverter::write_data(opcode, data, response); break; } }