From 435c43da3fbc9d65879594ac71417352946a026c Mon Sep 17 00:00:00 2001 From: Milo Turner Date: Sat, 22 Feb 2020 16:20:52 -0500 Subject: [PATCH] [async] ax__msg_name() --- src/concurrent/msg.enums | 4 ++++ src/concurrent/msg.h | 28 ++++++++++++++++++++++++++++ src/util.h | 5 ++++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/concurrent/msg.enums diff --git a/src/concurrent/msg.enums b/src/concurrent/msg.enums new file mode 100644 index 0000000..9b4c139 --- /dev/null +++ b/src/concurrent/msg.enums @@ -0,0 +1,4 @@ +[msg (ax_msg_shutdown_TAG "shutdown") + (ax_msg_load_font_TAG "load_font") + (ax_msg_theme_loaded_TAG "theme_loaded") + (ax_msg_make_window_TAG "make_window")] diff --git a/src/concurrent/msg.h b/src/concurrent/msg.h index ca5ff7d..a950090 100644 --- a/src/concurrent/msg.h +++ b/src/concurrent/msg.h @@ -1,11 +1,16 @@ #pragma once +#include + struct msgq; +struct ax_window; +struct ax_theme; enum { ax_msg_shutdown_TAG, ax_msg_load_font_TAG, ax_msg_theme_loaded_TAG, + ax_msg_make_window_TAG, }; struct ax_msg_shutdown { @@ -19,3 +24,26 @@ struct ax_msg_load_font { struct ax_msg_theme_loaded { struct ax_theme* theme; }; + +struct ax_msg_make_window { + struct ax_window* dst_win; + const char* title; + uint64_t width; + uint64_t height; + int flags; +}; + +static inline const char* ax__msg_name(int val) +{ +#ifdef IMPOSSIBLE +#undef IMPOSSIBLE +#endif + +#define IMPOSSIBLE(_) return "???"; + const char* str; +#include "../../_build/msg.printer.inc" + return str; + +#undef IMPOSSIBLE +#define IMPOSSIBLE(x) IMPOSSIBLE_(x) +} diff --git a/src/util.h b/src/util.h index 18cd36f..412fc63 100644 --- a/src/util.h +++ b/src/util.h @@ -18,5 +18,8 @@ #define UNIMPLEMENTED() \ ASSERT(0, "not implemented") -#define IMPOSSIBLE(what) \ +#define IMPOSSIBLE_(what) \ ASSERT(0, "unreachable: " what) + +// hard to explain why this is necessary ... +#define IMPOSSIBLE(x) IMPOSSIBLE_(x)