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

Function Enum_Index

Plugins/UnLua/Source/UnLua/Private/LuaCore.cpp:1289–1314  ·  view source on GitHub ↗

* __index meta methods for enum */

Source from the content-addressed store, hash-verified

1287 * __index meta methods for enum
1288 */
1289int32 Enum_Index(lua_State *L)
1290{
1291 // 1: meta table of the Enum; 2: entry name in Enum
1292
1293 check(lua_isstring(L, -1));
1294 lua_pushstring(L, "__name"); // 3
1295 lua_rawget(L, 1); // 3
1296 check(lua_isstring(L, -1));
1297
1298 const FEnumDesc* Enum = UnLua::FLuaEnv::FindEnvChecked(L).GetEnumRegistry()->Find(lua_tostring(L, -1));
1299 if ((!Enum)
1300 || (!Enum->IsValid()))
1301 {
1302 lua_pop(L, 1);
1303 return 0;
1304 }
1305 int64 Value = Enum->GetValue(lua_tostring(L, 2));
1306
1307 lua_pop(L, 1);
1308 lua_pushvalue(L, 2);
1309 lua_pushinteger(L, Value);
1310 lua_rawset(L, 1);
1311 lua_pushinteger(L, Value);
1312
1313 return 1;
1314}
1315
1316int32 Enum_Delete(lua_State *L)
1317{

Callers

nothing calls this directly

Calls 10

checkFunction · 0.85
lua_isstringFunction · 0.85
lua_pushstringFunction · 0.85
lua_rawgetFunction · 0.85
lua_pushvalueFunction · 0.85
lua_pushintegerFunction · 0.85
lua_rawsetFunction · 0.85
FindMethod · 0.45
IsValidMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected