|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
-** $Id: lstate.h,v 2.107 2014/06/12 19:07:30 roberto Exp roberto $
|
|
|
+** $Id: lstate.h,v 2.108 2014/07/17 13:53:37 roberto Exp roberto $
|
|
|
** Global State
|
|
|
** See Copyright Notice in lua.h
|
|
|
*/
|
|
@@ -172,8 +172,8 @@ struct lua_State {
|
|
|
/*
|
|
|
** Union of all collectable objects
|
|
|
*/
|
|
|
-union GCObject {
|
|
|
- GCheader gch; /* common header */
|
|
|
+union GCUnion {
|
|
|
+ GCObject gc; /* common header */
|
|
|
union TString ts;
|
|
|
union Udata u;
|
|
|
union Closure cl;
|
|
@@ -185,22 +185,31 @@ union GCObject {
|
|
|
|
|
|
#define gch(o) (&(o)->gch)
|
|
|
|
|
|
+#define cast_u(o) cast(union GCUnion *, (o))
|
|
|
+
|
|
|
/* macros to convert a GCObject into a specific value */
|
|
|
#define rawgco2ts(o) \
|
|
|
- check_exp(novariant((o)->gch.tt) == LUA_TSTRING, &((o)->ts))
|
|
|
+ check_exp(novariant((o)->gch.tt) == LUA_TSTRING, &((cast_u(o))->ts))
|
|
|
#define gco2ts(o) (&rawgco2ts(o)->tsv)
|
|
|
-#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
|
|
|
+#define rawgco2u(o) \
|
|
|
+ check_exp((o)->gch.tt == LUA_TUSERDATA, &((cast_u(o))->u))
|
|
|
#define gco2u(o) (&rawgco2u(o)->uv)
|
|
|
-#define gco2lcl(o) check_exp((o)->gch.tt == LUA_TLCL, &((o)->cl.l))
|
|
|
-#define gco2ccl(o) check_exp((o)->gch.tt == LUA_TCCL, &((o)->cl.c))
|
|
|
+#define gco2lcl(o) \
|
|
|
+ check_exp((o)->gch.tt == LUA_TLCL, &((cast_u(o))->cl.l))
|
|
|
+#define gco2ccl(o) \
|
|
|
+ check_exp((o)->gch.tt == LUA_TCCL, &((cast_u(o))->cl.c))
|
|
|
#define gco2cl(o) \
|
|
|
- check_exp(novariant((o)->gch.tt) == LUA_TFUNCTION, &((o)->cl))
|
|
|
-#define gco2t(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
|
|
|
-#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
|
|
|
-#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
|
|
|
+ check_exp(novariant((o)->gch.tt) == LUA_TFUNCTION, &((cast_u(o))->cl))
|
|
|
+#define gco2t(o) \
|
|
|
+ check_exp((o)->gch.tt == LUA_TTABLE, &((cast_u(o))->h))
|
|
|
+#define gco2p(o) \
|
|
|
+ check_exp((o)->gch.tt == LUA_TPROTO, &((cast_u(o))->p))
|
|
|
+#define gco2th(o) \
|
|
|
+ check_exp((o)->gch.tt == LUA_TTHREAD, &((cast_u(o))->th))
|
|
|
+
|
|
|
|
|
|
/* macro to convert any Lua object into a GCObject */
|
|
|
-#define obj2gco(v) (cast(GCObject *, (v)))
|
|
|
+#define obj2gco(v) (&(cast_u(v)->gc))
|
|
|
|
|
|
|
|
|
/* actual number of total bytes allocated */
|