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

Function luaTableSetH

app/src/DataModel/FrameBuilder.cpp:2560–2581  ·  view source on GitHub ↗

* @brief Lua C closure for tableSetH(handle, value); ignores non-computed/stale/invalid handles. * A nil value (e.g. a failed tonumber()) is a safe no-op for parity with JS, which never * raises here; a raise would fail the load-time parse() probe and reject the script. */

Source from the content-addressed store, hash-verified

2558 * raises here; a raise would fail the load-time parse() probe and reject the script.
2559 */
2560static int luaTableSetH(lua_State* L)
2561{
2562 auto* store = static_cast<DataModel::DataTableStore*>(lua_touserdata(L, lua_upvalueindex(1)));
2563 Q_ASSERT(store);
2564
2565 const qint64 handle = static_cast<qint64>(luaL_checknumber(L, 1));
2566
2567 if (lua_isnoneornil(L, 2))
2568 return 0;
2569
2570 DataModel::RegisterValue rv;
2571 if (lua_isnumber(L, 2)) {
2572 rv.numericValue = lua_tonumber(L, 2);
2573 rv.isNumeric = true;
2574 } else {
2575 rv.stringValue = QString::fromUtf8(luaL_checkstring(L, 2));
2576 rv.isNumeric = false;
2577 }
2578
2579 store->setByHandle(handle, rv);
2580 return 0;
2581}
2582
2583/**
2584 * @brief Lua C closure for datasetGetRaw(uniqueId).

Callers

nothing calls this directly

Calls 4

lua_touserdataFunction · 0.85
luaL_checknumberFunction · 0.85
lua_isnumberFunction · 0.85
setByHandleMethod · 0.80

Tested by

no test coverage detected