Skip to content

Commit

Permalink
Allow the destructor to be remapped so it doesn't force conflict with…
Browse files Browse the repository at this point in the history
… a method named Dispose
  • Loading branch information
tannergooding committed Dec 19, 2024
1 parent fd868d6 commit 7a7785f
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 7a7785f

Please sign in to comment.