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

Function TMap_Add

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

* @see FLuaMap::Add(...) */

Source from the content-addressed store, hash-verified

126 * @see FLuaMap::Add(...)
127 */
128static int32 TMap_Add(lua_State* L)
129{
130 int32 NumParams = lua_gettop(L);
131 if (NumParams != 3)
132 return luaL_error(L, "invalid parameters");
133
134 FLuaMap* Map = (FLuaMap*)(GetCppInstanceFast(L, 1));
135 TMap_Guard(L, Map);
136
137 void* ValueCache = (uint8*)Map->ElementCache + Map->MapLayout.ValueOffset;
138 Map->KeyInterface->Initialize(Map->ElementCache);
139 Map->ValueInterface->Initialize(ValueCache);
140 Map->KeyInterface->Write(L, Map->ElementCache, 2);
141 Map->ValueInterface->Write(L, Map->ValueInterface->GetOffset() > 0 ? Map->ElementCache : ValueCache, 3);
142 Map->Add(Map->ElementCache, ValueCache);
143 Map->KeyInterface->Destruct(Map->ElementCache);
144 Map->ValueInterface->Destruct(ValueCache);
145 return 0;
146}
147
148/**
149 * @see FLuaMap::Remove(...)

Callers

nothing calls this directly

Calls 9

lua_gettopFunction · 0.85
luaL_errorFunction · 0.85
GetCppInstanceFastFunction · 0.85
TMap_GuardFunction · 0.85
InitializeMethod · 0.45
WriteMethod · 0.45
GetOffsetMethod · 0.45
AddMethod · 0.45
DestructMethod · 0.45

Tested by

no test coverage detected