diff --git a/src/objects/lfunc.h b/src/objects/lfunc.h index 0228c287..4b0bcafe 100644 --- a/src/objects/lfunc.h +++ b/src/objects/lfunc.h @@ -21,16 +21,9 @@ typedef union StackValue *StkId; ** {================================================================== ** Functions ** =================================================================== +** Note: LUA_VUPVAL, LUA_VLCL, LUA_VLCF, LUA_VCCL now defined in ltvalue.h */ -inline constexpr int LUA_VUPVAL = makevariant(LUA_TUPVAL, 0); - - -/* Variant tags for functions */ -inline constexpr int LUA_VLCL = makevariant(LUA_TFUNCTION, 0); /* Lua closure */ -inline constexpr int LUA_VLCF = makevariant(LUA_TFUNCTION, 1); /* light C function */ -inline constexpr int LUA_VCCL = makevariant(LUA_TFUNCTION, 2); /* C closure */ - constexpr bool ttisfunction(const TValue* o) noexcept { return checktype(o, LUA_TFUNCTION); } constexpr bool ttisLclosure(const TValue* o) noexcept { return checktag(o, ctb(LUA_VLCL)); } constexpr bool ttislcf(const TValue* o) noexcept { return checktag(o, LUA_VLCF); } diff --git a/src/objects/lobject_core.h b/src/objects/lobject_core.h index 0430127a..067e618c 100644 --- a/src/objects/lobject_core.h +++ b/src/objects/lobject_core.h @@ -22,9 +22,8 @@ class lua_State; /* ** Extra types for collectable non-values +** Note: LUA_TUPVAL and LUA_TPROTO now defined in ltvalue.h */ -inline constexpr int LUA_TUPVAL = LUA_NUMTYPES; /* upvalues */ -inline constexpr int LUA_TPROTO = (LUA_NUMTYPES+1); /* function prototypes */ inline constexpr int LUA_TDEADKEY = (LUA_NUMTYPES+2); /* removed keys in tables */ @@ -38,21 +37,9 @@ inline constexpr int LUA_TOTALTYPES = (LUA_TPROTO + 2); ** {================================================================== ** Nil ** =================================================================== +** Note: LUA_VNIL, LUA_VEMPTY, LUA_VABSTKEY, LUA_VNOTABLE now defined in ltvalue.h */ -/* Standard nil */ -inline constexpr int LUA_VNIL = makevariant(LUA_TNIL, 0); - -/* Empty slot (which might be different from a slot containing nil) */ -inline constexpr int LUA_VEMPTY = makevariant(LUA_TNIL, 1); - -/* Value returned for a key not found in a table (absent key) */ -inline constexpr int LUA_VABSTKEY = makevariant(LUA_TNIL, 2); - -/* Special variant to signal that a fast get is accessing a non-table */ -inline constexpr int LUA_VNOTABLE = makevariant(LUA_TNIL, 3); - - /* macro to test for (any kind of) nil */ constexpr bool ttisnil(const TValue* v) noexcept { return checktype(v, LUA_TNIL); } @@ -115,12 +102,9 @@ inline void setempty(TValue* v) noexcept { settt_(v, LUA_VEMPTY); } ** {================================================================== ** Booleans ** =================================================================== +** Note: LUA_VFALSE, LUA_VTRUE now defined in ltvalue.h */ - -inline constexpr int LUA_VFALSE = makevariant(LUA_TBOOLEAN, 0); -inline constexpr int LUA_VTRUE = makevariant(LUA_TBOOLEAN, 1); - constexpr bool ttisboolean(const TValue* o) noexcept { return checktype(o, LUA_TBOOLEAN); } constexpr bool ttisfalse(const TValue* o) noexcept { return checktag(o, LUA_VFALSE); } constexpr bool ttistrue(const TValue* o) noexcept { return checktag(o, LUA_VTRUE); } @@ -146,10 +130,9 @@ inline void setbtvalue(TValue* obj) noexcept { obj->setTrue(); } ** {================================================================== ** Threads ** =================================================================== +** Note: LUA_VTHREAD now defined in ltvalue.h */ -inline constexpr int LUA_VTHREAD = makevariant(LUA_TTHREAD, 0); - constexpr bool ttisthread(const TValue* o) noexcept { return checktag(o, ctb(LUA_VTHREAD)); } constexpr bool TValue::isThread() const noexcept { return checktag(this, ctb(LUA_VTHREAD)); } @@ -165,12 +148,9 @@ inline lua_State* thvalue(const TValue* o) noexcept { return o->threadValue(); } ** {================================================================== ** Numbers ** =================================================================== +** Note: LUA_VNUMINT, LUA_VNUMFLT now defined in ltvalue.h */ -/* Variant tags for numbers */ -inline constexpr int LUA_VNUMINT = makevariant(LUA_TNUMBER, 0); /* integer numbers */ -inline constexpr int LUA_VNUMFLT = makevariant(LUA_TNUMBER, 1); /* float numbers */ - constexpr bool ttisnumber(const TValue* o) noexcept { return checktype(o, LUA_TNUMBER); } constexpr bool ttisfloat(const TValue* o) noexcept { return checktag(o, LUA_VNUMFLT); } constexpr bool ttisinteger(const TValue* o) noexcept { return checktag(o, LUA_VNUMINT); } @@ -339,17 +319,9 @@ inline bool TValue::hasRightType() const noexcept { return typeTag() == gcValue( ** {================================================================== ** Userdata ** =================================================================== +** Note: LUA_VLIGHTUSERDATA, LUA_VUSERDATA now defined in ltvalue.h */ - -/* -** Light userdata should be a variant of userdata, but for compatibility -** reasons they are also different types. -*/ -inline constexpr int LUA_VLIGHTUSERDATA = makevariant(LUA_TLIGHTUSERDATA, 0); - -inline constexpr int LUA_VUSERDATA = makevariant(LUA_TUSERDATA, 0); - constexpr bool ttislightuserdata(const TValue* o) noexcept { return checktag(o, LUA_VLIGHTUSERDATA); } constexpr bool ttisfulluserdata(const TValue* o) noexcept { return checktag(o, ctb(LUA_VUSERDATA)); } diff --git a/src/objects/lproto.h b/src/objects/lproto.h index 1d47a479..893c6f01 100644 --- a/src/objects/lproto.h +++ b/src/objects/lproto.h @@ -25,10 +25,9 @@ typedef l_uint32 Instruction; ** {================================================================== ** Prototypes ** =================================================================== +** Note: LUA_VPROTO now defined in ltvalue.h */ -inline constexpr int LUA_VPROTO = makevariant(LUA_TPROTO, 0); - /* ** Description of an upvalue for function prototypes diff --git a/src/objects/lstring.h b/src/objects/lstring.h index 8dffd73b..9aa705b0 100644 --- a/src/objects/lstring.h +++ b/src/objects/lstring.h @@ -37,12 +37,9 @@ class global_State; ** {================================================================== ** Strings ** =================================================================== +** Note: LUA_VSHRSTR, LUA_VLNGSTR now defined in ltvalue.h */ -/* Variant tags for strings */ -inline constexpr int LUA_VSHRSTR = makevariant(LUA_TSTRING, 0); /* short strings */ -inline constexpr int LUA_VLNGSTR = makevariant(LUA_TSTRING, 1); /* long strings */ - constexpr bool ttisstring(const TValue* o) noexcept { return checktype(o, LUA_TSTRING); } constexpr bool ttisshrstring(const TValue* o) noexcept { return checktag(o, ctb(LUA_VSHRSTR)); } constexpr bool ttislngstring(const TValue* o) noexcept { return checktag(o, ctb(LUA_VLNGSTR)); } diff --git a/src/objects/ltable.h b/src/objects/ltable.h index 3a18fb1c..b0a16ad3 100644 --- a/src/objects/ltable.h +++ b/src/objects/ltable.h @@ -21,10 +21,9 @@ typedef union StackValue *StkId; ** {================================================================== ** Tables ** =================================================================== +** Note: LUA_VTABLE now defined in ltvalue.h */ -inline constexpr int LUA_VTABLE = makevariant(LUA_TTABLE, 0); - constexpr bool ttistable(const TValue* o) noexcept { return checktag(o, ctb(LUA_VTABLE)); } constexpr bool TValue::isTable() const noexcept { return checktag(this, ctb(LUA_VTABLE)); } diff --git a/src/objects/ltvalue.h b/src/objects/ltvalue.h index 90eada01..6e0a24c7 100644 --- a/src/objects/ltvalue.h +++ b/src/objects/ltvalue.h @@ -22,6 +22,61 @@ constexpr int makevariant(int t, int v) noexcept { return (t | (v << 4)); } +/* +** Extra types for collectable non-values +*/ +inline constexpr int LUA_TUPVAL = LUA_NUMTYPES; /* upvalues */ +inline constexpr int LUA_TPROTO = (LUA_NUMTYPES+1); /* function prototypes */ + + +/* +** {================================================================== +** Variant tags for all Lua types +** =================================================================== +*/ + +/* Nil variants */ +inline constexpr int LUA_VNIL = makevariant(LUA_TNIL, 0); +inline constexpr int LUA_VEMPTY = makevariant(LUA_TNIL, 1); +inline constexpr int LUA_VABSTKEY = makevariant(LUA_TNIL, 2); +inline constexpr int LUA_VNOTABLE = makevariant(LUA_TNIL, 3); + +/* Boolean variants */ +inline constexpr int LUA_VFALSE = makevariant(LUA_TBOOLEAN, 0); +inline constexpr int LUA_VTRUE = makevariant(LUA_TBOOLEAN, 1); + +/* Number variants */ +inline constexpr int LUA_VNUMINT = makevariant(LUA_TNUMBER, 0); /* integer numbers */ +inline constexpr int LUA_VNUMFLT = makevariant(LUA_TNUMBER, 1); /* float numbers */ + +/* String variants */ +inline constexpr int LUA_VSHRSTR = makevariant(LUA_TSTRING, 0); /* short strings */ +inline constexpr int LUA_VLNGSTR = makevariant(LUA_TSTRING, 1); /* long strings */ + +/* Table variant */ +inline constexpr int LUA_VTABLE = makevariant(LUA_TTABLE, 0); + +/* Function variants */ +inline constexpr int LUA_VLCL = makevariant(LUA_TFUNCTION, 0); /* Lua closure */ +inline constexpr int LUA_VLCF = makevariant(LUA_TFUNCTION, 1); /* light C function */ +inline constexpr int LUA_VCCL = makevariant(LUA_TFUNCTION, 2); /* C closure */ + +/* Userdata variants */ +inline constexpr int LUA_VLIGHTUSERDATA = makevariant(LUA_TLIGHTUSERDATA, 0); +inline constexpr int LUA_VUSERDATA = makevariant(LUA_TUSERDATA, 0); + +/* Thread variant */ +inline constexpr int LUA_VTHREAD = makevariant(LUA_TTHREAD, 0); + +/* Upvalue variant (collectable non-value) */ +inline constexpr int LUA_VUPVAL = makevariant(LUA_TUPVAL, 0); + +/* Proto variant (collectable non-value) */ +inline constexpr int LUA_VPROTO = makevariant(LUA_TPROTO, 0); + +/* }================================================================== */ + + /* ** Rounding modes for float->integer coercion (needed by TValue conversion methods) */