From 08f286253c8057cbed6ea6f430e801542827c23c Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Tue, 6 Aug 2024 12:30:59 -0500 Subject: [PATCH 1/2] Handle cpp .f in bindings generator. --- Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs index 70b23502b..3bc679a80 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs @@ -142,6 +142,7 @@ namespace Flax.Build.Bindings // Numbers if (float.TryParse(value, out _) || (value[value.Length - 1] == 'f' && float.TryParse(value.Substring(0, value.Length - 1), out _))) { + value = value.Replace(".f", ".0f"); // If the value type is different than the value (eg. value is int but the field is float) then cast it for the [DefaultValue] attribute if (valueType != null && attribute) return $"({GenerateCSharpNativeToManaged(buildData, valueType, caller)}){value}"; @@ -166,7 +167,7 @@ namespace Flax.Build.Bindings foreach (var vectorType in CSharpVectorTypes) { if (value.Length > vectorType.Length + 4 && value.StartsWith(vectorType) && value[vectorType.Length] == '(') - return $"typeof({vectorType}), \"{value.Substring(vectorType.Length + 1, value.Length - vectorType.Length - 2).Replace("f", "")}\""; + return $"typeof({vectorType}), \"{value.Substring(vectorType.Length + 1, value.Length - vectorType.Length - 2).Replace(".f", "").Replace("f", "")}\""; } return null; From 443bc347efdcefe7b854ddd701208d6f0c65f0be Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Tue, 6 Aug 2024 17:37:04 -0500 Subject: [PATCH 2/2] Fix vector type floats from .f to .0 --- Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs index 3bc679a80..a437a4158 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs @@ -167,7 +167,7 @@ namespace Flax.Build.Bindings foreach (var vectorType in CSharpVectorTypes) { if (value.Length > vectorType.Length + 4 && value.StartsWith(vectorType) && value[vectorType.Length] == '(') - return $"typeof({vectorType}), \"{value.Substring(vectorType.Length + 1, value.Length - vectorType.Length - 2).Replace(".f", "").Replace("f", "")}\""; + return $"typeof({vectorType}), \"{value.Substring(vectorType.Length + 1, value.Length - vectorType.Length - 2).Replace(".f", ".0").Replace("f", "")}\""; } return null;