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

Function TArray_Get

Plugins/UnLua/Source/UnLua/Private/BaseLib/LuaLib_Array.cpp:308–330  ·  view source on GitHub ↗

* @see FLuaArray::Get(...). Create a copy for the element */

Source from the content-addressed store, hash-verified

306 * @see FLuaArray::Get(...). Create a copy for the element
307 */
308static int32 TArray_Get(lua_State* L)
309{
310 int32 NumParams = lua_gettop(L);
311 if (NumParams != 2)
312 return luaL_error(L, "invalid parameters");
313
314 FLuaArray* Array = (FLuaArray*)(GetCppInstanceFast(L, 1));
315 TArray_Guard(L, Array);
316
317 int32 Index = lua_tointeger(L, 2);
318 --Index;
319 if (!Array->IsValidIndex(Index))
320 {
321 UNLUA_LOGERROR(L, LogUnLua, Log, TEXT("%s: TArray Invalid Index!"), ANSI_TO_TCHAR(__FUNCTION__));
322 return 0;
323 }
324
325 Array->Inner->Initialize(Array->ElementCache);
326 Array->Get(Index, Array->ElementCache);
327 Array->Inner->Read(L, Array->ElementCache, true);
328 Array->Inner->Destruct(Array->ElementCache);
329 return 1;
330}
331
332/**
333 * @see FLuaArray::Get(...). Return a reference for the element

Callers 1

TArray_IndexFunction · 0.85

Calls 9

lua_gettopFunction · 0.85
luaL_errorFunction · 0.85
GetCppInstanceFastFunction · 0.85
TArray_GuardFunction · 0.85
IsValidIndexMethod · 0.45
InitializeMethod · 0.45
GetMethod · 0.45
ReadMethod · 0.45
DestructMethod · 0.45

Tested by

no test coverage detected