aboutsummaryrefslogtreecommitdiff
path: root/lstate.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-18 10:36:14 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-18 10:36:14 -0300
commitca41b43f53562e64abe433d6346d174c92548603 (patch)
tree03f7a99f76359fc1e0bbc45fc13e579ff2aafabb /lstate.h
parent3511e186cde4b78f268d17199d0f46fb3eaa9638 (diff)
downloadlua-ca41b43f53562e64abe433d6346d174c92548603.tar.gz
lua-ca41b43f53562e64abe433d6346d174c92548603.tar.bz2
lua-ca41b43f53562e64abe433d6346d174c92548603.zip
type 'TString' refers directly to the structure inside the union
(union used only for size purposes)
Diffstat (limited to 'lstate.h')
-rw-r--r--lstate.h14
1 files changed, 3 insertions, 11 deletions
diff --git a/lstate.h b/lstate.h
index 69c91b63..662e925a 100644
--- a/lstate.h
+++ b/lstate.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.h,v 2.110 2014/07/17 17:27:49 roberto Exp roberto $ 2** $Id: lstate.h,v 2.111 2014/07/18 12:17:54 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -174,7 +174,7 @@ struct lua_State {
174*/ 174*/
175union GCUnion { 175union GCUnion {
176 GCObject gc; /* common header */ 176 GCObject gc; /* common header */
177 union TString ts; 177 struct TString ts;
178 union Udata u; 178 union Udata u;
179 union Closure cl; 179 union Closure cl;
180 struct Table h; 180 struct Table h;
@@ -186,9 +186,8 @@ union GCUnion {
186#define cast_u(o) cast(union GCUnion *, (o)) 186#define cast_u(o) cast(union GCUnion *, (o))
187 187
188/* macros to convert a GCObject into a specific value */ 188/* macros to convert a GCObject into a specific value */
189#define rawgco2ts(o) \ 189#define gco2ts(o) \
190 check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts)) 190 check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts))
191#define gco2ts(o) (&rawgco2ts(o)->tsv)
192#define rawgco2u(o) check_exp((o)->tt == LUA_TUSERDATA, &((cast_u(o))->u)) 191#define rawgco2u(o) check_exp((o)->tt == LUA_TUSERDATA, &((cast_u(o))->u))
193#define gco2u(o) (&rawgco2u(o)->uv) 192#define gco2u(o) (&rawgco2u(o)->uv)
194#define gco2lcl(o) check_exp((o)->tt == LUA_TLCL, &((cast_u(o))->cl.l)) 193#define gco2lcl(o) check_exp((o)->tt == LUA_TLCL, &((cast_u(o))->cl.l))
@@ -204,13 +203,6 @@ union GCUnion {
204#define obj2gco(v) \ 203#define obj2gco(v) \
205 check_exp(novariant((v)->tt) < LUA_TDEADKEY, (&(cast_u(v)->gc))) 204 check_exp(novariant((v)->tt) < LUA_TDEADKEY, (&(cast_u(v)->gc)))
206 205
207/*
208** macro to convert a TString into a GCObject.
209** (TString is a union, and therefore needs an access slightly different
210** from the other objects.)
211*/
212#define ts2gco(v) (obj2gco(&(v)->tsv))
213
214 206
215/* actual number of total bytes allocated */ 207/* actual number of total bytes allocated */
216#define gettotalbytes(g) ((g)->totalbytes + (g)->GCdebt) 208#define gettotalbytes(g) ((g)->totalbytes + (g)->GCdebt)