From ed3745d29324b1d3f3b334bbeb5e7431d866a906 Mon Sep 17 00:00:00 2001 From: nakst <> Date: Sun, 13 Feb 2022 20:43:35 +0000 Subject: [PATCH] header generator: fix bitsets in odin --- desktop/os.header | 15 --------------- desktop/prefix.h | 16 ++++++++++++++-- util/header_generator.c | 18 ++++++++++++++++-- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/desktop/os.header b/desktop/os.header index aebe5bf..504745f 100644 --- a/desktop/os.header +++ b/desktop/os.header @@ -660,18 +660,6 @@ define ES_COMMAND_REDO (0xF0000007) define ES_COMMAND_SAVE (0xF0000008) define ES_COMMAND_SHOW_IN_FILE_MANAGER (0xF0000009) -// Some common layouts... -define ES_CELL_FILL (ES_CELL_H_FILL | ES_CELL_V_FILL) -define ES_CELL_H_FILL (ES_CELL_H_PUSH | ES_CELL_H_EXPAND | ES_CELL_H_SHRINK) -define ES_CELL_V_FILL (ES_CELL_V_PUSH | ES_CELL_V_EXPAND | ES_CELL_V_SHRINK) -define ES_CELL_CENTER (ES_CELL_H_CENTER | ES_CELL_V_CENTER) -define ES_CELL_PUSH (ES_CELL_H_PUSH | ES_CELL_V_PUSH) -define ES_CELL_EXPAND (ES_CELL_H_EXPAND | ES_CELL_V_EXPAND) -define ES_CELL_CORNER (ES_CELL_H_LEFT | ES_CELL_V_TOP) -define ES_CELL_SHRINK (ES_CELL_H_SHRINK | ES_CELL_V_SHRINK) -define ES_CELL_H_CENTER (ES_CELL_H_LEFT | ES_CELL_H_RIGHT) -define ES_CELL_V_CENTER (ES_CELL_V_TOP | ES_CELL_V_BOTTOM) - // Mask bits for EsThemeMetrics: bitset EsThemeMetricsMask ES_THEME_METRICS_ uint64_t none { INSETS @@ -701,8 +689,6 @@ bitset EsThemeMetricsMask ES_THEME_METRICS_ uint64_t none { TEXT_FIGURES }; -define ES_THEME_METRICS_GAP_ALL (ES_THEME_METRICS_GAP_MAJOR | ES_THEME_METRICS_GAP_MINOR | ES_THEME_METRICS_GAP_WRAP) - define ES_WINDOW_MOVE_MAXIMIZED (1 << 0) define ES_WINDOW_MOVE_ADJUST_TO_FIT_SCREEN (1 << 1) define ES_WINDOW_MOVE_HIDDEN (1 << 2) @@ -842,7 +828,6 @@ bitset EsClipboardDataFlags ES_CLIPBOARD_ADD_ uint32_t none { LAZY_CUT }; -define ES_SCROLL_WHEEL_NOTCH (0x100) define ES_SCROLL_WHEEL_NOTCH (0x100) // Scroll view modes. diff --git a/desktop/prefix.h b/desktop/prefix.h index bc6e4fd..662adcf 100644 --- a/desktop/prefix.h +++ b/desktop/prefix.h @@ -145,9 +145,21 @@ ES_EXTERN_C __attribute__((noreturn)) void _EsCRTlongjmp(EsCRTjmp_buf *env, int #define EsCommandSetEnabled(command, enabled) EsCommandSetDisabled(command, !(enabled)) #define EsClipboardHasText(clipboard) EsClipboardHasFormat(clipboard, ES_CLIPBOARD_FORMAT_TEXT) -#define EsLiteral(x) (char *) x, EsCStringLength((char *) x) +#define ES_THEME_METRICS_GAP_ALL (ES_THEME_METRICS_GAP_MAJOR | ES_THEME_METRICS_GAP_MINOR | ES_THEME_METRICS_GAP_WRAP) -#define ES_STYLE_CAST(x) ((EsStyle *) (uintptr_t) (x)) +// Some common layouts... +#define ES_CELL_FILL (ES_CELL_H_FILL | ES_CELL_V_FILL) +#define ES_CELL_H_FILL (ES_CELL_H_PUSH | ES_CELL_H_EXPAND | ES_CELL_H_SHRINK) +#define ES_CELL_V_FILL (ES_CELL_V_PUSH | ES_CELL_V_EXPAND | ES_CELL_V_SHRINK) +#define ES_CELL_CENTER (ES_CELL_H_CENTER | ES_CELL_V_CENTER) +#define ES_CELL_PUSH (ES_CELL_H_PUSH | ES_CELL_V_PUSH) +#define ES_CELL_EXPAND (ES_CELL_H_EXPAND | ES_CELL_V_EXPAND) +#define ES_CELL_CORNER (ES_CELL_H_LEFT | ES_CELL_V_TOP) +#define ES_CELL_SHRINK (ES_CELL_H_SHRINK | ES_CELL_V_SHRINK) +#define ES_CELL_H_CENTER (ES_CELL_H_LEFT | ES_CELL_H_RIGHT) +#define ES_CELL_V_CENTER (ES_CELL_V_TOP | ES_CELL_V_BOTTOM) + +#define EsLiteral(x) (char *) x, EsCStringLength((char *) x) #ifndef ES_INSTANCE_TYPE #define ES_INSTANCE_TYPE struct EsInstance diff --git a/util/header_generator.c b/util/header_generator.c index 99ca846..b8da60a 100644 --- a/util/header_generator.c +++ b/util/header_generator.c @@ -925,10 +925,10 @@ void OutputOdinFunction(Entry *entry, Entry *root) { if (0 == strcmp(initialValue, "NULL")) { initialValue = "nil"; - } else if (0 == strcmp(initialValue, "DEFAULT_PROPERTIES")) { - initialValue = "{}"; } else if (0 == strcmp(initialValue, "BLANK_STRING")) { initialValue = "\"\""; + } else if (0 == strcmp(initialValue, "FLAGS_DEFAULT")) { + initialValue = "{}"; } bool needLeadingDot = false; @@ -941,6 +941,20 @@ void OutputOdinFunction(Entry *entry, Entry *root) { break; } } + + for (int i = 0; i < arrlen(root->children); i++) { + Entry *entry = root->children + i; + + if (entry->type == ENTRY_BITSET && 0 == strcmp(variable->variable.type, entry->name)) { + needLeadingDot = true; + + if (0 == memcmp(initialValue, entry->bitset.definePrefix + 3, strlen(entry->bitset.definePrefix) - 3)) { + initialValue += strlen(entry->bitset.definePrefix) - 3; + } + + break; + } + } FilePrintFormat(output, " = %c%s", needLeadingDot ? '.' : ' ', initialValue); }