* Convert the set to a Lua table */
| 174 | * Convert the set to a Lua table |
| 175 | */ |
| 176 | static int32 TSet_ToTable(lua_State* L) |
| 177 | { |
| 178 | int32 NumParams = lua_gettop(L); |
| 179 | if (NumParams != 1) |
| 180 | return luaL_error(L, "invalid parameters"); |
| 181 | |
| 182 | FLuaSet* Set = (FLuaSet*)(GetCppInstanceFast(L, 1)); |
| 183 | TSet_Guard(L, Set); |
| 184 | |
| 185 | if (!Set->ElementInterface->IsValid()) |
| 186 | return luaL_error(L, TCHAR_TO_UTF8(*FString::Printf(TEXT("invalid TSet element type:%s"), *Set->ElementInterface->GetName()))); |
| 187 | |
| 188 | void* MemData = FMemory::Malloc(sizeof(FLuaArray), alignof(FLuaArray)); |
| 189 | FLuaArray* Array = Set->ToArray(MemData); |
| 190 | Array->Inner->Initialize(Array->ElementCache); |
| 191 | lua_newtable(L); |
| 192 | for (int32 i = 0; i < Array->Num(); ++i) |
| 193 | { |
| 194 | lua_pushinteger(L, i + 1); |
| 195 | Array->Get(i, Array->ElementCache); |
| 196 | Array->Inner->Read(L, Array->ElementCache, true); |
| 197 | lua_rawset(L, -3); |
| 198 | } |
| 199 | Array->Inner->Destruct(Array->ElementCache); |
| 200 | FMemory::Free(MemData); |
| 201 | return 1; |
| 202 | } |
| 203 | |
| 204 | static const luaL_Reg TSetLib[] = |
| 205 | { |
nothing calls this directly
no test coverage detected