| 793 | #endif |
| 794 | |
| 795 | LUAMOD_API int luaopen_package (lua_State *L) { |
| 796 | // createclibstable(L); |
| 797 | luaL_newlib(L, pk_funcs); /* create 'package' table */ |
| 798 | // createsearcherstable(L); |
| 799 | /* set paths */ |
| 800 | #if defined(ARDUPILOT_BUILD) |
| 801 | setpath(L, "path", LUA_PATH_VAR, lua_get_modules_path()); |
| 802 | #else |
| 803 | setpath(L, "path", LUA_PATH_VAR, LUA_PATH_DEFAULT); |
| 804 | #endif |
| 805 | // setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT); |
| 806 | /* store config information */ |
| 807 | lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n" |
| 808 | LUA_EXEC_DIR "\n" LUA_IGMARK "\n"); |
| 809 | lua_setfield(L, -2, "config"); |
| 810 | /* set field 'loaded' */ |
| 811 | luaL_getsubtable(L, -3, LUA_LOADED_TABLE); |
| 812 | lua_setfield(L, -2, "loaded"); |
| 813 | |
| 814 | /* set field 'preload' */ |
| 815 | luaL_getsubtable(L, -3, LUA_PRELOAD_TABLE); |
| 816 | lua_setfield(L, -2, "preload"); |
| 817 | |
| 818 | lua_pushvalue(L, -3); |
| 819 | lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ |
| 820 | luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ |
| 821 | lua_pop(L, 1); |
| 822 | |
| 823 | return 1; /* return 'package' table */ |
| 824 | } |
no test coverage detected