MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaL_requiref

Function luaL_requiref

third-party/lua-5.2.4/src/lauxlib.c:886–899  ·  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

884** Leaves resulting module on the top.
885*/
886LUALIB_API void luaL_requiref (lua_State *L, const char *modname,
887 lua_CFunction openf, int glb) {
888 lua_pushcfunction(L, openf);
889 lua_pushstring(L, modname); /* argument to open function */
890 lua_call(L, 1, 1); /* open module */
891 luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
892 lua_pushvalue(L, -2); /* make copy of module (call result) */
893 lua_setfield(L, -2, modname); /* _LOADED[modname] = module */
894 lua_pop(L, 1); /* remove _LOADED table */
895 if (glb) {
896 lua_pushvalue(L, -1); /* copy of 'mod' */
897 lua_setglobal(L, modname); /* _G[modname] = module */
898 }
899}
900
901
902LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,

Callers 1

luaL_openlibsFunction · 0.70

Calls 6

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

Tested by

no test coverage detected