fix: Mirror now supports TC_CAST

i hate this
This commit is contained in:
Sara 2024-01-25 00:00:06 +01:00
parent 8c5aa78195
commit 368332b2b3

View file

@ -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