diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-05-08 17:49:05 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-05-08 17:49:05 -0300 |
commit | bad6365540ad9e17e51137a6797ff196d6b8d2a1 (patch) | |
tree | 8d16d51f0c4167f59a879751660742ff28bf011f /lapi.c | |
parent | 91f34fb05caa9590cd19a986e865a93361b1c398 (diff) | |
download | lua-bad6365540ad9e17e51137a6797ff196d6b8d2a1.tar.gz lua-bad6365540ad9e17e51137a6797ff196d6b8d2a1.tar.bz2 lua-bad6365540ad9e17e51137a6797ff196d6b8d2a1.zip |
details
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.78 2000/04/17 19:23:12 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.79 2000/05/08 19:32:53 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -44,13 +44,6 @@ lua_Object luaA_putluaObject (lua_State *L, const TObject *o) { | |||
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | lua_Object luaA_putObjectOnTop (lua_State *L) { | ||
48 | luaD_openstack(L, L->Cstack.base); | ||
49 | *L->Cstack.base++ = *(--L->top); | ||
50 | return L->Cstack.base-1; | ||
51 | } | ||
52 | |||
53 | |||
54 | static void top2LC (lua_State *L, int n) { | 47 | static void top2LC (lua_State *L, int n) { |
55 | /* Put the `n' elements on the top as the Lua2C contents */ | 48 | /* Put the `n' elements on the top as the Lua2C contents */ |
56 | L->Cstack.base = L->top; /* new base */ | 49 | L->Cstack.base = L->top; /* new base */ |
@@ -61,7 +54,11 @@ static void top2LC (lua_State *L, int n) { | |||
61 | 54 | ||
62 | lua_Object lua_pop (lua_State *L) { | 55 | lua_Object lua_pop (lua_State *L) { |
63 | luaA_checkCargs(L, 1); | 56 | luaA_checkCargs(L, 1); |
64 | return luaA_putObjectOnTop(L); | 57 | if (L->Cstack.base != L->top-1) { |
58 | luaD_openstack(L, L->Cstack.base); | ||
59 | *L->Cstack.base = *(--L->top); | ||
60 | } | ||
61 | return L->Cstack.base++; | ||
65 | } | 62 | } |
66 | 63 | ||
67 | 64 | ||
@@ -112,14 +109,14 @@ lua_Object lua_settagmethod (lua_State *L, int tag, const char *event) { | |||
112 | if ((ttype(method) != TAG_NIL) && (*lua_type(L, method) != 'f')) | 109 | if ((ttype(method) != TAG_NIL) && (*lua_type(L, method) != 'f')) |
113 | lua_error(L, "Lua API error - tag method must be a function or nil"); | 110 | lua_error(L, "Lua API error - tag method must be a function or nil"); |
114 | luaT_settagmethod(L, tag, event, method); | 111 | luaT_settagmethod(L, tag, event, method); |
115 | return luaA_putObjectOnTop(L); | 112 | return lua_pop(L); |
116 | } | 113 | } |
117 | 114 | ||
118 | 115 | ||
119 | lua_Object lua_gettable (lua_State *L) { | 116 | lua_Object lua_gettable (lua_State *L) { |
120 | luaA_checkCargs(L, 2); | 117 | luaA_checkCargs(L, 2); |
121 | luaV_gettable(L, L->top--); | 118 | luaV_gettable(L, L->top--); |
122 | return luaA_putObjectOnTop(L); | 119 | return lua_pop(L); |
123 | } | 120 | } |
124 | 121 | ||
125 | 122 | ||
@@ -163,7 +160,7 @@ lua_Object lua_createtable (lua_State *L) { | |||
163 | 160 | ||
164 | lua_Object lua_getglobal (lua_State *L, const char *name) { | 161 | lua_Object lua_getglobal (lua_State *L, const char *name) { |
165 | luaV_getglobal(L, luaS_new(L, name), L->top++); | 162 | luaV_getglobal(L, luaS_new(L, name), L->top++); |
166 | return luaA_putObjectOnTop(L); | 163 | return lua_pop(L); |
167 | } | 164 | } |
168 | 165 | ||
169 | 166 | ||