diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-05-16 16:53:29 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-05-16 16:53:29 -0300 |
| commit | 819bd51d87b799fdee029754c660dc9a5587ef57 (patch) | |
| tree | 0b1ffb9a3fd591372992c72a27e4590b48236b71 /ltable.h | |
| parent | f8d30826dda6ee8e99200de57a1997734b853db2 (diff) | |
| download | lua-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.h | 37 |
1 files changed, 22 insertions, 15 deletions
| @@ -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 | ||
| 58 | LUAI_FUNC int luaH_getshortstr1 (Table *t, TString *key, TValue *res); | 68 | LUAI_FUNC int luaH_getshortstr (Table *t, TString *key, TValue *res); |
| 59 | LUAI_FUNC int luaH_getstr1 (Table *t, TString *key, TValue *res); | 69 | LUAI_FUNC int luaH_getstr (Table *t, TString *key, TValue *res); |
| 60 | LUAI_FUNC int luaH_get1 (Table *t, const TValue *key, TValue *res); | 70 | LUAI_FUNC int luaH_get (Table *t, const TValue *key, TValue *res); |
| 61 | LUAI_FUNC int luaH_getint1 (Table *t, lua_Integer key, TValue *res); | 71 | LUAI_FUNC int luaH_getint (Table *t, lua_Integer key, TValue *res); |
| 72 | |||
| 73 | LUAI_FUNC TString *luaH_getstrkey (Table *t, TString *key); | ||
| 62 | 74 | ||
| 63 | LUAI_FUNC int luaH_setint1 (Table *t, lua_Integer key, TValue *val); | 75 | LUAI_FUNC int luaH_psetint (Table *t, lua_Integer key, TValue *val); |
| 64 | LUAI_FUNC int luaH_setshortstr1 (Table *t, TString *key, TValue *val); | 76 | LUAI_FUNC int luaH_psetshortstr (Table *t, TString *key, TValue *val); |
| 65 | LUAI_FUNC int luaH_setstr1 (Table *t, TString *key, TValue *val); | 77 | LUAI_FUNC int luaH_psetstr (Table *t, TString *key, TValue *val); |
| 66 | LUAI_FUNC int luaH_set1 (Table *t, const TValue *key, TValue *val); | 78 | LUAI_FUNC int luaH_pset (Table *t, const TValue *key, TValue *val); |
| 67 | 79 | ||
| 68 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); | ||
| 69 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, | 80 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, |
| 70 | TValue *value); | 81 | TValue *value); |
| 71 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); | 82 | LUAI_FUNC const TValue *luaH_Hgetshortstr (Table *t, TString *key); |
| 72 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); | ||
| 73 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); | ||
| 74 | LUAI_FUNC void luaH_newkey (lua_State *L, Table *t, const TValue *key, | 83 | LUAI_FUNC void luaH_newkey (lua_State *L, Table *t, const TValue *key, |
| 75 | TValue *value); | 84 | TValue *value); |
| 76 | LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key, | 85 | LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key, |
| 77 | TValue *value); | 86 | TValue *value); |
| 78 | LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key, | 87 | LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key, |
| 79 | const TValue *slot, TValue *value); | ||
| 80 | LUAI_FUNC void luaH_finishset1 (lua_State *L, Table *t, const TValue *key, | ||
| 81 | TValue *value, int aux); | 88 | TValue *value, int aux); |
| 82 | LUAI_FUNC Table *luaH_new (lua_State *L); | 89 | LUAI_FUNC Table *luaH_new (lua_State *L); |
| 83 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, | 90 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, |
