* @brief Lua C closure for tableGetH(handle); nil for a stale or invalid handle. */
| 2531 | * @brief Lua C closure for tableGetH(handle); nil for a stale or invalid handle. |
| 2532 | */ |
| 2533 | static 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. |
nothing calls this directly
no test coverage detected