13
0
livetrax/libs/lua/LuaBridge/detail/dump.h
Robin Gareus 12a58015a3 customize LuaBridge
* introduce boost::shared_ptr support
* support enum & const
* allow to add non-class member functions
* STL iterators (vector, list, set, bitset & map)
* support reference arguments (framecnt_t&)
* add support for arrays of basic types (e.g. float*, int*)
* fix compiler warnings
2016-02-22 22:06:47 +01:00

29 lines
693 B
C++

#include <sstream>
#include <string>
static std::string dumpLuaState(lua_State *L) {
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:
ostr << " " << i << ": " <<
(lua_toboolean(L, i) ? "true" : "false") << "\n";
break;
case LUA_TNUMBER:
ostr << " " << i << ": " << lua_tonumber(L, i) << "\n";
break;
default:
ostr << " " << i << ": TYPE=" << lua_typename(L, t) << ": " << lua_topointer(L, i)<< "\n";
break;
}
}
return ostr.str();
}