aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-07-12 13:15:19 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-07-12 13:15:19 -0300
commit41d9ea948c18db38473e353ac7a84bc501f3ce74 (patch)
tree1232f5d3a602000f4bd2822e6def23bc4e3b7f77
parentee912e5a7f090314915be7b354be5bfa1002ed79 (diff)
downloadlua-41d9ea948c18db38473e353ac7a84bc501f3ce74.tar.gz
lua-41d9ea948c18db38473e353ac7a84bc501f3ce74.tar.bz2
lua-41d9ea948c18db38473e353ac7a84bc501f3ce74.zip
auxiliar functions "luaH_setint" & "luaH_getint".
-rw-r--r--ltable.c21
-rw-r--r--ltable.h5
2 files changed, 23 insertions, 3 deletions
diff --git a/ltable.c b/ltable.c
index aaf9f16e..91556b78 100644
--- a/ltable.c
+++ b/ltable.c
@@ -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
219void 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
227TObject *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
diff --git a/ltable.h b/ltable.h
index 06cf17c3..292e1e55 100644
--- a/ltable.h
+++ b/ltable.h
@@ -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);
20TObject *luaH_get (Hash *t, TObject *ref); 20TObject *luaH_get (Hash *t, TObject *ref);
21TObject *luaH_set (Hash *t, TObject *ref); 21TObject *luaH_set (Hash *t, TObject *ref);
22Node *luaH_next (TObject *o, TObject *r); 22Node *luaH_next (TObject *o, TObject *r);
23void luaH_setint (Hash *t, int ref, TObject *val);
24TObject *luaH_getint (Hash *t, int ref);
25
23 26
24#endif 27#endif