qtlua/qtlua/qtluautils.cpp
/*! Enrichs the message on the stack with a traceback.
  This function must be called with one string argument
  representing an error message for instance.
  It safely augments the string with a stack trace
  starting \a skip levels above the current level.
  This function does not cause an error.
  If something goes wrong during the stack exploration,
  the function silently returns the unchanged error message.
 */
Enrichs the message on the stack with a traceback.
This function must be called with one string argument
representing an error message for instance.
It safely augments the string with a stack trace
starting \a skip levels above the current level.
This function does not cause an error.
If something goes wrong during the stack exploration,
the function silently returns the unchanged error message.
Enrichs the message on the stack with a traceback . This function must be called with one string argument representing an error message for instance . It safely augments the string with a stack trace starting \ a skip levels above the current level . This function does not cause an error . If something goes wrong during the stack exploration the function silently returns the unchanged error message .
int
luaQ_tracebackskip(struct lua_State *L, int skip)
{
  luaQ_getfield(L, LUA_GLOBALSINDEX, "debug");
  luaQ_getfield(L, -1, "traceback");
  lua_remove(L, -2);
  if (! lua_isfunction(L, -1)) 
    {
      lua_pop(L, 1);
    } 
  else 
    {
      lua_pushvalue(L, -2);
      lua_pushinteger(L, skip+1);
      lua_Hook hf = lua_gethook(L);
      int hm = lua_gethookmask(L);
      int hc = lua_gethookcount(L);
      lua_sethook(L, 0, 0, 0);
      if (lua_pcall(L, 2, 1, 0))
        lua_remove(L, -1);
      else
         msg
        lua_remove(L, -2);
      lua_sethook(L, hf, hm, hc);
    }
  return 1;
}
int luaQ_tracebackskip ( struct lua_State * L , int skip ) { luaQ_getfield ( L , LUA_GLOBALSINDEX , " " ) ; luaQ_getfield ( L , -1 , " " ) ; lua_remove ( L , -2 ) ; if ( ! lua_isfunction ( L , -1 ) ) { lua_pop ( L , 1 ) ; } else { lua_pushvalue ( L , -2 ) ; lua_pushinteger ( L , skip + 1 ) ; lua_Hook hf = lua_gethook ( L ) ; int hm = lua_gethookmask ( L ) ; int hc = lua_gethookcount ( L ) ; lua_sethook ( L , 0 , 0 , 0 ) ; if ( lua_pcall ( L , 2 , 1 , 0 ) ) lua_remove ( L , -1 ) ; else lua_remove ( L , -2 ) ; lua_sethook ( L , hf , hm , hc ) ; } return 1 ; }
Enrichs the message on the stack with a traceback.
Enrichs the message on the stack with a traceback .
// stack: msg // stack: traceback debug msg // stack: traceback msg // save hook // stack: skip msg traceback msg // stack: err msg // stack: msg msg // restore hook // stack: msg