From 172d1ee10e07ad67db2da98275c2333646d77ea0 Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 12 Sep 2024 23:33:30 +0200 Subject: [PATCH] chore: improved mirror macro isolation --- mirror.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mirror.h b/mirror.h index a9ac4cd..569aa71 100644 --- a/mirror.h +++ b/mirror.h @@ -56,17 +56,17 @@ extern void* mirror_get_function(void* data, IMirror const* tc, const char* type // example: // TC_CAST(physics_entity, BehaviourEntity) #define TC_CAST(From_, To_)\ -MIRROR_GET_WRAP_FUNC(From_.data, From_.mirror, To_)(From_.data) +(MIRROR_GET_WRAP_FUNC(From_.data, From_.mirror, To_)(From_.data)) #define TC_MIRRORS(From_, To_)\ -MIRROR_GET_WRAP_FUNC(From_.data, From_.mirror, To_) != NULL +(MIRROR_GET_WRAP_FUNC(From_.data, From_.mirror, To_) != NULL) -#define MIRROR_TRY_WRAP(Into_, Mirror_, Typeclass_){\ +#define MIRROR_TRY_WRAP(Into_, Mirror_, Typeclass_)do{\ MirroredTypeclassWrapFunc fn_ = mirror_get_typeclass(Mirror_, #Typeclass_);\ if(fn_ != NULL) {\ - Into_ = (TypeClass_)fn(Mirror_->data);\ + Into_ = (TypeClass_)fn_(Mirror_->data);\ }\ -} +} while(0) #define impl_Mirror_for(T, get_typestring_f, get_typeid_f, get_typeclasses_f)\ Mirror T##_as_Mirror(T* x) {\