aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-06-04 09:21:15 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-06-04 09:21:15 +0200
commit3a86e1f2fde002199fff0ca4bb2ed4674b32ec8e (patch)
treea2e2f10dff1b6659fdc69f4ac205bbae6f9da604 /src
parent2baf7a6e001951d08098149d80d7ce79e7035a16 (diff)
downloadlanes-3a86e1f2fde002199fff0ca4bb2ed4674b32ec8e.tar.gz
lanes-3a86e1f2fde002199fff0ca4bb2ed4674b32ec8e.tar.bz2
lanes-3a86e1f2fde002199fff0ca4bb2ed4674b32ec8e.zip
Remove some useless compatibility stuff
Diffstat (limited to 'src')
-rw-r--r--src/compat.h37
-rw-r--r--src/linda.cpp5
-rw-r--r--src/tools.cpp10
3 files changed, 5 insertions, 47 deletions
diff --git a/src/compat.h b/src/compat.h
index fb31cab..7ac864e 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -61,7 +61,6 @@ inline char const* lua_typename(lua_State* L_, LuaType t_)
61// add some Lua 5.3-style API when building for Lua 5.1 61// add some Lua 5.3-style API when building for Lua 5.1
62#if LUA_VERSION_NUM == 501 62#if LUA_VERSION_NUM == 501
63 63
64#define lua501_equal lua_equal
65inline int lua_absindex(lua_State* L_, int idx_) 64inline int lua_absindex(lua_State* L_, int idx_)
66{ 65{
67 return (((idx_) >= 0 || (idx_) <= LUA_REGISTRYINDEX) ? (idx_) : lua_gettop(L_) + (idx_) + 1); 66 return (((idx_) >= 0 || (idx_) <= LUA_REGISTRYINDEX) ? (idx_) : lua_gettop(L_) + (idx_) + 1);
@@ -107,18 +106,6 @@ int luaL_getsubtable(lua_State* L_, int idx_, const char* fname_);
107// wrap Lua 5.2 calls under Lua 5.1 API when it is simpler that way 106// wrap Lua 5.2 calls under Lua 5.1 API when it is simpler that way
108#if LUA_VERSION_NUM == 502 107#if LUA_VERSION_NUM == 502
109 108
110#ifndef lua501_equal // already defined when compatibility is active in luaconf.h
111inline int lua501_equal(lua_State* L_, int a_, int b_)
112{
113 return lua_compare(L_, a_, b_, LUA_OPEQ);
114}
115#endif // lua501_equal
116#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h
117inline int lua_lessthan(lua_State* L_, int a_, int b_)
118{
119 return lua_compare(L_, a_, b_, LUA_OPLT);
120}
121#endif // lua_lessthan
122inline void luaG_registerlibfuncs(lua_State* L_, luaL_Reg const funcs_[]) 109inline void luaG_registerlibfuncs(lua_State* L_, luaL_Reg const funcs_[])
123{ 110{
124 luaL_setfuncs(L_, funcs_, 0); 111 luaL_setfuncs(L_, funcs_, 0);
@@ -149,18 +136,6 @@ inline int lua504_dump(lua_State* L_, lua_Writer writer_, void* data_, [[maybe_u
149// wrap Lua 5.3 calls under Lua 5.1 API when it is simpler that way 136// wrap Lua 5.3 calls under Lua 5.1 API when it is simpler that way
150#if LUA_VERSION_NUM == 503 137#if LUA_VERSION_NUM == 503
151 138
152#ifndef lua501_equal // already defined when compatibility is active in luaconf.h
153inline int lua501_equal(lua_State* L_, int a_, int b_)
154{
155 return lua_compare(L_, a_, b_, LUA_OPEQ);
156}
157#endif // lua501_equal
158#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h
159inline int lua_lessthan(lua_State* L_, int a_, int b_)
160{
161 return lua_compare(L_, a_, b_, LUA_OPLT);
162}
163#endif // lua_lessthan
164inline void luaG_registerlibfuncs(lua_State* L_, luaL_Reg const funcs_[]) 139inline void luaG_registerlibfuncs(lua_State* L_, luaL_Reg const funcs_[])
165{ 140{
166 luaL_setfuncs(L_, funcs_, 0); 141 luaL_setfuncs(L_, funcs_, 0);
@@ -193,18 +168,6 @@ int lua_setiuservalue(lua_State* L_, int idx_, int n_);
193// wrap Lua 5.4 calls under Lua 5.1 API when it is simpler that way 168// wrap Lua 5.4 calls under Lua 5.1 API when it is simpler that way
194#if LUA_VERSION_NUM == 504 169#if LUA_VERSION_NUM == 504
195 170
196#ifndef lua501_equal // already defined when compatibility is active in luaconf.h
197inline int lua501_equal(lua_State* L_, int a_, int b_)
198{
199 return lua_compare(L_, a_, b_, LUA_OPEQ);
200}
201#endif // lua501_equal
202#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h
203inline int lua_lessthan(lua_State* L_, int a_, int b_)
204{
205 return lua_compare(L_, a_, b_, LUA_OPLT);
206}
207#endif // lua_lessthan
208inline void luaG_registerlibfuncs(lua_State* L_, luaL_Reg const funcs_[]) 171inline void luaG_registerlibfuncs(lua_State* L_, luaL_Reg const funcs_[])
209{ 172{
210 luaL_setfuncs(L_, funcs_, 0); 173 luaL_setfuncs(L_, funcs_, 0);
diff --git a/src/linda.cpp b/src/linda.cpp
index 2a31799..f1a99fd 100644
--- a/src/linda.cpp
+++ b/src/linda.cpp
@@ -461,10 +461,7 @@ LUAG_FUNC(linda_receive)
461 keeper_api_t _selected_keeper_receive{ nullptr }; 461 keeper_api_t _selected_keeper_receive{ nullptr };
462 int _expected_pushed_min{ 0 }, _expected_pushed_max{ 0 }; 462 int _expected_pushed_min{ 0 }, _expected_pushed_max{ 0 };
463 // are we in batched mode? 463 // are we in batched mode?
464 kLindaBatched.pushKey(L_); 464 if (kLindaBatched.equals(L_, -1)) {
465 int const _is_batched{ lua501_equal(L_, _key_i, -1) };
466 lua_pop(L_, 1);
467 if (_is_batched) {
468 // no need to pass linda.batched in the keeper state 465 // no need to pass linda.batched in the keeper state
469 ++_key_i; 466 ++_key_i;
470 // make sure the keys are of a valid type 467 // make sure the keys are of a valid type
diff --git a/src/tools.cpp b/src/tools.cpp
index 94e941d..e6dadd2 100644
--- a/src/tools.cpp
+++ b/src/tools.cpp
@@ -151,14 +151,12 @@ static void update_lookup_entry(lua_State* L_, int ctxBase_, int depth_)
151 std::string_view const _newName{ tools::PushFQN(L_, _fqn, depth_) }; // L_: ... {bfc} k o name? "f.q.n" 151 std::string_view const _newName{ tools::PushFQN(L_, _fqn, depth_) }; // L_: ... {bfc} k o name? "f.q.n"
152 // Lua 5.2 introduced a hash randomizer seed which causes table iteration to yield a different key order 152 // Lua 5.2 introduced a hash randomizer seed which causes table iteration to yield a different key order
153 // on different VMs even when the tables are populated the exact same way. 153 // on different VMs even when the tables are populated the exact same way.
154 // When Lua is built with compatibility options (such as LUA_COMPAT_ALL), 154 // Also, when Lua is built with compatibility options (such as LUA_COMPAT_ALL), some base libraries register functions under multiple names.
155 // this causes several base libraries to register functions under multiple names. 155 // This, with the randomizer, can cause the first generated name of an object to be different on different VMs, which breaks function transfer.
156 // This, with the randomizer, can cause the first generated name of an object to be different on different VMs,
157 // which breaks function transfer.
158 // Also, nothing prevents any external module from exposing a given object under several names, so... 156 // Also, nothing prevents any external module from exposing a given object under several names, so...
159 // Therefore, when we encounter an object for which a name was previously registered, we need to select the names 157 // Therefore, when we encounter an object for which a name was previously registered, we need to select the a single name
160 // based on some sorting order so that we end up with the same name in all databases whatever order the table walk yielded 158 // based on some sorting order so that we end up with the same name in all databases whatever order the table walk yielded
161 if (!_prevName.empty() && (_prevName.size() < _newName.size() || lua_lessthan(L_, -2, -1))) { 159 if (!_prevName.empty() && ((_prevName.size() < _newName.size()) || (_prevName <= _newName))) {
162 DEBUGSPEW_CODE(DebugSpew(_U) << lua_typename(L_, lua_type(L_, -3)) << " '" << _newName << "' remains named '" << _prevName << "'" << std::endl); 160 DEBUGSPEW_CODE(DebugSpew(_U) << lua_typename(L_, lua_type(L_, -3)) << " '" << _newName << "' remains named '" << _prevName << "'" << std::endl);
163 // the previous name is 'smaller' than the one we just generated: keep it! 161 // the previous name is 'smaller' than the one we just generated: keep it!
164 lua_pop(L_, 3); // L_: ... {bfc} k 162 lua_pop(L_, 3); // L_: ... {bfc} k