Add Bindings for handling MAX c++ defines and converting them to c#.

This commit is contained in:
Chandler Cox
2024-08-20 18:30:02 -05:00
parent d779862271
commit a69a3812c2

View File

@@ -2042,13 +2042,18 @@ namespace Flax.Build.Bindings
GenerateCSharpAttributes(buildData, contents, indent, enumInfo, true);
contents.Append(indent).Append(GenerateCSharpAccessLevel(enumInfo.Access));
contents.Append("enum ").Append(enumInfo.Name);
string managedType = string.Empty;
if (enumInfo.UnderlyingType != null)
contents.Append(" : ").Append(GenerateCSharpNativeToManaged(buildData, enumInfo.UnderlyingType, enumInfo));
{
managedType = GenerateCSharpNativeToManaged(buildData, enumInfo.UnderlyingType, enumInfo);
contents.Append(" : ").Append(managedType);
}
contents.AppendLine();
contents.Append(indent + "{");
indent += " ";
// Entries
bool usedMax = false;
foreach (var entryInfo in enumInfo.Entries)
{
contents.AppendLine();
@@ -2056,7 +2061,25 @@ namespace Flax.Build.Bindings
GenerateCSharpAttributes(buildData, contents, indent, enumInfo, entryInfo.Attributes, entryInfo.Comment, true, false);
contents.Append(indent).Append(entryInfo.Name);
if (!string.IsNullOrEmpty(entryInfo.Value))
contents.Append(" = ").Append(entryInfo.Value);
{
string value;
if (enumInfo.UnderlyingType != null)
{
value = GenerateCSharpDefaultValueNativeToManaged(buildData, entryInfo.Value, enumInfo, enumInfo.UnderlyingType, false, managedType);
if (value.Contains($"{managedType}.MaxValue", StringComparison.Ordinal))
usedMax = true;
}
else
{
value = entryInfo.Value;
}
contents.Append(" = ").Append(value);
}
else if (string.IsNullOrEmpty(entryInfo.Value) && usedMax)
{
contents.Append(" = ").Append('0');
usedMax = false;
}
contents.Append(',');
contents.AppendLine();
}