aboutsummaryrefslogtreecommitdiff
path: root/deep_test
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-10-24 14:53:09 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-10-24 14:53:09 +0200
commit4044e86ea4197535b70bc434634faf90cd2317d0 (patch)
tree522af1b44e3dda30ff66ed2245aad54ceeb7e1b2 /deep_test
parent958ed4f1e29418e90f3dd3de6779e30e05f70448 (diff)
downloadlanes-4044e86ea4197535b70bc434634faf90cd2317d0.tar.gz
lanes-4044e86ea4197535b70bc434634faf90cd2317d0.tar.bz2
lanes-4044e86ea4197535b70bc434634faf90cd2317d0.zip
Strengthen more code with UserValueIndex
Diffstat (limited to 'deep_test')
-rw-r--r--deep_test/deep_test.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/deep_test/deep_test.cpp b/deep_test/deep_test.cpp
index 974709f..43df188 100644
--- a/deep_test/deep_test.cpp
+++ b/deep_test/deep_test.cpp
@@ -70,7 +70,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* const L_, DeepPrelude* c
70{ 70{
71 MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L, StackIndex{ 1 })) }; 71 MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L, StackIndex{ 1 })) };
72 _self->inUse.fetch_add(1, std::memory_order_seq_cst); 72 _self->inUse.fetch_add(1, std::memory_order_seq_cst);
73 int _uv = (int) luaL_optinteger(L, 2, 1); 73 UserValueIndex const _uv{ static_cast<UserValueIndex::type>(luaL_optinteger(L, 2, 1)) };
74 lua_getiuservalue(L, StackIndex{ 1 }, _uv); 74 lua_getiuservalue(L, StackIndex{ 1 }, _uv);
75 _self->inUse.fetch_sub(1, std::memory_order_seq_cst); 75 _self->inUse.fetch_sub(1, std::memory_order_seq_cst);
76 return 1; 76 return 1;
@@ -106,7 +106,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* const L_, DeepPrelude* c
106{ 106{
107 MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L, StackIndex{ 1 })) }; 107 MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L, StackIndex{ 1 })) };
108 _self->inUse.fetch_add(1, std::memory_order_seq_cst); 108 _self->inUse.fetch_add(1, std::memory_order_seq_cst);
109 int _uv = (int) luaL_optinteger(L, 2, 1); 109 UserValueIndex const _uv{ static_cast<UserValueIndex::type>(luaL_optinteger(L, 2, 1)) };
110 lua_settop(L, 3); 110 lua_settop(L, 3);
111 lua_pushboolean(L, lua_setiuservalue(L, StackIndex{ 1 }, _uv) != 0); 111 lua_pushboolean(L, lua_setiuservalue(L, StackIndex{ 1 }, _uv) != 0);
112 _self->inUse.fetch_sub(1, std::memory_order_seq_cst); 112 _self->inUse.fetch_sub(1, std::memory_order_seq_cst);
@@ -157,10 +157,10 @@ struct MyClonableUserdata
157 157
158[[nodiscard]] static int clonable_setuv(lua_State* L) 158[[nodiscard]] static int clonable_setuv(lua_State* L)
159{ 159{
160 MyClonableUserdata* self = static_cast<MyClonableUserdata*>(lua_touserdata(L, 1)); 160 MyClonableUserdata* const _self{ static_cast<MyClonableUserdata*>(lua_touserdata(L, 1)) };
161 int uv = (int) luaL_optinteger(L, 2, 1); 161 UserValueIndex const _uv{ static_cast<UserValueIndex::type>(luaL_optinteger(L, 2, 1)) };
162 lua_settop(L, 3); 162 lua_settop(L, 3);
163 lua_pushboolean(L, lua_setiuservalue(L, StackIndex{ 1 }, uv) != 0); 163 lua_pushboolean(L, lua_setiuservalue(L, StackIndex{ 1 }, _uv) != 0);
164 return 1; 164 return 1;
165} 165}
166 166
@@ -168,9 +168,9 @@ struct MyClonableUserdata
168 168
169[[nodiscard]] static int clonable_getuv(lua_State* L) 169[[nodiscard]] static int clonable_getuv(lua_State* L)
170{ 170{
171 MyClonableUserdata* self = static_cast<MyClonableUserdata*>(lua_touserdata(L, 1)); 171 MyClonableUserdata* const _self{ static_cast<MyClonableUserdata*>(lua_touserdata(L, 1)) };
172 int uv = (int) luaL_optinteger(L, 2, 1); 172 UserValueIndex const _uv{ static_cast<UserValueIndex::type>(luaL_optinteger(L, 2, 1)) };
173 lua_getiuservalue(L, StackIndex{ 1 }, uv); 173 lua_getiuservalue(L, StackIndex{ 1 }, _uv);
174 return 1; 174 return 1;
175} 175}
176 176