From 43238419974e599a84f17b5faa8fb52401bdfe90 Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Sun, 8 Sep 2024 13:07:22 +0200 Subject: Refactor config parsing --- src/blocks/group.c | 15 --------------- src/blocks/info.h | 12 ------------ src/blocks/ram.c | 22 ---------------------- src/blocks/scheme.c | 5 +++++ src/blocks/scheme.h | 17 +++++++++++++++++ src/blocks/text.c | 16 ---------------- 6 files changed, 22 insertions(+), 65 deletions(-) delete mode 100644 src/blocks/group.c delete mode 100644 src/blocks/info.h delete mode 100644 src/blocks/ram.c create mode 100644 src/blocks/scheme.c create mode 100644 src/blocks/scheme.h delete mode 100644 src/blocks/text.c (limited to 'src/blocks') diff --git a/src/blocks/group.c b/src/blocks/group.c deleted file mode 100644 index 00afb00..0000000 --- a/src/blocks/group.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "info.h" - -static const config_entry_t block_group_entries[] = { - { "spacing", CONFIG_INT, offsetof(block_t, group.spacing) }, - { 0 }, -}; - -// TODO -const config_block_t block_group_info = { - .type_name = "group", - .type_size = 0, - .base = { 0 }, - .entries = block_group_entries, - .apply = NULL, -}; diff --git a/src/blocks/info.h b/src/blocks/info.h deleted file mode 100644 index 2b42c72..0000000 --- a/src/blocks/info.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef COMET_BLOCKS_H -#define COMET_BLOCKS_H - -#include "../config.h" - -extern const config_block_t block_text_info; - -extern const config_block_t block_group_info; - -extern const config_block_t block_ram_info; - -#endif diff --git a/src/blocks/ram.c b/src/blocks/ram.c deleted file mode 100644 index 2190b20..0000000 --- a/src/blocks/ram.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "info.h" - -static bool block_ram_apply(block_t *block, void *result) -{ - return true; -} - -static const config_entry_t block_ram_entries[] = { - { "text", CONFIG_STRING, offsetof(block_t, text.text) }, - { "text-color", CONFIG_COLOR, offsetof(block_t, text.text_color) }, - { "text-size", CONFIG_INT, offsetof(block_t, text.text_size) }, - { 0 }, -}; - -const config_block_t block_ram_info = { - .type_name = "ram", - .type_size = 0, - .base = { 0 }, - .entries = block_ram_entries, - .apply = block_ram_apply, -}; - diff --git a/src/blocks/scheme.c b/src/blocks/scheme.c new file mode 100644 index 0000000..7a49b90 --- /dev/null +++ b/src/blocks/scheme.c @@ -0,0 +1,5 @@ +#include "scheme.h" + +const block_scheme_t *block_schemes[] = { + NULL, +}; diff --git a/src/blocks/scheme.h b/src/blocks/scheme.h new file mode 100644 index 0000000..b73f181 --- /dev/null +++ b/src/blocks/scheme.h @@ -0,0 +1,17 @@ +#ifndef COMET_SCHEME_H +#define COMET_SCHEME_H + +#include "../block.h" + +typedef struct block_scheme { + const char *name; + block_t block; + size_t size; + const config_entry_t *entries; + + bool (*block_scheme_verify_t)(block_t *block, struct block_scheme *scheme); +} block_scheme_t; + +extern const block_scheme_t *block_schemes[]; + +#endif diff --git a/src/blocks/text.c b/src/blocks/text.c deleted file mode 100644 index 74df3c3..0000000 --- a/src/blocks/text.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "info.h" - -static const config_entry_t block_text_entries[] = { - { "text", CONFIG_STRING, offsetof(block_t, text.text) }, - { "text-color", CONFIG_COLOR, offsetof(block_t, text.text_color) }, - { "text-size", CONFIG_INT, offsetof(block_t, text.text_size) }, - { 0 }, -}; - -const config_block_t block_text_info = { - .type_name = "text", - .type_size = 0, - .base = { 0 }, - .entries = block_text_entries, - .apply = NULL, -}; -- cgit v1.2.3