** 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. */
| 740 | ** Leaves resulting module on the top. |
| 741 | */ |
| 742 | LUALIB_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 | |
| 758 | LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, |
nothing calls this directly
no test coverage detected