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

Method convertResult

app/src/DataModel/Scripting/LuaScriptEngine.cpp:673–709  ·  view source on GitHub ↗

* @brief Converts the Lua return value at stack top to a frame list. */

Source from the content-addressed store, hash-verified

671 * @brief Converts the Lua return value at stack top to a frame list.
672 */
673QList<QStringList> DataModel::LuaScriptEngine::convertResult()
674{
675 QList<QStringList> results;
676
677 if (!lua_istable(m_state, -1)) {
678 QStringList frame = scalarToStringList();
679 lua_pop(m_state, 1);
680 if (!frame.isEmpty())
681 results.append(frame);
682
683 return results;
684 }
685
686 const int len = static_cast<int>(lua_rawlen(m_state, -1));
687 if (len == 0) {
688 lua_pop(m_state, 1);
689 return results;
690 }
691
692 const int scanLen = qMin(len, kMaxElements);
693 QStringList scalars;
694 scalars.reserve(scanLen);
695 for (int i = 1; i <= scanLen; ++i) {
696 lua_rawgeti(m_state, -1, i);
697 if (lua_istable(m_state, -1)) [[unlikely]] {
698 lua_pop(m_state, 1);
699 return classifyTable(len);
700 }
701
702 scalars.append(luaValueToString());
703 lua_pop(m_state, 1);
704 }
705
706 lua_pop(m_state, 1);
707 results.append(scalars);
708 return results;
709}
710
711/**
712 * @brief Dispatches the table at stack top to scalar/2D/mixed conversion paths.

Callers

nothing calls this directly

Calls 3

lua_rawgetiFunction · 0.85
isEmptyMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected