* @brief Pushes a {ok, error?} table onto the Lua stack. */
| 77 | * @brief Pushes a {ok, error?} table onto the Lua stack. |
| 78 | */ |
| 79 | static void pushLuaResult(lua_State* L, bool ok, const QString& errorMsg) |
| 80 | { |
| 81 | lua_createtable(L, 0, ok ? 1 : 2); |
| 82 | |
| 83 | lua_pushboolean(L, ok ? 1 : 0); |
| 84 | lua_setfield(L, -2, "ok"); |
| 85 | |
| 86 | if (!ok) { |
| 87 | const QByteArray utf8 = errorMsg.toUtf8(); |
| 88 | lua_pushlstring(L, utf8.constData(), static_cast<size_t>(utf8.size())); |
| 89 | lua_setfield(L, -2, "error"); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * @brief Lua C closure for deviceWrite(data, sourceId?) returning a result table. |
no test coverage detected