FSM is now even cleaner, as long as you don't look at that CPP macro.

This commit is contained in:
Zed A. Shaw 2024-09-16 08:05:43 -04:00
parent c9425aebf9
commit f632f2d5af
6 changed files with 51 additions and 53 deletions

View file

@ -3,9 +3,9 @@
#include <fmt/core.h>
#ifndef FSM_DEBUG
#define FSM_STATE(C, S, F, E, ...) case C::S: F(E, ##__VA_ARGS__); break
#define FSM_STATE(C, S, E, ...) case C::S: S(E, ##__VA_ARGS__); break
#else
#define FSM_STATE(C, S, F, E, ...) case C::S: fmt::println(">> " #C " " #S ":" #F " event={}, state={}", int(E), int(_state)); F(E, ##__VA_ARGS__); fmt::println("<< " #C " state={}", int(_state)); break
#define FSM_STATE(C, S, E, ...) case C::S: fmt::println(">> " #C " " #S " event={}, state={}", int(E), int(_state)); S(E, ##__VA_ARGS__); fmt::println("<< " #C " state={}", int(_state)); break
#endif
template<typename S, typename E>