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

Function TMap_Pairs

Plugins/UnLua/Source/UnLua/Private/BaseLib/LuaLib_Map.cpp:84–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84static int32 TMap_Pairs(lua_State* L)
85{
86 int32 NumParams = lua_gettop(L);
87 if (NumParams != 1)
88 return luaL_error(L, "invalid parameters");
89
90 FLuaMap* Map = (FLuaMap*)GetCppInstanceFast(L, 1);
91 if (!Map)
92 return UnLua::LowLevel::PushEmptyIterator(L);
93
94 TMap_Guard(L, Map);
95
96 lua_pushcfunction(L, TMap_Enumerable);
97 FLuaMap::FLuaMapEnumerator** Enumerator = (FLuaMap::FLuaMapEnumerator**)lua_newuserdata(L, sizeof(FLuaMap::FLuaMapEnumerator*));
98 *Enumerator = new FLuaMap::FLuaMapEnumerator(Map, 0);
99
100 lua_newtable(L);
101 lua_pushcfunction(L, FLuaMap::FLuaMapEnumerator::gc);
102 lua_setfield(L, -2, "__gc");
103 lua_setmetatable(L, -2);
104 lua_pushnil(L);
105
106 return 3;
107}
108
109/**
110 * @see FLuaMap::Num(...)

Callers

nothing calls this directly

Calls 8

lua_gettopFunction · 0.85
luaL_errorFunction · 0.85
GetCppInstanceFastFunction · 0.85
PushEmptyIteratorFunction · 0.85
TMap_GuardFunction · 0.85
lua_setfieldFunction · 0.85
lua_setmetatableFunction · 0.85
lua_pushnilFunction · 0.85

Tested by

no test coverage detected