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

Function luaDatasetGetFinal

app/src/DataModel/FrameBuilder.cpp:2612–2633  ·  view source on GitHub ↗

* @brief Lua C closure for datasetGetFinal(uniqueId). */

Source from the content-addressed store, hash-verified

2610 * @brief Lua C closure for datasetGetFinal(uniqueId).
2611 */
2612static int luaDatasetGetFinal(lua_State* L)
2613{
2614 auto* store = static_cast<DataModel::DataTableStore*>(lua_touserdata(L, lua_upvalueindex(1)));
2615 Q_ASSERT(store);
2616
2617 const int uid = static_cast<int>(luaL_checkinteger(L, 1));
2618 const auto* val = store->getDatasetFinal(uid);
2619
2620 if (!val) {
2621 lua_pushnil(L);
2622 return 1;
2623 }
2624
2625 if (val->isNumeric) {
2626 lua_pushnumber(L, val->numericValue);
2627 } else {
2628 const auto utf8 = val->stringValue.toUtf8();
2629 lua_pushlstring(L, utf8.constData(), static_cast<size_t>(utf8.size()));
2630 }
2631
2632 return 1;
2633}
2634
2635#ifdef BUILD_COMMERCIAL
2636/**

Callers

nothing calls this directly

Calls 7

lua_touserdataFunction · 0.85
luaL_checkintegerFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushnumberFunction · 0.85
lua_pushlstringFunction · 0.85
getDatasetFinalMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected