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

Function luaL_setfuncs

3rd/lua-5.4.3/src/lauxlib.c:926–940  ·  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

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

Callers 7

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

Calls 5

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

Tested by

no test coverage detected