|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
// (find-esfile "lua5.e" "debug.mygetstack")
// (find-esfile "lua5.e" "debug.mygetstack-idea-1")
// http://lua-users.org/lists/lua-l/2019-05/msg00126.html my question
// http://lua-users.org/lists/lua-l/2019-05/msg00137.html Sean's last answer
#define TYPE_LUA_DEBUG "lua_Debug"
luaL_newmetatable(L,TYPE_LUA_DEBUG);
/* add metamethods as you see fit */
static int mygetstack(lua_State *L)
{
lua_Debug *par;
int level = luaL_checkinteger(L,1);
par = lua_newuserdata(L,sizeof(lua_Debug));
if (!lua_getstack(L,level,par))
return 0;
luaL_getmetatable(L,TYPE_LUA_DEBUG);
lua_setmetatable(L,-2);
return 1;
}