diff options
Diffstat (limited to 'lstate.h')
| -rw-r--r-- | lstate.h | 33 |
1 files changed, 21 insertions, 12 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.h,v 2.107 2014/06/12 19:07:30 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 2.108 2014/07/17 13:53:37 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 | */ |
| @@ -172,8 +172,8 @@ struct lua_State { | |||
| 172 | /* | 172 | /* |
| 173 | ** Union of all collectable objects | 173 | ** Union of all collectable objects |
| 174 | */ | 174 | */ |
| 175 | union GCObject { | 175 | union GCUnion { |
| 176 | GCheader gch; /* common header */ | 176 | GCObject gc; /* common header */ |
| 177 | union TString ts; | 177 | union TString ts; |
| 178 | union Udata u; | 178 | union Udata u; |
| 179 | union Closure cl; | 179 | union Closure cl; |
| @@ -185,22 +185,31 @@ union GCObject { | |||
| 185 | 185 | ||
| 186 | #define gch(o) (&(o)->gch) | 186 | #define gch(o) (&(o)->gch) |
| 187 | 187 | ||
| 188 | #define cast_u(o) cast(union GCUnion *, (o)) | ||
| 189 | |||
| 188 | /* macros to convert a GCObject into a specific value */ | 190 | /* macros to convert a GCObject into a specific value */ |
| 189 | #define rawgco2ts(o) \ | 191 | #define rawgco2ts(o) \ |
| 190 | check_exp(novariant((o)->gch.tt) == LUA_TSTRING, &((o)->ts)) | 192 | check_exp(novariant((o)->gch.tt) == LUA_TSTRING, &((cast_u(o))->ts)) |
| 191 | #define gco2ts(o) (&rawgco2ts(o)->tsv) | 193 | #define gco2ts(o) (&rawgco2ts(o)->tsv) |
| 192 | #define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) | 194 | #define rawgco2u(o) \ |
| 195 | check_exp((o)->gch.tt == LUA_TUSERDATA, &((cast_u(o))->u)) | ||
| 193 | #define gco2u(o) (&rawgco2u(o)->uv) | 196 | #define gco2u(o) (&rawgco2u(o)->uv) |
| 194 | #define gco2lcl(o) check_exp((o)->gch.tt == LUA_TLCL, &((o)->cl.l)) | 197 | #define gco2lcl(o) \ |
| 195 | #define gco2ccl(o) check_exp((o)->gch.tt == LUA_TCCL, &((o)->cl.c)) | 198 | check_exp((o)->gch.tt == LUA_TLCL, &((cast_u(o))->cl.l)) |
| 199 | #define gco2ccl(o) \ | ||
| 200 | check_exp((o)->gch.tt == LUA_TCCL, &((cast_u(o))->cl.c)) | ||
| 196 | #define gco2cl(o) \ | 201 | #define gco2cl(o) \ |
| 197 | check_exp(novariant((o)->gch.tt) == LUA_TFUNCTION, &((o)->cl)) | 202 | check_exp(novariant((o)->gch.tt) == LUA_TFUNCTION, &((cast_u(o))->cl)) |
| 198 | #define gco2t(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) | 203 | #define gco2t(o) \ |
| 199 | #define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) | 204 | check_exp((o)->gch.tt == LUA_TTABLE, &((cast_u(o))->h)) |
| 200 | #define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) | 205 | #define gco2p(o) \ |
| 206 | check_exp((o)->gch.tt == LUA_TPROTO, &((cast_u(o))->p)) | ||
| 207 | #define gco2th(o) \ | ||
| 208 | check_exp((o)->gch.tt == LUA_TTHREAD, &((cast_u(o))->th)) | ||
| 209 | |||
| 201 | 210 | ||
| 202 | /* macro to convert any Lua object into a GCObject */ | 211 | /* macro to convert any Lua object into a GCObject */ |
| 203 | #define obj2gco(v) (cast(GCObject *, (v))) | 212 | #define obj2gco(v) (&(cast_u(v)->gc)) |
| 204 | 213 | ||
| 205 | 214 | ||
| 206 | /* actual number of total bytes allocated */ | 215 | /* actual number of total bytes allocated */ |
