@@ -44,8 +44,8 @@ class Node {
4444 union {
4545 struct {
4646 Value value_; /* value */
47- lu_byte tt_; /* value type tag */
48- lu_byte key_tt; /* key type */
47+ LuaT tt_; /* value type tag */
48+ LuaT key_tt; /* key type */
4949 int next; /* for chaining */
5050 Value key_val; /* key value */
5151 } u;
@@ -54,10 +54,10 @@ class Node {
5454
5555public:
5656 // Default constructor
57- constexpr Node () noexcept : u{{0 }, static_cast <lu_byte>( LuaT::NIL), LUA_TNIL, 0 , {0 }} {}
57+ constexpr Node () noexcept : u{{0 }, LuaT::NIL, static_cast <LuaT>( LUA_TNIL) , 0 , {0 }} {}
5858
5959 // Constructor for initializing with explicit values
60- constexpr Node (Value val, lu_byte val_tt, lu_byte key_tt, int next_val, Value key_val) noexcept
60+ constexpr Node (Value val, LuaT val_tt, LuaT key_tt, int next_val, Value key_val) noexcept
6161 : u{val, val_tt, key_tt, next_val, key_val} {}
6262
6363 // Copy assignment operator (needed because union contains TValue with user-declared operator=)
@@ -76,8 +76,8 @@ class Node {
7676 void setNext (int n) noexcept { u.next = n; }
7777
7878 // Key type access
79- lu_byte getKeyType () const noexcept { return u.key_tt ; }
80- void setKeyType (lu_byte tt) noexcept { u.key_tt = tt; }
79+ LuaT getKeyType () const noexcept { return u.key_tt ; }
80+ void setKeyType (LuaT tt) noexcept { u.key_tt = tt; }
8181
8282 // Key value access
8383 const Value& getKeyValue () const noexcept { return u.key_val ; }
@@ -86,23 +86,23 @@ class Node {
8686
8787 // Key type checks
8888 bool isKeyNil () const noexcept {
89- return u.key_tt == LUA_TNIL;
89+ return novariant ( u.key_tt ) == LUA_TNIL;
9090 }
9191
9292 bool isKeyInteger () const noexcept {
93- return u.key_tt == LUA_VNUMINT ;
93+ return u.key_tt == LuaT::NUMINT ;
9494 }
9595
9696 bool isKeyShrStr () const noexcept {
97- return u.key_tt == ctb (LUA_VSHRSTR );
97+ return u.key_tt == ctb (LuaT::SHRSTR );
9898 }
9999
100100 bool isKeyDead () const noexcept {
101- return u.key_tt == LUA_TDEADKEY;
101+ return novariant ( u.key_tt ) == LUA_TDEADKEY;
102102 }
103103
104104 bool isKeyCollectable () const noexcept {
105- return (u.key_tt & BIT_ISCOLLECTABLE) != 0 ;
105+ return (static_cast < int >( u.key_tt ) & BIT_ISCOLLECTABLE) != 0 ;
106106 }
107107
108108 // Key value getters (typed)
@@ -124,11 +124,11 @@ class Node {
124124
125125 // Key setters
126126 void setKeyNil () noexcept {
127- u.key_tt = LUA_TNIL ;
127+ u.key_tt = LuaT::NIL ;
128128 }
129129
130130 void setKeyDead () noexcept {
131- u.key_tt = LUA_TDEADKEY;
131+ u.key_tt = static_cast <LuaT>( LUA_TDEADKEY) ;
132132 }
133133
134134 // Copy TValue to key
@@ -244,12 +244,12 @@ class Table : public GCBase<Table> {
244244 return static_cast <const unsigned int *>(static_cast <const void *>(array));
245245 }
246246
247- lu_byte * getArrayTag (lua_Unsigned k) noexcept {
248- return static_cast <lu_byte*>(static_cast <void *>(array)) + sizeof (unsigned ) + k;
247+ LuaT * getArrayTag (lua_Unsigned k) noexcept {
248+ return reinterpret_cast <LuaT*>( static_cast <lu_byte*>(static_cast <void *>(array)) + sizeof (unsigned ) + k) ;
249249 }
250250
251- const lu_byte * getArrayTag (lua_Unsigned k) const noexcept {
252- return static_cast <const lu_byte*>(static_cast <const void *>(array)) + sizeof (unsigned ) + k;
251+ const LuaT * getArrayTag (lua_Unsigned k) const noexcept {
252+ return reinterpret_cast < const LuaT*>( static_cast <const lu_byte*>(static_cast <const void *>(array)) + sizeof (unsigned ) + k) ;
253253 }
254254
255255 Value* getArrayVal (lua_Unsigned k) noexcept {
@@ -269,10 +269,10 @@ class Table : public GCBase<Table> {
269269 const Node* getNode (unsigned int i) const noexcept { return &node[i]; }
270270
271271 // Method declarations (implemented in ltable.cpp)
272- lu_byte get (const TValue* key, TValue* res);
273- lu_byte getInt (lua_Integer key, TValue* res);
274- lu_byte getShortStr (TString* key, TValue* res);
275- lu_byte getStr (TString* key, TValue* res);
272+ LuaT get (const TValue* key, TValue* res);
273+ LuaT getInt (lua_Integer key, TValue* res);
274+ LuaT getShortStr (TString* key, TValue* res);
275+ LuaT getStr (TString* key, TValue* res);
276276 TValue* HgetShortStr (TString* key);
277277
278278 int pset (const TValue* key, TValue* val);
@@ -432,20 +432,20 @@ inline void obj2arr(Table* h, lua_Unsigned k, const TValue* val) noexcept {
432432** following inline functions also move TValues to/from arrays, but receive the
433433** precomputed tag value or address as an extra argument.
434434*/
435- inline void farr2val (const Table* h, lua_Unsigned k, lu_byte tag, TValue* res) noexcept {
435+ inline void farr2val (const Table* h, lua_Unsigned k, LuaT tag, TValue* res) noexcept {
436436 res->setType (tag);
437437 res->valueField () = *h->getArrayVal (k);
438438}
439439
440- inline void fval2arr (Table* h, lua_Unsigned k, lu_byte * tag, const TValue* val) noexcept {
440+ inline void fval2arr (Table* h, lua_Unsigned k, LuaT * tag, const TValue* val) noexcept {
441441 *tag = val->getType ();
442442 *h->getArrayVal (k) = val->getValue ();
443443}
444444
445- LUAI_FUNC lu_byte luaH_get (Table *t, const TValue *key, TValue *res);
446- LUAI_FUNC lu_byte luaH_getshortstr (Table *t, TString *key, TValue *res);
447- LUAI_FUNC lu_byte luaH_getstr (Table *t, TString *key, TValue *res);
448- LUAI_FUNC lu_byte luaH_getint (Table *t, lua_Integer key, TValue *res);
445+ LUAI_FUNC LuaT luaH_get (Table *t, const TValue *key, TValue *res);
446+ LUAI_FUNC LuaT luaH_getshortstr (Table *t, TString *key, TValue *res);
447+ LUAI_FUNC LuaT luaH_getstr (Table *t, TString *key, TValue *res);
448+ LUAI_FUNC LuaT luaH_getint (Table *t, lua_Integer key, TValue *res);
449449
450450/* Special get for metamethods */
451451LUAI_FUNC const TValue *luaH_Hgetshortstr (Table *t, TString *key);
0 commit comments