| 729 | |
| 730 | |
| 731 | LUAMOD_API int luaopen_package (lua_State *L) { |
| 732 | createclibstable(L); |
| 733 | luaL_newlib(L, pk_funcs); /* create 'package' table */ |
| 734 | createsearcherstable(L); |
| 735 | /* set paths */ |
| 736 | setpath(L, "path", LUA_PATH_VAR, LUA_PATH_DEFAULT); |
| 737 | setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT); |
| 738 | /* store config information */ |
| 739 | lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n" |
| 740 | LUA_EXEC_DIR "\n" LUA_IGMARK "\n"); |
| 741 | lua_setfield(L, -2, "config"); |
| 742 | /* set field 'loaded' */ |
| 743 | luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); |
| 744 | lua_setfield(L, -2, "loaded"); |
| 745 | /* set field 'preload' */ |
| 746 | luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); |
| 747 | lua_setfield(L, -2, "preload"); |
| 748 | lua_pushglobaltable(L); |
| 749 | lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ |
| 750 | luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ |
| 751 | lua_pop(L, 1); /* pop global table */ |
| 752 | return 1; /* return 'package' table */ |
| 753 | } |
| 754 |
nothing calls this directly
no test coverage detected