diff options
author | Robin Gareus <robin@gareus.org> | 2016-01-11 11:50:50 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-02-22 22:06:47 +0100 |
commit | e98f21dd297819fcb4931bd5a87474736c7a450e (patch) | |
tree | 018a17a9f67c206cea1394c3f4012c58a1a2f6d4 /libs/lua/LuaBridge/detail/dump.h | |
parent | c8973f67a65d911d1b08e1121d1c7da57c58b182 (diff) |
add LuaBridge
https://github.com/vinniefalco/LuaBridge
Diffstat (limited to 'libs/lua/LuaBridge/detail/dump.h')
-rw-r--r-- | libs/lua/LuaBridge/detail/dump.h | 28 |
1 files changed, 28 insertions, 0 deletions
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 <sstream> +#include <string> + +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(); +} |