diff options
| -rw-r--r-- | lobject.h | 31 |
1 files changed, 16 insertions, 15 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.h,v 2.111 2015/06/09 14:21:42 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.112 2015/09/08 15:49:25 roberto Exp roberto $ |
| 3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -187,9 +187,9 @@ typedef struct lua_TValue { | |||
| 187 | /* Macros for internal tests */ | 187 | /* Macros for internal tests */ |
| 188 | #define righttt(obj) (ttype(obj) == gcvalue(obj)->tt) | 188 | #define righttt(obj) (ttype(obj) == gcvalue(obj)->tt) |
| 189 | 189 | ||
| 190 | #define checkliveness(g,obj) \ | 190 | #define checkliveness(L,obj) \ |
| 191 | lua_longassert(!iscollectable(obj) || \ | 191 | lua_longassert(!iscollectable(obj) || \ |
| 192 | (righttt(obj) && !isdead(g,gcvalue(obj)))) | 192 | (righttt(obj) && !isdead(G(L),gcvalue(obj)))) |
| 193 | 193 | ||
| 194 | 194 | ||
| 195 | /* Macros to set values */ | 195 | /* Macros to set values */ |
| @@ -225,32 +225,32 @@ typedef struct lua_TValue { | |||
| 225 | #define setsvalue(L,obj,x) \ | 225 | #define setsvalue(L,obj,x) \ |
| 226 | { TValue *io = (obj); TString *x_ = (x); \ | 226 | { TValue *io = (obj); TString *x_ = (x); \ |
| 227 | val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \ | 227 | val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \ |
| 228 | checkliveness(G(L),io); } | 228 | checkliveness(L,io); } |
| 229 | 229 | ||
| 230 | #define setuvalue(L,obj,x) \ | 230 | #define setuvalue(L,obj,x) \ |
| 231 | { TValue *io = (obj); Udata *x_ = (x); \ | 231 | { TValue *io = (obj); Udata *x_ = (x); \ |
| 232 | val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TUSERDATA)); \ | 232 | val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TUSERDATA)); \ |
| 233 | checkliveness(G(L),io); } | 233 | checkliveness(L,io); } |
| 234 | 234 | ||
| 235 | #define setthvalue(L,obj,x) \ | 235 | #define setthvalue(L,obj,x) \ |
| 236 | { TValue *io = (obj); lua_State *x_ = (x); \ | 236 | { TValue *io = (obj); lua_State *x_ = (x); \ |
| 237 | val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTHREAD)); \ | 237 | val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTHREAD)); \ |
| 238 | checkliveness(G(L),io); } | 238 | checkliveness(L,io); } |
| 239 | 239 | ||
| 240 | #define setclLvalue(L,obj,x) \ | 240 | #define setclLvalue(L,obj,x) \ |
| 241 | { TValue *io = (obj); LClosure *x_ = (x); \ | 241 | { TValue *io = (obj); LClosure *x_ = (x); \ |
| 242 | val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TLCL)); \ | 242 | val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TLCL)); \ |
| 243 | checkliveness(G(L),io); } | 243 | checkliveness(L,io); } |
| 244 | 244 | ||
| 245 | #define setclCvalue(L,obj,x) \ | 245 | #define setclCvalue(L,obj,x) \ |
| 246 | { TValue *io = (obj); CClosure *x_ = (x); \ | 246 | { TValue *io = (obj); CClosure *x_ = (x); \ |
| 247 | val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TCCL)); \ | 247 | val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TCCL)); \ |
| 248 | checkliveness(G(L),io); } | 248 | checkliveness(L,io); } |
| 249 | 249 | ||
| 250 | #define sethvalue(L,obj,x) \ | 250 | #define sethvalue(L,obj,x) \ |
| 251 | { TValue *io = (obj); Table *x_ = (x); \ | 251 | { TValue *io = (obj); Table *x_ = (x); \ |
| 252 | val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTABLE)); \ | 252 | val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTABLE)); \ |
| 253 | checkliveness(G(L),io); } | 253 | checkliveness(L,io); } |
| 254 | 254 | ||
| 255 | #define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY) | 255 | #define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY) |
| 256 | 256 | ||
| @@ -258,7 +258,7 @@ typedef struct lua_TValue { | |||
| 258 | 258 | ||
| 259 | #define setobj(L,obj1,obj2) \ | 259 | #define setobj(L,obj1,obj2) \ |
| 260 | { TValue *io1=(obj1); *io1 = *(obj2); \ | 260 | { TValue *io1=(obj1); *io1 = *(obj2); \ |
| 261 | (void)L; checkliveness(G(L),io1); } | 261 | (void)L; checkliveness(L,io1); } |
| 262 | 262 | ||
| 263 | 263 | ||
| 264 | /* | 264 | /* |
| @@ -274,12 +274,13 @@ typedef struct lua_TValue { | |||
| 274 | #define setptvalue2s setptvalue | 274 | #define setptvalue2s setptvalue |
| 275 | /* from table to same table */ | 275 | /* from table to same table */ |
| 276 | #define setobjt2t setobj | 276 | #define setobjt2t setobj |
| 277 | /* to table */ | ||
| 278 | #define setobj2t setobj | ||
| 279 | /* to new object */ | 277 | /* to new object */ |
| 280 | #define setobj2n setobj | 278 | #define setobj2n setobj |
| 281 | #define setsvalue2n setsvalue | 279 | #define setsvalue2n setsvalue |
| 282 | 280 | ||
| 281 | /* to table (define it as an expression to be used in macros) */ | ||
| 282 | #define setobj2t(L,o1,o2) ((void)L, *(o1)=*(o2), checkliveness(L,(o1))) | ||
| 283 | |||
| 283 | 284 | ||
| 284 | 285 | ||
| 285 | 286 | ||
| @@ -370,13 +371,13 @@ typedef union UUdata { | |||
| 370 | #define setuservalue(L,u,o) \ | 371 | #define setuservalue(L,u,o) \ |
| 371 | { const TValue *io=(o); Udata *iu = (u); \ | 372 | { const TValue *io=(o); Udata *iu = (u); \ |
| 372 | iu->user_ = io->value_; iu->ttuv_ = rttype(io); \ | 373 | iu->user_ = io->value_; iu->ttuv_ = rttype(io); \ |
| 373 | checkliveness(G(L),io); } | 374 | checkliveness(L,io); } |
| 374 | 375 | ||
| 375 | 376 | ||
| 376 | #define getuservalue(L,u,o) \ | 377 | #define getuservalue(L,u,o) \ |
| 377 | { TValue *io=(o); const Udata *iu = (u); \ | 378 | { TValue *io=(o); const Udata *iu = (u); \ |
| 378 | io->value_ = iu->user_; settt_(io, iu->ttuv_); \ | 379 | io->value_ = iu->user_; settt_(io, iu->ttuv_); \ |
| 379 | checkliveness(G(L),io); } | 380 | checkliveness(L,io); } |
| 380 | 381 | ||
| 381 | 382 | ||
| 382 | /* | 383 | /* |
| @@ -484,7 +485,7 @@ typedef union TKey { | |||
| 484 | #define setnodekey(L,key,obj) \ | 485 | #define setnodekey(L,key,obj) \ |
| 485 | { TKey *k_=(key); const TValue *io_=(obj); \ | 486 | { TKey *k_=(key); const TValue *io_=(obj); \ |
| 486 | k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \ | 487 | k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \ |
| 487 | (void)L; checkliveness(G(L),io_); } | 488 | (void)L; checkliveness(L,io_); } |
| 488 | 489 | ||
| 489 | 490 | ||
| 490 | typedef struct Node { | 491 | typedef struct Node { |
