@@ -55,16 +55,16 @@ constexpr bool tagisempty(int tag) noexcept { return novariant(tag) == LUA_TNIL;
5555
5656
5757/* macro to test for a standard nil */
58- constexpr bool ttisstrictnil (const TValue* o) noexcept { return checktag (o, LUA_VNIL ); }
58+ constexpr bool ttisstrictnil (const TValue* o) noexcept { return checktag (o, LuaT::NIL ); }
5959
60- constexpr bool TValue::isStrictNil () const noexcept { return checktag (this , LUA_VNIL ); }
60+ constexpr bool TValue::isStrictNil () const noexcept { return checktag (this , LuaT::NIL ); }
6161
6262inline void setnilvalue (TValue* obj) noexcept { obj->setNil (); }
6363
6464
65- constexpr bool isabstkey (const TValue* v) noexcept { return checktag (v, LUA_VABSTKEY ); }
65+ constexpr bool isabstkey (const TValue* v) noexcept { return checktag (v, LuaT::ABSTKEY ); }
6666
67- constexpr bool TValue::isAbstKey () const noexcept { return checktag (this , LUA_VABSTKEY ); }
67+ constexpr bool TValue::isAbstKey () const noexcept { return checktag (this , LuaT::ABSTKEY ); }
6868
6969
7070/*
@@ -89,11 +89,11 @@ constexpr bool TValue::isEmpty() const noexcept { return isNil(); }
8989
9090
9191/* macro defining a value corresponding to an absent key */
92- #define ABSTKEYCONSTANT {nullptr }, LUA_VABSTKEY
92+ #define ABSTKEYCONSTANT {nullptr }, LuaT::ABSTKEY
9393
9494
9595/* mark an entry as empty */
96- inline void setempty (TValue* v) noexcept { settt_ (v, LUA_VEMPTY ); }
96+ inline void setempty (TValue* v) noexcept { settt_ (v, LuaT::EMPTY ); }
9797
9898/* }================================================================== */
9999
@@ -106,15 +106,16 @@ inline void setempty(TValue* v) noexcept { settt_(v, LUA_VEMPTY); }
106106*/
107107
108108constexpr bool ttisboolean (const TValue* o) noexcept { return checktype (o, LUA_TBOOLEAN); }
109- constexpr bool ttisfalse (const TValue* o) noexcept { return checktag (o, LUA_VFALSE ); }
110- constexpr bool ttistrue (const TValue* o) noexcept { return checktag (o, LUA_VTRUE ); }
109+ constexpr bool ttisfalse (const TValue* o) noexcept { return checktag (o, LuaT::VFALSE ); }
110+ constexpr bool ttistrue (const TValue* o) noexcept { return checktag (o, LuaT::VTRUE ); }
111111
112112constexpr bool TValue::isBoolean () const noexcept { return checktype (this , LUA_TBOOLEAN); }
113- constexpr bool TValue::isFalse () const noexcept { return checktag (this , LUA_VFALSE ); }
114- constexpr bool TValue::isTrue () const noexcept { return checktag (this , LUA_VTRUE ); }
113+ constexpr bool TValue::isFalse () const noexcept { return checktag (this , LuaT::VFALSE ); }
114+ constexpr bool TValue::isTrue () const noexcept { return checktag (this , LuaT::VTRUE ); }
115115
116116constexpr bool l_isfalse (const TValue* o) noexcept { return ttisfalse (o) || ttisnil (o); }
117- constexpr bool tagisfalse (int t) noexcept { return (t == LUA_VFALSE || novariant (t) == LUA_TNIL); }
117+ constexpr bool tagisfalse (LuaT t) noexcept { return (t == LuaT::VFALSE || novariant (t) == LUA_TNIL); }
118+ constexpr bool tagisfalse (int t) noexcept { return (t == static_cast <int >(LuaT::VFALSE) || novariant (t) == LUA_TNIL); }
118119
119120constexpr bool TValue::isFalseLike () const noexcept { return isFalse () || isNil (); }
120121
@@ -133,9 +134,9 @@ inline void setbtvalue(TValue* obj) noexcept { obj->setTrue(); }
133134** Note: LUA_VTHREAD now defined in ltvalue.h
134135*/
135136
136- constexpr bool ttisthread (const TValue* o) noexcept { return checktag (o, ctb (LUA_VTHREAD )); }
137+ constexpr bool ttisthread (const TValue* o) noexcept { return checktag (o, ctb (LuaT::THREAD )); }
137138
138- constexpr bool TValue::isThread () const noexcept { return checktag (this , ctb (LUA_VTHREAD )); }
139+ constexpr bool TValue::isThread () const noexcept { return checktag (this , ctb (LuaT::THREAD )); }
139140
140141inline lua_State* thvalue (const TValue* o) noexcept { return o->threadValue (); }
141142
@@ -152,16 +153,16 @@ inline lua_State* thvalue(const TValue* o) noexcept { return o->threadValue(); }
152153*/
153154
154155constexpr bool ttisnumber (const TValue* o) noexcept { return checktype (o, LUA_TNUMBER); }
155- constexpr bool ttisfloat (const TValue* o) noexcept { return checktag (o, LUA_VNUMFLT ); }
156- constexpr bool ttisinteger (const TValue* o) noexcept { return checktag (o, LUA_VNUMINT ); }
156+ constexpr bool ttisfloat (const TValue* o) noexcept { return checktag (o, LuaT::NUMFLT ); }
157+ constexpr bool ttisinteger (const TValue* o) noexcept { return checktag (o, LuaT::NUMINT ); }
157158
158159constexpr bool TValue::isNumber () const noexcept { return checktype (this , LUA_TNUMBER); }
159- constexpr bool TValue::isFloat () const noexcept { return checktag (this , LUA_VNUMFLT ); }
160- constexpr bool TValue::isInteger () const noexcept { return checktag (this , LUA_VNUMINT ); }
160+ constexpr bool TValue::isFloat () const noexcept { return checktag (this , LuaT::NUMFLT ); }
161+ constexpr bool TValue::isInteger () const noexcept { return checktag (this , LuaT::NUMINT ); }
161162
162- // TValue::numberValue() implementation (needs LUA_VNUMINT constant)
163+ // TValue::numberValue() implementation (needs NUMINT constant)
163164inline lua_Number TValue::numberValue () const noexcept {
164- return (tt_ == LUA_VNUMINT ) ? static_cast <lua_Number>(value_.i ) : value_.n ;
165+ return (tt_ == LuaT::NUMINT ) ? static_cast <lua_Number>(value_.i ) : value_.n ;
165166}
166167
167168inline lua_Number nvalue (const TValue* o) noexcept { return o->numberValue (); }
@@ -190,7 +191,7 @@ constexpr lua_Integer ivalueraw(const Value& v) noexcept { return v.i; }
190191class GCObject {
191192protected:
192193 mutable GCObject* next; /* GC list linkage (mutable for GC bookkeeping) */
193- lu_byte tt; /* Type tag (immutable) */
194+ LuaT tt; /* Type tag (immutable) */
194195 mutable lu_byte marked; /* GC mark bits (mutable for GC bookkeeping) */
195196
196197public:
@@ -199,8 +200,9 @@ class GCObject {
199200 void setNext (GCObject* n) const noexcept { next = n; } /* const - next is mutable */
200201 // Pointer-to-pointer for efficient GC list manipulation (allows in-place removal)
201202 GCObject** getNextPtr () const noexcept { return &next; } /* const - next is mutable */
202- lu_byte getType () const noexcept { return tt; }
203- void setType (lu_byte t) noexcept { tt = t; }
203+ LuaT getType () const noexcept { return tt; }
204+ void setType (LuaT t) noexcept { tt = t; }
205+ void setType (lu_byte t) noexcept { tt = static_cast <LuaT>(t); } /* for legacy code */
204206 lu_byte getMarked () const noexcept { return marked; }
205207 void setMarked (lu_byte m) const noexcept { marked = m; } /* const - marked is mutable */
206208 bool isMarked () const noexcept { return marked != 0 ; }
@@ -276,8 +278,9 @@ class GCBase: public GCObject {
276278 constexpr GCObject* getNext () const noexcept { return next; }
277279 constexpr void setNext (GCObject* n) const noexcept { next = n; } /* const - next is mutable */
278280
279- constexpr lu_byte getType () const noexcept { return tt; }
280- constexpr void setType (lu_byte t) noexcept { tt = t; }
281+ constexpr LuaT getType () const noexcept { return tt; }
282+ constexpr void setType (LuaT t) noexcept { tt = t; }
283+ constexpr void setType (lu_byte t) noexcept { tt = static_cast <LuaT>(t); } /* for legacy code */
281284
282285 constexpr lu_byte getMarked () const noexcept { return marked; }
283286 constexpr void setMarked (lu_byte m) const noexcept { marked = m; } /* const - marked is mutable */
@@ -297,9 +300,9 @@ class GCBase: public GCObject {
297300 }
298301};
299302
300- constexpr bool iscollectable (const TValue* o) noexcept { return (rawtt (o) & BIT_ISCOLLECTABLE) != 0 ; }
303+ constexpr bool iscollectable (const TValue* o) noexcept { return (static_cast < int >( rawtt (o) ) & BIT_ISCOLLECTABLE) != 0 ; }
301304
302- constexpr bool TValue::isCollectable () const noexcept { return (tt_ & BIT_ISCOLLECTABLE) != 0 ; }
305+ constexpr bool TValue::isCollectable () const noexcept { return (static_cast < int >( tt_) & BIT_ISCOLLECTABLE) != 0 ; }
303306
304307inline GCObject* gcvalue (const TValue* o) noexcept { return o->gcValue (); }
305308
@@ -322,11 +325,11 @@ inline bool TValue::hasRightType() const noexcept { return typeTag() == gcValue(
322325** Note: LUA_VLIGHTUSERDATA, LUA_VUSERDATA now defined in ltvalue.h
323326*/
324327
325- constexpr bool ttislightuserdata (const TValue* o) noexcept { return checktag (o, LUA_VLIGHTUSERDATA ); }
326- constexpr bool ttisfulluserdata (const TValue* o) noexcept { return checktag (o, ctb (LUA_VUSERDATA )); }
328+ constexpr bool ttislightuserdata (const TValue* o) noexcept { return checktag (o, LuaT::LIGHTUSERDATA ); }
329+ constexpr bool ttisfulluserdata (const TValue* o) noexcept { return checktag (o, ctb (LuaT::USERDATA )); }
327330
328- constexpr bool TValue::isLightUserdata () const noexcept { return checktag (this , LUA_VLIGHTUSERDATA ); }
329- constexpr bool TValue::isFullUserdata () const noexcept { return checktag (this , ctb (LUA_VUSERDATA )); }
331+ constexpr bool TValue::isLightUserdata () const noexcept { return checktag (this , LuaT::LIGHTUSERDATA ); }
332+ constexpr bool TValue::isFullUserdata () const noexcept { return checktag (this , ctb (LuaT::USERDATA )); }
330333
331334inline void * pvalue (const TValue* o) noexcept { return o->pointerValue (); }
332335
0 commit comments