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

Function resolveLuaArgs

app/src/DataModel/NotificationCenter.cpp:468–487  ·  view source on GitHub ↗

* @brief Resolves positional notify* arguments into (channel, title, subtitle). */

Source from the content-addressed store, hash-verified

466 * @brief Resolves positional notify* arguments into (channel, title, subtitle).
467 */
468static void resolveLuaArgs(
469 lua_State* L, int baseIdx, QString& channel, QString& title, QString& subtitle)
470{
471 const int total = lua_gettop(L);
472 const int remain = total - (baseIdx - 1);
473
474 if (remain <= 1) {
475 channel = QStringLiteral("Dashboard");
476 title = QString::fromUtf8(luaL_optstring(L, baseIdx, ""));
477 subtitle = QString();
478 } else if (remain == 2) {
479 channel = QStringLiteral("Dashboard");
480 title = QString::fromUtf8(luaL_optstring(L, baseIdx, ""));
481 subtitle = QString::fromUtf8(luaL_optstring(L, baseIdx + 1, ""));
482 } else {
483 channel = QString::fromUtf8(luaL_optstring(L, baseIdx, ""));
484 title = QString::fromUtf8(luaL_optstring(L, baseIdx + 1, ""));
485 subtitle = QString::fromUtf8(luaL_optstring(L, baseIdx + 2, ""));
486 }
487}
488
489/**
490 * @brief Lua C closure that posts a notification event by level integer.

Callers 5

luaNotifyFunction · 0.85
luaNotifyInfoFunction · 0.85
luaNotifyWarningFunction · 0.85
luaNotifyCriticalFunction · 0.85
luaNotifyClearFunction · 0.85

Calls 1

lua_gettopFunction · 0.85

Tested by

no test coverage detected