diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2025-03-06 15:14:21 +0100 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2025-03-06 15:14:21 +0100 |
commit | b92dbd75b1c9988dcc83e5876e1ce2815145fa30 (patch) | |
tree | 81c0937808f43907ef1adad6c596755194ea6ee3 /src/lane.cpp | |
parent | 8b33e3022f0dd882a8aa11634cabdf7b5a2054fc (diff) | |
download | lanes-b92dbd75b1c9988dcc83e5876e1ce2815145fa30.tar.gz lanes-b92dbd75b1c9988dcc83e5876e1ce2815145fa30.tar.bz2 lanes-b92dbd75b1c9988dcc83e5876e1ce2815145fa30.zip |
New compatibility helper luaG_rawget
Diffstat (limited to 'src/lane.cpp')
-rw-r--r-- | src/lane.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/lane.cpp b/src/lane.cpp index 5b05b4e..7a5c257 100644 --- a/src/lane.cpp +++ b/src/lane.cpp | |||
@@ -298,8 +298,7 @@ static int lane_index_string(lua_State* L_) | |||
298 | // look in metatable first | 298 | // look in metatable first |
299 | lua_getmetatable(L_, kIdxSelf); // L_: lane "key" mt | 299 | lua_getmetatable(L_, kIdxSelf); // L_: lane "key" mt |
300 | lua_replace(L_, -3); // L_: mt "key" | 300 | lua_replace(L_, -3); // L_: mt "key" |
301 | lua_rawget(L_, -2); // L_: mt value | 301 | if (luaG_rawget(L_, StackIndex{ -2 }) != LuaType::NIL) { // found something? // L_: mt value |
302 | if (luaG_type(L_, kIdxTop) != LuaType::NIL) { // found something? | ||
303 | return 1; // done | 302 | return 1; // done |
304 | } | 303 | } |
305 | 304 | ||
@@ -335,14 +334,12 @@ static LUAG_FUNC(lane_index) | |||
335 | default: // unknown key | 334 | default: // unknown key |
336 | lua_getmetatable(L_, kIdxSelf); // L_: mt | 335 | lua_getmetatable(L_, kIdxSelf); // L_: mt |
337 | kCachedError.pushKey(L_); // L_: mt kCachedError | 336 | kCachedError.pushKey(L_); // L_: mt kCachedError |
338 | lua_rawget(L_, -2); // L_: mt error() | 337 | if (luaG_rawget(L_, StackIndex{ -2 }) != LuaType::FUNCTION) { // L_: mt error() |
339 | if (luaG_type(L_, kIdxTop) != LuaType::FUNCTION) { | ||
340 | raise_luaL_error(L_, "INTERNAL ERROR: cached error() is a %s, not a function", luaG_typename(L_, kIdxTop).data()); | 338 | raise_luaL_error(L_, "INTERNAL ERROR: cached error() is a %s, not a function", luaG_typename(L_, kIdxTop).data()); |
341 | } | 339 | } |
342 | luaG_pushstring(L_, "Unknown key: "); // L_: mt error() "Unknown key: " | 340 | luaG_pushstring(L_, "Unknown key: "); // L_: mt error() "Unknown key: " |
343 | kCachedTostring.pushKey(L_); // L_: mt error() "Unknown key: " kCachedTostring | 341 | kCachedTostring.pushKey(L_); // L_: mt error() "Unknown key: " kCachedTostring |
344 | lua_rawget(L_, -4); // L_: mt error() "Unknown key: " tostring() | 342 | if (luaG_rawget(L_, StackIndex{ -4 }) != LuaType::FUNCTION) { // L_: mt error() "Unknown key: " tostring() |
345 | if (luaG_type(L_, kIdxTop) != LuaType::FUNCTION) { | ||
346 | raise_luaL_error(L_, "INTERNAL ERROR: cached tostring() is a %s, not a function", luaG_typename(L_, kIdxTop).data()); | 343 | raise_luaL_error(L_, "INTERNAL ERROR: cached tostring() is a %s, not a function", luaG_typename(L_, kIdxTop).data()); |
347 | } | 344 | } |
348 | lua_pushvalue(L_, kKey); // L_: mt error() "Unknown key: " tostring() k | 345 | lua_pushvalue(L_, kKey); // L_: mt error() "Unknown key: " tostring() k |
@@ -840,8 +837,7 @@ static LUAG_FUNC(lane_gc) | |||
840 | // if there a gc callback? | 837 | // if there a gc callback? |
841 | lua_getiuservalue(L_, StackIndex{ 1 }, UserValueIndex{ 1 }); // L_: ud uservalue | 838 | lua_getiuservalue(L_, StackIndex{ 1 }, UserValueIndex{ 1 }); // L_: ud uservalue |
842 | kLaneGC.pushKey(L_); // L_: ud uservalue __gc | 839 | kLaneGC.pushKey(L_); // L_: ud uservalue __gc |
843 | lua_rawget(L_, -2); // L_: ud uservalue gc_cb|nil | 840 | if (luaG_rawget(L_, StackIndex{ -2 }) != LuaType::NIL) { // L_: ud uservalue gc_cb|nil |
844 | if (!lua_isnil(L_, -1)) { | ||
845 | lua_remove(L_, -2); // L_: ud gc_cb|nil | 841 | lua_remove(L_, -2); // L_: ud gc_cb|nil |
846 | luaG_pushstring(L_, _lane->getDebugName()); // L_: ud gc_cb name | 842 | luaG_pushstring(L_, _lane->getDebugName()); // L_: ud gc_cb name |
847 | _have_gc_cb = true; | 843 | _have_gc_cb = true; |