From c194e33e98492bbd0384f2a6b9a533bcfb57701d Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Wed, 8 Mar 2023 16:41:27 -0400 Subject: macros: Add `as()` --- context.h | 6 ++++-- include/pso/TPlySmth.h | 6 +++--- include/pso/macros.h | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/context.h b/context.h index 39fa7f3..def67af 100644 --- a/context.h +++ b/context.h @@ -142,6 +142,8 @@ typedef long ptrdiff_t; PRIVATE_MEMBER_GETTER_FUNC(ret_type, name, __VA_ARGS__); \ PRIVATE_MEMBER_SETTER_FUNC(ret_type, name, __VA_ARGS__) +#define as(type, var) reinterpret_cast(var) + // pso/TMainTask.h #define X_OR_Y_CHILD(flags, old_flags, one_prefix, zero_prefix, suffix) \ if (flags != old_flags) { \ @@ -837,8 +839,8 @@ public: TPlySmth() {}; void bswap() { - bswap_32(reinterpret_cast(&m_smth)); - bswap_32(reinterpret_cast(&m_smth1)); + bswap_32(as(u32 *, &m_smth)); + bswap_32(as(u32 *, &m_smth1)); }; public: u8 m_smth[4]; diff --git a/include/pso/TPlySmth.h b/include/pso/TPlySmth.h index 2530c7b..e510047 100644 --- a/include/pso/TPlySmth.h +++ b/include/pso/TPlySmth.h @@ -2,8 +2,8 @@ #define TPLYSMTH_H #include +#include #include -#include #include class TPlySmth { @@ -11,8 +11,8 @@ public: TPlySmth() {}; void bswap() { - bswap_32(reinterpret_cast(&m_smth)); - bswap_32(reinterpret_cast(&m_smth1)); + bswap_32(as(u32 *, &m_smth)); + bswap_32(as(u32 *, &m_smth1)); }; public: u8 m_smth[4]; diff --git a/include/pso/macros.h b/include/pso/macros.h index 291a550..e182c54 100644 --- a/include/pso/macros.h +++ b/include/pso/macros.h @@ -108,4 +108,6 @@ PRIVATE_MEMBER_GETTER_FUNC(ret_type, name, __VA_ARGS__); \ PRIVATE_MEMBER_SETTER_FUNC(ret_type, name, __VA_ARGS__) +#define as(type, var) reinterpret_cast(var) + #endif -- cgit v1.2.3-13-gbd6f