aboutsummaryrefslogtreecommitdiff
path: root/src/lua.h
diff options
context:
space:
mode:
authorame <[email protected]>2024-02-05 16:03:56 -0600
committerame <[email protected]>2024-02-05 16:03:56 -0600
commit340f17a474401563de89aa0444f7cdee209b9c35 (patch)
treee4bb24263fade94cbeeaaa81a6ef5e0d352cb461 /src/lua.h
parent056b24c2601c9ac932134c69cb1559905fa2d18b (diff)
cleaning and fixes
Diffstat (limited to 'src/lua.h')
-rw-r--r--src/lua.h17
1 files changed, 17 insertions, 0 deletions
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);\