From 42b9cf902ce7e83d5b8ef8e930c4aab548a605f7 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 30 Dec 2020 16:38:19 +0100 Subject: [PATCH] Swap read_object arguments to match write_object --- CHANGELOG.md | 2 +- src/common/communication/common.h | 15 ++++++--------- src/common/communication/vst3.h | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66d4564f..38cad5c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] TODO: Remove the mentions of VST3 support not yet being part of the released version from the readme -TODO: Add an updates screenshot with some fancy VST3-only plugins to the readme +TODO: Add an updated screenshot with some fancy VST3-only plugins to the readme ### Added diff --git a/src/common/communication/common.h b/src/common/communication/common.h index ef9a34be..de2595a1 100644 --- a/src/common/communication/common.h +++ b/src/common/communication/common.h @@ -92,10 +92,10 @@ inline void write_object(Socket& socket, const T& object) { * together with `write_object`. This will block until the object is available. * * @param socket The Boost.Asio socket to read from. - * @param buffer The buffer to read into. This is useful for sending audio and - * chunk data since that can vary in size by a lot. * @param object The object to serialize into. There are also overrides that * create a new default initialized `T` + * @param buffer The buffer to read into. This is useful for sending audio and + * chunk data since that can vary in size by a lot. * * @return The deserialized object. * @@ -103,13 +103,10 @@ inline void write_object(Socket& socket, const T& object) { * @throw boost::system::system_error If the socket is closed or gets closed * while reading. * - * TODO: Swap these arguments around so they match `write_object`'s argument - * order - * * @relates write_object */ template -inline T& read_object(Socket& socket, std::vector& buffer, T& object) { +inline T& read_object(Socket& socket, T& object, std::vector& buffer) { // See the note above on the use of `uint64_t` instead of `size_t` std::array message_length; boost::asio::read(socket, boost::asio::buffer(message_length), @@ -146,7 +143,7 @@ inline T& read_object(Socket& socket, std::vector& buffer, T& object) { template inline T read_object(Socket& socket, std::vector& buffer) { T object; - read_object(socket, buffer, object); + read_object(socket, object, buffer); return object; } @@ -160,7 +157,7 @@ inline T read_object(Socket& socket, std::vector& buffer) { template inline T& read_object(Socket& socket, T& object) { std::vector buffer(64); - return read_object(socket, buffer, object); + return read_object(socket, object, buffer); } /** @@ -173,7 +170,7 @@ template inline T read_object(Socket& socket) { T object; std::vector buffer(64); - read_object(socket, buffer, object); + read_object(socket, object, buffer); return object; } diff --git a/src/common/communication/vst3.h b/src/common/communication/vst3.h index e306c333..c5bad2bc 100644 --- a/src/common/communication/vst3.h +++ b/src/common/communication/vst3.h @@ -141,7 +141,7 @@ class Vst3MessageHandler : public AdHocSocketHandler { this->template send( [&](boost::asio::local::stream_protocol::socket& socket) { write_object(socket, Request(object), buffer); - read_object(socket, buffer, response_object); + read_object(socket, response_object, buffer); // FIXME: We have to return something here, and ML was not yet // invented when they came up with C++ so void is not // valid here