diff options
author | Linnnus <[email protected]> | 2025-04-11 23:37:41 +0000 |
---|---|---|
committer | Linnnus <[email protected]> | 2025-04-15 00:55:59 +0000 |
commit | 31eacdeefe6099e68dd8596faab8108671e4c6a5 (patch) | |
tree | 989bbfac4f6e77ee96ae293562216802288a8f2f | |
parent | a08a23885d1c80b19680b907357aaf6a0faf6d62 (diff) |
refactor(core): Move SandConfig into own header file
-rw-r--r-- | src/core/config.h | 15 | ||||
-rw-r--r-- | src/core/state.h | 9 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/core/config.h b/src/core/config.h new file mode 100644 index 0000000..389a146 --- /dev/null +++ b/src/core/config.h @@ -0,0 +1,15 @@ +#ifndef SAND_CONFIG_H +#define SAND_CONFIG_H + +// This module defines the configuration type. This is a fully transparent (i.e. +// not opaque) type which the consumer of the core library is supposed to +// assemble themselves. It contains hooks which the State will use for all effects. + +// This handler is used for output from the user-supplied actual program. +typedef void (* SandPrintHandler)(const char *message, size_t length); + +typedef struct { + SandPrintHandler print_handler; +} SandConfig; + +#endif diff --git a/src/core/state.h b/src/core/state.h index 406a79c..85c604b 100644 --- a/src/core/state.h +++ b/src/core/state.h @@ -4,20 +4,15 @@ // This module defines the evaluator state. This is the "world" in Sand. // Multiple evaluator states can coexist as they are totally separate. -#include <stddef.h> - -typedef void (* SandPrintHandler)(const char *message, size_t length); +#include "config.h" -typedef struct { - SandPrintHandler print_handler; -} SandConfig; +#include <stddef.h> // This data structure should be treated as entirely opaque by consuming code. typedef struct { SandConfig config; } SandState; - SandState sand_create_state(SandConfig config); void sand_destroy_state(SandState *); |