/// <summary>[-0, +0, -] Returns whether the currently executing code was called by Lua.</summary> public static bool infunction(lua.State L) { // this function should resolve to the same thing as "L->ci != L->base_ci" in internal lua code var ar = new lua.Debug(); return(lua.getstack(L, 0, ref ar)); // returns unsuccessful if there is no stack }
/// <summary>[-0, +0, m] luaL.where clone that returns a string rather than pushing to the stack.</summary> public static string where (lua.State L, int level) { var ar = new lua.Debug(); if (lua.getstack(L, level, ref ar)) // check function at level { lua.getinfo(L, "Sl", ref ar); // get info about it if (ar.currentline > 0) // is there info? { return(string.Format("{0}:{1}: ", ar.short_src, ar.currentline.ToString())); // tostring here avoids boxing } } return(""); // else, no information available... }
/// <summary>[-0, +0, -] luaL.where clone that returns a string rather than pushing to the stack.</summary> public static string where (lua.State L, int level) { /* * I checked lua_getinfo implementation and couldn't find any memory allocation for the 'S' or 'l' flags. * My guess is that the luaL_where documentation marked it as m because it uses lua_pushfstring. * - DBN */ var ar = new lua.Debug(); if (lua.getstack(L, level, ref ar)) // check function at level { lua.getinfo(L, "Sl", ref ar); // get info about it if (ar.currentline > 0) // is there info? { return(string.Format("{0}:{1}: ", ar.short_src, ar.currentline.ToString())); // tostring here avoids boxing } } return(""); // else, no information available... }