aboutsummaryrefslogtreecommitdiff
path: root/ltable.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-05-16 16:53:29 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-05-16 16:53:29 -0300
commit819bd51d87b799fdee029754c660dc9a5587ef57 (patch)
tree0b1ffb9a3fd591372992c72a27e4590b48236b71 /ltable.h
parentf8d30826dda6ee8e99200de57a1997734b853db2 (diff)
downloadlua-819bd51d87b799fdee029754c660dc9a5587ef57.tar.gz
lua-819bd51d87b799fdee029754c660dc9a5587ef57.tar.bz2
lua-819bd51d87b799fdee029754c660dc9a5587ef57.zip
Some cleaning in the new table API
Diffstat (limited to 'ltable.h')
-rw-r--r--ltable.h37
1 files changed, 22 insertions, 15 deletions
diff --git a/ltable.h b/ltable.h
index b9bb416a..5ec7b447 100644
--- a/ltable.h
+++ b/ltable.h
@@ -35,12 +35,22 @@
35#define nodefromval(v) cast(Node *, (v)) 35#define nodefromval(v) cast(Node *, (v))
36 36
37 37
38/* results from get/set */ 38/* results from get/pset */
39#define HOK 0 39#define HOK 0
40#define HNOTFOUND 1 40#define HNOTFOUND 1
41#define HNOTATABLE 2 41#define HNOTATABLE 2
42#define HFIRSTNODE 3 42#define HFIRSTNODE 3
43 43
44/*
45** Besides these values, pset (pre-set) operations may also return an
46** encoding of where the value should go (usually called 'hres'). That
47** means that there is a slot with that key but with no value. (pset
48** cannot set that value because there might be a metamethod.) If the
49** slot is in the hash part, the encoding is (HFIRSTNODE + hash index);
50** if the slot is in the array part, the encoding is (~array index).
51*/
52
53
44 54
45/* fast access to components of array values */ 55/* fast access to components of array values */
46#define getArrTag(t,k) (&(t)->array[k - 1].tt_) 56#define getArrTag(t,k) (&(t)->array[k - 1].tt_)
@@ -55,29 +65,26 @@
55 (*tag = (val)->tt_, *getArrVal(h,k) = (val)->value_) 65 (*tag = (val)->tt_, *getArrVal(h,k) = (val)->value_)
56 66
57 67
58LUAI_FUNC int luaH_getshortstr1 (Table *t, TString *key, TValue *res); 68LUAI_FUNC int luaH_getshortstr (Table *t, TString *key, TValue *res);
59LUAI_FUNC int luaH_getstr1 (Table *t, TString *key, TValue *res); 69LUAI_FUNC int luaH_getstr (Table *t, TString *key, TValue *res);
60LUAI_FUNC int luaH_get1 (Table *t, const TValue *key, TValue *res); 70LUAI_FUNC int luaH_get (Table *t, const TValue *key, TValue *res);
61LUAI_FUNC int luaH_getint1 (Table *t, lua_Integer key, TValue *res); 71LUAI_FUNC int luaH_getint (Table *t, lua_Integer key, TValue *res);
72
73LUAI_FUNC TString *luaH_getstrkey (Table *t, TString *key);
62 74
63LUAI_FUNC int luaH_setint1 (Table *t, lua_Integer key, TValue *val); 75LUAI_FUNC int luaH_psetint (Table *t, lua_Integer key, TValue *val);
64LUAI_FUNC int luaH_setshortstr1 (Table *t, TString *key, TValue *val); 76LUAI_FUNC int luaH_psetshortstr (Table *t, TString *key, TValue *val);
65LUAI_FUNC int luaH_setstr1 (Table *t, TString *key, TValue *val); 77LUAI_FUNC int luaH_psetstr (Table *t, TString *key, TValue *val);
66LUAI_FUNC int luaH_set1 (Table *t, const TValue *key, TValue *val); 78LUAI_FUNC int luaH_pset (Table *t, const TValue *key, TValue *val);
67 79
68LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
69LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 80LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
70 TValue *value); 81 TValue *value);
71LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); 82LUAI_FUNC const TValue *luaH_Hgetshortstr (Table *t, TString *key);
72LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
73LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
74LUAI_FUNC void luaH_newkey (lua_State *L, Table *t, const TValue *key, 83LUAI_FUNC void luaH_newkey (lua_State *L, Table *t, const TValue *key,
75 TValue *value); 84 TValue *value);
76LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key, 85LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key,
77 TValue *value); 86 TValue *value);
78LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key, 87LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key,
79 const TValue *slot, TValue *value);
80LUAI_FUNC void luaH_finishset1 (lua_State *L, Table *t, const TValue *key,
81 TValue *value, int aux); 88 TValue *value, int aux);
82LUAI_FUNC Table *luaH_new (lua_State *L); 89LUAI_FUNC Table *luaH_new (lua_State *L);
83LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 90LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize,