MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / luaL_setfuncs

Function luaL_setfuncs

xrepo/packages/l/lua/port/lua/src/lauxlib.c:927–941  ·  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

925** Returns with only the table at the stack.
926*/
927LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
928 luaL_checkstack(L, nup, "too many upvalues");
929 for (; l->name != NULL; l++) { /* fill the table with given functions */
930 if (l->func == NULL) /* place holder? */
931 lua_pushboolean(L, 0);
932 else {
933 int i;
934 for (i = 0; i < nup; i++) /* copy upvalues to the top */
935 lua_pushvalue(L, -nup);
936 lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
937 }
938 lua_setfield(L, -(nup + 2), l->name);
939 }
940 lua_pop(L, nup); /* remove upvalues */
941}
942
943
944/*

Callers 6

luaopen_baseFunction · 0.85
setrandfuncFunction · 0.85
createmetatableFunction · 0.85
newboxFunction · 0.85
luaopen_packageFunction · 0.85
createmetaFunction · 0.85

Calls 5

lua_pushcclosureFunction · 0.85
luaL_checkstackFunction · 0.70
lua_pushbooleanFunction · 0.70
lua_pushvalueFunction · 0.70
lua_setfieldFunction · 0.70

Tested by

no test coverage detected