GTK4_GG_hack/automaton.c

79 lines
2.5 KiB
C

#include <gtk-4.0/gtk/gtk.h>
#include <assert.h>
#include "callback.h"
#include "automaton.h"
/******************************************************************************/
/* S T A T E S */
/******************************************************************************/
static int choice_EXEC_EDIT = EXEC;
static int choice_STATE_RULES_DATA = STATE;
/******************************************************************************/
/* T R A N S I T I O N S */
/******************************************************************************/
void debug_printing (int prescribed, int sub_automaton);
void set_EXEC_EDIT (int prescribed) {
if (choice_EXEC_EDIT != prescribed) {
debug_printing (prescribed, 0);
choice_EXEC_EDIT = prescribed;
}
}
void set_STATE_RULES_DATA (int prescribed) {
if (choice_STATE_RULES_DATA != prescribed) {
debug_printing (prescribed, 1);
choice_STATE_RULES_DATA = prescribed;
}
}
/******************************************************************************/
/* G E T T E R S & D E B U G G E R S */
/******************************************************************************/
int get_EXEC_EDIT () {return choice_EXEC_EDIT;}
int get_STATE_RULES_DATA () {return choice_STATE_RULES_DATA;}
char *get_str_EXEC_EDIT (int value) {
switch (value) {
case (EXEC) : return "EXEC";
case (EDIT) : return "EDIT";
default : printf("default in automaton.get_EXEC_EDIT ()\n"); return NULL;
}
}
char *get_str_STATE_RULES_DATA (int value) {
switch (value) {
case (STATE) : return "STATE";
case (RULES) : return "RULES";
case (DATA) : return "DATA";
default : printf("default in automaton.get_STATE_RULES_DATA ()\n"); return NULL;
}
}
void debug_printing (int prescribed, int sub_automaton) {
switch (sub_automaton) {
case (0) : printf("switch > %5s X %5s <> %5s X %5s\n",
get_str_EXEC_EDIT (choice_EXEC_EDIT),
get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA),
get_str_EXEC_EDIT (prescribed),
get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA));
break;
case (1) : printf("switch > %5s X %5s <> %5s X %5s\n",
get_str_EXEC_EDIT (choice_EXEC_EDIT),
get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA),
get_str_EXEC_EDIT (choice_EXEC_EDIT),
get_str_STATE_RULES_DATA (prescribed));
break;
default : printf("default in automaton.debug_printing()\n");
}
}