|
|
|
@ -3,6 +3,9 @@ using System.Globalization; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq; |
|
|
|
using CppSharp.AST; |
|
|
|
using CppSharp.AST; |
|
|
|
using CppSharp.AST.Extensions; |
|
|
|
using CppSharp.AST.Extensions; |
|
|
|
|
|
|
|
using CppSharp.Generators; |
|
|
|
|
|
|
|
using CppSharp.Generators.CLI; |
|
|
|
|
|
|
|
using CppSharp.Generators.CSharp; |
|
|
|
|
|
|
|
|
|
|
|
namespace CppSharp.Passes |
|
|
|
namespace CppSharp.Passes |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -100,14 +103,10 @@ namespace CppSharp.Passes |
|
|
|
return signature; |
|
|
|
return signature; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class ParameterTypeComparer : IEqualityComparer<Parameter> |
|
|
|
public class ParameterTypeComparer : IEqualityComparer<Parameter> |
|
|
|
{ |
|
|
|
{ |
|
|
|
public static readonly ParameterTypeComparer Instance = new ParameterTypeComparer(); |
|
|
|
public static readonly ParameterTypeComparer Instance = new ParameterTypeComparer(); |
|
|
|
|
|
|
|
|
|
|
|
private ParameterTypeComparer() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool Equals(Parameter x, Parameter y) |
|
|
|
public bool Equals(Parameter x, Parameter y) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Type left = x.Type.Desugar(resolveTemplateSubstitution: false); |
|
|
|
Type left = x.Type.Desugar(resolveTemplateSubstitution: false); |
|
|
|
@ -115,17 +114,24 @@ namespace CppSharp.Passes |
|
|
|
if (left.Equals(right)) |
|
|
|
if (left.Equals(right)) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
// TODO: some target languages might maek a difference between values and pointers
|
|
|
|
// TODO: some target languages might make a difference between values and pointers
|
|
|
|
Type leftPointee = left.GetPointee(); |
|
|
|
Type leftPointee = left.GetPointee(); |
|
|
|
Type rightPointee = right.GetPointee(); |
|
|
|
Type rightPointee = right.GetPointee(); |
|
|
|
return (leftPointee != null && leftPointee.Desugar(false).Equals(right)) || |
|
|
|
if ((leftPointee != null && leftPointee.Desugar(false).Equals(right)) || |
|
|
|
(rightPointee != null && rightPointee.Desugar(false).Equals(left)); |
|
|
|
(rightPointee != null && rightPointee.Desugar(false).Equals(left))) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return TypePrinter != null && |
|
|
|
|
|
|
|
left.IsPrimitiveType() && right.IsPrimitiveType() && |
|
|
|
|
|
|
|
left.Visit(TypePrinter).Type == right.Visit(TypePrinter).Type; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int GetHashCode(Parameter obj) |
|
|
|
public int GetHashCode(Parameter obj) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return obj.Type.GetHashCode(); |
|
|
|
return obj.Type.GetHashCode(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static TypePrinter TypePrinter { get; set; } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -139,6 +145,22 @@ namespace CppSharp.Passes |
|
|
|
names = new Dictionary<string, DeclarationName>(); |
|
|
|
names = new Dictionary<string, DeclarationName>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override bool VisitASTContext(ASTContext context) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
TypePrinter typePrinter = null; |
|
|
|
|
|
|
|
switch (Options.GeneratorKind) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case GeneratorKind.CLI: |
|
|
|
|
|
|
|
typePrinter = new CLITypePrinter(Context); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case GeneratorKind.CSharp: |
|
|
|
|
|
|
|
typePrinter = new CSharpTypePrinter(Context); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
DeclarationName.ParameterTypeComparer.TypePrinter = typePrinter; |
|
|
|
|
|
|
|
return base.VisitASTContext(context); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override bool VisitProperty(Property decl) |
|
|
|
public override bool VisitProperty(Property decl) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!VisitDeclaration(decl)) |
|
|
|
if (!VisitDeclaration(decl)) |
|
|
|
|