Add Lua runtime helper functions for error-handling
Add two helper functions to the Lua runtime, "SWIG_Lua_pusherrstring" and "SWIG_Lua_pushferrstring". These are like the standard Lua functions lua_pushstring and lua_pushfstring respectively, except that the strings are prefixed with the location of the innermost Lua call-point (as generated by luaL_where).
This commit is contained in:
parent
ada7dd92e4
commit
663c41e248
1 changed files with 30 additions and 0 deletions
|
|
@ -71,6 +71,36 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Helper functions for error handling
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
/* Push the string STR on the Lua stack, like lua_pushstring, but
|
||||
prefixed with the the location of the innermost Lua call-point
|
||||
(as formated by luaL_where). */
|
||||
SWIGRUNTIME void
|
||||
SWIG_Lua_pusherrstring (lua_State *L, const char *str)
|
||||
{
|
||||
luaL_where (L, 1);
|
||||
lua_pushstring (L, str);
|
||||
lua_concat (L, 2);
|
||||
}
|
||||
|
||||
/* Push a formatted string generated from FMT and following args on
|
||||
the Lua stack, like lua_pushfstring, but prefixed with the the
|
||||
location of the innermost Lua call-point (as formated by luaL_where). */
|
||||
SWIGRUNTIME void
|
||||
SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...)
|
||||
{
|
||||
va_list argp;
|
||||
va_start(argp, fmt);
|
||||
luaL_where(L, 1);
|
||||
lua_pushvfstring(L, fmt, argp);
|
||||
va_end(argp);
|
||||
lua_concat(L, 2);
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* global swig types
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue