aboutsummaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/lobject.h b/lobject.h
index a529ceba..62e4d05f 100644
--- a/lobject.h
+++ b/lobject.h
@@ -36,6 +36,9 @@
36** bit 6: whether value is collectable 36** bit 6: whether value is collectable
37*/ 37*/
38 38
39/* add variant bits to a type */
40#define makevariant(t,v) ((t) | ((v) << 4))
41
39 42
40 43
41/* 44/*
@@ -165,13 +168,13 @@ typedef StackValue *StkId;
165** Variant tag, used only in tables to signal an empty slot 168** Variant tag, used only in tables to signal an empty slot
166** (which might be different from a slot containing nil) 169** (which might be different from a slot containing nil)
167*/ 170*/
168#define LUA_TEMPTY (LUA_TNIL | (1 << 4)) 171#define LUA_TEMPTY makevariant(LUA_TNIL, 1)
169 172
170/* 173/*
171** Variant used only in the value returned for a key not found in a 174** Variant used only in the value returned for a key not found in a
172** table (absent key). 175** table (absent key).
173*/ 176*/
174#define LUA_TABSTKEY (LUA_TNIL | (2 << 4)) 177#define LUA_TABSTKEY makevariant(LUA_TNIL, 2)
175 178
176 179
177#define isabstkey(v) checktag((v), LUA_TABSTKEY) 180#define isabstkey(v) checktag((v), LUA_TABSTKEY)
@@ -210,8 +213,8 @@ typedef StackValue *StkId;
210*/ 213*/
211 214
212 215
213#define LUA_TFALSE (LUA_TBOOLEAN | (1 << 4)) 216#define LUA_TFALSE makevariant(LUA_TBOOLEAN, 1)
214#define LUA_TTRUE (LUA_TBOOLEAN | (2 << 4)) 217#define LUA_TTRUE makevariant(LUA_TBOOLEAN, 2)
215 218
216#define ttisboolean(o) checktype((o), LUA_TBOOLEAN) 219#define ttisboolean(o) checktype((o), LUA_TBOOLEAN)
217#define ttisfalse(o) checktag((o), LUA_TFALSE) 220#define ttisfalse(o) checktag((o), LUA_TFALSE)
@@ -292,8 +295,8 @@ typedef struct GCObject {
292*/ 295*/
293 296
294/* Variant tags for numbers */ 297/* Variant tags for numbers */
295#define LUA_TNUMFLT (LUA_TNUMBER | (1 << 4)) /* float numbers */ 298#define LUA_TNUMINT makevariant(LUA_TNUMBER, 1) /* integer numbers */
296#define LUA_TNUMINT (LUA_TNUMBER | (2 << 4)) /* integer numbers */ 299#define LUA_TNUMFLT makevariant(LUA_TNUMBER, 2) /* float numbers */
297 300
298#define ttisnumber(o) checktype((o), LUA_TNUMBER) 301#define ttisnumber(o) checktype((o), LUA_TNUMBER)
299#define ttisfloat(o) checktag((o), LUA_TNUMFLT) 302#define ttisfloat(o) checktag((o), LUA_TNUMFLT)
@@ -329,8 +332,8 @@ typedef struct GCObject {
329*/ 332*/
330 333
331/* Variant tags for strings */ 334/* Variant tags for strings */
332#define LUA_TSHRSTR (LUA_TSTRING | (1 << 4)) /* short strings */ 335#define LUA_TSHRSTR makevariant(LUA_TSTRING, 1) /* short strings */
333#define LUA_TLNGSTR (LUA_TSTRING | (2 << 4)) /* long strings */ 336#define LUA_TLNGSTR makevariant(LUA_TSTRING, 2) /* long strings */
334 337
335#define ttisstring(o) checktype((o), LUA_TSTRING) 338#define ttisstring(o) checktype((o), LUA_TSTRING)
336#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR)) 339#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR))
@@ -546,9 +549,9 @@ typedef struct Proto {
546*/ 549*/
547 550
548/* Variant tags for functions */ 551/* Variant tags for functions */
549#define LUA_TLCL (LUA_TFUNCTION | (1 << 4)) /* Lua closure */ 552#define LUA_TLCL makevariant(LUA_TFUNCTION, 1) /* Lua closure */
550#define LUA_TLCF (LUA_TFUNCTION | (2 << 4)) /* light C function */ 553#define LUA_TLCF makevariant(LUA_TFUNCTION, 2) /* light C function */
551#define LUA_TCCL (LUA_TFUNCTION | (3 << 4)) /* C closure */ 554#define LUA_TCCL makevariant(LUA_TFUNCTION, 3) /* C closure */
552 555
553#define ttisfunction(o) checktype(o, LUA_TFUNCTION) 556#define ttisfunction(o) checktype(o, LUA_TFUNCTION)
554#define ttisclosure(o) ((rawtt(o) & 0x1F) == LUA_TLCL) 557#define ttisclosure(o) ((rawtt(o) & 0x1F) == LUA_TLCL)