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