mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-25 10:52:48 -06:00
Merge pull request #2249 from lioncash/ipc
ipc_helpers: Allow pushing and popping floating-point values
This commit is contained in:
commit
9ad3b01d30
1 changed files with 30 additions and 0 deletions
|
@ -274,6 +274,20 @@ inline void ResponseBuilder::Push(u64 value) {
|
||||||
Push(static_cast<u32>(value >> 32));
|
Push(static_cast<u32>(value >> 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline void ResponseBuilder::Push(float value) {
|
||||||
|
u32 integral;
|
||||||
|
std::memcpy(&integral, &value, sizeof(u32));
|
||||||
|
Push(integral);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline void ResponseBuilder::Push(double value) {
|
||||||
|
u64 integral;
|
||||||
|
std::memcpy(&integral, &value, sizeof(u64));
|
||||||
|
Push(integral);
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void ResponseBuilder::Push(bool value) {
|
inline void ResponseBuilder::Push(bool value) {
|
||||||
Push(static_cast<u8>(value));
|
Push(static_cast<u8>(value));
|
||||||
|
@ -415,6 +429,22 @@ inline s64 RequestParser::Pop() {
|
||||||
return static_cast<s64>(Pop<u64>());
|
return static_cast<s64>(Pop<u64>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline float RequestParser::Pop() {
|
||||||
|
const u32 value = Pop<u32>();
|
||||||
|
float real;
|
||||||
|
std::memcpy(&real, &value, sizeof(real));
|
||||||
|
return real;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline double RequestParser::Pop() {
|
||||||
|
const u64 value = Pop<u64>();
|
||||||
|
float real;
|
||||||
|
std::memcpy(&real, &value, sizeof(real));
|
||||||
|
return real;
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline bool RequestParser::Pop() {
|
inline bool RequestParser::Pop() {
|
||||||
return Pop<u8>() != 0;
|
return Pop<u8>() != 0;
|
||||||
|
|
Loading…
Reference in a new issue