Go to the documentation of this file.
16 #define NUM_TAGS LUA_TTHREAD
22 #define LUA_TPROTO (NUM_TAGS+1)
23 #define LUA_TUPVAL (NUM_TAGS+2)
36 #define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
71 #define ttisnil(o) (ttype(o) == LUA_TNIL)
72 #define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
73 #define ttisstring(o) (ttype(o) == LUA_TSTRING)
74 #define ttistable(o) (ttype(o) == LUA_TTABLE)
75 #define ttisfunction(o) (ttype(o) == LUA_TFUNCTION)
76 #define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN)
77 #define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA)
78 #define ttisthread(o) (ttype(o) == LUA_TTHREAD)
79 #define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA)
82 #define ttype(o) ((o)->tt)
83 #define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc)
84 #define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p)
85 #define nvalue(o) check_exp(ttisnumber(o), (o)->value.n)
86 #define tsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts)
87 #define uvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u)
88 #define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl)
89 #define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h)
90 #define bvalue(o) check_exp(ttisboolean(o), (o)->value.b)
91 #define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th)
93 #define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
96 #define setnvalue(obj,x) \
97 { TObject *i_o=(obj); i_o->tt=LUA_TNUMBER; i_o->value.n=(x); }
99 #define chgnvalue(obj,x) \
100 check_exp(ttype(obj)==LUA_TNUMBER, (obj)->value.n=(x))
102 #define setpvalue(obj,x) \
103 { TObject *i_o=(obj); i_o->tt=LUA_TLIGHTUSERDATA; i_o->value.p=(x); }
105 #define setbvalue(obj,x) \
106 { TObject *i_o=(obj); i_o->tt=LUA_TBOOLEAN; i_o->value.b=(x); }
108 #define setsvalue(obj,x) \
109 { TObject *i_o=(obj); i_o->tt=LUA_TSTRING; \
110 i_o->value.gc=cast(GCObject *, (x)); \
111 lua_assert(i_o->value.gc->gch.tt == LUA_TSTRING); }
113 #define setuvalue(obj,x) \
114 { TObject *i_o=(obj); i_o->tt=LUA_TUSERDATA; \
115 i_o->value.gc=cast(GCObject *, (x)); \
116 lua_assert(i_o->value.gc->gch.tt == LUA_TUSERDATA); }
118 #define setthvalue(obj,x) \
119 { TObject *i_o=(obj); i_o->tt=LUA_TTHREAD; \
120 i_o->value.gc=cast(GCObject *, (x)); \
121 lua_assert(i_o->value.gc->gch.tt == LUA_TTHREAD); }
123 #define setclvalue(obj,x) \
124 { TObject *i_o=(obj); i_o->tt=LUA_TFUNCTION; \
125 i_o->value.gc=cast(GCObject *, (x)); \
126 lua_assert(i_o->value.gc->gch.tt == LUA_TFUNCTION); }
128 #define sethvalue(obj,x) \
129 { TObject *i_o=(obj); i_o->tt=LUA_TTABLE; \
130 i_o->value.gc=cast(GCObject *, (x)); \
131 lua_assert(i_o->value.gc->gch.tt == LUA_TTABLE); }
133 #define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
140 #define checkconsistency(obj) \
141 lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))
144 #define setobj(obj1,obj2) \
145 { const TObject *o2=(obj2); TObject *o1=(obj1); \
146 checkconsistency(o2); \
147 o1->tt=o2->tt; o1->value = o2->value; }
155 #define setobjs2s setobj
157 #define setobj2s setobj
158 #define setsvalue2s setsvalue
160 #define setobjt2t setobj
162 #define setobj2t setobj
164 #define setobj2n setobj
165 #define setsvalue2n setsvalue
167 #define setttype(obj, tt) (ttype(obj) = (tt))
170 #define iscollectable(o) (ttype(o) >= LUA_TSTRING)
191 #define getstr(ts) cast(const char *, (ts) + 1)
192 #define svalue(o) getstr(tsvalue(o))
268 #define ClosureHeader \
269 CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist
292 #define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
293 #define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
326 #define lmod(s,size) \
327 check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1))))
330 #define twoto(x) (1<<(x))
331 #define sizenode(t) (twoto((t)->lsizenode))
342 #define fb2int(x) (((x) & 7) << ((x) >> 3))
346 int luaO_str2d (
const char *s, lua_Number *result)
355 void luaO_chunkid (
char *out,
const char *source,
int len)