New table API for 'set' functions

This commit is contained in:
Roberto Ierusalimschy
2023-05-16 14:55:49 -03:00
parent 351ccd7332
commit f8d30826dd
5 changed files with 181 additions and 72 deletions

View File

@@ -39,6 +39,7 @@
#define HOK 0
#define HNOTFOUND 1
#define HNOTATABLE 2
#define HFIRSTNODE 3
/* fast access to components of array values */
@@ -50,12 +51,20 @@
#define arr2val(h,k,tag,res) \
((res)->tt_ = tag, (res)->value_ = *getArrVal(h,k))
#define val2arr(h,k,tag,val) \
(*tag = (val)->tt_, *getArrVal(h,k) = (val)->value_)
LUAI_FUNC int luaH_getshortstr1 (Table *t, TString *key, TValue *res);
LUAI_FUNC int luaH_getstr1 (Table *t, TString *key, TValue *res);
LUAI_FUNC int luaH_get1 (Table *t, const TValue *key, TValue *res);
LUAI_FUNC int luaH_getint1 (Table *t, lua_Integer key, TValue *res);
LUAI_FUNC int luaH_setint1 (Table *t, lua_Integer key, TValue *val);
LUAI_FUNC int luaH_setshortstr1 (Table *t, TString *key, TValue *val);
LUAI_FUNC int luaH_setstr1 (Table *t, TString *key, TValue *val);
LUAI_FUNC int luaH_set1 (Table *t, const TValue *key, TValue *val);
LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
TValue *value);
@@ -68,6 +77,8 @@ LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key,
TValue *value);
LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key,
const TValue *slot, TValue *value);
LUAI_FUNC void luaH_finishset1 (lua_State *L, Table *t, const TValue *key,
TValue *value, int aux);
LUAI_FUNC Table *luaH_new (lua_State *L);
LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
unsigned int nhsize);