/* Copyright (c) 2017-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "dlua-script-private.h"
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502
void luaL_setmetatable (lua_State *L, const char *tname) {
luaL_checkstack(L, 1, "not enough stack slots");
luaL_getmetatable(L, tname);
lua_setmetatable(L, -2);
}
void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
luaL_checkstack(L, nup+1, "too many upvalues");
for (; l->name != NULL; l++) {
int i;
lua_pushstring(L, l->name);
for (i = 0; i < nup; i++)
lua_pushvalue(L, -(nup+1));
lua_pushcclosure(L, l->func, nup);
lua_settable(L, -(nup + 3));
}
lua_pop(L, nup);
}
#endif