Lua向C#逻辑迁移 一期 #13

将整个插件代码上传
This commit is contained in:
2025-10-26 21:48:39 +08:00
parent 56994b3927
commit 648386cd73
785 changed files with 53683 additions and 2 deletions

View File

@ -0,0 +1,86 @@
using EpicGames.UHT.Types;
using System.Collections.Generic;
using UnrealSharpScriptGenerator.PropertyTranslators;
namespace UnrealSharpScriptGenerator.Utilities;
public static class StructUtilities
{
public static bool IsStructBlittable(this UhtStruct structObj)
{
if (PropertyTranslatorManager.SpecialTypeInfo.Structs.BlittableTypes.ContainsKey(structObj.SourceName))
{
return true;
}
// Any struct we haven't manually exported is not blittable, yet.
// The fix for this is to add a header parser to check for non-UPROPERTY properties in the struct.
// Because a struct can be recognized as blittable by the reflection data,
// but have a non-UPROPERTY property that is not picked up by UHT, that makes it not blittable causing a mismatch in memory layout.
// This is a temporary solution until we can get that working.
return false;
}
public static bool IsStructNativelyCopyable(this UhtStruct structObj)
{
return PropertyTranslatorManager.SpecialTypeInfo.Structs.NativelyCopyableTypes.ContainsKey(structObj.SourceName);
}
public static bool IsStructNativelyDestructible(this UhtStruct structObj)
{
return PropertyTranslatorManager.SpecialTypeInfo.Structs.NativelyCopyableTypes.TryGetValue(structObj.SourceName, out var info) && info.HasDestructor;
}
public static bool IsStructEquatable(this UhtStruct structObj, List<UhtProperty> exportedProperties)
{
if (InclusionLists.HasBannedEquality(structObj))
{
return false;
}
if (exportedProperties.Count == 0)
{
return false;
}
foreach (UhtProperty property in exportedProperties)
{
PropertyTranslator translator = PropertyTranslatorManager.GetTranslator(property)!;
if (!translator.IsPrimitive)
{
return false;
}
}
return true;
}
public static bool CanSupportArithmetic(this UhtStruct structObj, List<UhtProperty> exportedProperties)
{
if (InclusionLists.HasBannedEquality(structObj))
{
return false;
}
if (InclusionLists.HasBannedArithmetic(structObj))
{
return false;
}
if (exportedProperties.Count == 0)
{
return false;
}
foreach (UhtProperty property in exportedProperties)
{
PropertyTranslator translator = PropertyTranslatorManager.GetTranslator(property)!;
if (!translator.IsNumeric)
{
return false;
}
}
return true;
}
}