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

Function luaTableHandleMany

app/src/DataModel/FrameBuilder.cpp:2509–2528  ·  view source on GitHub ↗

* @brief Lua C closure for tableHandleMany(table, regs) -> handles; one handle per name, -1 if * unknown. */

Source from the content-addressed store, hash-verified

2507 * unknown.
2508 */
2509static int luaTableHandleMany(lua_State* L)
2510{
2511 auto* store = static_cast<DataModel::DataTableStore*>(lua_touserdata(L, lua_upvalueindex(1)));
2512 Q_ASSERT(store);
2513
2514 const QString table = QString::fromUtf8(luaL_checkstring(L, 1));
2515 luaL_checktype(L, 2, LUA_TTABLE);
2516
2517 const lua_Integer n = luaL_len(L, 2);
2518 lua_newtable(L);
2519 for (lua_Integer i = 1; i <= n; ++i) {
2520 lua_geti(L, 2, i);
2521 const qint64 handle = store->handleOf(table, QString::fromUtf8(luaL_checkstring(L, -1)));
2522 lua_pop(L, 1);
2523 lua_pushnumber(L, static_cast<lua_Number>(handle));
2524 lua_seti(L, -2, i);
2525 }
2526
2527 return 1;
2528}
2529
2530/**
2531 * @brief Lua C closure for tableGetH(handle); nil for a stale or invalid handle.

Callers

nothing calls this directly

Calls 6

lua_touserdataFunction · 0.85
luaL_checktypeFunction · 0.85
lua_getiFunction · 0.85
lua_pushnumberFunction · 0.85
lua_setiFunction · 0.85
handleOfMethod · 0.80

Tested by

no test coverage detected