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

Function TMap_FindRef

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

* @see FLuaMap::Find(...). Return a reference for the value */

Source from the content-addressed store, hash-verified

199 * @see FLuaMap::Find(...). Return a reference for the value
200 */
201static int32 TMap_FindRef(lua_State* L)
202{
203 int32 NumParams = lua_gettop(L);
204 if (NumParams != 2)
205 return luaL_error(L, "invalid parameters");
206
207 FLuaMap* Map = (FLuaMap*)(GetCppInstanceFast(L, 1));
208 TMap_Guard(L, Map);
209
210 Map->KeyInterface->Initialize(Map->ElementCache);
211 Map->KeyInterface->Write(L, Map->ElementCache, 2);
212 void* Value = Map->Find(Map->ElementCache);
213 if (Value)
214 {
215 const void* Key = (uint8*)Value - Map->ValueInterface->GetOffset();
216 Map->ValueInterface->Read(L, Key, false);
217 }
218 else
219 {
220 lua_pushnil(L);
221 }
222 Map->KeyInterface->Destruct(Map->ElementCache);
223 return 1;
224}
225
226/**
227 * @see FLuaMap::Clear(...)

Callers

nothing calls this directly

Calls 11

lua_gettopFunction · 0.85
luaL_errorFunction · 0.85
GetCppInstanceFastFunction · 0.85
TMap_GuardFunction · 0.85
lua_pushnilFunction · 0.85
InitializeMethod · 0.45
WriteMethod · 0.45
FindMethod · 0.45
GetOffsetMethod · 0.45
ReadMethod · 0.45
DestructMethod · 0.45

Tested by

no test coverage detected