Skip to content

Commit

Permalink
Merge pull request #520 from tannergooding/main
Browse files Browse the repository at this point in the history
Adding a switch to minimally support pointers in generics
  • Loading branch information
tannergooding committed Dec 27, 2023
2 parents 87ec122 + dc417d9 commit 0c89b5a
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 37 deletions.
Expand Up @@ -12,7 +12,7 @@ internal partial class CSharpOutputBuilder

public void WriteCustomAttribute(string attribute, Action? callback = null)
{
if (attribute.Equals("Flags", StringComparison.Ordinal) || attribute.Equals("Obsolete", StringComparison.Ordinal))
if (attribute.Equals("Flags", StringComparison.Ordinal) || attribute.Equals("Obsolete", StringComparison.Ordinal) || attribute.StartsWith("Obsolete(", StringComparison.Ordinal))
{
AddUsingDirective("System");
}
Expand Down
Expand Up @@ -340,7 +340,7 @@ void VisitArgs(CallExpr callExpr, IReadOnlyList<Expr>? args = null)

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

outputBuilder.AddUsingDirective("System.Runtime.CompilerServices");
outputBuilder.Write('(');
Expand Down Expand Up @@ -443,6 +443,12 @@ private void VisitCharacterLiteral(CharacterLiteral characterLiteral)
targetTypeName = GetRemappedTypeName(implicitCastExpr, context: null, targetType, out _, skipUsing: true);
targetTypeNumBits = targetType.Handle.NumBits;
}
else if (IsPrevContextStmt<BinaryOperator>(out var binaryOperator, out _))
{
var targetType = binaryOperator.Type;
targetTypeName = GetRemappedTypeName(implicitCastExpr, context: null, targetType, out _, skipUsing: true);
targetTypeNumBits = targetType.Handle.NumBits;
}
else if (PreviousContext.Cursor is VarDecl varDecl)
{
var targetType = varDecl.Type;
Expand Down Expand Up @@ -2106,7 +2112,7 @@ private void VisitReturnStmt(ReturnStmt returnStmt)

if (subExpr is CXXThisExpr)
{
var referenceTypeName = GetTypeName(returnStmt, context: null, referenceType, ignoreTransparentStructsWhereRequired: true, out _);
var referenceTypeName = GetTypeName(returnStmt, context: null, type: referenceType, ignoreTransparentStructsWhereRequired: true, isTemplate: false, nativeTypeName: out _);

outputBuilder.AddUsingDirective("System.Runtime.CompilerServices");
outputBuilder.Write('(');
Expand Down

0 comments on commit 0c89b5a

Please sign in to comment.