mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-14 12:30:00 +02:00
Split src/common/* into headers and definitions
This commit is contained in:
+11
-33
@@ -24,15 +24,15 @@
|
||||
#include <bitsery/traits/vector.h>
|
||||
#include <vestige/aeffect.h>
|
||||
|
||||
#ifdef __WINE__
|
||||
#include "../wine-host/boost-fix.h"
|
||||
#endif
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/local/stream_protocol.hpp>
|
||||
#include <cinttypes>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
|
||||
#ifdef __WINE__
|
||||
#include "../wine-host/boost-fix.h"
|
||||
#endif
|
||||
#include <boost/asio/local/stream_protocol.hpp>
|
||||
|
||||
// These are for the serialization done by bitsery
|
||||
|
||||
/**
|
||||
@@ -305,34 +305,12 @@ inline T read_object(Socket& socket) {
|
||||
*
|
||||
* @relates passthrough_event
|
||||
*/
|
||||
inline intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
|
||||
int32_t opcode,
|
||||
int32_t index,
|
||||
intptr_t value,
|
||||
void* data,
|
||||
float option) {
|
||||
auto payload =
|
||||
data == nullptr
|
||||
? std::nullopt
|
||||
: std::make_optional(std::string(static_cast<char*>(data)));
|
||||
|
||||
const Event event{opcode, index, value, option, payload};
|
||||
write_object(socket, event);
|
||||
|
||||
const auto response = read_object<EventResult>(socket);
|
||||
if (response.data.has_value()) {
|
||||
char* char_data = static_cast<char*>(data);
|
||||
|
||||
// For correctness we will copy the entire buffer and add a terminating
|
||||
// null byte ourselves. In practice `response.data` will only ever
|
||||
// contain C-style strings, but this would work with any other data
|
||||
// format that can contain null bytes.
|
||||
std::copy(response.data->begin(), response.data->end(), char_data);
|
||||
char_data[response.data->size()] = 0;
|
||||
}
|
||||
|
||||
return response.return_value;
|
||||
}
|
||||
intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
|
||||
int32_t opcode,
|
||||
int32_t index,
|
||||
intptr_t value,
|
||||
void* data,
|
||||
float option);
|
||||
|
||||
/**
|
||||
* Receive an event from a socket and pass it through to some callback function.
|
||||
|
||||
Reference in New Issue
Block a user