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

Function TSet_ToTable

Plugins/UnLua/Source/UnLua/Private/BaseLib/LuaLib_Set.cpp:176–202  ·  view source on GitHub ↗

* Convert the set to a Lua table */

Source from the content-addressed store, hash-verified

174 * Convert the set to a Lua table
175 */
176static 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
204static const luaL_Reg TSetLib[] =
205{

Callers

nothing calls this directly

Calls 14

lua_gettopFunction · 0.85
luaL_errorFunction · 0.85
GetCppInstanceFastFunction · 0.85
TSet_GuardFunction · 0.85
lua_pushintegerFunction · 0.85
lua_rawsetFunction · 0.85
ToArrayMethod · 0.80
IsValidMethod · 0.45
GetNameMethod · 0.45
InitializeMethod · 0.45
NumMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected