[async] ax__msg_name()

This commit is contained in:
Milo Turner 2020-02-22 16:20:52 -05:00
parent 7b2c1f0e07
commit 435c43da3f
3 changed files with 36 additions and 1 deletions

4
src/concurrent/msg.enums Normal file
View File

@ -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")]

View File

@ -1,11 +1,16 @@
#pragma once #pragma once
#include <stdint.h>
struct msgq; struct msgq;
struct ax_window;
struct ax_theme;
enum { enum {
ax_msg_shutdown_TAG, ax_msg_shutdown_TAG,
ax_msg_load_font_TAG, ax_msg_load_font_TAG,
ax_msg_theme_loaded_TAG, ax_msg_theme_loaded_TAG,
ax_msg_make_window_TAG,
}; };
struct ax_msg_shutdown { struct ax_msg_shutdown {
@ -19,3 +24,26 @@ struct ax_msg_load_font {
struct ax_msg_theme_loaded { struct ax_msg_theme_loaded {
struct ax_theme* theme; 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)
}

View File

@ -18,5 +18,8 @@
#define UNIMPLEMENTED() \ #define UNIMPLEMENTED() \
ASSERT(0, "not implemented") ASSERT(0, "not implemented")
#define IMPOSSIBLE(what) \ #define IMPOSSIBLE_(what) \
ASSERT(0, "unreachable: " what) ASSERT(0, "unreachable: " what)
// hard to explain why this is necessary ...
#define IMPOSSIBLE(x) IMPOSSIBLE_(x)