Skip to content

Commit 0c89b5a

Browse files
Merge pull request #520 from tannergooding/main
Adding a switch to minimally support pointers in generics
2 parents 87ec122 + dc417d9 commit 0c89b5a

File tree

6 files changed

+83
-37
lines changed

6 files changed

+83
-37
lines changed

sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal partial class CSharpOutputBuilder
1212

1313
public void WriteCustomAttribute(string attribute, Action? callback = null)
1414
{
15-
if (attribute.Equals("Flags", StringComparison.Ordinal) || attribute.Equals("Obsolete", StringComparison.Ordinal))
15+
if (attribute.Equals("Flags", StringComparison.Ordinal) || attribute.Equals("Obsolete", StringComparison.Ordinal) || attribute.StartsWith("Obsolete(", StringComparison.Ordinal))
1616
{
1717
AddUsingDirective("System");
1818
}

sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void VisitArgs(CallExpr callExpr, IReadOnlyList<Expr>? args = null)
340340

341341
if (subExpr is CXXThisExpr)
342342
{
343-
var referenceTypeName = GetTypeName(callExpr, context: null, referenceType, ignoreTransparentStructsWhereRequired: true, out _);
343+
var referenceTypeName = GetTypeName(callExpr, context: null, type: referenceType, ignoreTransparentStructsWhereRequired: true, isTemplate: false, nativeTypeName: out _);
344344

345345
outputBuilder.AddUsingDirective("System.Runtime.CompilerServices");
346346
outputBuilder.Write('(');
@@ -443,6 +443,12 @@ private void VisitCharacterLiteral(CharacterLiteral characterLiteral)
443443
targetTypeName = GetRemappedTypeName(implicitCastExpr, context: null, targetType, out _, skipUsing: true);
444444
targetTypeNumBits = targetType.Handle.NumBits;
445445
}
446+
else if (IsPrevContextStmt<BinaryOperator>(out var binaryOperator, out _))
447+
{
448+
var targetType = binaryOperator.Type;
449+
targetTypeName = GetRemappedTypeName(implicitCastExpr, context: null, targetType, out _, skipUsing: true);
450+
targetTypeNumBits = targetType.Handle.NumBits;
451+
}
446452
else if (PreviousContext.Cursor is VarDecl varDecl)
447453
{
448454
var targetType = varDecl.Type;
@@ -2106,7 +2112,7 @@ private void VisitReturnStmt(ReturnStmt returnStmt)
21062112

21072113
if (subExpr is CXXThisExpr)
21082114
{
2109-
var referenceTypeName = GetTypeName(returnStmt, context: null, referenceType, ignoreTransparentStructsWhereRequired: true, out _);
2115+
var referenceTypeName = GetTypeName(returnStmt, context: null, type: referenceType, ignoreTransparentStructsWhereRequired: true, isTemplate: false, nativeTypeName: out _);
21102116

21112117
outputBuilder.AddUsingDirective("System.Runtime.CompilerServices");
21122118
outputBuilder.Write('(');

0 commit comments

Comments
 (0)