void ScriptEngine::DEBUG_PrintGlobals(lua_State* luaState) { if (luaState == nullptr) { PRINT_ERROR << "Empty lua State!" << std::endl; return; } std::cout << "SCRIPT DEBUG: Printing script's global variables:" << std::endl; // Push the global table on top of the stack lua_pushglobaltable(luaState); // -1 is the value on top of the stack, here the global table index luabind::object o(luabind::from_stack(luaState, -1)); for(luabind::iterator it(o), end; it != end; ++it) { std::cout << it.key() << " = " << (*it) << " ::: data type = " << luabind::type(*it) << std::endl; if(luabind::type(*it) == LUA_TTABLE) { if(luabind::object_cast<std::string>(it.key()) != "_G") DEBUG_PrintTable(luabind::object(*it), 1); } } std::cout << std::endl; // Remove the table afterwards lua_pop(luaState, 1); }
void ScriptEngine::DEBUG_PrintTable(luabind::object table, uint32_t tab) { for(luabind::iterator it(table), end; it != end; ++it) { for(uint32_t i = 0; i < tab; ++i) std::cout << '\t'; std::cout << it.key() << " = " << (*it) << " (Type: " << luabind::type(*it) << ")" << std::endl; if(type(*it) == LUA_TTABLE) DEBUG_PrintTable(luabind::object(*it), tab + 1); } }
void ReadScriptDescriptor::DEBUG_PrintTable(object table, int tab) { for(luabind::iterator it(table), end; it != end; ++it) { for(int i = 0; i < tab; ++i) PRINT_WARNING << '\t'; PRINT_WARNING << it.key() << " = " << (*it) << " (Type: " << type(*it) << ")" << std::endl; if(type(*it) == LUA_TTABLE) DEBUG_PrintTable(object(*it), tab + 1); } }
void ReadScriptDescriptor::DEBUG_PrintGlobals() { cout << "SCRIPT DEBUG: Printing script's global variables:" << endl; object o(from_stack(_lstack, LUA_GLOBALSINDEX)); for (luabind::iterator it(o), end; it != end; ++it) { cout << it.key() << " = " << (*it) << " ::: data type = " << type(*it) << endl; if (luabind::type(*it) == LUA_TTABLE) { if (object_cast<string>(it.key()) != "_G") DEBUG_PrintTable(object(*it), 1); } } cout << endl; }
void ReadScriptDescriptor::DEBUG_PrintGlobals() { PRINT_WARNING << "SCRIPT DEBUG: Printing script's global variables:" << std::endl; // Push the global table on top of the stack lua_pushglobaltable(_lstack); object o(from_stack(_lstack, -1)); // -1 is the value on top of the stack, here the global table index for(luabind::iterator it(o), end; it != end; ++it) { PRINT_WARNING << it.key() << " = " << (*it) << " ::: data type = " << type(*it) << std::endl; if(luabind::type(*it) == LUA_TTABLE) { if(object_cast<std::string>(it.key()) != "_G") DEBUG_PrintTable(object(*it), 1); } } PRINT_WARNING << std::endl; // Remove the table afterwards lua_pop(_lstack, 1); }