From 76e750677841a659556fd20741aec33b922bcfdb Mon Sep 17 00:00:00 2001 From: ame Date: Mon, 5 Feb 2024 16:03:56 -0600 Subject: cleaning and fixes --- src/lua.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/lua.h') diff --git a/src/lua.h b/src/lua.h index a4933ff..7145098 100644 --- a/src/lua.h +++ b/src/lua.h @@ -4,6 +4,23 @@ void i_dcopy(lua_State* src, lua_State* dest, void*); +//generic macro that takes other macros (see below) +#define _tset_b(L, Tidx, K, V, F)\ + lua_pushvalue(L, Tidx);\ + lua_pushstring(L, K);\ + F(L, V);\ + lua_settable(L, Tidx); + +//some macros to make batch adding easier (may switch to arrays for this later) +#define luaI_tseti(L, Tidx, K, V)\ + _tset_b(L, Tidx, K, V, lua_pushinteger) +#define luaI_tsets(L, Tidx, K, V)\ + _tset_b(L, Tidx, K, V, lua_pushstring) +#define luaI_tsetv(L, Tidx, K, V)\ + _tset_b(L, Tidx, K, V, lua_pushvalue) +#define luaI_tsetcf(L, Tidx, K, V)\ + _tset_b(L, Tidx, K, V, lua_pushcfunction) + #if LUA_VERSION_NUM == 504 #define lreg(N, FN)\ lua_pushstring(L, N);\ -- cgit v1.2.3