** create table CLIBS to keep track of loaded C libraries, ** setting a finalizer to close all libraries when closing state. */
| 755 | ** setting a finalizer to close all libraries when closing state. |
| 756 | */ |
| 757 | static void createclibstable (lua_State *L) { |
| 758 | lua_newtable(L); /* create CLIBS table */ |
| 759 | lua_createtable(L, 0, 1); /* create metatable for CLIBS */ |
| 760 | lua_pushcfunction(L, gctm); |
| 761 | lua_setfield(L, -2, "__gc"); /* set finalizer for CLIBS table */ |
| 762 | lua_setmetatable(L, -2); |
| 763 | lua_rawsetp(L, LUA_REGISTRYINDEX, &CLIBS); /* set CLIBS table in registry */ |
| 764 | } |
| 765 | |
| 766 | |
| 767 | LUAMOD_API int luaopen_package (lua_State *L) { |
no test coverage detected