shithub: lua9

ref: 4d255d3f3e8bba62cdf62a4b1202d83f686b05b8
dir: /utils.c/

View raw version
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>

/* push a global definition in the lib on the stack */
void
pushglobal(lua_State *L, const char *name, int value)
{
	lua_pushnumber(L, value);
	lua_setfield(L, -2, name);	
}

void
createmetatable(lua_State *L, const char *name, luaL_Reg *funcs)
{
	luaL_newmetatable(L, name);
	luaL_setfuncs(L, funcs, 0);
	lua_pushliteral (L, "__metatable");
	lua_pushliteral (L, "metatable access forbidden");
	lua_settable (L, -3);
}