#include "lib-lua_priv.h"
static lua_State *L;
+static reg_entry registry[LTK_count];
static const luaL_Reg lualibs[] = {
{"", luaopen_base},
return status;
}
-ssize_t mlua_value(char *buf, ssize_t len,
- const char *table, const char *key)
+const char *mlua_reggets(int tk)
{
- ssize_t res;
+ if (registry[tk].type != REG_STR)
+ return NULL;
+ return registry[tk].s;
+}
- lua_getglobal(L, table);
- lua_pushstring(L, key);
- lua_gettable(L, -2);
- res = m_strcpy(buf, len, lua_tostring(L, -1));
- lua_remove(L, -1);
- lua_remove(L, -1);
+quadopt_t mlua_reggetq(int tk)
+{
+ if (registry[tk].type != REG_QUAD)
+ return -1;
+ return registry[tk].i;
+}
- return res;
+void mlua_regsets(int tk, const char *s)
+{
+ reg_entry_wipe(registry + tk);
+ registry[tk].type = REG_STR;
+ registry[tk].s = m_strdup(s);
}
+void mlua_regsetq(int tk, quadopt_t q)
+{
+ reg_entry_wipe(registry + tk);
+ registry[tk].type = REG_QUAD;
+ registry[tk].i = q;
+}