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

Function TArray_ToTable

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

* Convert the array to a Lua table */

Source from the content-addressed store, hash-verified

518 * Convert the array to a Lua table
519 */
520static int32 TArray_ToTable(lua_State* L)
521{
522 int32 NumParams = lua_gettop(L);
523 if (NumParams != 1)
524 return luaL_error(L, "invalid parameters");
525
526 FLuaArray* Array = (FLuaArray*)(GetCppInstanceFast(L, 1));
527 TArray_Guard(L, Array);
528
529 if (!Array->Inner->IsValid())
530 return luaL_error(L, TCHAR_TO_UTF8(*FString::Printf(TEXT("invalid TArray element type:%s"), *Array->Inner->GetName())));
531
532 lua_newtable(L);
533 Array->Inner->Initialize(Array->ElementCache);
534 for (int32 i = 0; i < Array->Num(); ++i)
535 {
536 lua_pushinteger(L, i + 1);
537 Array->Get(i, Array->ElementCache);
538 Array->Inner->Read(L, Array->ElementCache, true);
539 lua_rawset(L, -3);
540 }
541 Array->Inner->Destruct(Array->ElementCache);
542 return 1;
543}
544
545static int32 TArray_Index(lua_State* L)
546{

Callers

nothing calls this directly

Calls 13

lua_gettopFunction · 0.85
luaL_errorFunction · 0.85
GetCppInstanceFastFunction · 0.85
TArray_GuardFunction · 0.85
lua_pushintegerFunction · 0.85
lua_rawsetFunction · 0.85
IsValidMethod · 0.45
GetNameMethod · 0.45
InitializeMethod · 0.45
NumMethod · 0.45
GetMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected