| 2087 | } |
| 2088 | |
| 2089 | static void Lua::Core::InitCoreContext(color_ostream &out) |
| 2090 | { |
| 2091 | auto State = DFHack::Core::getInstance().getLuaState(); |
| 2092 | lua_newtable(State); |
| 2093 | lua_rawsetp(State, LUA_REGISTRYINDEX, &DFHACK_TIMEOUTS_TOKEN); |
| 2094 | |
| 2095 | // Register events |
| 2096 | lua_rawgetp(State, LUA_REGISTRYINDEX, &DFHACK_DFHACK_TOKEN); |
| 2097 | |
| 2098 | Event::Make(State, (void*)onStateChange); |
| 2099 | lua_setfield(State, -2, "onStateChange"); |
| 2100 | |
| 2101 | lua_pushcfunction(State, dfhack_timeout); |
| 2102 | lua_setfield(State, -2, "timeout"); |
| 2103 | lua_pushcfunction(State, dfhack_timeout_active); |
| 2104 | lua_setfield(State, -2, "timeout_active"); |
| 2105 | |
| 2106 | lua_pop(State, 1); |
| 2107 | |
| 2108 | if (getenv("DFHACK_ENABLE_LUACOV")) |
| 2109 | { |
| 2110 | // reads config from .luacov or uses defaults if file doesn't exist. |
| 2111 | // note that luacov overrides the debug hook installed by |
| 2112 | // interrupt_init() above. |
| 2113 | if (Lua::PushModulePublic(out, State, "luacov.runner", "init") && |
| 2114 | Lua::SafeCall(out, State, 0, 0)) |
| 2115 | { |
| 2116 | out.print("Initialized luacov coverage monitoring\n"); |
| 2117 | } |
| 2118 | else |
| 2119 | { |
| 2120 | out.printerr("Failed to initialize luacov coverage monitoring\n"); |
| 2121 | // non-fatal error |
| 2122 | } |
| 2123 | } |
| 2124 | } |
| 2125 | |
| 2126 | void DFHack::Lua::Core::Reset(color_ostream &out, const char *where) |
| 2127 | { |
nothing calls this directly
no test coverage detected