aboutsummaryrefslogtreecommitdiff
path: root/ltable.h
diff options
context:
space:
mode:
Diffstat (limited to 'ltable.h')
-rw-r--r--ltable.h29
1 files changed, 13 insertions, 16 deletions
diff --git a/ltable.h b/ltable.h
index 8b0340b5..10dae5c7 100644
--- a/ltable.h
+++ b/ltable.h
@@ -46,13 +46,11 @@
46 46
47 47
48 48
49#define luaH_fastgeti(t,k,res,hres) \ 49#define luaH_fastgeti(t,k,res,aux) \
50 { Table *h = t; lua_Unsigned u = l_castS2U(k); \ 50 { Table *h = t; lua_Unsigned u = l_castS2U(k); \
51 if ((u - 1u < h->alimit)) { \ 51 if ((u - 1u < h->alimit)) arr2objV(h,u,aux); \
52 int tag = *getArrTag(h,(u)-1u); \ 52 else aux = luaH_getint(h, u); \
53 if (tagisempty(tag)) hres = HNOTFOUND; \ 53 if (!isemptyV(aux)) setobjV(cast(lua_State*, NULL), res, aux); }
54 else { farr2val(h, u, tag, res); hres = HOK; }} \
55 else { hres = luaH_getint(h, u, res); }}
56 54
57 55
58#define luaH_fastseti(t,k,val,hres) \ 56#define luaH_fastseti(t,k,val,hres) \
@@ -64,15 +62,13 @@
64 else { hres = luaH_psetint(h, u, val); }} 62 else { hres = luaH_psetint(h, u, val); }}
65 63
66 64
67/* results from get/pset */ 65/* results from pset */
68#define HOK 0 66#define HOK 0
69#define HNOTFOUND 1 67#define HNOTFOUND 1
70#define HNOTATABLE 2 68#define HNOTATABLE 2
71#define HFIRSTNODE 3 69#define HFIRSTNODE 3
72 70
73/* 71/*
74** 'luaH_get*' operations set 'res' and return HOK, unless the value is
75** absent. In that case, they set nothing and return HNOTFOUND.
76** The 'luaH_pset*' (pre-set) operations set the given value and return 72** The 'luaH_pset*' (pre-set) operations set the given value and return
77** HOK, unless the original value is absent. In that case, if the key 73** HOK, unless the original value is absent. In that case, if the key
78** is really absent, they return HNOTFOUND. Otherwise, if there is a 74** is really absent, they return HNOTFOUND. Otherwise, if there is a
@@ -109,8 +105,10 @@ struct ArrayCell {
109/* 105/*
110** Move TValues to/from arrays, using Lua indices 106** Move TValues to/from arrays, using Lua indices
111*/ 107*/
112#define arr2obj(h,k,val) \ 108#define arr2objV(h,k,val) \
113 ((val)->tt_ = *getArrTag(h,(k)-1u), (val)->value_ = *getArrVal(h,(k)-1u)) 109 ((val).tt_ = *getArrTag(h,(k)-1u), (val).value_ = *getArrVal(h,(k)-1u))
110
111#define arr2obj(h,k,val) arr2objV(h,k,*(val))
114 112
115#define obj2arr(h,k,val) \ 113#define obj2arr(h,k,val) \
116 (*getArrTag(h,(k)-1u) = (val)->tt_, *getArrVal(h,(k)-1u) = (val)->value_) 114 (*getArrTag(h,(k)-1u) = (val)->tt_, *getArrVal(h,(k)-1u) = (val)->value_)
@@ -128,12 +126,11 @@ struct ArrayCell {
128 (*tag = (val)->tt_, *getArrVal(h,(k)-1u) = (val)->value_) 126 (*tag = (val)->tt_, *getArrVal(h,(k)-1u) = (val)->value_)
129 127
130 128
131LUAI_FUNC int luaH_get (Table *t, const TValue *key, TValue *res); 129LUAI_FUNC TValue luaH_get (Table *t, const TValue *key);
132LUAI_FUNC int luaH_getshortstr (Table *t, TString *key, TValue *res); 130LUAI_FUNC TValue luaH_getshortstr (Table *t, TString *key);
133LUAI_FUNC int luaH_getstr (Table *t, TString *key, TValue *res); 131LUAI_FUNC TValue luaH_getstr (Table *t, TString *key);
134LUAI_FUNC int luaH_getint (Table *t, lua_Integer key, TValue *res); 132LUAI_FUNC TValue luaH_getint (Table *t, lua_Integer key);
135 133
136/* Special get for metamethods */
137LUAI_FUNC const TValue *luaH_Hgetshortstr (Table *t, TString *key); 134LUAI_FUNC const TValue *luaH_Hgetshortstr (Table *t, TString *key);
138 135
139LUAI_FUNC TString *luaH_getstrkey (Table *t, TString *key); 136LUAI_FUNC TString *luaH_getstrkey (Table *t, TString *key);