Skip to content

Commit 1dfd06d

Browse files
committed
Prepare code generator for 1.75 default enum arguments.
1 parent 35aabdc commit 1dfd06d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/CodeGenerator/Program.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,12 @@ private static bool CorrectDefaultValue(string defaultVal, TypeReference tr, out
962962

963963
if (defaultVal.Contains("%")) { correctedDefault = null; return false; }
964964

965+
if (tr.IsEnum)
966+
{
967+
correctedDefault = $"({tr.Type}){defaultVal}";
968+
return true;
969+
}
970+
965971
correctedDefault = defaultVal;
966972
return true;
967973
}
@@ -1120,6 +1126,7 @@ class TypeReference
11201126
public int ArraySize { get; }
11211127
public bool IsFunctionPointer { get; }
11221128
public string[] TypeVariants { get; }
1129+
public bool IsEnum { get; }
11231130

11241131
public TypeReference(string name, string type, EnumDefinition[] enums)
11251132
: this(name, type, null, enums, null) { }
@@ -1161,6 +1168,8 @@ public TypeReference(string name, string type, string templateType, EnumDefiniti
11611168
IsFunctionPointer = Type.IndexOf('(') != -1;
11621169

11631170
TypeVariants = typeVariants;
1171+
1172+
IsEnum = enums.Any(t => t.Name == type || t.FriendlyName == type);
11641173
}
11651174

11661175
private int ParseSizeString(string sizePart, EnumDefinition[] enums)

0 commit comments

Comments
 (0)