* __newindex meta methods for class */
| 1460 | * __newindex meta methods for class |
| 1461 | */ |
| 1462 | int32 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 |
nothing calls this directly
no test coverage detected