Skip to content

Commit 38079cb

Browse files
committed
[SharpGen] In CastXML, init attributes contain expressions. Cast to correct type if necessary
1 parent 7c3c4c6 commit 38079cb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Source/Tools/SharpGen/Parser/CppParser.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,13 @@ private CppElement ParseVariable(XElement xElement)
11601160
return new CppGuid { Name = name, Guid = guid.Value };
11611161
}
11621162

1163+
// CastXML outputs initialization expressions. Cast to proper type.
1164+
var match = Regex.Match(value, @"\((?:\(.+\))?(.+)\)");
1165+
if (match.Success)
1166+
{
1167+
value = $"unchecked(({cppType.TypeName}){match.Groups[1].Value})";
1168+
}
1169+
11631170
// Handle C++ floating point literals
11641171
value = value.Replace(".F", ".0F");
11651172

0 commit comments

Comments
 (0)