From 4d364d3e77667b70bf3261da004f4990ef0c3ada Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Fri, 14 Jun 2024 16:01:26 +0200 Subject: lua_pushliteral -> luaG_pushstring --- deep_test/deep_test.cpp | 4 ++-- src/compat.h | 2 +- src/deep.cpp | 2 +- src/intercopycontext.cpp | 12 ++++++------ src/keeper.cpp | 2 +- src/lane.cpp | 24 ++++++++++++------------ src/lane.h | 2 +- src/lanes.cpp | 12 ++++++------ src/linda.cpp | 10 +++++----- src/lindafactory.cpp | 2 +- src/nameof.cpp | 10 +++++----- src/state.cpp | 6 +++--- src/tools.cpp | 6 +++--- src/tracker.cpp | 2 +- src/uniquekey.h | 8 ++++---- src/universe.cpp | 2 +- 16 files changed, 53 insertions(+), 53 deletions(-) diff --git a/deep_test/deep_test.cpp b/deep_test/deep_test.cpp index 2497742..7e16b2e 100644 --- a/deep_test/deep_test.cpp +++ b/deep_test/deep_test.cpp @@ -58,7 +58,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* const L_, DeepPrelude* c { MyDeepUserdata* const _self{ static_cast(MyDeepFactory::Instance.toDeep(L, 1)) }; _self->inUse.fetch_add(1, std::memory_order_seq_cst); - std::ignore = luaG_pushstring(L, "%p:deep(%d)", _self, _self->val); + luaG_pushstring(L, "%p:deep(%d)", _self, _self->val); _self->inUse.fetch_sub(1, std::memory_order_seq_cst); return 1; } @@ -179,7 +179,7 @@ struct MyClonableUserdata [[nodiscard]] static int clonable_tostring(lua_State* L) { MyClonableUserdata* self = static_cast(lua_touserdata(L, 1)); - std::ignore = luaG_pushstring(L, "%p:clonable(%d)", lua_topointer(L, 1), self->val); + luaG_pushstring(L, "%p:clonable(%d)", lua_topointer(L, 1), self->val); return 1; } diff --git a/src/compat.h b/src/compat.h index 714556e..0a02174 100644 --- a/src/compat.h +++ b/src/compat.h @@ -349,7 +349,7 @@ template } template -[[nodiscard]] inline std::string_view luaG_pushstring(lua_State* const L_, std::string_view const& str_, EXTRA&&... extra_) +inline std::string_view luaG_pushstring(lua_State* const L_, std::string_view const& str_, EXTRA&&... extra_) { if constexpr (sizeof...(EXTRA) == 0) { if constexpr (LUA_VERSION_NUM == 501) { diff --git a/src/deep.cpp b/src/deep.cpp index 249c497..8754178 100644 --- a/src/deep.cpp +++ b/src/deep.cpp @@ -237,7 +237,7 @@ void DeepFactory::PushDeepProxy(DestState const L_, DeepPrelude* const prelude_, raise_luaL_error(errL_, "lanes receiving deep userdata should register the 'package' library"); } - std::ignore = luaG_pushstring(L_, _modname); // L_: DPC proxy metatable require() "module" + luaG_pushstring(L_, _modname); // L_: DPC proxy metatable require() "module" if (luaG_getfield(L_, LUA_REGISTRYINDEX, LUA_LOADED_TABLE) != LuaType::TABLE) { // L_: DPC proxy metatable require() "module" _R._LOADED // no L.registry._LOADED; can this ever happen? lua_pop(L_, 6); // L_: diff --git a/src/intercopycontext.cpp b/src/intercopycontext.cpp index 9fa5911..285ca9b 100644 --- a/src/intercopycontext.cpp +++ b/src/intercopycontext.cpp @@ -310,7 +310,7 @@ void InterCopyContext::lookupNativeFunction() const case LookupMode::ToKeeper: // push a sentinel closure that holds the lookup name as upvalue - std::ignore = luaG_pushstring(L2, _fqn); // L1: ... f ... L2: "f.q.n" + luaG_pushstring(L2, _fqn); // L1: ... f ... L2: "f.q.n" lua_pushcclosure(L2, func_lookup_sentinel, 1); // L1: ... f ... L2: f break; @@ -319,7 +319,7 @@ void InterCopyContext::lookupNativeFunction() const kLookupRegKey.pushValue(L2); // L1: ... f ... L2: {} STACK_CHECK(L2, 1); LUA_ASSERT(L1, lua_istable(L2, -1)); - std::ignore = luaG_pushstring(L2, _fqn); // L1: ... f ... L2: {} "f.q.n" + luaG_pushstring(L2, _fqn); // L1: ... f ... L2: {} "f.q.n" lua_rawget(L2, -2); // L1: ... f ... L2: {} f // nil means we don't know how to transfer stuff: user should do something // anything other than function or table should not happen! @@ -430,7 +430,7 @@ void InterCopyContext::copyCachedFunction() const case LookupMode::ToKeeper: // push a sentinel closure that holds the lookup name as upvalue - std::ignore = luaG_pushstring(L2, _fqn); // L1: ... t ... L2: "f.q.n" + luaG_pushstring(L2, _fqn); // L1: ... t ... L2: "f.q.n" lua_pushcclosure(L2, table_lookup_sentinel, 1); // L1: ... t ... L2: f break; @@ -439,7 +439,7 @@ void InterCopyContext::copyCachedFunction() const kLookupRegKey.pushValue(L2); // L1: ... t ... L2: {} STACK_CHECK(L2, 1); LUA_ASSERT(L1, lua_istable(L2, -1)); - std::ignore = luaG_pushstring(L2, _fqn); // L2: {} "f.q.n" + luaG_pushstring(L2, _fqn); // L2: {} "f.q.n" lua_rawget(L2, -2); // L2: {} t // we accept destination lookup failures in the case of transfering the Lanes body function (this will result in the source table being cloned instead) // but not when we extract something out of a keeper, as there is nothing to clone! @@ -582,7 +582,7 @@ LuaType InterCopyContext::processConversion() const case LuaType::FUNCTION: lua_pushvalue(L1, L1_i); // L1: ... mt kConvertField val - std::ignore = luaG_pushstring(L1, mode == LookupMode::ToKeeper ? "keeper" : "regular"); // L1: ... mt kConvertField val string + luaG_pushstring(L1, mode == LookupMode::ToKeeper ? "keeper" : "regular"); // L1: ... mt kConvertField val string lua_call(L1, 2, 1); // val:kConvertField(str) -> result // L1: ... mt kConvertField converted lua_replace(L1, L1_i); // L1: ... mt lua_pop(L1, 1); // L1: ... mt @@ -1003,7 +1003,7 @@ LuaType InterCopyContext::processConversion() const { std::string_view const _s{ luaG_tostring(L1, L1_i) }; DEBUGSPEW_CODE(DebugSpew(nullptr) << "'" << _s << "'" << std::endl); - std::ignore = luaG_pushstring(L2, _s); + luaG_pushstring(L2, _s); return true; } diff --git a/src/keeper.cpp b/src/keeper.cpp index 6aeea45..7038f2c 100644 --- a/src/keeper.cpp +++ b/src/keeper.cpp @@ -838,7 +838,7 @@ void Keepers::initialize(Universe& U_, lua_State* L_, int const nbKeepers_, int keeper_.K = _K; // Give a name to the state - std::ignore = luaG_pushstring(_K, "Keeper #%d", i_ + 1); // L_: settings _K: "Keeper #n" + luaG_pushstring(_K, "Keeper #%d", i_ + 1); // L_: settings _K: "Keeper #n" if constexpr (HAVE_DECODA_SUPPORT()) { lua_pushvalue(_K, -1); // _K: "Keeper #n" Keeper #n" lua_setglobal(_K, "decoda_name"); // L_: settings _K: "Keeper #n" diff --git a/src/lane.cpp b/src/lane.cpp index 8f31973..17c4126 100644 --- a/src/lane.cpp +++ b/src/lane.cpp @@ -48,7 +48,7 @@ static LUAG_FUNC(get_debug_threadname) { Lane* const _lane{ ToLane(L_, 1) }; luaL_argcheck(L_, lua_gettop(L_) == 1, 2, "too many arguments"); - std::ignore = luaG_pushstring(L_, _lane->debugName); + luaG_pushstring(L_, _lane->debugName); return 1; } @@ -123,7 +123,7 @@ static LUAG_FUNC(thread_join) lua_State* const _L2{ _lane->L }; if (!_done || !_L2) { lua_pushnil(L_); // L_: lane nil - lua_pushliteral(L_, "timeout"); // L_: lane nil "timeout" + luaG_pushstring(L_, "timeout"); // L_: lane nil "timeout" return 2; } @@ -218,7 +218,7 @@ static int thread_index_number(lua_State* L_) lua_pushboolean(L_, 1); // L_: lane n {uv} 0 true lua_rawset(L_, kUsr); // L_: lane n {uv} // tell join() that we are called from __index, to avoid raising an error if the first returned value is not nil - std::ignore = luaG_pushstring(L_, "[]"); // L_: lane n {uv} "[]" + luaG_pushstring(L_, "[]"); // L_: lane n {uv} "[]" // wait until thread has completed, transfer everything from the lane's stack to our side lua_pushcclosure(L_, LG_thread_join, 1); // L_: lane n {uv} join lua_pushvalue(L_, kSelf); // L_: lane n {uv} join lane @@ -227,7 +227,7 @@ static int thread_index_number(lua_State* L_) default: // this is an internal error, we probably never get here lua_settop(L_, 0); // L_: - lua_pushliteral(L_, "Unexpected status: "); // L_: "Unexpected status: " + luaG_pushstring(L_, "Unexpected status: "); // L_: "Unexpected status: " std::ignore = _lane->pushThreadStatus(L_); // L_: "Unexpected status: " "" lua_concat(L_, 2); // L_: "Unexpected status: " raise_lua_error(L_); @@ -353,7 +353,7 @@ static LUAG_FUNC(thread_index) default: // unknown key lua_getmetatable(L_, kSelf); // L_: mt std::ignore = luaG_getfield(L_, -1, "cached_error"); // L_: mt error - lua_pushliteral(L_, "Unknown key: "); // L_: mt error "Unknown key: " + luaG_pushstring(L_, "Unknown key: "); // L_: mt error "Unknown key: " lua_pushvalue(L_, kKey); // L_: mt error "Unknown key: " k lua_concat(L_, 2); // L_: mt error "Unknown key: " lua_call(L_, 1, 0); // error( "Unknown key: " .. key) -> doesn't return // L_: mt @@ -474,9 +474,9 @@ static constexpr RegistryUniqueKey kStackTraceRegKey{ 0x3F327747CACAA904ull }; lua_pushstring(L_, _ar.what); // L_: some_error {} {} what lua_setfield(L_, -2, "what"); // L_: some_error {} {} } else if (_ar.currentline > 0) { - std::ignore = luaG_pushstring(L_, "%s:%d", _ar.short_src, _ar.currentline); // L_: some_error {} "blah:blah" + luaG_pushstring(L_, "%s:%d", _ar.short_src, _ar.currentline); // L_: some_error {} "blah:blah" } else { - std::ignore = luaG_pushstring(L_, "%s:?", _ar.short_src); // L_: some_error {} "blah" + luaG_pushstring(L_, "%s:?", _ar.short_src); // L_: some_error {} "blah" } lua_rawseti(L_, -2, static_cast(_n)); // L_: some_error {} } @@ -745,7 +745,7 @@ static LUAG_FUNC(lane_close) lua_settop(L_, 1); // L_: lane // no error if the lane body doesn't return a non-nil first value - std::ignore = luaG_pushstring(L_, "close"); // L_: lane "close" + luaG_pushstring(L_, "close"); // L_: lane "close" lua_pushcclosure(L_, LG_thread_join, 1); // L_: lane join() lua_insert(L_, 1); // L_: join() lane lua_call(L_, 1, LUA_MULTRET); // L_: join() results @@ -777,7 +777,7 @@ static LUAG_FUNC(lane_gc) lua_rawget(L_, -2); // L_: ud uservalue gc_cb|nil if (!lua_isnil(L_, -1)) { lua_remove(L_, -2); // L_: ud gc_cb|nil - std::ignore = luaG_pushstring(L_, _lane->debugName); // L_: ud gc_cb name + luaG_pushstring(L_, _lane->debugName); // L_: ud gc_cb name _have_gc_cb = true; } else { lua_pop(L_, 2); // L_: ud @@ -789,7 +789,7 @@ static LUAG_FUNC(lane_gc) selfdestruct_add(_lane); assert(_lane->selfdestruct_next); if (_have_gc_cb) { - lua_pushliteral(L_, "selfdestruct"); // L_: ud gc_cb name status + luaG_pushstring(L_, "selfdestruct"); // L_: ud gc_cb name status lua_call(L_, 2, 0); // L_: ud } return 0; @@ -805,7 +805,7 @@ static LUAG_FUNC(lane_gc) // do this after lane cleanup in case the callback triggers an error if (_have_gc_cb) { - lua_pushliteral(L_, "closed"); // L_: ud gc_cb name status + luaG_pushstring(L_, "closed"); // L_: ud gc_cb name status lua_call(L_, 2, 0); // L_: ud } return 0; @@ -979,7 +979,7 @@ void Lane::PushMetatable(lua_State* L_) lua_getglobal(L_, "tostring"); // L_: mt kCachedTostring tostring() lua_rawset(L_, -3); // L_: mt // hide the actual metatable from getmetatable() - lua_pushliteral(L_, kLaneMetatableName); // L_: mt "Lane" + luaG_pushstring(L_, kLaneMetatableName); // L_: mt "Lane" lua_setfield(L_, -2, "__metatable"); // L_: mt } STACK_CHECK(L_, 1); diff --git a/src/lane.h b/src/lane.h index 3c3cced..704a760 100644 --- a/src/lane.h +++ b/src/lane.h @@ -34,7 +34,7 @@ static constexpr RegistryUniqueKey kLaneNameRegKey{ 0xA194E2645C57F6DDull }; // The chain is ended by '(Lane*)(-1)', not nullptr: 'selfdestructFirst -> ... -> ... -> (-1)' #define SELFDESTRUCT_END ((Lane*) (-1)) -// must be a #define instead of a constexpr to work with lua_pushliteral (until I templatize it) +// must be a #define instead of a constexpr to benefit from compile-time string concatenation #define kLaneMetatableName "Lane" #define kLanesLibName "lanes" #define kLanesCoreLibName kLanesLibName ".core" diff --git a/src/lanes.cpp b/src/lanes.cpp index 7196b72..f1aa873 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp @@ -179,7 +179,7 @@ LUAG_FUNC(sleep) else { lua_pushnumber(L_, lua_tonumber(L_, 1)); // L_: duration? receive() timerLinda duration } - std::ignore = luaG_pushstring(L_, "ac100de1-a696-4619-b2f0-a26de9d58ab8"); // L_: duration? receive() timerLinda duration key + luaG_pushstring(L_, "ac100de1-a696-4619-b2f0-a26de9d58ab8"); // L_: duration? receive() timerLinda duration key STACK_CHECK(L_, 3); // 3 arguments ready lua_call(L_, 3, LUA_MULTRET); // timerLinda:receive(duration,key) // L_: duration? result... return lua_gettop(L_) - 1; @@ -352,12 +352,12 @@ LUAG_FUNC(lane_new) if (!_debugName.empty()) { if (_debugName != "auto") { - std::ignore = luaG_pushstring(_L2, _debugName); // L: ... lane L2: "" + luaG_pushstring(_L2, _debugName); // L: ... lane L2: "" } else { lua_Debug _ar; lua_pushvalue(L, 1); // L: ... lane func lua_getinfo(L, ">S", &_ar); // L: ... lane - std::ignore = luaG_pushstring(_L2, "%s:%d", _ar.short_src, _ar.linedefined); // L: ... lane L2: "" + luaG_pushstring(_L2, "%s:%d", _ar.short_src, _ar.linedefined); // L: ... lane L2: "" } lane->changeDebugName(-1); lua_pop(_L2, 1); // L: ... lane L2: @@ -440,7 +440,7 @@ LUAG_FUNC(lane_new) lua_pop(_L2, 1); // L_: [fixed] args... n "modname" L2: raise_luaL_error(L_, "cannot pre-require modules without loading 'package' library first"); } else { - std::ignore = luaG_pushstring(_L2, _name); // L_: [fixed] args... n "modname" L2: require() name + luaG_pushstring(_L2, _name); // L_: [fixed] args... n "modname" L2: require() name LuaError const _rc{ lua_pcall(_L2, 1, 1, 0) }; // L_: [fixed] args... n "modname" L2: ret/errcode if (_rc != LuaError::OK) { // propagate error to main state if any @@ -674,7 +674,7 @@ LUAG_FUNC(configure) if (_U == nullptr) { // store a hidden reference in the registry to make sure the string is kept around even if a lane decides to manually change the "decoda_name" global... - kLaneNameRegKey.setValue(L_, [](lua_State* L_) { std::ignore = luaG_pushstring(L_, "main"); }); + kLaneNameRegKey.setValue(L_, [](lua_State* L_) { luaG_pushstring(L_, "main"); }); // create the universe _U = Universe::Create(L_); // L_: settings universe @@ -714,7 +714,7 @@ LUAG_FUNC(configure) lua_pushcclosure(L_, LG_require, 1); // L_: settings M lanes.require lua_setfield(L_, -2, "require"); // L_: settings M - std::ignore = luaG_pushstring( + luaG_pushstring( L_, "%d.%d.%d", LANES_VERSION_MAJOR, diff --git a/src/linda.cpp b/src/linda.cpp index 3c04bae..1933b06 100644 --- a/src/linda.cpp +++ b/src/linda.cpp @@ -81,13 +81,13 @@ template { Linda* const _linda{ ToLinda(L_, idx_) }; if (_linda != nullptr) { - std::ignore = luaG_pushstring(L_, "Linda: "); + luaG_pushstring(L_, "Linda: "); std::string_view const _lindaName{ _linda->getName() }; if (!_lindaName.empty()) { - std::ignore = luaG_pushstring(L_, _lindaName); + luaG_pushstring(L_, _lindaName); } else { // obfuscate the pointer so that we can't read the value with our eyes out of a script - std::ignore = luaG_pushstring(L_, "%p", _linda->obfuscated()); + luaG_pushstring(L_, "%p", _linda->obfuscated()); } lua_concat(L_, 2); return 1; @@ -599,7 +599,7 @@ LUAG_FUNC(linda_receive) if (_nbPushed == 0) { // not enough data in the linda slot to fulfill the request, return nil, "timeout" lua_pushnil(L_); - std::ignore = luaG_pushstring(L_, "timeout"); + luaG_pushstring(L_, "timeout"); return 2; } return _nbPushed; @@ -752,7 +752,7 @@ LUAG_FUNC(linda_send) } else { // not enough room in the Linda slot to fulfill the request, return nil, "timeout" lua_pushnil(L_); - std::ignore = luaG_pushstring(L_, "timeout"); + luaG_pushstring(L_, "timeout"); return 2; } } diff --git a/src/lindafactory.cpp b/src/lindafactory.cpp index 863f16e..9ae2611 100644 --- a/src/lindafactory.cpp +++ b/src/lindafactory.cpp @@ -49,7 +49,7 @@ void LindaFactory::createMetatable(lua_State* L_) const lua_setfield(L_, -2, "__index"); // protect metatable from external access - lua_pushliteral(L_, kLindaMetatableName); + luaG_pushstring(L_, kLindaMetatableName); lua_setfield(L_, -2, "__metatable"); // the linda functions diff --git a/src/nameof.cpp b/src/nameof.cpp index 543c3d4..a33c2e5 100644 --- a/src/nameof.cpp +++ b/src/nameof.cpp @@ -91,7 +91,7 @@ THE SOFTWARE. if (lua_getmetatable(L_, -1)) { // L_: o "r" {c} {fqn} ... {?} k {} {mt} if (lua_istable(L_, -1)) { ++depth_; - lua_pushliteral(L_, "__metatable"); // L_: o "r" {c} {fqn} ... {?} k {} {mt} "__metatable" + luaG_pushstring(L_, "__metatable"); // L_: o "r" {c} {fqn} ... {?} k {} {mt} "__metatable" lua_rawseti(L_, kFQN, depth_); // L_: o "r" {c} {fqn} ... {?} k {} {mt} shortest_ = DiscoverObjectNameRecur(L_, shortest_, depth_); lua_pushnil(L_); // L_: o "r" {c} {fqn} ... {?} k {} {mt} nil @@ -113,7 +113,7 @@ THE SOFTWARE. if (lua_getmetatable(L_, -1)) { // L_: o "r" {c} {fqn} ... {?} k U {mt} if (lua_istable(L_, -1)) { ++depth_; - lua_pushliteral(L_, "__metatable"); // L_: o "r" {c} {fqn} ... {?} k U {mt} "__metatable" + luaG_pushstring(L_, "__metatable"); // L_: o "r" {c} {fqn} ... {?} k U {mt} "__metatable" lua_rawseti(L_, kFQN, depth_); // L_: o "r" {c} {fqn} ... {?} k U {mt} shortest_ = DiscoverObjectNameRecur(L_, shortest_, depth_); lua_pushnil(L_); // L_: o "r" {c} {fqn} ... {?} k U {mt} nil @@ -129,7 +129,7 @@ THE SOFTWARE. while (lua_getiuservalue(L_, -1, _uvi) != LUA_TNONE) { // L_: o "r" {c} {fqn} ... {?} k U {u} if (lua_istable(L_, -1)) { // if it is a table, look inside ++depth_; - lua_pushliteral(L_, "uservalue"); // L_: o "r" {c} {fqn} ... {?} k v {u} "uservalue" + luaG_pushstring(L_, "uservalue"); // L_: o "r" {c} {fqn} ... {?} k v {u} "uservalue" lua_rawseti(L_, kFQN, depth_); // L_: o "r" {c} {fqn} ... {?} k v {u} shortest_ = DiscoverObjectNameRecur(L_, shortest_, depth_); lua_pushnil(L_); // L_: o "r" {c} {fqn} ... {?} k v {u} nil @@ -188,14 +188,14 @@ LUAG_FUNC(nameof) // push a table whose contents are strings that, when concatenated, produce unique name lua_newtable(L_); // L_: o nil {c} {fqn} // {fqn}[1] = "_G" - lua_pushliteral(L_, LUA_GNAME); // L_: o nil {c} {fqn} "_G" + luaG_pushstring(L_, LUA_GNAME); // L_: o nil {c} {fqn} "_G" lua_rawseti(L_, -2, 1); // L_: o nil {c} {fqn} // this is where we start the search luaG_pushglobaltable(L_); // L_: o nil {c} {fqn} _G std::ignore = DiscoverObjectNameRecur(L_, std::numeric_limits::max(), 1); if (lua_isnil(L_, 2)) { // try again with registry, just in case... lua_pop(L_, 1); // L_: o nil {c} {fqn} - lua_pushliteral(L_, "_R"); // L_: o nil {c} {fqn} "_R" + luaG_pushstring(L_, "_R"); // L_: o nil {c} {fqn} "_R" lua_rawseti(L_, -2, 1); // L_: o nil {c} {fqn} lua_pushvalue(L_, LUA_REGISTRYINDEX); // L_: o nil {c} {fqn} _R std::ignore = DiscoverObjectNameRecur(L_, std::numeric_limits::max(), 1); diff --git a/src/state.cpp b/src/state.cpp index 6d27256..18c5ae2 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -183,7 +183,7 @@ namespace state { STACK_CHECK(L_, 1); // capture error and raise it in caller state std::string_view const _stateType{ mode_ == LookupMode::LaneBody ? "lane" : "keeper" }; - std::ignore = luaG_pushstring(L_, _stateType); // L_: on_state_create() "" + luaG_pushstring(L_, _stateType); // L_: on_state_create() "" if (lua_pcall(L_, 1, 0, 0) != LUA_OK) { raise_luaL_error(from_, "%s failed: \"%s\"", kOnStateCreate.data(), lua_isstring(L_, -1) ? luaG_tostring(L_, -1).data() : luaG_typename(L_, -1).data()); } @@ -364,13 +364,13 @@ namespace state { kLookupRegKey.pushValue(_L); // L: {} lua_pushnil(_L); // L: {} nil while (lua_next(_L, -2)) { // L: {} k v - std::ignore = luaG_pushstring(_L, "["); // L: {} k v "[" + luaG_pushstring(_L, "["); // L: {} k v "[" lua_getglobal(_L, "tostring"); // L: {} k v "[" tostring lua_pushvalue(_L, -4); // L: {} k v "[" tostring k lua_call(_L, 1, 1); // L: {} k v "[" 'k' - std::ignore = luaG_pushstring(_L, "] = "); // L: {} k v "[" 'k' "] = " + luaG_pushstring(_L, "] = "); // L: {} k v "[" 'k' "] = " lua_getglobal(_L, "tostring"); // L: {} k v "[" 'k' "] = " tostring lua_pushvalue(_L, -5); // L: {} k v "[" 'k' "] = " tostring v diff --git a/src/tools.cpp b/src/tools.cpp index 3a331f5..9fc1e35 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -323,9 +323,9 @@ namespace tools { _name = "nullptr"; } lua_pushvalue(L_, _in_base); // L_: {} f - std::ignore = luaG_pushstring(L_, _name); // L_: {} f name_ + luaG_pushstring(L_, _name); // L_: {} f name_ lua_rawset(L_, -3); // L_: {} - std::ignore = luaG_pushstring(L_, _name); // L_: {} name_ + luaG_pushstring(L_, _name); // L_: {} name_ lua_pushvalue(L_, _in_base); // L_: {} name_ f lua_rawset(L_, -3); // L_: {} lua_pop(L_, 1); // L_: @@ -334,7 +334,7 @@ namespace tools { int _startDepth{ 0 }; if (!_name.empty()) { STACK_CHECK(L_, 2); - std::ignore = luaG_pushstring(L_, _name); // L_: {} {fqn} "name" + luaG_pushstring(L_, _name); // L_: {} {fqn} "name" // generate a name, and if we already had one name, keep whichever is the shorter lua_pushvalue(L_, _in_base); // L_: {} {fqn} "name" t update_lookup_entry(L_, _dbIdx, _startDepth); // L_: {} {fqn} "name" diff --git a/src/tracker.cpp b/src/tracker.cpp index ae4d116..315b56b 100644 --- a/src/tracker.cpp +++ b/src/tracker.cpp @@ -94,7 +94,7 @@ void LaneTracker::tracking_add(Lane* lane_) while (_lane != TRACKING_END) { // insert a { name='', status='' } tuple, so that several lanes with the same name can't clobber each other lua_createtable(L_, 0, 2); // L_: {} {} - std::ignore = luaG_pushstring(L_, _lane->debugName); // L_: {} {} "name" + luaG_pushstring(L_, _lane->debugName); // L_: {} {} "name" lua_setfield(L_, -2, "name"); // L_: {} {} std::ignore = _lane->pushThreadStatus(L_); // L_: {} {} "status" lua_setfield(L_, -2, "status"); // L_: {} {} diff --git a/src/uniquekey.h b/src/uniquekey.h index 94c09c7..debfee4 100644 --- a/src/uniquekey.h +++ b/src/uniquekey.h @@ -105,16 +105,16 @@ class RegistryUniqueKey return false; } // --------------------------------------------------------------------------------------------- - void getSubTableMode(lua_State* const L_, char const* const mode_) const + void getSubTableMode(lua_State* const L_, std::string_view const& mode_) const { STACK_CHECK_START_REL(L_, 0); if (!getSubTable(L_, 0, 0)) { // L_: {} // Set its metatable if requested - if (mode_) { + if (!mode_.empty()) { STACK_GROW(L_, 3); lua_createtable(L_, 0, 1); // L_: {} mt - lua_pushliteral(L_, "__mode"); // L_: {} mt "__mode" - lua_pushstring(L_, mode_); // L_: {} mt "__mode" mode + luaG_pushstring(L_, "__mode"); // L_: {} mt "__mode" + luaG_pushstring(L_, mode_); // L_: {} mt "__mode" mode lua_rawset(L_, -3); // L_: {} mt lua_setmetatable(L_, -2); // L_: {} } diff --git a/src/universe.cpp b/src/universe.cpp index c95884f..c98e2c8 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -131,7 +131,7 @@ Universe::Universe() // Initialize 'timerLinda'; a common Linda object shared by all states lua_pushcfunction(L_, LG_linda); // L_: settings lanes.linda - std::ignore = luaG_pushstring(L_, "lanes-timer"); // L_: settings lanes.linda "lanes-timer" + luaG_pushstring(L_, "lanes-timer"); // L_: settings lanes.linda "lanes-timer" lua_pushinteger(L_, 0); // L_: settings lanes.linda "lanes-timer" 0 lua_call(L_, 2, 1); // L_: settings linda STACK_CHECK(L_, 1); -- cgit v1.2.3-55-g6feb