MCPcopy Create free account
hub / github.com/Tencent/UnLua / TMap_Enumerable

Function TMap_Enumerable

Plugins/UnLua/Source/UnLua/Private/BaseLib/LuaLib_Map.cpp:53–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53static int TMap_Enumerable(lua_State* L)
54{
55 int32 NumParams = lua_gettop(L);
56 if (NumParams != 2)
57 return luaL_error(L, "invalid parameters");
58
59 FLuaMap::FLuaMapEnumerator** Enumerator = (FLuaMap::FLuaMapEnumerator**)(lua_touserdata(L, 1));
60 if (!Enumerator || !*Enumerator)
61 return luaL_error(L, "invalid enumerator");
62
63 const auto Map = (*Enumerator)->LuaMap;
64 TMap_Guard(L, Map);
65
66 while ((*Enumerator)->Index < Map->GetMaxIndex())
67 {
68 if (!Map->IsValidIndex((*Enumerator)->Index))
69 {
70 ++(*Enumerator)->Index;
71 }
72 else
73 {
74 Map->KeyInterface->Read(L, Map->GetData((*Enumerator)->Index), false);
75 Map->ValueInterface->Read(L, Map->GetData((*Enumerator)->Index) + Map->MapLayout.ValueOffset - Map->ValueInterface->GetOffset(), false);
76 ++(*Enumerator)->Index;
77 return 2;
78 }
79 }
80
81 return 0;
82}
83
84static int32 TMap_Pairs(lua_State* L)
85{

Callers

nothing calls this directly

Calls 9

lua_gettopFunction · 0.85
luaL_errorFunction · 0.85
lua_touserdataFunction · 0.85
TMap_GuardFunction · 0.85
GetMaxIndexMethod · 0.80
IsValidIndexMethod · 0.45
ReadMethod · 0.45
GetDataMethod · 0.45
GetOffsetMethod · 0.45

Tested by

no test coverage detected