diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-11-13 09:32:26 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-11-13 09:32:26 -0200 |
commit | 2f91f95d94d3a27fee6b45c31ea9ab631924a8bf (patch) | |
tree | bbc605f6643b4958f45536dc5f5f84297eda70c2 /lstate.h | |
parent | 42dd080a2e3e8fb6887ca1e066f53bb8fd23c9e7 (diff) | |
download | lua-2f91f95d94d3a27fee6b45c31ea9ab631924a8bf.tar.gz lua-2f91f95d94d3a27fee6b45c31ea9ab631924a8bf.tar.bz2 lua-2f91f95d94d3a27fee6b45c31ea9ab631924a8bf.zip |
better control over GCObjects
Diffstat (limited to 'lstate.h')
-rw-r--r-- | lstate.h | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.h,v 1.99 2002/10/25 20:05:28 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 1.100 2002/11/06 19:08:00 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 | */ |
@@ -144,6 +144,7 @@ struct lua_State { | |||
144 | lua_Hook hook; | 144 | lua_Hook hook; |
145 | TObject _gt; /* table of globals */ | 145 | TObject _gt; /* table of globals */ |
146 | GCObject *openupval; /* list of open upvalues in this stack */ | 146 | GCObject *openupval; /* list of open upvalues in this stack */ |
147 | GCObject *gclist; | ||
147 | struct lua_longjmp *errorJmp; /* current error recover point */ | 148 | struct lua_longjmp *errorJmp; /* current error recover point */ |
148 | ptrdiff_t errfunc; /* current error handling function (stack index) */ | 149 | ptrdiff_t errfunc; /* current error handling function (stack index) */ |
149 | }; | 150 | }; |
@@ -167,6 +168,21 @@ union GCObject { | |||
167 | }; | 168 | }; |
168 | 169 | ||
169 | 170 | ||
171 | /* macros to convert a GCObject into a specific value */ | ||
172 | #define gcotots(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) | ||
173 | #define gcotou(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) | ||
174 | #define gcotocl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) | ||
175 | #define gcotoh(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) | ||
176 | #define gcotop(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) | ||
177 | #define gcotouv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) | ||
178 | #define ngcotouv(o) \ | ||
179 | check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) | ||
180 | #define gcototh(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) | ||
181 | |||
182 | /* macro to convert any value into a GCObject */ | ||
183 | #define valtogco(v) (cast(GCObject *, (v))) | ||
184 | |||
185 | |||
170 | lua_State *luaE_newthread (lua_State *L); | 186 | lua_State *luaE_newthread (lua_State *L); |
171 | void luaE_freethread (lua_State *L, lua_State *L1); | 187 | void luaE_freethread (lua_State *L, lua_State *L1); |
172 | 188 | ||