| 2290 | } |
| 2291 | |
| 2292 | DISABLE_WARNING_CONDEXPR_IS_CONSTANT |
| 2293 | |
| 2294 | lua_State * |
| 2295 | nhl_init(nhl_sandbox_info *sbi) |
| 2296 | { |
| 2297 | /* It would be nice to import EXPECTED from each build system. XXX */ |
| 2298 | /* And it would be nice to do it only once, but it's cheap. */ |
| 2299 | #ifndef NHL_VERSION_EXPECTED |
| 2300 | #if LUA_VERSION_NUM >= 505 |
| 2301 | #define NHL_VERSION_EXPECTED 50500 |
| 2302 | #else |
| 2303 | #define NHL_VERSION_EXPECTED 50408 |
| 2304 | #endif |
| 2305 | #endif |
| 2306 | |
| 2307 | #ifdef NHL_SANDBOX |
| 2308 | if (NHL_VERSION_EXPECTED != LUA_VERSION_RELEASE_NUM) { |
| 2309 | panic( |
| 2310 | "sandbox doesn't know this Lua version: this=%d != expected=%d ", |
| 2311 | LUA_VERSION_RELEASE_NUM, NHL_VERSION_EXPECTED); |
| 2312 | } |
| 2313 | #endif |
| 2314 | |
| 2315 | lua_State *L = nhlL_newstate(sbi, "nhl_init"); |
| 2316 | if(!L) return 0; |
| 2317 | |
| 2318 | iflags.in_lua = TRUE; |
| 2319 | /* Temporary for development XXX */ |
| 2320 | /* Turn this off in config.h to disable the sandbox. */ |
| 2321 | #ifdef NHL_SANDBOX |
| 2322 | nhlL_openlibs(L, sbi->flags); |
| 2323 | #else |
| 2324 | luaL_openlibs(L); |
| 2325 | #endif |
| 2326 | |
| 2327 | #ifdef notyet |
| 2328 | if (sbi->flags & NHL_SB_PACKAGE) { |
| 2329 | /* XXX Is this still needed? */ |
| 2330 | if (nhl_set_package_path(L, "./?.lua")) |
| 2331 | return 0; |
| 2332 | } |
| 2333 | #endif |
| 2334 | |
| 2335 | /* register nh -table, and functions for it */ |
| 2336 | lua_newtable(L); |
| 2337 | luaL_setfuncs(L, nhl_functions, 0); |
| 2338 | lua_setglobal(L, "nh"); |
| 2339 | |
| 2340 | /* init nhc -table */ |
| 2341 | init_nhc_data(L); |
| 2342 | |
| 2343 | /* init u -table */ |
| 2344 | init_u_data(L); |
| 2345 | |
| 2346 | l_selection_register(L); |
| 2347 | l_register_des(L); |
| 2348 | |
| 2349 | l_obj_register(L); |
no test coverage detected