Refactor LuaInstance to prepare coroutine handling

This commit is contained in:
Jérôme Leclercq
2017-06-07 21:18:07 +02:00
parent b7df3bd1c4
commit a8129b218b
34 changed files with 2635 additions and 2594 deletions

View File

@@ -164,25 +164,25 @@ namespace Ndk
LuaAPI::RegisterClasses(overlay->lua);
// Override "print" function to add a line in the console
overlay->lua.PushFunction([&consoleRef] (Nz::LuaInstance& instance)
overlay->lua.PushFunction([&consoleRef] (Nz::LuaState& state)
{
Nz::StringStream stream;
unsigned int argCount = instance.GetStackTop();
instance.GetGlobal("tostring");
unsigned int argCount = state.GetStackTop();
state.GetGlobal("tostring");
for (unsigned int i = 1; i <= argCount; ++i)
{
instance.PushValue(-1); // tostring function
instance.PushValue(i); // argument
instance.Call(1, 1);
state.PushValue(-1); // tostring function
state.PushValue(i); // argument
state.Call(1, 1);
std::size_t length;
const char* str = instance.CheckString(-1, &length);
const char* str = state.CheckString(-1, &length);
if (i > 1)
stream << '\t';
stream << Nz::String(str, length);
instance.Pop(1);
state.Pop(1);
}
consoleRef.AddLine(stream);