From e98f21dd297819fcb4931bd5a87474736c7a450e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 11 Jan 2016 11:50:50 +0100 Subject: add LuaBridge https://github.com/vinniefalco/LuaBridge --- libs/lua/LuaBridge/detail/dump.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 libs/lua/LuaBridge/detail/dump.h (limited to 'libs/lua/LuaBridge/detail/dump.h') diff --git a/libs/lua/LuaBridge/detail/dump.h b/libs/lua/LuaBridge/detail/dump.h new file mode 100644 index 0000000000..c066803573 --- /dev/null +++ b/libs/lua/LuaBridge/detail/dump.h @@ -0,0 +1,28 @@ +#include +#include + +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) << "\n"; + break; + } + } + return ostr.str(); +} -- cgit v1.2.3