aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compat.cpp8
-rw-r--r--src/compat.h4
-rw-r--r--src/keeper.cpp2
-rw-r--r--src/lane.cpp18
-rw-r--r--src/lanes.cpp2
-rw-r--r--src/nameof.cpp2
6 files changed, 18 insertions, 18 deletions
diff --git a/src/compat.cpp b/src/compat.cpp
index b661b28..04ac819 100644
--- a/src/compat.cpp
+++ b/src/compat.cpp
@@ -9,7 +9,7 @@ UserValueCount luaG_getalluservalues(lua_State* const L_, StackIndex const idx_)
9{ 9{
10 STACK_CHECK_START_REL(L_, 0); 10 STACK_CHECK_START_REL(L_, 0);
11 StackIndex const _idx{ luaG_absindex(L_, idx_) }; 11 StackIndex const _idx{ luaG_absindex(L_, idx_) };
12 UserValueCount _nuv{ 0 }; 12 UserValueIndex _nuv{ 0 };
13 do { 13 do {
14 // we don't know how many uservalues we are going to extract, there might be a lot... 14 // we don't know how many uservalues we are going to extract, there might be a lot...
15 STACK_GROW(L_, 1); 15 STACK_GROW(L_, 1);
@@ -18,7 +18,7 @@ UserValueCount luaG_getalluservalues(lua_State* const L_, StackIndex const idx_)
18 lua_pop(L_, 1); // L_: ... [uv]* 18 lua_pop(L_, 1); // L_: ... [uv]*
19 --_nuv; 19 --_nuv;
20 STACK_CHECK(L_, _nuv); 20 STACK_CHECK(L_, _nuv);
21 return _nuv; 21 return UserValueCount{ _nuv.value() };
22} 22}
23 23
24// ################################################################################################# 24// #################################################################################################
@@ -92,7 +92,7 @@ void* lua_newuserdatauv(lua_State* const L_, size_t const sz_, [[maybe_unused]]
92// ################################################################################################# 92// #################################################################################################
93 93
94// push on stack uservalue #n of full userdata at idx 94// push on stack uservalue #n of full userdata at idx
95int lua_getiuservalue(lua_State* const L_, StackIndex const idx_, int const n_) 95int lua_getiuservalue(lua_State* const L_, StackIndex const idx_, UserValueIndex const n_)
96{ 96{
97 STACK_CHECK_START_REL(L_, 0); 97 STACK_CHECK_START_REL(L_, 0);
98 // full userdata can have only 1 uservalue before 5.4 98 // full userdata can have only 1 uservalue before 5.4
@@ -129,7 +129,7 @@ int lua_getiuservalue(lua_State* const L_, StackIndex const idx_, int const n_)
129 129
130// Pops a value from the stack and sets it as the new n-th user value associated to the full userdata at the given index. 130// Pops a value from the stack and sets it as the new n-th user value associated to the full userdata at the given index.
131// Returns 0 if the userdata does not have that value. 131// Returns 0 if the userdata does not have that value.
132int lua_setiuservalue(lua_State* const L_, StackIndex const idx_, int const n_) 132int lua_setiuservalue(lua_State* const L_, StackIndex const idx_, UserValueIndex const n_)
133{ 133{
134 if (n_ > 1 134 if (n_ > 1
135#if LUA_VERSION_NUM == 501 135#if LUA_VERSION_NUM == 501
diff --git a/src/compat.h b/src/compat.h
index 0b6b12b..0ea35bf 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -81,8 +81,8 @@ inline int luaL_optint(lua_State* L_, int n_, lua_Integer d_)
81#if LUA_VERSION_NUM < 504 81#if LUA_VERSION_NUM < 504
82 82
83void* lua_newuserdatauv(lua_State* L_, size_t sz_, UserValueCount nuvalue_); 83void* lua_newuserdatauv(lua_State* L_, size_t sz_, UserValueCount nuvalue_);
84int lua_getiuservalue(lua_State* L_, StackIndex idx_, int n_); 84int lua_getiuservalue(lua_State* L_, StackIndex idx_, UserValueIndex n_);
85int lua_setiuservalue(lua_State* L_, StackIndex idx_, int n_); 85int lua_setiuservalue(lua_State* L_, StackIndex idx_, UserValueIndex n_);
86 86
87#define LUA_GNAME "_G" 87#define LUA_GNAME "_G"
88 88
diff --git a/src/keeper.cpp b/src/keeper.cpp
index 7deb2b3..4b1ae3d 100644
--- a/src/keeper.cpp
+++ b/src/keeper.cpp
@@ -63,7 +63,7 @@ namespace {
63class KeyUD 63class KeyUD
64{ 64{
65 private: 65 private:
66 static constexpr int kContentsTableIndex{ 1 }; 66 static constexpr UserValueIndex kContentsTableIndex{ 1 };
67 67
68 public: 68 public:
69 static constexpr std::string_view kUnder{ "under" }; 69 static constexpr std::string_view kUnder{ "under" };
diff --git a/src/lane.cpp b/src/lane.cpp
index 29ad8bb..65cb58d 100644
--- a/src/lane.cpp
+++ b/src/lane.cpp
@@ -150,7 +150,7 @@ static LUAG_FUNC(thread_join)
150 if (_stored == 0) { 150 if (_stored == 0) {
151 raise_luaL_error(L_, _lane->L ? "First return value must be non-nil when using join()" : "Can't join() more than once or after indexing"); 151 raise_luaL_error(L_, _lane->L ? "First return value must be non-nil when using join()" : "Can't join() more than once or after indexing");
152 } 152 }
153 lua_getiuservalue(L_, StackIndex{ 1 }, 1); // L_: lane {uv} 153 lua_getiuservalue(L_, StackIndex{ 1 }, UserValueIndex{ 1 }); // L_: lane {uv}
154 for (int _i = 2; _i <= _stored; ++_i) { 154 for (int _i = 2; _i <= _stored; ++_i) {
155 lua_rawgeti(L_, 2, _i); // L_: lane {uv} results2...N 155 lua_rawgeti(L_, 2, _i); // L_: lane {uv} results2...N
156 } 156 }
@@ -163,7 +163,7 @@ static LUAG_FUNC(thread_join)
163 case Lane::Error: 163 case Lane::Error:
164 { 164 {
165 LUA_ASSERT(L_, _stored == 2 || _stored == 3); 165 LUA_ASSERT(L_, _stored == 2 || _stored == 3);
166 lua_getiuservalue(L_, StackIndex{ 1 }, 1); // L_: lane {uv} 166 lua_getiuservalue(L_, StackIndex{ 1 }, UserValueIndex{ 1 }); // L_: lane {uv}
167 lua_rawgeti(L_, 2, 2); // L_: lane {uv} <error> 167 lua_rawgeti(L_, 2, 2); // L_: lane {uv} <error>
168 lua_rawgeti(L_, 2, 3); // L_: lane {uv} <error> <trace>|nil 168 lua_rawgeti(L_, 2, 3); // L_: lane {uv} <error> <trace>|nil
169 if (lua_isnil(L_, -1)) { 169 if (lua_isnil(L_, -1)) {
@@ -178,7 +178,7 @@ static LUAG_FUNC(thread_join)
178 178
179 case Lane::Cancelled: 179 case Lane::Cancelled:
180 LUA_ASSERT(L_, _stored == 2); 180 LUA_ASSERT(L_, _stored == 2);
181 lua_getiuservalue(L_, StackIndex{ 1 }, 1); // L_: lane {uv} 181 lua_getiuservalue(L_, StackIndex{ 1 }, UserValueIndex{ 1 }); // L_: lane {uv}
182 lua_rawgeti(L_, 2, 2); // L_: lane {uv} cancel_error 182 lua_rawgeti(L_, 2, 2); // L_: lane {uv} cancel_error
183 lua_rawgeti(L_, 2, 1); // L_: lane {uv} cancel_error nil 183 lua_rawgeti(L_, 2, 1); // L_: lane {uv} cancel_error nil
184 lua_replace(L_, -3); // L_: lane nil cancel_error 184 lua_replace(L_, -3); // L_: lane nil cancel_error
@@ -828,7 +828,7 @@ static LUAG_FUNC(lane_gc)
828 Lane* const _lane{ ToLane(L_, StackIndex{ 1 }) }; // L_: ud 828 Lane* const _lane{ ToLane(L_, StackIndex{ 1 }) }; // L_: ud
829 829
830 // if there a gc callback? 830 // if there a gc callback?
831 lua_getiuservalue(L_, StackIndex{ 1 }, 1); // L_: ud uservalue 831 lua_getiuservalue(L_, StackIndex{ 1 }, UserValueIndex{ 1 }); // L_: ud uservalue
832 kLaneGC.pushKey(L_); // L_: ud uservalue __gc 832 kLaneGC.pushKey(L_); // L_: ud uservalue __gc
833 lua_rawget(L_, -2); // L_: ud uservalue gc_cb|nil 833 lua_rawget(L_, -2); // L_: ud uservalue gc_cb|nil
834 if (!lua_isnil(L_, -1)) { 834 if (!lua_isnil(L_, -1)) {
@@ -1070,7 +1070,7 @@ void Lane::pushIndexedResult(lua_State* const L_, int const key_) const
1070 LUA_ASSERT(L_, ToLane(L_, kIdxSelf) == this); // L_: lane ... 1070 LUA_ASSERT(L_, ToLane(L_, kIdxSelf) == this); // L_: lane ...
1071 STACK_GROW(L_, 3); 1071 STACK_GROW(L_, 3);
1072 1072
1073 lua_getiuservalue(L_, kIdxSelf, 1); // L_: lane ... {uv} 1073 lua_getiuservalue(L_, kIdxSelf, UserValueIndex{ 1 }); // L_: lane ... {uv}
1074 if (status != Lane::Error) { 1074 if (status != Lane::Error) {
1075 lua_rawgeti(L_, -1, key_); // L_: lane ... {uv} uv[i] 1075 lua_rawgeti(L_, -1, key_); // L_: lane ... {uv} uv[i]
1076 lua_remove(L_, -2); // L_: lane ... uv[i] 1076 lua_remove(L_, -2); // L_: lane ... uv[i]
@@ -1138,7 +1138,7 @@ void Lane::resetResultsStorage(lua_State* const L_, StackIndex const self_idx_)
1138 // create the new table 1138 // create the new table
1139 lua_newtable(L_); // L_: ... self ... {} 1139 lua_newtable(L_); // L_: ... self ... {}
1140 // get the current table 1140 // get the current table
1141 lua_getiuservalue(L_, _self_idx, 1); // L_: ... self ... {} {uv} 1141 lua_getiuservalue(L_, _self_idx, UserValueIndex{ 1 }); // L_: ... self ... {} {uv}
1142 LUA_ASSERT(L_, lua_istable(L_, -1)); 1142 LUA_ASSERT(L_, lua_istable(L_, -1));
1143 // read gc_cb from the current table 1143 // read gc_cb from the current table
1144 kLaneGC.pushKey(L_); // L_: ... self ... {} {uv} kLaneGC 1144 kLaneGC.pushKey(L_); // L_: ... self ... {} {uv} kLaneGC
@@ -1149,7 +1149,7 @@ void Lane::resetResultsStorage(lua_State* const L_, StackIndex const self_idx_)
1149 // we can forget the old table 1149 // we can forget the old table
1150 lua_pop(L_, 1); // L_: ... self ... {} 1150 lua_pop(L_, 1); // L_: ... self ... {}
1151 // and store the new one 1151 // and store the new one
1152 lua_setiuservalue(L_, _self_idx, 1); // L_: ... self ... 1152 lua_setiuservalue(L_, _self_idx, UserValueIndex{ 1 }); // L_: ... self ...
1153 STACK_CHECK(L_, 0); 1153 STACK_CHECK(L_, 0);
1154} 1154}
1155 1155
@@ -1161,7 +1161,7 @@ void Lane::securizeDebugName(lua_State* const L_)
1161 STACK_CHECK_START_REL(L_, 0); 1161 STACK_CHECK_START_REL(L_, 0);
1162 STACK_GROW(L_, 3); 1162 STACK_GROW(L_, 3);
1163 // a Lane's uservalue should be a table 1163 // a Lane's uservalue should be a table
1164 lua_getiuservalue(L_, StackIndex{ 1 }, 1); // L_: lane ... {uv} 1164 lua_getiuservalue(L_, StackIndex{ 1 }, UserValueIndex{ 1 }); // L_: lane ... {uv}
1165 LUA_ASSERT(L_, lua_istable(L_, -1)); 1165 LUA_ASSERT(L_, lua_istable(L_, -1));
1166 // we don't care about the actual key, so long as it's unique and can't collide with anything. 1166 // we don't care about the actual key, so long as it's unique and can't collide with anything.
1167 lua_newtable(L_); // L_: lane ... {uv} {} 1167 lua_newtable(L_); // L_: lane ... {uv} {}
@@ -1195,7 +1195,7 @@ int Lane::storeResults(lua_State* const L_)
1195 LUA_ASSERT(L_, ToLane(L_, kIdxSelf) == this); 1195 LUA_ASSERT(L_, ToLane(L_, kIdxSelf) == this);
1196 1196
1197 STACK_CHECK_START_REL(L_, 0); 1197 STACK_CHECK_START_REL(L_, 0);
1198 lua_getiuservalue(L_, kIdxSelf, 1); // L_: lane ... {uv} 1198 lua_getiuservalue(L_, kIdxSelf, UserValueIndex{ 1 }); // L_: lane ... {uv}
1199 StackIndex const _tidx{ lua_gettop(L_) }; 1199 StackIndex const _tidx{ lua_gettop(L_) };
1200 1200
1201 int _stored{}; 1201 int _stored{};
diff --git a/src/lanes.cpp b/src/lanes.cpp
index e545ca0..8c4ef61 100644
--- a/src/lanes.cpp
+++ b/src/lanes.cpp
@@ -350,7 +350,7 @@ LUAG_FUNC(lane_new)
350 } 350 }
351 STACK_CHECK(L, 2); 351 STACK_CHECK(L, 2);
352 // store the uservalue in the Lane full userdata 352 // store the uservalue in the Lane full userdata
353 lua_setiuservalue(L, StackIndex{ -2 }, 1); // L: ... lane 353 lua_setiuservalue(L, StackIndex{ -2 }, UserValueIndex{ 1 }); // L: ... lane
354 354
355 lua_State* const _L2{ lane->L }; 355 lua_State* const _L2{ lane->L };
356 STACK_CHECK_START_REL(_L2, 0); 356 STACK_CHECK_START_REL(_L2, 0);
diff --git a/src/nameof.cpp b/src/nameof.cpp
index fd31a28..ef03820 100644
--- a/src/nameof.cpp
+++ b/src/nameof.cpp
@@ -125,7 +125,7 @@ THE SOFTWARE.
125 STACK_CHECK(L_, 2); 125 STACK_CHECK(L_, 2);
126 // search in the object's uservalues 126 // search in the object's uservalues
127 { 127 {
128 int _uvi{ 1 }; 128 UserValueIndex _uvi{ 1 };
129 while (lua_getiuservalue(L_, kIdxTop, _uvi) != LUA_TNONE) { // L_: o "r" {c} {fqn} ... {?} k U {u} 129 while (lua_getiuservalue(L_, kIdxTop, _uvi) != LUA_TNONE) { // L_: o "r" {c} {fqn} ... {?} k U {u}
130 if (lua_istable(L_, -1)) { // if it is a table, look inside 130 if (lua_istable(L_, -1)) { // if it is a table, look inside
131 ++depth_; 131 ++depth_;