* @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. */
| 2558 | * raises here; a raise would fail the load-time parse() probe and reject the script. |
| 2559 | */ |
| 2560 | static 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). |
nothing calls this directly
no test coverage detected