diff options
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -248,7 +248,7 @@ LUA_API size_t lua_strlen (lua_State *L, int index) { | |||
248 | 248 | ||
249 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) { | 249 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) { |
250 | StkId o = luaA_indexAcceptable(L, index); | 250 | StkId o = luaA_indexAcceptable(L, index); |
251 | return (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->f.c; | 251 | return (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->u.c.f; |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
@@ -310,9 +310,16 @@ LUA_API void lua_pushstring (lua_State *L, const l_char *s) { | |||
310 | 310 | ||
311 | 311 | ||
312 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { | 312 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { |
313 | Closure *cl; | ||
313 | lua_lock(L); | 314 | lua_lock(L); |
314 | api_checknelems(L, n); | 315 | api_checknelems(L, n); |
315 | luaV_Cclosure(L, fn, n); | 316 | cl = luaF_newCclosure(L, n); |
317 | cl->u.c.f = fn; | ||
318 | L->top -= n; | ||
319 | while (n--) | ||
320 | setobj(&cl->u.c.upvalue[n], L->top+n); | ||
321 | setclvalue(L->top, cl); | ||
322 | incr_top; | ||
316 | lua_unlock(L); | 323 | lua_unlock(L); |
317 | } | 324 | } |
318 | 325 | ||