From 1dfd06d6b4435a052563512752066c014199cea8 Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Mon, 17 Feb 2020 23:24:03 -0800 Subject: [PATCH] Prepare code generator for 1.75 default enum arguments. --- src/CodeGenerator/Program.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/CodeGenerator/Program.cs b/src/CodeGenerator/Program.cs index c6e7937..f3f8886 100644 --- a/src/CodeGenerator/Program.cs +++ b/src/CodeGenerator/Program.cs @@ -962,6 +962,12 @@ namespace CodeGenerator if (defaultVal.Contains("%")) { correctedDefault = null; return false; } + if (tr.IsEnum) + { + correctedDefault = $"({tr.Type}){defaultVal}"; + return true; + } + correctedDefault = defaultVal; return true; } @@ -1120,6 +1126,7 @@ namespace CodeGenerator public int ArraySize { get; } public bool IsFunctionPointer { get; } public string[] TypeVariants { get; } + public bool IsEnum { get; } public TypeReference(string name, string type, EnumDefinition[] enums) : this(name, type, null, enums, null) { } @@ -1161,6 +1168,8 @@ namespace CodeGenerator IsFunctionPointer = Type.IndexOf('(') != -1; TypeVariants = typeVariants; + + IsEnum = enums.Any(t => t.Name == type || t.FriendlyName == type); } private int ParseSizeString(string sizePart, EnumDefinition[] enums)