MCPcopy Create free account
hub / github.com/DFHack/dfhack / complex_enum_next_item_helper

Function complex_enum_next_item_helper

library/LuaWrapper.cpp:1401–1415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1399 */
1400
1401static bool complex_enum_next_item_helper(lua_State *L, int64_t &item, bool wrap = false)
1402{
1403 const auto *complex = (enum_identity::ComplexData*)lua_touserdata(L, lua_upvalueindex(2));
1404 auto it = complex->value_index_map.find(item);
1405 if (it != complex->value_index_map.end())
1406 {
1407 size_t index = it->second;
1408 if (!wrap && index >= complex->size() - 1)
1409 return false;
1410
1411 item = complex->index_value_map[(index + 1) % complex->size()];
1412 return true;
1413 }
1414 return false;
1415}
1416
1417static int complex_enum_inext(lua_State *L)
1418{

Callers 2

complex_enum_inextFunction · 0.85
complex_enum_next_itemFunction · 0.85

Calls 4

lua_touserdataFunction · 0.85
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected