MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaL_setfuncs

Function luaL_setfuncs

depends/lua/src/lauxlib.c:934–944  ·  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

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

Callers 12

OpenMethod · 0.85
OpenPersistentFunction · 0.85
OpenMatinfoFunction · 0.85
OpenPenFunction · 0.85
OpenPenArrayFunction · 0.85
OpenRandomFunction · 0.85
OpenModuleFunction · 0.85
OpenDFHackApiFunction · 0.85
luaopen_baseFunction · 0.85
luaL_openlibFunction · 0.85
luaopen_packageFunction · 0.85
createmetaFunction · 0.85

Calls 4

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

Tested by

no test coverage detected