diff --git a/core/src/mirror.h b/core/src/mirror.h index b9fce0d..5778693 100644 --- a/core/src/mirror.h +++ b/core/src/mirror.h @@ -5,7 +5,7 @@ #include "stdint.h" #include "string.h" #include "list.h" -#include "strutil.h" +#include "strutil.h" // included because the impl macros require strhash typedef uintptr_t typeid; @@ -17,7 +17,11 @@ typedef struct { typedef struct { void* data; - IMirror const* tc; + union { + IMirror const* tc; + // this is cursed, but it allows the TC_CAST macro to work + IMirror const* mirror; + }; } Mirror; typedef struct { @@ -40,7 +44,7 @@ static inline int mirror_eq(const Mirror* lhs, const Mirror* rhs) { extern const void* mirror_get_typeclass(void* data, IMirror const* tc, const char* typeclass); // get the wrapper function for a given typeclass name // example: -// +// mirror_get_function(physics_entity.data, physics_entity.mirror, "BehaviourEntity") extern void* mirror_get_function(void* data, IMirror const* tc, const char* typeclass_name); // macro reexport of mirror_get_function which will cast the function so it can be called immediately