From 2f91f95d94d3a27fee6b45c31ea9ab631924a8bf Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 13 Nov 2002 09:32:26 -0200 Subject: better control over GCObjects --- lstate.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lstate.h') diff --git a/lstate.h b/lstate.h index f14738ba..e8bdb32b 100644 --- a/lstate.h +++ b/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 1.99 2002/10/25 20:05:28 roberto Exp roberto $ +** $Id: lstate.h,v 1.100 2002/11/06 19:08:00 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -144,6 +144,7 @@ struct lua_State { lua_Hook hook; TObject _gt; /* table of globals */ GCObject *openupval; /* list of open upvalues in this stack */ + GCObject *gclist; struct lua_longjmp *errorJmp; /* current error recover point */ ptrdiff_t errfunc; /* current error handling function (stack index) */ }; @@ -167,6 +168,21 @@ union GCObject { }; +/* macros to convert a GCObject into a specific value */ +#define gcotots(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) +#define gcotou(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) +#define gcotocl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) +#define gcotoh(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) +#define gcotop(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) +#define gcotouv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define ngcotouv(o) \ + check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define gcototh(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) + +/* macro to convert any value into a GCObject */ +#define valtogco(v) (cast(GCObject *, (v))) + + lua_State *luaE_newthread (lua_State *L); void luaE_freethread (lua_State *L, lua_State *L1); -- cgit v1.2.3-55-g6feb