MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / pushLuaResult

Function pushLuaResult

app/src/DataModel/Scripting/DashboardApi.cpp:43–55  ·  view source on GitHub ↗

* @brief Pushes a {ok, error?} table onto the Lua stack. */

Source from the content-addressed store, hash-verified

41 * @brief Pushes a {ok, error?} table onto the Lua stack.
42 */
43static void pushLuaResult(lua_State* L, bool ok, const QString& errorMsg)
44{
45 lua_createtable(L, 0, ok ? 1 : 2);
46
47 lua_pushboolean(L, ok ? 1 : 0);
48 lua_setfield(L, -2, "ok");
49
50 if (!ok) {
51 const QByteArray utf8 = errorMsg.toUtf8();
52 lua_pushlstring(L, utf8.constData(), static_cast<size_t>(utf8.size()));
53 lua_setfield(L, -2, "error");
54 }
55}
56
57/**
58 * @brief Builds a JS-style {ok, error?} map.

Callers 4

luaClearPlotsFunction · 0.70
luaSetPlotPointsFunction · 0.70
luaSetVisibilityFunction · 0.70
luaSetActiveWorkspaceFunction · 0.70

Calls 5

lua_createtableFunction · 0.85
lua_pushbooleanFunction · 0.85
lua_setfieldFunction · 0.85
lua_pushlstringFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected