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

@ -73,7 +73,7 @@ MatchResult Builder::parse_line(const string &line) {
}
}
void Builder::building(BuildEvent ev) {
void Builder::BUILDING(BuildEvent ev) {
// check if there's output
if(build_done) {
int rc = pclose(build_out);
@ -100,7 +100,7 @@ void Builder::building(BuildEvent ev) {
}
}
void Builder::start(BuildEvent ev) {
void Builder::START(BuildEvent ev) {
gui.output(format("Using build command: {}", build_cmd));
fileWatcher = new efsw::FileWatcher();
dbc::check(fileWatcher != nullptr, "Failed to create filewatcher.");
@ -120,7 +120,7 @@ void Builder::start(BuildEvent ev) {
state(BuildState::WAITING);
}
void Builder::waiting(BuildEvent ev) {
void Builder::WAITING(BuildEvent ev) {
if(listener->changes) {
game.event(GameEvent::BUILD_START);
gui.building();
@ -129,7 +129,7 @@ void Builder::waiting(BuildEvent ev) {
}
}
void Builder::forking(BuildEvent ev) {
void Builder::FORKING(BuildEvent ev) {
if(build_fut.valid()) {
std::future_status status = build_fut.wait_for(0ms);
@ -148,7 +148,7 @@ void Builder::forking(BuildEvent ev) {
}
}
void Builder::reading(BuildEvent ev) {
void Builder::READING(BuildEvent ev) {
// BUG: too much copy-pasta so turn this into a class?
if(read_fut.valid()) {
std::future_status status = read_fut.wait_for(0ms);
@ -166,7 +166,7 @@ void Builder::reading(BuildEvent ev) {
}
}
void Builder::done(BuildEvent ev) {
void Builder::DONE(BuildEvent ev) {
if(game.is_dead()) {
gui.you_died();
}
@ -176,7 +176,7 @@ void Builder::done(BuildEvent ev) {
state(BuildState::WAITING);
}
void Builder::exit(BuildEvent ev) {
void Builder::EXIT(BuildEvent ev) {
if(ev == QUIT) {
fileWatcher->removeWatch(wid);
git_libgit2_shutdown();
@ -184,7 +184,7 @@ void Builder::exit(BuildEvent ev) {
}
}
void Builder::error(BuildEvent ev) {
void Builder::ERROR(BuildEvent ev) {
// how to avoid doing this more than once?
if(ev == CRASH) {
if(repo != nullptr) git_repository_free(repo);