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

Function Class_Index

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

* __index meta methods for class */

Source from the content-addressed store, hash-verified

1430 * __index meta methods for class
1431 */
1432int32 Class_Index(lua_State *L)
1433{
1434 GetField(L);
1435
1436 const auto Ptr = lua_touserdata(L, -1);
1437 if (!Ptr)
1438 return 1;
1439
1440 const auto Property = static_cast<TSharedPtr<UnLua::ITypeOps>*>(Ptr)->Get();
1441 if (!Property || !Property->IsValid())
1442 return 0;
1443
1444 const auto Self = GetCppInstance(L, 1);
1445 if (!Self)
1446 return 1;
1447
1448 if (UnLua::LowLevel::IsReleasedPtr(Self))
1449 return luaL_error(L, TCHAR_TO_UTF8(*FString::Printf(TEXT("attempt to read property '%s' on released object"), *Property->GetName())));
1450
1451 if (!UnLua::LowLevel::CheckPropertyOwner(L, Property, Self))
1452 return 0;
1453
1454 Property->Read(L, Self, false);
1455 lua_remove(L, -2);
1456 return 1;
1457}
1458
1459/**
1460 * __newindex meta methods for class

Callers

nothing calls this directly

Calls 10

GetFieldFunction · 0.85
lua_touserdataFunction · 0.85
GetCppInstanceFunction · 0.85
IsReleasedPtrFunction · 0.85
luaL_errorFunction · 0.85
CheckPropertyOwnerFunction · 0.85
GetMethod · 0.45
IsValidMethod · 0.45
GetNameMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected