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

Function luaL_requiref

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

** stripped-down 'require'. Calls 'openf' to open a module, ** registers the result in 'package.loaded' table and, if 'glb' ** is true, also registers the result in the global table. ** Leaves resulting module on the top. */

Source from the content-addressed store, hash-verified

740** Leaves resulting module on the top.
741*/
742LUALIB_API void luaL_requiref (lua_State *L, const char *modname,
743 lua_CFunction openf, int glb) {
744 lua_pushcfunction(L, openf);
745 lua_pushstring(L, modname); /* argument to open function */
746 lua_call(L, 1, 1); /* open module */
747 luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
748 lua_pushvalue(L, -2); /* make copy of module (call result) */
749 lua_setfield(L, -2, modname); /* _LOADED[modname] = module */
750 lua_pop(L, 1); /* remove _LOADED table */
751 if (glb) {
752 lua_pushvalue(L, -1); /* copy of 'mod' */
753 lua_setglobal(L, modname); /* _G[modname] = module */
754 }
755}
756
757
758LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,

Callers

nothing calls this directly

Calls 6

lua_callFunction · 0.85
luaL_getsubtableFunction · 0.85
lua_setglobalFunction · 0.85
lua_pushstringFunction · 0.70
lua_pushvalueFunction · 0.70
lua_setfieldFunction · 0.70

Tested by

no test coverage detected