* Convert the array to a Lua table */
| 518 | * Convert the array to a Lua table |
| 519 | */ |
| 520 | static 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 | |
| 545 | static int32 TArray_Index(lua_State* L) |
| 546 | { |
nothing calls this directly
no test coverage detected