diff options
author | sanine <sanine.not@pm.me> | 2023-03-10 02:05:18 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-03-10 02:05:18 -0600 |
commit | 51c7235d4e0a2df109dd5050328a0ad4a1878ae4 (patch) | |
tree | 201b065e93bf6a35d2bab0e49bcd32f7a971da94 /src/glfw/setup.c | |
parent | 5bb783912ac384156b8abbe6e83a5a61da73881d (diff) |
refactor: move glfw functions into separate table
Diffstat (limited to 'src/glfw/setup.c')
-rw-r--r-- | src/glfw/setup.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/glfw/setup.c b/src/glfw/setup.c new file mode 100644 index 0000000..0abab35 --- /dev/null +++ b/src/glfw/setup.c @@ -0,0 +1,33 @@ +#include <lua.h> +#include <lauxlib.h> +#include "util/util.h" +#include "setup.h" + + +#define X(str, mt) const char *glfw_ ## mt ## _tname = str; +H_GLFW_METATABLES +#undef X + + +void setup_glfw(lua_State *L, int honey_tbl) +{ + /* create metatables */ + #define X(str, mt) luaL_newmetatable(L, glfw_ ## mt ## _tname); lua_pop(L, 1); + H_GLFW_METATABLES + #undef X + + struct honey_tbl_t tbl[] = { + #define X(name, val) H_INT(name, val), + H_GLFW_ENUM + #undef X + + #define X(name, func) H_FUNC(name, func), + H_GLFW_FUNCTIONS + #undef X + + H_END + }; + + create_table(L, tbl); + lua_setfield(L, honey_tbl, "glfw"); +} |