| 251 | } |
| 252 | |
| 253 | void pushLuaFramework(lua_State *L) |
| 254 | { |
| 255 | lua_createtable(L, 0, 2); |
| 256 | // push logging functions. note we only accept one string as argument |
| 257 | // because you can just do all the formatting and concatenation in lua |
| 258 | lua_pushcfunction(L, [](lua_State *L) { |
| 259 | lua_settop(L, 1); |
| 260 | handleLuaError(L, LogLevel::Info); |
| 261 | return 0; |
| 262 | }); |
| 263 | lua_setfield(L, -2, "LogInfo"); |
| 264 | lua_pushcfunction(L, [](lua_State *L) { |
| 265 | lua_settop(L, 1); |
| 266 | handleLuaError(L, LogLevel::Warning); |
| 267 | return 0; |
| 268 | }); |
| 269 | lua_setfield(L, -2, "LogWarning"); |
| 270 | lua_pushcfunction(L, [](lua_State *L) { |
| 271 | lua_settop(L, 1); |
| 272 | handleLuaError(L, LogLevel::Error); |
| 273 | return 0; |
| 274 | }); |
| 275 | lua_setfield(L, -2, "LogError"); |
| 276 | |
| 277 | // config table |
| 278 | lua_createtable(L, 0, 2); |
| 279 | |
| 280 | lua_pushcfunction(L, [](lua_State *L) { |
| 281 | UString key; |
| 282 | getFromLua(L, 1, key); |
| 283 | lua_settop(L, 0); |
| 284 | pushToLua(L, config().getString(key)); |
| 285 | return 1; |
| 286 | }); |
| 287 | lua_setfield(L, -2, "getString"); |
| 288 | |
| 289 | lua_pushcfunction(L, [](lua_State *L) { |
| 290 | UString key; |
| 291 | getFromLua(L, 1, key); |
| 292 | lua_settop(L, 0); |
| 293 | pushToLua(L, config().getInt(key)); |
| 294 | return 1; |
| 295 | }); |
| 296 | lua_setfield(L, -2, "getInt"); |
| 297 | |
| 298 | lua_pushcfunction(L, [](lua_State *L) { |
| 299 | UString key; |
| 300 | getFromLua(L, 1, key); |
| 301 | lua_settop(L, 0); |
| 302 | pushToLua(L, config().getBool(key)); |
| 303 | return 1; |
| 304 | }); |
| 305 | lua_setfield(L, -2, "getBool"); |
| 306 | |
| 307 | lua_pushcfunction(L, [](lua_State *L) { |
| 308 | UString key; |
| 309 | getFromLua(L, 1, key); |
| 310 | lua_settop(L, 0); |
no test coverage detected