diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-06-05 17:15:33 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-06-05 17:15:33 -0300 |
commit | 292c9530183a8e9939cff9a7d30fc50e85031698 (patch) | |
tree | 20dc1c90af03ef60396d6a8df737369fb8238f21 | |
parent | c542aac0b935a65203244c130cdfa700113f0bc8 (diff) | |
download | lua-292c9530183a8e9939cff9a7d30fc50e85031698.tar.gz lua-292c9530183a8e9939cff9a7d30fc50e85031698.tar.bz2 lua-292c9530183a8e9939cff9a7d30fc50e85031698.zip |
new auxiliar function `luaH_setstr'
-rw-r--r-- | lbuiltin.c | 9 | ||||
-rw-r--r-- | ltable.c | 10 | ||||
-rw-r--r-- | ltable.h | 3 | ||||
-rw-r--r-- | lvm.c | 7 |
4 files changed, 16 insertions, 13 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbuiltin.c,v 1.111 2000/05/26 19:17:57 roberto Exp roberto $ | 2 | ** $Id: lbuiltin.c,v 1.112 2000/06/02 19:08:56 roberto Exp roberto $ |
3 | ** Built-in functions | 3 | ** Built-in functions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -68,12 +68,7 @@ static Number getsize (const Hash *h) { | |||
68 | 68 | ||
69 | 69 | ||
70 | static Number getnarg (lua_State *L, const Hash *a) { | 70 | static Number getnarg (lua_State *L, const Hash *a) { |
71 | TObject index; | 71 | const TObject *value = luaH_getstr(a, luaS_new(L, "n")); /* value = a.n */ |
72 | const TObject *value; | ||
73 | /* value = table.n */ | ||
74 | ttype(&index) = TAG_STRING; | ||
75 | tsvalue(&index) = luaS_new(L, "n"); | ||
76 | value = luaH_get(L, a, &index); | ||
77 | return (ttype(value) == TAG_NUMBER) ? nvalue(value) : getsize(a); | 72 | return (ttype(value) == TAG_NUMBER) ? nvalue(value) : getsize(a); |
78 | } | 73 | } |
79 | 74 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.43 2000/05/24 13:54:49 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 1.44 2000/06/05 20:07:53 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 | */ |
@@ -278,6 +278,14 @@ void luaH_setint (lua_State *L, Hash *t, int key, const TObject *val) { | |||
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | void luaH_setstr (lua_State *L, Hash *t, TString *key, const TObject *val) { | ||
282 | TObject index; | ||
283 | ttype(&index) = TAG_STRING; | ||
284 | tsvalue(&index) = key; | ||
285 | luaH_set(L, t, &index, val); | ||
286 | } | ||
287 | |||
288 | |||
281 | const TObject *luaH_getglobal (lua_State *L, const char *name) { | 289 | const TObject *luaH_getglobal (lua_State *L, const char *name) { |
282 | return luaH_getstr(L->gt, luaS_new(L, name)); | 290 | return luaH_getstr(L->gt, luaS_new(L, name)); |
283 | } | 291 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.h,v 1.20 2000/05/08 19:32:53 roberto Exp roberto $ | 2 | ** $Id: ltable.h,v 1.21 2000/06/05 20:07:53 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 | */ |
@@ -25,6 +25,7 @@ void luaH_remove (Hash *t, TObject *key); | |||
25 | void luaH_set (lua_State *L, Hash *t, const TObject *key, const TObject *val); | 25 | void luaH_set (lua_State *L, Hash *t, const TObject *key, const TObject *val); |
26 | int luaH_pos (lua_State *L, const Hash *t, const TObject *r); | 26 | int luaH_pos (lua_State *L, const Hash *t, const TObject *r); |
27 | void luaH_setint (lua_State *L, Hash *t, int key, const TObject *val); | 27 | void luaH_setint (lua_State *L, Hash *t, int key, const TObject *val); |
28 | void luaH_setstr (lua_State *L, Hash *t, TString *key, const TObject *val); | ||
28 | unsigned long luaH_hash (lua_State *L, const TObject *key); | 29 | unsigned long luaH_hash (lua_State *L, const TObject *key); |
29 | const TObject *luaH_getglobal (lua_State *L, const char *name); | 30 | const TObject *luaH_getglobal (lua_State *L, const char *name); |
30 | 31 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.110 2000/05/30 19:00:31 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.111 2000/06/05 14:56:18 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -66,10 +66,9 @@ int luaV_tostring (lua_State *L, TObject *obj) { /* LUA_NUMBER */ | |||
66 | 66 | ||
67 | 67 | ||
68 | void luaV_setn (lua_State *L, Hash *t, int val) { | 68 | void luaV_setn (lua_State *L, Hash *t, int val) { |
69 | TObject index, value; | 69 | TObject value; |
70 | ttype(&index) = TAG_STRING; tsvalue(&index) = luaS_new(L, "n"); | ||
71 | ttype(&value) = TAG_NUMBER; nvalue(&value) = val; | 70 | ttype(&value) = TAG_NUMBER; nvalue(&value) = val; |
72 | luaH_set(L, t, &index, &value); | 71 | luaH_setstr(L, t, luaS_new(L, "n"), &value); |
73 | } | 72 | } |
74 | 73 | ||
75 | 74 | ||