2024-01-26 21:58:02 +00:00
|
|
|
#ifndef CUTES_DROP_H
|
|
|
|
#define CUTES_DROP_H
|
2024-01-25 13:13:42 +00:00
|
|
|
|
|
|
|
#include "typeclass_helpers.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
void (*const drop)(void* self);
|
|
|
|
} IDrop;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
void* data;
|
|
|
|
IDrop const* tc;
|
|
|
|
} Drop;
|
|
|
|
|
|
|
|
#define impl_Drop_for(T, drop_f)\
|
|
|
|
Drop T##_as_Drop(T* x) {\
|
|
|
|
TC_FN_TYPECHECK(void, drop_f, T*);\
|
|
|
|
static IDrop const tc = {\
|
|
|
|
.drop = (void(*const)(void*)) drop_f,\
|
|
|
|
};\
|
|
|
|
return (Drop){.tc = &tc, .data = x};\
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void default_drop(void*);
|
|
|
|
|
|
|
|
#define impl_default_Drop_for(T)\
|
|
|
|
Drop T##_as_Drop(T* x) {\
|
|
|
|
static IDrop const tc = {\
|
|
|
|
.drop = default_drop,\
|
|
|
|
};\
|
|
|
|
return (Drop){.tc = &tc, .data = x};\
|
|
|
|
}
|
2024-01-26 21:58:02 +00:00
|
|
|
#endif // !CUTES_DROP_H
|