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

Function luaTableGetH

app/src/DataModel/FrameBuilder.cpp:2533–2553  ·  view source on GitHub ↗

* @brief Lua C closure for tableGetH(handle); nil for a stale or invalid handle. */

Source from the content-addressed store, hash-verified

2531 * @brief Lua C closure for tableGetH(handle); nil for a stale or invalid handle.
2532 */
2533static int luaTableGetH(lua_State* L)
2534{
2535 auto* store = static_cast<DataModel::DataTableStore*>(lua_touserdata(L, lua_upvalueindex(1)));
2536 Q_ASSERT(store);
2537
2538 const qint64 handle = static_cast<qint64>(luaL_checknumber(L, 1));
2539 const auto* val = store->getByHandle(handle);
2540 if (!val) {
2541 lua_pushnil(L);
2542 return 1;
2543 }
2544
2545 if (val->isNumeric) {
2546 lua_pushnumber(L, val->numericValue);
2547 } else {
2548 const auto utf8 = val->stringValue.toUtf8();
2549 lua_pushlstring(L, utf8.constData(), static_cast<size_t>(utf8.size()));
2550 }
2551
2552 return 1;
2553}
2554
2555/**
2556 * @brief Lua C closure for tableSetH(handle, value); ignores non-computed/stale/invalid handles.

Callers

nothing calls this directly

Calls 7

lua_touserdataFunction · 0.85
luaL_checknumberFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushnumberFunction · 0.85
lua_pushlstringFunction · 0.85
getByHandleMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected