Skip to content

Commit 2188fcd

Browse files
committed
Use GetNativeElementTypeName in order to simplify code
Apparently ModUtils already had this exact logic.
1 parent 64cbea3 commit 2188fcd

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

sources/SilkTouch/SilkTouch/Mods/MixKhronosData.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,22 +2035,18 @@ private bool TryGetManagedEnumType(SyntaxList<AttributeListSyntax> attributes, [
20352035
// ClangSharp does not know how to handle FlagBits and Flags types
20362036
// Because of this ClangSharp outputs Flags types as uints or ulongs
20372037
// We have to look at the NativeTypeName in order to determine the correct type
2038-
var nativeName = attributes.GetNativeTypeName()?.Replace("FlagBits", "Flags");
2038+
var nativeName = attributes.GetNativeElementTypeName(out var pointerDimension)?.Replace("FlagBits", "Flags");
20392039
if (nativeName == null || !nativeName.Contains("Flags"))
20402040
{
20412041
return false;
20422042
}
20432043

2044-
var nativeNameParts = nativeName.Split(' ');
2045-
var typeName = nativeName.StartsWith("const ") ? nativeNameParts[1] : nativeNameParts[0];
2046-
var pointerDimension = nativeName.Count(c => c == '*');
2047-
2048-
if (!phase1.AllKnownEnums.Contains(typeName))
2044+
if (!phase1.AllKnownEnums.Contains(nativeName))
20492045
{
20502046
return false;
20512047
}
20522048

2053-
managedName = typeName + new string('*', pointerDimension);
2049+
managedName = nativeName + new string('*', pointerDimension);
20542050

20552051
return true;
20562052
}

0 commit comments

Comments
 (0)