MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / luaL_requiref

Function luaL_requiref

lib/lua/src/lauxlib.c:983–1000  ·  view source on GitHub ↗

** Stripped-down 'require': After checking "loaded" table, 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

981** Leaves resulting module on the top.
982*/
983LUALIB_API void luaL_requiref (lua_State *L, const char *modname,
984 lua_CFunction openf, int glb) {
985 luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
986 lua_getfield(L, -1, modname); /* LOADED[modname] */
987 if (!lua_toboolean(L, -1)) { /* package not already loaded? */
988 lua_pop(L, 1); /* remove field */
989 lua_pushcfunction(L, openf);
990 lua_pushstring(L, modname); /* argument to open function */
991 lua_call(L, 1, 1); /* call 'openf' to open module */
992 lua_pushvalue(L, -1); /* make copy of module (call result) */
993 lua_setfield(L, -3, modname); /* LOADED[modname] = module */
994 }
995 lua_remove(L, -2); /* remove LOADED table */
996 if (glb) {
997 lua_pushvalue(L, -1); /* copy of module */
998 lua_setglobal(L, modname); /* _G[modname] = module */
999 }
1000}
1001
1002
1003LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s,

Callers 8

luaL_openlibsFunction · 0.85
openSafeLibsFunction · 0.85
definesMqttFunctionMethod · 0.85
runScriptMethod · 0.85
openSafeLibsForTransformFunction · 0.85
validateTransformMethod · 0.85
testTransformMethod · 0.85
openSafeLibsFunction · 0.85

Calls 7

luaL_getsubtableFunction · 0.85
lua_getfieldFunction · 0.85
lua_tobooleanFunction · 0.85
lua_pushstringFunction · 0.85
lua_pushvalueFunction · 0.85
lua_setfieldFunction · 0.85
lua_setglobalFunction · 0.85

Tested by

no test coverage detected