add LuaBridge
[ardour.git] / libs / lua / LuaBridge / detail / dump.h
1 #include <sstream>
2 #include <string>
3
4 std::string dumpLuaState(lua_State *L) {
5         std::stringstream ostr;
6         int i;
7         int top = lua_gettop(L);
8         ostr << "top=" << top << ":\n";
9         for (i = 1; i <= top; ++i) {
10                 int t = lua_type(L, i);
11                 switch(t) {
12                 case LUA_TSTRING:
13                         ostr << "  " << i << ": '" << lua_tostring(L, i) << "'\n";
14                         break;
15                 case LUA_TBOOLEAN:
16                         ostr << "  " << i << ": " << 
17                                         (lua_toboolean(L, i) ? "true" : "false") << "\n";
18                         break;
19                 case LUA_TNUMBER:
20                         ostr << "  " << i << ": " << lua_tonumber(L, i) << "\n";
21                         break;
22                 default:
23                         ostr << "  " << i << ": TYPE=" << lua_typename(L, t) << "\n";
24                         break;
25                 }
26         }
27         return ostr.str();
28 }