* @brief Lua C closure for datasetGetFinal(uniqueId). */
| 2610 | * @brief Lua C closure for datasetGetFinal(uniqueId). |
| 2611 | */ |
| 2612 | static 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 | /** |
nothing calls this directly
no test coverage detected