1
0
mirror of https://github.com/lua/lua.git synced 2025-01-14 05:43:00 +08:00
This commit is contained in:
Roberto Ierusalimschy 2000-05-08 17:49:05 -03:00
parent 91f34fb05c
commit bad6365540
3 changed files with 12 additions and 16 deletions

21
lapi.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lapi.c,v 1.78 2000/04/17 19:23:12 roberto Exp roberto $ ** $Id: lapi.c,v 1.79 2000/05/08 19:32:53 roberto Exp roberto $
** Lua API ** Lua API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -44,13 +44,6 @@ lua_Object luaA_putluaObject (lua_State *L, const TObject *o) {
} }
lua_Object luaA_putObjectOnTop (lua_State *L) {
luaD_openstack(L, L->Cstack.base);
*L->Cstack.base++ = *(--L->top);
return L->Cstack.base-1;
}
static void top2LC (lua_State *L, int n) { static void top2LC (lua_State *L, int n) {
/* Put the `n' elements on the top as the Lua2C contents */ /* Put the `n' elements on the top as the Lua2C contents */
L->Cstack.base = L->top; /* new base */ L->Cstack.base = L->top; /* new base */
@ -61,7 +54,11 @@ static void top2LC (lua_State *L, int n) {
lua_Object lua_pop (lua_State *L) { lua_Object lua_pop (lua_State *L) {
luaA_checkCargs(L, 1); luaA_checkCargs(L, 1);
return luaA_putObjectOnTop(L); if (L->Cstack.base != L->top-1) {
luaD_openstack(L, L->Cstack.base);
*L->Cstack.base = *(--L->top);
}
return L->Cstack.base++;
} }
@ -112,14 +109,14 @@ lua_Object lua_settagmethod (lua_State *L, int tag, const char *event) {
if ((ttype(method) != TAG_NIL) && (*lua_type(L, method) != 'f')) if ((ttype(method) != TAG_NIL) && (*lua_type(L, method) != 'f'))
lua_error(L, "Lua API error - tag method must be a function or nil"); lua_error(L, "Lua API error - tag method must be a function or nil");
luaT_settagmethod(L, tag, event, method); luaT_settagmethod(L, tag, event, method);
return luaA_putObjectOnTop(L); return lua_pop(L);
} }
lua_Object lua_gettable (lua_State *L) { lua_Object lua_gettable (lua_State *L) {
luaA_checkCargs(L, 2); luaA_checkCargs(L, 2);
luaV_gettable(L, L->top--); luaV_gettable(L, L->top--);
return luaA_putObjectOnTop(L); return lua_pop(L);
} }
@ -163,7 +160,7 @@ lua_Object lua_createtable (lua_State *L) {
lua_Object lua_getglobal (lua_State *L, const char *name) { lua_Object lua_getglobal (lua_State *L, const char *name) {
luaV_getglobal(L, luaS_new(L, name), L->top++); luaV_getglobal(L, luaS_new(L, name), L->top++);
return luaA_putObjectOnTop(L); return lua_pop(L);
} }

3
lapi.h
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lapi.h,v 1.16 2000/03/29 20:19:20 roberto Exp roberto $ ** $Id: lapi.h,v 1.17 2000/05/08 19:32:53 roberto Exp roberto $
** Auxiliary functions from Lua API ** Auxiliary functions from Lua API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -15,6 +15,5 @@ void luaA_checkCargs (lua_State *L, int nargs);
void luaA_pushobject (lua_State *L, const TObject *o); void luaA_pushobject (lua_State *L, const TObject *o);
int luaA_next (lua_State *L, const Hash *t, int i); int luaA_next (lua_State *L, const Hash *t, int i);
lua_Object luaA_putluaObject (lua_State *L, const TObject *o); lua_Object luaA_putluaObject (lua_State *L, const TObject *o);
lua_Object luaA_putObjectOnTop (lua_State *L);
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
** $Id: ldebug.c,v 1.16 2000/03/30 20:55:50 roberto Exp roberto $ ** $Id: ldebug.c,v 1.17 2000/05/08 19:32:53 roberto Exp roberto $
** Debug Interface ** Debug Interface
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -197,7 +197,7 @@ int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
case 'f': case 'f':
setnormalized(L->top, func); setnormalized(L->top, func);
incr_top; incr_top;
ar->func = luaA_putObjectOnTop(L); ar->func = lua_pop(L);
break; break;
default: return 0; /* invalid option */ default: return 0; /* invalid option */
} }