mirror of
https://github.com/lua/lua
synced 2024-12-28 21:29:44 +03:00
new auxiliar function `luaH_setstr'
This commit is contained in:
parent
c542aac0b9
commit
292c953018
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lbuiltin.c,v 1.111 2000/05/26 19:17:57 roberto Exp roberto $
|
||||
** $Id: lbuiltin.c,v 1.112 2000/06/02 19:08:56 roberto Exp roberto $
|
||||
** Built-in functions
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -68,12 +68,7 @@ static Number getsize (const Hash *h) {
|
||||
|
||||
|
||||
static Number getnarg (lua_State *L, const Hash *a) {
|
||||
TObject index;
|
||||
const TObject *value;
|
||||
/* value = table.n */
|
||||
ttype(&index) = TAG_STRING;
|
||||
tsvalue(&index) = luaS_new(L, "n");
|
||||
value = luaH_get(L, a, &index);
|
||||
const TObject *value = luaH_getstr(a, luaS_new(L, "n")); /* value = a.n */
|
||||
return (ttype(value) == TAG_NUMBER) ? nvalue(value) : getsize(a);
|
||||
}
|
||||
|
||||
|
10
ltable.c
10
ltable.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ltable.c,v 1.43 2000/05/24 13:54:49 roberto Exp roberto $
|
||||
** $Id: ltable.c,v 1.44 2000/06/05 20:07:53 roberto Exp roberto $
|
||||
** Lua tables (hash)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -278,6 +278,14 @@ void luaH_setint (lua_State *L, Hash *t, int key, const TObject *val) {
|
||||
}
|
||||
|
||||
|
||||
void luaH_setstr (lua_State *L, Hash *t, TString *key, const TObject *val) {
|
||||
TObject index;
|
||||
ttype(&index) = TAG_STRING;
|
||||
tsvalue(&index) = key;
|
||||
luaH_set(L, t, &index, val);
|
||||
}
|
||||
|
||||
|
||||
const TObject *luaH_getglobal (lua_State *L, const char *name) {
|
||||
return luaH_getstr(L->gt, luaS_new(L, name));
|
||||
}
|
||||
|
3
ltable.h
3
ltable.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ltable.h,v 1.20 2000/05/08 19:32:53 roberto Exp roberto $
|
||||
** $Id: ltable.h,v 1.21 2000/06/05 20:07:53 roberto Exp roberto $
|
||||
** Lua tables (hash)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -25,6 +25,7 @@ void luaH_remove (Hash *t, TObject *key);
|
||||
void luaH_set (lua_State *L, Hash *t, const TObject *key, const TObject *val);
|
||||
int luaH_pos (lua_State *L, const Hash *t, const TObject *r);
|
||||
void luaH_setint (lua_State *L, Hash *t, int key, const TObject *val);
|
||||
void luaH_setstr (lua_State *L, Hash *t, TString *key, const TObject *val);
|
||||
unsigned long luaH_hash (lua_State *L, const TObject *key);
|
||||
const TObject *luaH_getglobal (lua_State *L, const char *name);
|
||||
|
||||
|
7
lvm.c
7
lvm.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lvm.c,v 1.110 2000/05/30 19:00:31 roberto Exp roberto $
|
||||
** $Id: lvm.c,v 1.111 2000/06/05 14:56:18 roberto Exp roberto $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -66,10 +66,9 @@ int luaV_tostring (lua_State *L, TObject *obj) { /* LUA_NUMBER */
|
||||
|
||||
|
||||
void luaV_setn (lua_State *L, Hash *t, int val) {
|
||||
TObject index, value;
|
||||
ttype(&index) = TAG_STRING; tsvalue(&index) = luaS_new(L, "n");
|
||||
TObject value;
|
||||
ttype(&value) = TAG_NUMBER; nvalue(&value) = val;
|
||||
luaH_set(L, t, &index, &value);
|
||||
luaH_setstr(L, t, luaS_new(L, "n"), &value);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user