e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define lua_setfield(L, i, k) (lua_pushstring(L, k), lua_settable(L, i))
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define lua_getref(L, ref) lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define luaL_unref(L, ref) luaL_unref(L, LUA_REGISTRYINDEX, ref);
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi (luaL_newmetatable(L, tn) ? (lua_pushstring(L, tn), lua_setfield(L, -2, "__name"), 1) : 0)
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define luaL_newlibtable(L, l) (lua_createtable(L, 0, sizeof(l)/sizeof(*(l))-1))
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define luaL_newlib(L, l) (luaL_newlibtable(L, l), luaL_register(L, NULL, l))
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define lua_load(L, r, s, fn, m) lua_load(L, r, s, fn)
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomivoid luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomivoid luaL_setmetatable (lua_State *L, const char *tname);
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi/* consistency helpers */
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define lua_isstring(L, n) (lua_isstring(L, n) == 1)
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define lua_isnumber(L, n) (lua_isnumber(L, n) == 1)
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define lua_toboolean(L, n) (lua_toboolean(L, n) == 1)
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define DLUA_TABLE_STRING(n, s) { .name = n, .type = DLUA_TABLE_VALUE_STRING, .v.s = s }
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define DLUA_TABLE_INTEGER(n, i) { .name = n, .type = DLUA_TABLE_VALUE_INTEGER, .v.i = i }
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define DLUA_TABLE_ENUM(n) { .name = #n, .type = DLUA_TABLE_VALUE_INTEGER, .v.i = n }
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define DLUA_TABLE_DOUBLE(n, d) { .name = n, .type = DLUA_TABLE_VALUE_DOUBLE, .v.d = d }
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define DLUA_TABLE_BOOLEAN(n, b) { .name = n, .type = DLUA_TABLE_VALUE_BOOLEAN, .v.b = b }
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi#define DLUA_TABLE_NULL(n, s) { .name = n, .type = DLUA_TABLE_VALUE_NULL }
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi const char *s;
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi/* Get dlua_script from lua_State */
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomistruct dlua_script *dlua_script_from_state(lua_State *L);
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi/* register 'dovecot' global */
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomivoid dlua_dovecot_register(struct dlua_script *script);
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi/* push 'dovecot' global on top of stack */
e88e76e782853e826d00524ee1133e64fb69b3d9Aki Tuomi/* assign values to table on idx */