diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-07-12 13:15:19 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-07-12 13:15:19 -0300 |
commit | 41d9ea948c18db38473e353ac7a84bc501f3ce74 (patch) | |
tree | 1232f5d3a602000f4bd2822e6def23bc4e3b7f77 | |
parent | ee912e5a7f090314915be7b354be5bfa1002ed79 (diff) | |
download | lua-41d9ea948c18db38473e353ac7a84bc501f3ce74.tar.gz lua-41d9ea948c18db38473e353ac7a84bc501f3ce74.tar.bz2 lua-41d9ea948c18db38473e353ac7a84bc501f3ce74.zip |
auxiliar functions "luaH_setint" & "luaH_getint".
-rw-r--r-- | ltable.c | 21 | ||||
-rw-r--r-- | ltable.h | 5 |
2 files changed, 23 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.11 1998/01/13 18:06:27 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 1.12 1998/01/28 16:50:33 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -162,7 +162,7 @@ TObject *luaH_get (Hash *t, TObject *ref) | |||
162 | { | 162 | { |
163 | int h = present(t, ref); | 163 | int h = present(t, ref); |
164 | if (ttype(ref(node(t, h))) != LUA_T_NIL) return val(node(t, h)); | 164 | if (ttype(ref(node(t, h))) != LUA_T_NIL) return val(node(t, h)); |
165 | else return NULL; | 165 | else return &luaO_nilobject; |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
@@ -214,3 +214,20 @@ Node *luaH_next (TObject *o, TObject *r) | |||
214 | return hashnext(t, i+1); | 214 | return hashnext(t, i+1); |
215 | } | 215 | } |
216 | } | 216 | } |
217 | |||
218 | |||
219 | void luaH_setint (Hash *t, int ref, TObject *val) { | ||
220 | TObject index; | ||
221 | ttype(&index) = LUA_T_NUMBER; | ||
222 | nvalue(&index) = ref; | ||
223 | *(luaH_set(t, &index)) = *val; | ||
224 | } | ||
225 | |||
226 | |||
227 | TObject *luaH_getint (Hash *t, int ref) { | ||
228 | TObject index; | ||
229 | ttype(&index) = LUA_T_NUMBER; | ||
230 | nvalue(&index) = ref; | ||
231 | return luaH_get(t, &index); | ||
232 | } | ||
233 | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.h,v 1.4 1997/11/19 17:29:23 roberto Exp roberto $ | 2 | ** $Id: ltable.h,v 1.5 1997/11/26 18:53:45 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -20,5 +20,8 @@ void luaH_free (Hash *frees); | |||
20 | TObject *luaH_get (Hash *t, TObject *ref); | 20 | TObject *luaH_get (Hash *t, TObject *ref); |
21 | TObject *luaH_set (Hash *t, TObject *ref); | 21 | TObject *luaH_set (Hash *t, TObject *ref); |
22 | Node *luaH_next (TObject *o, TObject *r); | 22 | Node *luaH_next (TObject *o, TObject *r); |
23 | void luaH_setint (Hash *t, int ref, TObject *val); | ||
24 | TObject *luaH_getint (Hash *t, int ref); | ||
25 | |||
23 | 26 | ||
24 | #endif | 27 | #endif |