cutes/typeclass_helpers.h

16 lines
521 B
C
Raw Normal View History

#ifndef CUTES_TYPECLASS_HELPERS_H
#define CUTES_TYPECLASS_HELPERS_H
2024-01-25 13:08:23 +00:00
#define TC_FN_TYPECHECK(__Return, __Name, ...)\
__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 tc_is_null(SELF) (SELF.data == NULL && SELF.tc == NULL)
#define tc_null(TC) ((TC){.data=NULL, .tc=NULL})
2024-09-10 07:47:14 +00:00
#endif // !CUTES_TYPECLASS_HELPERS_H