chore(organization): state functions are now ordered to lifetime (enter < update < exit)

This commit is contained in:
Sara 2023-11-24 16:22:16 +01:00
parent fa38d1a7ca
commit 0d28097818

View file

@ -11,15 +11,15 @@ struct State {
const State* (*const update)(void* data, float dt);
};
#define DefineState(_StateName, _DataType, enter_fn, exit_fn, update_fn)\
#define DefineState(_StateName, _DataType, enter_fn, update_fn, exit_fn)\
static inline const State* _StateName() {\
TC_FN_TYPECHECK(void, enter_fn, _DataType*);\
TC_FN_TYPECHECK(void, exit_fn, _DataType*);\
TC_FN_TYPECHECK(const State*, update_fn, _DataType*, float);\
TC_FN_TYPECHECK(void, exit_fn, _DataType*);\
static const State instance = {\
.enter = (void(*const)(void*)) enter_fn,\
.exit = (void(*const)(void*)) exit_fn,\
.update = (const State*(*const)(void*, float)) update_fn,\
.exit = (void(*const)(void*)) exit_fn,\
};\
return &instance;\
}