diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-03-26 17:46:00 +0100 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-03-26 17:46:00 +0100 |
commit | f214d35df5f09e7026dafd8553e83cc6ea21cbde (patch) | |
tree | 2bd19bfddf4949183fe0e84ca58940fd6a6aa918 /src/lanes.cpp | |
parent | 2eeb245b98bd702379aa92d888f7b7d21d1193b8 (diff) | |
download | lanes-f214d35df5f09e7026dafd8553e83cc6ea21cbde.tar.gz lanes-f214d35df5f09e7026dafd8553e83cc6ea21cbde.tar.bz2 lanes-f214d35df5f09e7026dafd8553e83cc6ea21cbde.zip |
C++ migration: templated lua_touserdata
Diffstat (limited to 'src/lanes.cpp')
-rw-r--r-- | src/lanes.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lanes.cpp b/src/lanes.cpp index 5945a1a..6b3542b 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp | |||
@@ -442,7 +442,7 @@ static bool selfdestruct_remove( Lane* s) | |||
442 | */ | 442 | */ |
443 | static int selfdestruct_gc( lua_State* L) | 443 | static int selfdestruct_gc( lua_State* L) |
444 | { | 444 | { |
445 | Universe* U = (Universe*) lua_touserdata( L, 1); | 445 | Universe* const U{ lua_touserdata<Universe>(L, 1) }; |
446 | 446 | ||
447 | while( U->selfdestruct_first != SELFDESTRUCT_END) // true at most once! | 447 | while( U->selfdestruct_first != SELFDESTRUCT_END) // true at most once! |
448 | { | 448 | { |
@@ -781,7 +781,7 @@ LUAG_FUNC( set_debug_threadname) | |||
781 | // fnv164 of string "debug_threadname" generated at https://www.pelock.com/products/hash-calculator | 781 | // fnv164 of string "debug_threadname" generated at https://www.pelock.com/products/hash-calculator |
782 | constexpr UniqueKey hidden_regkey{ 0x79C0669AAAE04440ull }; | 782 | constexpr UniqueKey hidden_regkey{ 0x79C0669AAAE04440ull }; |
783 | // C s_lane structure is a light userdata upvalue | 783 | // C s_lane structure is a light userdata upvalue |
784 | Lane* s = (Lane*) lua_touserdata( L, lua_upvalueindex( 1)); | 784 | Lane* const s{ lua_touserdata<Lane>(L, lua_upvalueindex(1)) }; |
785 | luaL_checktype( L, -1, LUA_TSTRING); // "name" | 785 | luaL_checktype( L, -1, LUA_TSTRING); // "name" |
786 | lua_settop( L, 1); | 786 | lua_settop( L, 1); |
787 | STACK_CHECK_START_ABS( L, 1); | 787 | STACK_CHECK_START_ABS( L, 1); |
@@ -1887,7 +1887,7 @@ LUAG_FUNC( configure) | |||
1887 | STACK_CHECK( L, 2); | 1887 | STACK_CHECK( L, 2); |
1888 | 1888 | ||
1889 | // Proxy userdata contents is only a 'DeepPrelude*' pointer | 1889 | // Proxy userdata contents is only a 'DeepPrelude*' pointer |
1890 | U->timer_deep = *(DeepPrelude**) lua_touserdata( L, -1); | 1890 | U->timer_deep = *lua_touserdata<DeepPrelude*>(L, -1); |
1891 | // increment refcount so that this linda remains alive as long as the universe exists. | 1891 | // increment refcount so that this linda remains alive as long as the universe exists. |
1892 | U->timer_deep->m_refcount.fetch_add(1, std::memory_order_relaxed); | 1892 | U->timer_deep->m_refcount.fetch_add(1, std::memory_order_relaxed); |
1893 | lua_pop( L, 1); // settings | 1893 | lua_pop( L, 1); // settings |