diff options
Diffstat (limited to 'lobject.h')
-rw-r--r-- | lobject.h | 59 |
1 files changed, 31 insertions, 28 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 2.29 2009/09/28 16:32:50 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.30 2009/09/30 15:38:37 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 | */ |
@@ -52,7 +52,6 @@ typedef struct GCheader { | |||
52 | 52 | ||
53 | 53 | ||
54 | 54 | ||
55 | |||
56 | /* | 55 | /* |
57 | ** Union of all Lua values | 56 | ** Union of all Lua values |
58 | */ | 57 | */ |
@@ -64,11 +63,12 @@ typedef union { | |||
64 | } Value; | 63 | } Value; |
65 | 64 | ||
66 | 65 | ||
66 | |||
67 | /* | 67 | /* |
68 | ** Tagged Values | 68 | ** Tagged Values |
69 | */ | 69 | */ |
70 | 70 | ||
71 | #define TValuefields Value value; int tt | 71 | #define TValuefields Value value_; int tt_ |
72 | 72 | ||
73 | typedef struct lua_TValue { | 73 | typedef struct lua_TValue { |
74 | TValuefields; | 74 | TValuefields; |
@@ -87,18 +87,18 @@ typedef struct lua_TValue { | |||
87 | #define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) | 87 | #define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) |
88 | 88 | ||
89 | /* Macros to access values */ | 89 | /* Macros to access values */ |
90 | #define ttype(o) ((o)->tt) | 90 | #define ttype(o) ((o)->tt_) |
91 | #define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc) | 91 | #define gcvalue(o) check_exp(iscollectable(o), (o)->value_.gc) |
92 | #define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p) | 92 | #define pvalue(o) check_exp(ttislightuserdata(o), (o)->value_.p) |
93 | #define nvalue(o) check_exp(ttisnumber(o), (o)->value.n) | 93 | #define nvalue(o) check_exp(ttisnumber(o), (o)->value_.n) |
94 | #define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts) | 94 | #define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value_.gc->ts) |
95 | #define tsvalue(o) (&rawtsvalue(o)->tsv) | 95 | #define tsvalue(o) (&rawtsvalue(o)->tsv) |
96 | #define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u) | 96 | #define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value_.gc->u) |
97 | #define uvalue(o) (&rawuvalue(o)->uv) | 97 | #define uvalue(o) (&rawuvalue(o)->uv) |
98 | #define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl) | 98 | #define clvalue(o) check_exp(ttisfunction(o), &(o)->value_.gc->cl) |
99 | #define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h) | 99 | #define hvalue(o) check_exp(ttistable(o), &(o)->value_.gc->h) |
100 | #define bvalue(o) check_exp(ttisboolean(o), (o)->value.b) | 100 | #define bvalue(o) check_exp(ttisboolean(o), (o)->value_.b) |
101 | #define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th) | 101 | #define thvalue(o) check_exp(ttisthread(o), &(o)->value_.gc->th) |
102 | 102 | ||
103 | #define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) | 103 | #define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) |
104 | 104 | ||
@@ -106,56 +106,56 @@ typedef struct lua_TValue { | |||
106 | ** for internal debug only | 106 | ** for internal debug only |
107 | */ | 107 | */ |
108 | #define checkconsistency(obj) \ | 108 | #define checkconsistency(obj) \ |
109 | lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt)) | 109 | lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value_.gc->gch.tt)) |
110 | 110 | ||
111 | #define checkliveness(g,obj) \ | 111 | #define checkliveness(g,obj) \ |
112 | lua_assert(!iscollectable(obj) || \ | 112 | lua_assert(!iscollectable(obj) || \ |
113 | ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc))) | 113 | ((ttype(obj) == (obj)->value_.gc->gch.tt) && !isdead(g, (obj)->value_.gc))) |
114 | 114 | ||
115 | 115 | ||
116 | /* Macros to set values */ | 116 | /* Macros to set values */ |
117 | #define setnilvalue(obj) ((obj)->tt=LUA_TNIL) | 117 | #define setnilvalue(obj) ((obj)->tt_=LUA_TNIL) |
118 | 118 | ||
119 | #define setnvalue(obj,x) \ | 119 | #define setnvalue(obj,x) \ |
120 | { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } | 120 | { TValue *i_o=(obj); i_o->value_.n=(x); i_o->tt_=LUA_TNUMBER; } |
121 | 121 | ||
122 | #define changenvalue(obj,x) \ | 122 | #define changenvalue(obj,x) \ |
123 | ( lua_assert((obj)->tt==LUA_TNUMBER), (obj)->value.n=(x) ) | 123 | ( lua_assert((obj)->tt_==LUA_TNUMBER), (obj)->value_.n=(x) ) |
124 | 124 | ||
125 | #define setpvalue(obj,x) \ | 125 | #define setpvalue(obj,x) \ |
126 | { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } | 126 | { TValue *i_o=(obj); i_o->value_.p=(x); i_o->tt_=LUA_TLIGHTUSERDATA; } |
127 | 127 | ||
128 | #define setbvalue(obj,x) \ | 128 | #define setbvalue(obj,x) \ |
129 | { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; } | 129 | { TValue *i_o=(obj); i_o->value_.b=(x); i_o->tt_=LUA_TBOOLEAN; } |
130 | 130 | ||
131 | #define setsvalue(L,obj,x) \ | 131 | #define setsvalue(L,obj,x) \ |
132 | { TValue *i_o=(obj); \ | 132 | { TValue *i_o=(obj); \ |
133 | i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \ | 133 | i_o->value_.gc=cast(GCObject *, (x)); i_o->tt_=LUA_TSTRING; \ |
134 | checkliveness(G(L),i_o); } | 134 | checkliveness(G(L),i_o); } |
135 | 135 | ||
136 | #define setuvalue(L,obj,x) \ | 136 | #define setuvalue(L,obj,x) \ |
137 | { TValue *i_o=(obj); \ | 137 | { TValue *i_o=(obj); \ |
138 | i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \ | 138 | i_o->value_.gc=cast(GCObject *, (x)); i_o->tt_=LUA_TUSERDATA; \ |
139 | checkliveness(G(L),i_o); } | 139 | checkliveness(G(L),i_o); } |
140 | 140 | ||
141 | #define setthvalue(L,obj,x) \ | 141 | #define setthvalue(L,obj,x) \ |
142 | { TValue *i_o=(obj); \ | 142 | { TValue *i_o=(obj); \ |
143 | i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \ | 143 | i_o->value_.gc=cast(GCObject *, (x)); i_o->tt_=LUA_TTHREAD; \ |
144 | checkliveness(G(L),i_o); } | 144 | checkliveness(G(L),i_o); } |
145 | 145 | ||
146 | #define setclvalue(L,obj,x) \ | 146 | #define setclvalue(L,obj,x) \ |
147 | { TValue *i_o=(obj); \ | 147 | { TValue *i_o=(obj); \ |
148 | i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \ | 148 | i_o->value_.gc=cast(GCObject *, (x)); i_o->tt_=LUA_TFUNCTION; \ |
149 | checkliveness(G(L),i_o); } | 149 | checkliveness(G(L),i_o); } |
150 | 150 | ||
151 | #define sethvalue(L,obj,x) \ | 151 | #define sethvalue(L,obj,x) \ |
152 | { TValue *i_o=(obj); \ | 152 | { TValue *i_o=(obj); \ |
153 | i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \ | 153 | i_o->value_.gc=cast(GCObject *, (x)); i_o->tt_=LUA_TTABLE; \ |
154 | checkliveness(G(L),i_o); } | 154 | checkliveness(G(L),i_o); } |
155 | 155 | ||
156 | #define setptvalue(L,obj,x) \ | 156 | #define setptvalue(L,obj,x) \ |
157 | { TValue *i_o=(obj); \ | 157 | { TValue *i_o=(obj); \ |
158 | i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \ | 158 | i_o->value_.gc=cast(GCObject *, (x)); i_o->tt_=LUA_TPROTO; \ |
159 | checkliveness(G(L),i_o); } | 159 | checkliveness(G(L),i_o); } |
160 | 160 | ||
161 | 161 | ||
@@ -163,7 +163,7 @@ typedef struct lua_TValue { | |||
163 | 163 | ||
164 | #define setobj(L,obj1,obj2) \ | 164 | #define setobj(L,obj1,obj2) \ |
165 | { const TValue *o2=(obj2); TValue *o1=(obj1); \ | 165 | { const TValue *o2=(obj2); TValue *o1=(obj1); \ |
166 | o1->value = o2->value; o1->tt=o2->tt; \ | 166 | o1->value_ = o2->value_; o1->tt_=o2->tt_; \ |
167 | checkliveness(G(L),o1); } | 167 | checkliveness(G(L),o1); } |
168 | 168 | ||
169 | 169 | ||
@@ -186,7 +186,7 @@ typedef struct lua_TValue { | |||
186 | #define setobj2n setobj | 186 | #define setobj2n setobj |
187 | #define setsvalue2n setsvalue | 187 | #define setsvalue2n setsvalue |
188 | 188 | ||
189 | #define setttype(obj, tt) (ttype(obj) = (tt)) | 189 | #define setttype(obj, tt_) (ttype(obj) = (tt_)) |
190 | 190 | ||
191 | 191 | ||
192 | #define iscollectable(o) (ttype(o) >= LUA_TSTRING) | 192 | #define iscollectable(o) (ttype(o) >= LUA_TSTRING) |
@@ -341,6 +341,9 @@ typedef struct Node { | |||
341 | TKey i_key; | 341 | TKey i_key; |
342 | } Node; | 342 | } Node; |
343 | 343 | ||
344 | #define setnodekey(nd,obj) { Node *n = (nd); const TValue *o = (obj); \ | ||
345 | n->i_key.nk.value_ = o->value_; n->i_key.nk.tt_ = o->tt_; } | ||
346 | |||
344 | 347 | ||
345 | typedef struct Table { | 348 | typedef struct Table { |
346 | CommonHeader; | 349 | CommonHeader; |