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

Function Class_NewIndex

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

* __newindex meta methods for class */

Source from the content-addressed store, hash-verified

1460 * __newindex meta methods for class
1461 */
1462int32 Class_NewIndex(lua_State *L)
1463{
1464 GetField(L);
1465
1466 const auto Ptr = lua_touserdata(L, -1);
1467 if (Ptr)
1468 {
1469 const auto Property = static_cast<TSharedPtr<UnLua::ITypeOps>*>(Ptr)->Get();
1470 if (Property && Property->IsValid())
1471 {
1472 const auto Self = GetCppInstance(L, 1);
1473 if (Self)
1474 {
1475 if (UnLua::LowLevel::IsReleasedPtr(Self))
1476 return luaL_error(L, TCHAR_TO_UTF8(*FString::Printf(TEXT("attempt to write property '%s' on released object"), *Property->GetName())));
1477
1478 if (!UnLua::LowLevel::CheckPropertyOwner(L, Property, Self))
1479 return 0;
1480
1481 Property->Write(L, Self, 3);
1482 }
1483 }
1484 }
1485 else
1486 {
1487 int32 Type = lua_type(L, 1);
1488 if (Type == LUA_TTABLE)
1489 {
1490 lua_pushvalue(L, 2);
1491 lua_pushvalue(L, 3);
1492 lua_rawset(L, 1);
1493
1494 //UE_LOG(LogUnLua, Warning, TEXT("%s: You are modifying metatable! Please make sure you know what you are doing!"), ANSI_TO_TCHAR(__FUNCTION__));
1495 }
1496 }
1497 lua_pop(L, 1);
1498 return 0;
1499}
1500
1501/**
1502 * Generic closure to call a UFunction

Callers

nothing calls this directly

Calls 13

GetFieldFunction · 0.85
lua_touserdataFunction · 0.85
GetCppInstanceFunction · 0.85
IsReleasedPtrFunction · 0.85
luaL_errorFunction · 0.85
CheckPropertyOwnerFunction · 0.85
lua_typeFunction · 0.85
lua_pushvalueFunction · 0.85
lua_rawsetFunction · 0.85
GetMethod · 0.45
IsValidMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected