MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / lua_pushcclosure

Function lua_pushcclosure

3rd/lua-5.4.3/src/lapi.c:573–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

571
572
573LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
574 lua_lock(L);
575 if (n == 0) {
576 setfvalue(s2v(L->top), fn);
577 api_incr_top(L);
578 }
579 else {
580 CClosure *cl;
581 api_checknelems(L, n);
582 api_check(L, n <= MAXUPVAL, "upvalue index too large");
583 cl = luaF_newCclosure(L, n);
584 cl->f = fn;
585 L->top -= n;
586 while (n--) {
587 setobj2n(L, &cl->upvalue[n], s2v(L->top + n));
588 /* does not need barrier because closure is white */
589 lua_assert(iswhite(cl));
590 }
591 setclCvalue(L, s2v(L->top), cl);
592 api_incr_top(L);
593 luaC_checkGC(L);
594 }
595 lua_unlock(L);
596}
597
598
599LUA_API void lua_pushboolean (lua_State *L, int b) {

Callers 5

gmatchFunction · 0.85
luaL_setfuncsFunction · 0.85
luaB_cowrapFunction · 0.85
createsearcherstableFunction · 0.85
aux_linesFunction · 0.85

Calls 1

luaF_newCclosureFunction · 0.85

Tested by

no test coverage detected