diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-06-01 13:51:34 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-06-01 13:51:34 -0300 |
commit | fb8fa661366e15e98c60d8929feaab9e551a02f9 (patch) | |
tree | b3eb16fcfe3eab8f4b07ccaa71c55011016ad005 /lobject.h | |
parent | b3970649550fe8471c55bfae57aa3752ddfa97a9 (diff) | |
download | lua-fb8fa661366e15e98c60d8929feaab9e551a02f9.tar.gz lua-fb8fa661366e15e98c60d8929feaab9e551a02f9.tar.bz2 lua-fb8fa661366e15e98c60d8929feaab9e551a02f9.zip |
no more 'luaH_emptyobject' and comparisons of addresses of global variables
(instead, use a different kind of nil to signal the fake entry returned
when a key is not found in a table)
Diffstat (limited to 'lobject.h')
-rw-r--r-- | lobject.h | 36 |
1 files changed, 28 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 2.141 2018/02/26 14:16:05 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.142 2018/04/04 14:23:41 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 | */ |
@@ -137,7 +137,12 @@ typedef StackValue *StkId; /* index to stack elements */ | |||
137 | ** =================================================================== | 137 | ** =================================================================== |
138 | */ | 138 | */ |
139 | 139 | ||
140 | #define ttisnil(o) checktag((o), LUA_TNIL) | 140 | /* macro to test for (any kind of) nil */ |
141 | #define ttisnil(v) checktype((v), LUA_TNIL) | ||
142 | |||
143 | /* macro to test for a "pure" nil */ | ||
144 | #define ttisstrictnil(o) checktag((o), LUA_TNIL) | ||
145 | |||
141 | 146 | ||
142 | /* macro defining a nil value */ | 147 | /* macro defining a nil value */ |
143 | #define NILCONSTANT {NULL}, LUA_TNIL | 148 | #define NILCONSTANT {NULL}, LUA_TNIL |
@@ -155,17 +160,32 @@ typedef StackValue *StkId; /* index to stack elements */ | |||
155 | */ | 160 | */ |
156 | #define LUA_TEMPTY (LUA_TNIL | (1 << 4)) | 161 | #define LUA_TEMPTY (LUA_TNIL | (1 << 4)) |
157 | 162 | ||
158 | #define ttisnilorempty(v) checktype((v), LUA_TNIL) | 163 | /* |
164 | ** Variant used only in the value returned for a key not found in a | ||
165 | ** table (absent key). | ||
166 | */ | ||
167 | #define LUA_TABSTKEY (LUA_TNIL | (2 << 4)) | ||
168 | |||
159 | 169 | ||
160 | #define isreallyempty(v) checktag((v), LUA_TEMPTY) | 170 | #define isabstkey(v) checktag((v), LUA_TABSTKEY) |
161 | 171 | ||
162 | 172 | ||
163 | /* By default, entries with any kind of nil are considered empty */ | 173 | /* |
164 | #define isempty(v) ttisnilorempty(v) | 174 | ** macro to detect non-standard nils (used only in assertions) |
175 | */ | ||
176 | #define isreallyempty(v) (ttisnil(v) && !ttisstrictnil(v)) | ||
177 | |||
178 | |||
179 | /* | ||
180 | ** By default, entries with any kind of nil are considered empty. | ||
181 | ** (In any definition, values associated with absent keys must also | ||
182 | ** be accepted as empty.) | ||
183 | */ | ||
184 | #define isempty(v) ttisnil(v) | ||
165 | 185 | ||
166 | 186 | ||
167 | /* macro defining an empty value */ | 187 | /* macro defining a value corresponding to an absent key */ |
168 | #define EMPTYCONSTANT {NULL}, LUA_TEMPTY | 188 | #define ABSTKEYCONSTANT {NULL}, LUA_TABSTKEY |
169 | 189 | ||
170 | 190 | ||
171 | /* mark an entry as empty */ | 191 | /* mark an entry as empty */ |