2016-01-11 05:50:50 -05:00
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
|
2016-02-21 13:25:42 -05:00
|
|
|
static std::string dumpLuaState(lua_State *L) {
|
2016-01-11 05:50:50 -05:00
|
|
|
std::stringstream ostr;
|
|
|
|
int i;
|
|
|
|
int top = lua_gettop(L);
|
|
|
|
ostr << "top=" << top << ":\n";
|
|
|
|
for (i = 1; i <= top; ++i) {
|
|
|
|
int t = lua_type(L, i);
|
|
|
|
switch(t) {
|
|
|
|
case LUA_TSTRING:
|
|
|
|
ostr << " " << i << ": '" << lua_tostring(L, i) << "'\n";
|
|
|
|
break;
|
|
|
|
case LUA_TBOOLEAN:
|
2016-01-17 15:25:56 -05:00
|
|
|
ostr << " " << i << ": " <<
|
2016-01-11 05:50:50 -05:00
|
|
|
(lua_toboolean(L, i) ? "true" : "false") << "\n";
|
|
|
|
break;
|
|
|
|
case LUA_TNUMBER:
|
|
|
|
ostr << " " << i << ": " << lua_tonumber(L, i) << "\n";
|
|
|
|
break;
|
|
|
|
default:
|
2016-02-21 13:25:42 -05:00
|
|
|
ostr << " " << i << ": TYPE=" << lua_typename(L, t) << ": " << lua_topointer(L, i)<< "\n";
|
2016-01-11 05:50:50 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ostr.str();
|
|
|
|
}
|