Skip to content

Commit 174c2bb

Browse files
committed
Improve method naming for conversions to pointers
1 parent 53dbe11 commit 174c2bb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6581,9 +6581,20 @@ private bool TryRemapOperatorName(ref string name, FunctionDecl functionDecl)
65816581
if (functionDecl is CXXConversionDecl)
65826582
{
65836583
var returnType = functionDecl.ReturnType;
6584+
var pointerIndirectionLevel = 0;
6585+
while (returnType is PointerType pointerType)
6586+
{
6587+
pointerIndirectionLevel++;
6588+
returnType = pointerType.PointeeType;
6589+
}
65846590
var returnTypeName = GetRemappedTypeName(cursor: null, context: null, returnType, out _, skipUsing: true);
65856591

6586-
name = $"To{returnTypeName}";
6592+
var pointerSuffix = "";
6593+
if (pointerIndirectionLevel > 0)
6594+
{
6595+
pointerSuffix = string.Concat(Enumerable.Repeat("Pointer", pointerIndirectionLevel));
6596+
}
6597+
name = $"To{returnTypeName}{pointerSuffix}";
65876598
return true;
65886599
}
65896600

0 commit comments

Comments
 (0)