aboutsummaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-26 11:16:05 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-26 11:16:05 -0300
commitef8263f81fdde2310ebb15c9a3fe5e954d57cab5 (patch)
tree8532d24bcfc4c59212616bdae1b25f087f1eb179 /lobject.h
parent2952bc5fc9cdc05ed061539cb7be26899513f004 (diff)
downloadlua-ef8263f81fdde2310ebb15c9a3fe5e954d57cab5.tar.gz
lua-ef8263f81fdde2310ebb15c9a3fe5e954d57cab5.tar.bz2
lua-ef8263f81fdde2310ebb15c9a3fe5e954d57cab5.zip
better names for macros for tags and types.
rttype -> rawtt; ttyperaw -> withvariant; ttype -> ttypetag; tnov -> ttype
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/lobject.h b/lobject.h
index 6d34759f..b18dce47 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 2.139 2018/02/25 12:52:32 roberto Exp roberto $ 2** $Id: lobject.h,v 2.140 2018/02/26 13:35:03 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -67,26 +67,26 @@ typedef struct TValue {
67 67
68 68
69/* raw type tag of a TValue */ 69/* raw type tag of a TValue */
70#define rttype(o) ((o)->tt_) 70#define rawtt(o) ((o)->tt_)
71 71
72/* tag with no variants (bits 0-3) */ 72/* tag with no variants (bits 0-3) */
73#define novariant(t) ((t) & 0x0F) 73#define novariant(t) ((t) & 0x0F)
74 74
75/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */ 75/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */
76#define ttyperaw(t) ((t) & 0x3F) 76#define withvariant(t) ((t) & 0x3F)
77#define ttype(o) ttyperaw(rttype(o)) 77#define ttypetag(o) withvariant(rawtt(o))
78 78
79/* type tag of a TValue with no variants (bits 0-3) */ 79/* type of a TValue */
80#define ttnov(o) (novariant(rttype(o))) 80#define ttype(o) (novariant(rawtt(o)))
81 81
82 82
83/* Macros to test type */ 83/* Macros to test type */
84#define checktag(o,t) (rttype(o) == (t)) 84#define checktag(o,t) (rawtt(o) == (t))
85#define checktype(o,t) (ttnov(o) == (t)) 85#define checktype(o,t) (ttype(o) == (t))
86 86
87 87
88/* Macros for internal tests */ 88/* Macros for internal tests */
89#define righttt(obj) (ttype(obj) == gcvalue(obj)->tt) 89#define righttt(obj) (ttypetag(obj) == gcvalue(obj)->tt)
90 90
91#define checkliveness(L,obj) \ 91#define checkliveness(L,obj) \
92 lua_longassert(!iscollectable(obj) || \ 92 lua_longassert(!iscollectable(obj) || \
@@ -244,7 +244,7 @@ typedef struct GCObject {
244/* Bit mark for collectable types */ 244/* Bit mark for collectable types */
245#define BIT_ISCOLLECTABLE (1 << 6) 245#define BIT_ISCOLLECTABLE (1 << 6)
246 246
247#define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE) 247#define iscollectable(o) (rawtt(o) & BIT_ISCOLLECTABLE)
248 248
249/* mark a tag as collectable */ 249/* mark a tag as collectable */
250#define ctb(t) ((t) | BIT_ISCOLLECTABLE) 250#define ctb(t) ((t) | BIT_ISCOLLECTABLE)
@@ -535,7 +535,7 @@ typedef struct Proto {
535#define LUA_TCCL (LUA_TFUNCTION | (3 << 4)) /* C closure */ 535#define LUA_TCCL (LUA_TFUNCTION | (3 << 4)) /* C closure */
536 536
537#define ttisfunction(o) checktype(o, LUA_TFUNCTION) 537#define ttisfunction(o) checktype(o, LUA_TFUNCTION)
538#define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TLCL) 538#define ttisclosure(o) ((rawtt(o) & 0x1F) == LUA_TLCL)
539#define ttisLclosure(o) checktag((o), ctb(LUA_TLCL)) 539#define ttisLclosure(o) checktag((o), ctb(LUA_TLCL))
540#define ttislcf(o) checktag((o), LUA_TLCF) 540#define ttislcf(o) checktag((o), LUA_TLCF)
541#define ttisCclosure(o) checktag((o), ctb(LUA_TCCL)) 541#define ttisCclosure(o) checktag((o), ctb(LUA_TCCL))