diff options
| author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-10-08 18:42:39 +0200 |
|---|---|---|
| committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-10-08 18:42:39 +0200 |
| commit | 16b5070c0cd56e10c5074eb9903dbc3ae4e15a61 (patch) | |
| tree | f6d5cdb74b505e13aa3261f7ab6192da0133b7b9 /deep_test | |
| parent | e939e5e6a894a042d3301e47faa05264445f27f6 (diff) | |
| download | lanes-16b5070c0cd56e10c5074eb9903dbc3ae4e15a61.tar.gz lanes-16b5070c0cd56e10c5074eb9903dbc3ae4e15a61.tar.bz2 lanes-16b5070c0cd56e10c5074eb9903dbc3ae4e15a61.zip | |
Sprinkling StackIndex all over the place
Diffstat (limited to 'deep_test')
| -rw-r--r-- | deep_test/deep_test.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/deep_test/deep_test.cpp b/deep_test/deep_test.cpp index c071dc6..39352f3 100644 --- a/deep_test/deep_test.cpp +++ b/deep_test/deep_test.cpp | |||
| @@ -47,7 +47,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* const L_, DeepPrelude* c | |||
| 47 | 47 | ||
| 48 | [[nodiscard]] static int deep_gc(lua_State* L) | 48 | [[nodiscard]] static int deep_gc(lua_State* L) |
| 49 | { | 49 | { |
| 50 | MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L, 1)) }; | 50 | MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L, StackIndex{ 1 })) }; |
| 51 | luaL_argcheck(L, 1, !_self->inUse.load(), "being collected while in use!"); | 51 | luaL_argcheck(L, 1, !_self->inUse.load(), "being collected while in use!"); |
| 52 | return 0; | 52 | return 0; |
| 53 | } | 53 | } |
| @@ -56,7 +56,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* const L_, DeepPrelude* c | |||
| 56 | 56 | ||
| 57 | [[nodiscard]] static int deep_tostring(lua_State* L) | 57 | [[nodiscard]] static int deep_tostring(lua_State* L) |
| 58 | { | 58 | { |
| 59 | MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L, 1)) }; | 59 | MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L, StackIndex{ 1 })) }; |
| 60 | _self->inUse.fetch_add(1, std::memory_order_seq_cst); | 60 | _self->inUse.fetch_add(1, std::memory_order_seq_cst); |
| 61 | luaG_pushstring(L, "%p:deep(%d)", _self, _self->val); | 61 | luaG_pushstring(L, "%p:deep(%d)", _self, _self->val); |
| 62 | _self->inUse.fetch_sub(1, std::memory_order_seq_cst); | 62 | _self->inUse.fetch_sub(1, std::memory_order_seq_cst); |
| @@ -68,10 +68,10 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* const L_, DeepPrelude* c | |||
| 68 | // won't actually do anything as deep userdata don't have uservalue slots | 68 | // won't actually do anything as deep userdata don't have uservalue slots |
| 69 | [[nodiscard]] static int deep_getuv(lua_State* L) | 69 | [[nodiscard]] static int deep_getuv(lua_State* L) |
| 70 | { | 70 | { |
| 71 | MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L, 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 | int _uv = (int) luaL_optinteger(L, 2, 1); |
| 74 | lua_getiuservalue(L, 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; |
| 77 | } | 77 | } |
| @@ -80,7 +80,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* const L_, DeepPrelude* c | |||
| 80 | 80 | ||
| 81 | [[nodiscard]] static int deep_invoke(lua_State* L) | 81 | [[nodiscard]] static int deep_invoke(lua_State* L) |
| 82 | { | 82 | { |
| 83 | MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L, 1)) }; | 83 | MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L, StackIndex{ 1 })) }; |
| 84 | luaL_argcheck(L, 2, lua_gettop(L) >= 2, "need something to call"); | 84 | luaL_argcheck(L, 2, lua_gettop(L) >= 2, "need something to call"); |
| 85 | _self->inUse.fetch_add(1, std::memory_order_seq_cst); | 85 | _self->inUse.fetch_add(1, std::memory_order_seq_cst); |
| 86 | lua_call(L, lua_gettop(L) - 2, LUA_MULTRET); | 86 | lua_call(L, lua_gettop(L) - 2, LUA_MULTRET); |
| @@ -92,7 +92,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* const L_, DeepPrelude* c | |||
| 92 | 92 | ||
| 93 | [[nodiscard]] static int deep_set(lua_State* const L_) | 93 | [[nodiscard]] static int deep_set(lua_State* const L_) |
| 94 | { | 94 | { |
| 95 | MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L_, 1)) }; | 95 | MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L_, StackIndex{ 1 })) }; |
| 96 | _self->inUse.fetch_add(1, std::memory_order_seq_cst); | 96 | _self->inUse.fetch_add(1, std::memory_order_seq_cst); |
| 97 | lua_Integer _i = lua_tointeger(L_, 2); | 97 | lua_Integer _i = lua_tointeger(L_, 2); |
| 98 | _self->val = _i; | 98 | _self->val = _i; |
| @@ -104,11 +104,11 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* const L_, DeepPrelude* c | |||
| 104 | 104 | ||
| 105 | [[nodiscard]] static int deep_setuv(lua_State* L) | 105 | [[nodiscard]] static int deep_setuv(lua_State* L) |
| 106 | { | 106 | { |
| 107 | MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L, 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 | int _uv = (int) luaL_optinteger(L, 2, 1); |
| 110 | lua_settop(L, 3); | 110 | lua_settop(L, 3); |
| 111 | lua_pushboolean(L, lua_setiuservalue(L, 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); |
| 113 | return 1; | 113 | return 1; |
| 114 | } | 114 | } |
| @@ -160,7 +160,7 @@ struct MyClonableUserdata | |||
| 160 | MyClonableUserdata* self = static_cast<MyClonableUserdata*>(lua_touserdata(L, 1)); | 160 | MyClonableUserdata* self = static_cast<MyClonableUserdata*>(lua_touserdata(L, 1)); |
| 161 | int uv = (int) luaL_optinteger(L, 2, 1); | 161 | int uv = (int) luaL_optinteger(L, 2, 1); |
| 162 | lua_settop(L, 3); | 162 | lua_settop(L, 3); |
| 163 | lua_pushboolean(L, lua_setiuservalue(L, 1, uv) != 0); | 163 | lua_pushboolean(L, lua_setiuservalue(L, StackIndex{ 1 }, uv) != 0); |
| 164 | return 1; | 164 | return 1; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| @@ -170,7 +170,7 @@ struct MyClonableUserdata | |||
| 170 | { | 170 | { |
| 171 | MyClonableUserdata* self = static_cast<MyClonableUserdata*>(lua_touserdata(L, 1)); | 171 | MyClonableUserdata* self = static_cast<MyClonableUserdata*>(lua_touserdata(L, 1)); |
| 172 | int uv = (int) luaL_optinteger(L, 2, 1); | 172 | int uv = (int) luaL_optinteger(L, 2, 1); |
| 173 | lua_getiuservalue(L, 1, uv); | 173 | lua_getiuservalue(L, StackIndex{ 1 }, uv); |
| 174 | return 1; | 174 | return 1; |
| 175 | } | 175 | } |
| 176 | 176 | ||
