Skip to content

Commit

Permalink
Merge pull request #588 from tannergooding/main
Browse files Browse the repository at this point in the history
Allow the destructor to be remapped so it doesn't force conflict with a method named Dispose
  • Loading branch information
tannergooding authored Dec 19, 2024
2 parents 2d4e661 + 7a7785f commit c245e16
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2805,9 +2805,11 @@ private string GetCursorName(NamedDecl namedDecl)
Debug.Assert(parent is not null);
name = GetCursorName(parent);
}
else if (namedDecl is CXXDestructorDecl)
else if (namedDecl is CXXDestructorDecl cxxDestructorDecl)
{
name = "Dispose";
var parent = cxxDestructorDecl.Parent;
Debug.Assert(parent is not null);
name = $"~{GetCursorName(parent)}";
}
else if (string.IsNullOrWhiteSpace(name) || name.StartsWith('('))
{
Expand Down Expand Up @@ -3160,6 +3162,10 @@ private string GetRemappedCursorName(NamedDecl namedDecl, out string nativeTypeN
Debug.Assert(parent is not null);
remappedName = GetRemappedCursorName(parent);
}
else if (namedDecl is CXXDestructorDecl)
{
remappedName = "Dispose";
}
else if (namedDecl is FieldDecl fieldDecl)
{
if (name.StartsWith("__AnonymousFieldDecl_", StringComparison.Ordinal))
Expand Down

0 comments on commit c245e16

Please sign in to comment.