aboutsummaryrefslogtreecommitdiff
path: root/src/lua.h
diff options
context:
space:
mode:
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);\