lua: main reason is object dead, so report that

Dieser Commit ist enthalten in:
Reinder Feenstra 2022-01-09 10:00:54 +01:00
Ursprung 9fe67a6c37
Commit c600a34489
2 geänderte Dateien mit 6 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -3,7 +3,7 @@
*
* This file is part of the traintastic source code.
*
* Copyright (C) 2021 Reinder Feenstra
* Copyright (C) 2021-2022 Reinder Feenstra
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -29,8 +29,8 @@
namespace Lua {
// Note:
// All these functions call abort(), it's just a trick to let the compiler understand it is a noretrun function,
// Lua's error funtions aren't marked as noretrun functions, but they are.
// All these functions call abort(), it's just a trick to let the compiler understand it is a noreturn function,
// Lua's error funtions aren't marked as noreturn functions, but they are.
[[noreturn]] inline void errorArgumentOutOfRange(lua_State* L, int arg) { luaL_argerror(L, arg, "out of range"); abort(); }
@ -38,7 +38,6 @@ namespace Lua {
[[noreturn]] inline void errorCantSetReadOnlyProperty(lua_State* L) { luaL_error(L, "can't set read only property"); abort(); }
[[noreturn]] inline void errorDeadEvent(lua_State* L) { luaL_error(L, "dead event"); abort(); }
[[noreturn]] inline void errorDeadMethod(lua_State* L) { luaL_error(L, "dead method"); abort(); }
[[noreturn]] inline void errorDeadObject(lua_State* L) { luaL_error(L, "dead object"); abort(); }
[[noreturn]] inline void errorExpectedNArgumentsGotN(lua_State* L, int expected, int got) { luaL_error(L, "expected %d arguments, got %d", expected, got); abort(); }

Datei anzeigen

@ -3,7 +3,7 @@
*
* This file is part of the traintastic source code.
*
* Copyright (C) 2019-2020 Reinder Feenstra
* Copyright (C) 2019-2020,2022 Reinder Feenstra
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -46,7 +46,7 @@ AbstractMethod& Method::check(lua_State* L, int index)
if(!data.object.expired())
return data.method;
errorDeadMethod(L);
errorDeadObject(L);
}
AbstractMethod* Method::test(lua_State* L, int index)
@ -57,7 +57,7 @@ AbstractMethod* Method::test(lua_State* L, int index)
if(!(**data).object.expired())
return &(**data).method;
errorDeadMethod(L);
errorDeadObject(L);
}
void Method::push(lua_State* L, AbstractMethod& value)