better control over GCObjects

This commit is contained in:
Roberto Ierusalimschy
2002-11-13 09:32:26 -02:00
parent 42dd080a2e
commit 2f91f95d94
7 changed files with 49 additions and 30 deletions

View File

@@ -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);