diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-11-27 16:25:14 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-11-27 16:25:14 -0200 |
commit | 5482992dec286ca800ffab539b0f81eddaa2665b (patch) | |
tree | 77759747324cf65d22c9a10f81df3468ff724f36 /lapi.c | |
parent | 024528e0c2ce75ac28ebbbc1220d4ae4045d3adf (diff) | |
download | lua-5482992dec286ca800ffab539b0f81eddaa2665b.tar.gz lua-5482992dec286ca800ffab539b0f81eddaa2665b.tar.bz2 lua-5482992dec286ca800ffab539b0f81eddaa2665b.zip |
other access method for C upvalues (as arguments)
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 32 |
1 files changed, 8 insertions, 24 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.8 1997/11/26 18:53:45 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.9 1997/11/27 15:59:25 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 | */ |
@@ -95,18 +95,6 @@ lua_Object lua_lua2C (int number) | |||
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | lua_Object lua_upvalue (int n) | ||
99 | { | ||
100 | TObject *f = L->stack.stack+L->Cstack.lua2C-1; | ||
101 | if (ttype(f) != LUA_T_MARK || n <= 0 || n > clvalue(f)->nelems) | ||
102 | return LUA_NOOBJECT; | ||
103 | if (ttype(protovalue(f)) != LUA_T_CPROTO) lua_error("BAD!!"); | ||
104 | *L->stack.top = clvalue(f)->consts[n]; | ||
105 | incr_top; | ||
106 | return put_luaObjectonTop(); | ||
107 | } | ||
108 | |||
109 | |||
110 | int lua_callfunction (lua_Object function) | 98 | int lua_callfunction (lua_Object function) |
111 | { | 99 | { |
112 | if (function == LUA_NOOBJECT) | 100 | if (function == LUA_NOOBJECT) |
@@ -317,17 +305,13 @@ void lua_pushstring (char *s) | |||
317 | 305 | ||
318 | void lua_pushCclosure (lua_CFunction fn, int n) | 306 | void lua_pushCclosure (lua_CFunction fn, int n) |
319 | { | 307 | { |
320 | if (fn == NULL) { | 308 | if (fn == NULL) |
321 | ttype(L->stack.top) = LUA_T_NIL; | 309 | lua_error("API error - attempt to push a NULL Cfunction"); |
322 | incr_top; | 310 | checkCparams(n); |
323 | } | 311 | ttype(L->stack.top) = LUA_T_CPROTO; |
324 | else { | 312 | fvalue(L->stack.top) = fn; |
325 | checkCparams(n); | 313 | incr_top; |
326 | ttype(L->stack.top) = LUA_T_CPROTO; | 314 | luaV_closure(n); |
327 | fvalue(L->stack.top) = fn; | ||
328 | incr_top; | ||
329 | luaV_closure(n); | ||
330 | } | ||
331 | } | 315 | } |
332 | 316 | ||
333 | void lua_pushusertag (void *u, int tag) | 317 | void lua_pushusertag (void *u, int tag) |