mirror of https://github.com/rusefi/lua.git
several small changes to simplify changing TValue if needed
This commit is contained in:
parent
63a3b1a1eb
commit
2583bac3d3
36
lobject.h
36
lobject.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lobject.h,v 2.30 2009/09/30 15:38:37 roberto Exp roberto $
|
** $Id: lobject.h,v 2.31 2009/11/05 17:43:54 roberto Exp roberto $
|
||||||
** Type definitions for Lua objects
|
** Type definitions for Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -75,6 +75,10 @@ typedef struct lua_TValue {
|
||||||
} TValue;
|
} TValue;
|
||||||
|
|
||||||
|
|
||||||
|
/* macro defining a nil value to be used in definitions */
|
||||||
|
#define NILCONSTANT {NULL}, LUA_TNIL
|
||||||
|
|
||||||
|
|
||||||
/* Macros to test type */
|
/* Macros to test type */
|
||||||
#define ttisnil(o) (ttype(o) == LUA_TNIL)
|
#define ttisnil(o) (ttype(o) == LUA_TNIL)
|
||||||
#define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
|
#define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
|
||||||
|
@ -85,6 +89,7 @@ typedef struct lua_TValue {
|
||||||
#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA)
|
#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA)
|
||||||
#define ttisthread(o) (ttype(o) == LUA_TTHREAD)
|
#define ttisthread(o) (ttype(o) == LUA_TTHREAD)
|
||||||
#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA)
|
#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA)
|
||||||
|
#define ttisdeadkey(o) (ttype(o) == LUA_TDEADKEY)
|
||||||
|
|
||||||
/* Macros to access values */
|
/* Macros to access values */
|
||||||
#define ttype(o) ((o)->tt_)
|
#define ttype(o) ((o)->tt_)
|
||||||
|
@ -105,12 +110,14 @@ typedef struct lua_TValue {
|
||||||
/*
|
/*
|
||||||
** for internal debug only
|
** for internal debug only
|
||||||
*/
|
*/
|
||||||
#define checkconsistency(obj) \
|
#define iscollectable(o) (ttype(o) >= LUA_TSTRING)
|
||||||
lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value_.gc->gch.tt))
|
|
||||||
|
#define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt)
|
||||||
|
|
||||||
|
#define checkconsistency(obj) lua_assert(!iscollectable(obj) || righttt(obj))
|
||||||
|
|
||||||
#define checkliveness(g,obj) \
|
#define checkliveness(g,obj) \
|
||||||
lua_assert(!iscollectable(obj) || \
|
lua_assert(!iscollectable(obj) || (righttt(obj) && !isdead(g,gcvalue(obj))))
|
||||||
((ttype(obj) == (obj)->value_.gc->gch.tt) && !isdead(g, (obj)->value_.gc)))
|
|
||||||
|
|
||||||
|
|
||||||
/* Macros to set values */
|
/* Macros to set values */
|
||||||
|
@ -158,13 +165,12 @@ typedef struct lua_TValue {
|
||||||
i_o->value_.gc=cast(GCObject *, (x)); i_o->tt_=LUA_TPROTO; \
|
i_o->value_.gc=cast(GCObject *, (x)); i_o->tt_=LUA_TPROTO; \
|
||||||
checkliveness(G(L),i_o); }
|
checkliveness(G(L),i_o); }
|
||||||
|
|
||||||
|
#define setdeadvalue(obj) ((obj)->tt_=LUA_TDEADKEY)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define setobj(L,obj1,obj2) \
|
|
||||||
{ const TValue *o2=(obj2); TValue *o1=(obj1); \
|
#define setobj(L,obj1,obj2) { *(obj1) = *(obj2); }
|
||||||
o1->value_ = o2->value_; o1->tt_=o2->tt_; \
|
|
||||||
checkliveness(G(L),o1); }
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -186,11 +192,6 @@ typedef struct lua_TValue {
|
||||||
#define setobj2n setobj
|
#define setobj2n setobj
|
||||||
#define setsvalue2n setsvalue
|
#define setsvalue2n setsvalue
|
||||||
|
|
||||||
#define setttype(obj, tt_) (ttype(obj) = (tt_))
|
|
||||||
|
|
||||||
|
|
||||||
#define iscollectable(o) (ttype(o) >= LUA_TSTRING)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef TValue *StkId; /* index to stack elements */
|
typedef TValue *StkId; /* index to stack elements */
|
||||||
|
@ -318,8 +319,8 @@ typedef union Closure {
|
||||||
} Closure;
|
} Closure;
|
||||||
|
|
||||||
|
|
||||||
#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
|
#define iscfunction(o) (ttisfunction(o) && clvalue(o)->c.isC)
|
||||||
#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
|
#define isLfunction(o) (ttisfunction(o) && !clvalue(o)->c.isC)
|
||||||
|
|
||||||
#define getproto(o) (clvalue(o)->l.p)
|
#define getproto(o) (clvalue(o)->l.p)
|
||||||
|
|
||||||
|
@ -341,9 +342,6 @@ typedef struct Node {
|
||||||
TKey i_key;
|
TKey i_key;
|
||||||
} Node;
|
} Node;
|
||||||
|
|
||||||
#define setnodekey(nd,obj) { Node *n = (nd); const TValue *o = (obj); \
|
|
||||||
n->i_key.nk.value_ = o->value_; n->i_key.nk.tt_ = o->tt_; }
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct Table {
|
typedef struct Table {
|
||||||
CommonHeader;
|
CommonHeader;
|
||||||
|
|
Loading…
Reference in New Issue