mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-25 21:08:27 -05:00
Auto generate SWA.h, add offsetof/sizeof asserts.
This commit is contained in:
@@ -4,13 +4,33 @@
|
||||
#include <cpu/guest_stack_var.h>
|
||||
#include <kernel/function.h>
|
||||
|
||||
#define SWA__CONCAT2(x, y) x##y
|
||||
#define SWA_CONCAT2(x, y) _CONCAT(x, y)
|
||||
#define SWA_CONCAT2(x, y) x##y
|
||||
#define SWA_CONCAT(x, y) SWA_CONCAT2(x, y)
|
||||
|
||||
#define SWA_INSERT_PADDING(length) \
|
||||
uint8_t SWA_CONCAT2(pad, __LINE__)[length]
|
||||
uint8_t SWA_CONCAT(pad, __LINE__)[length]
|
||||
|
||||
#define SWA_ASSERT_OFFSETOF(type, field, offset) \
|
||||
static inline swa_assert_offsetof<BB_OFFSETOF(type, field), offset> SWA_CONCAT(_, __COUNTER__)
|
||||
|
||||
#define SWA_ASSERT_SIZEOF(type, size) \
|
||||
static inline swa_assert_sizeof<sizeof type, size> SWA_CONCAT(_, __COUNTER__)
|
||||
|
||||
#define SWA_VIRTUAL_FUNCTION(returnType, virtualIndex, ...) \
|
||||
GuestToHostFunction<returnType>(*(be<uint32_t>*)(g_memory.Translate(*(be<uint32_t>*)(this) + (4 * virtualIndex))), __VA_ARGS__)
|
||||
|
||||
struct swa_null_ctor {};
|
||||
struct swa_null_ctor
|
||||
{
|
||||
};
|
||||
|
||||
template<int TActual, int TExpected>
|
||||
struct swa_assert_offsetof
|
||||
{
|
||||
static_assert(TActual == TExpected, "offsetof assertion failed");
|
||||
};
|
||||
|
||||
template<int TActual, int TExpected>
|
||||
struct swa_assert_sizeof
|
||||
{
|
||||
static_assert(TActual == TExpected, "sizeof assertion failed");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user