MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaL_setfuncs

Function luaL_setfuncs

freebsd/contrib/openzfs/module/lua/lauxlib.c:704–715  ·  view source on GitHub ↗

** set functions from list 'l' into table at top - 'nup'; each ** function gets the 'nup' elements at the top as upvalues. ** Returns with only the table at the stack. */

Source from the content-addressed store, hash-verified

702** Returns with only the table at the stack.
703*/
704LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
705 luaL_checkversion(L);
706 luaL_checkstack(L, nup, "too many upvalues");
707 for (; l->name != NULL; l++) { /* fill the table with given functions */
708 int i;
709 for (i = 0; i < nup; i++) /* copy upvalues to the top */
710 lua_pushvalue(L, -nup);
711 lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
712 lua_setfield(L, -(nup + 2), l->name);
713 }
714 lua_pop(L, nup); /* remove upvalues */
715}
716
717
718/*

Callers 2

luaopen_baseFunction · 0.70
luaL_openlibFunction · 0.70

Calls 4

luaL_checkstackFunction · 0.70
lua_pushvalueFunction · 0.70
lua_pushcclosureFunction · 0.70
lua_setfieldFunction · 0.70

Tested by

no test coverage detected