From a72494b52a790cf9c0e4712ee1f10beea5eafd54 Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 12 Sep 2024 14:02:18 +0200 Subject: [PATCH] feat: added tc_is_null and tc_null to typeclass_helpers.h --- typeclass_helpers.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/typeclass_helpers.h b/typeclass_helpers.h index 7c96b97..832fdbe 100644 --- a/typeclass_helpers.h +++ b/typeclass_helpers.h @@ -7,7 +7,9 @@ __Return (*const __Name##_)(__VA_ARGS__) = __Name; (void)__Name##_ #define decl_typeclass_impl(__Typeclass, __Type)\ extern __Typeclass __Type##_as_##__Typeclass(__Type*); -#define new(T) malloc(sizeof(T)) -#define new_as(T, TC) T##_as_##TC(new(T)) +#define new(T) (malloc(sizeof(T))) +#define new_as(T, TC) (T##_as_##TC(new(T))) +#define tc_is_null(SELF) (SELF.data == NULL && SELF.tc == NULL) +#define tc_null(TC) (TC){.data=NULL, .tc=NULL} #endif // !CUTES_TYPECLASS_HELPERS_H