3
3
using System . Linq ;
4
4
using CppSharp . AST ;
5
5
using CppSharp . AST . Extensions ;
6
+ using CppSharp . Generators ;
7
+ using CppSharp . Generators . CLI ;
8
+ using CppSharp . Generators . CSharp ;
6
9
7
10
namespace CppSharp . Passes
8
11
{
@@ -100,32 +103,35 @@ public static string FixSignatureForConversions(Function function, string signat
100
103
return signature ;
101
104
}
102
105
103
- private class ParameterTypeComparer : IEqualityComparer < Parameter >
106
+ public class ParameterTypeComparer : IEqualityComparer < Parameter >
104
107
{
105
108
public static readonly ParameterTypeComparer Instance = new ParameterTypeComparer ( ) ;
106
109
107
- private ParameterTypeComparer ( )
108
- {
109
- }
110
-
111
110
public bool Equals ( Parameter x , Parameter y )
112
111
{
113
112
Type left = x . Type . Desugar ( resolveTemplateSubstitution : false ) ;
114
113
Type right = y . Type . Desugar ( resolveTemplateSubstitution : false ) ;
115
114
if ( left . Equals ( right ) )
116
115
return true ;
117
116
118
- // TODO: some target languages might maek a difference between values and pointers
117
+ // TODO: some target languages might make a difference between values and pointers
119
118
Type leftPointee = left . GetPointee ( ) ;
120
119
Type rightPointee = right . GetPointee ( ) ;
121
- return ( leftPointee != null && leftPointee . Desugar ( false ) . Equals ( right ) ) ||
122
- ( rightPointee != null && rightPointee . Desugar ( false ) . Equals ( left ) ) ;
120
+ if ( ( leftPointee != null && leftPointee . Desugar ( false ) . Equals ( right ) ) ||
121
+ ( rightPointee != null && rightPointee . Desugar ( false ) . Equals ( left ) ) )
122
+ return true ;
123
+
124
+ return TypePrinter != null &&
125
+ left . IsPrimitiveType ( ) && right . IsPrimitiveType ( ) &&
126
+ left . Visit ( TypePrinter ) . Type == right . Visit ( TypePrinter ) . Type ;
123
127
}
124
128
125
129
public int GetHashCode ( Parameter obj )
126
130
{
127
131
return obj . Type . GetHashCode ( ) ;
128
132
}
133
+
134
+ public static TypePrinter TypePrinter { get ; set ; }
129
135
}
130
136
}
131
137
@@ -139,6 +145,22 @@ public CheckDuplicatedNamesPass()
139
145
names = new Dictionary < string , DeclarationName > ( ) ;
140
146
}
141
147
148
+ public override bool VisitASTContext ( ASTContext context )
149
+ {
150
+ TypePrinter typePrinter = null ;
151
+ switch ( Options . GeneratorKind )
152
+ {
153
+ case GeneratorKind . CLI :
154
+ typePrinter = new CLITypePrinter ( Context ) ;
155
+ break ;
156
+ case GeneratorKind . CSharp :
157
+ typePrinter = new CSharpTypePrinter ( Context ) ;
158
+ break ;
159
+ }
160
+ DeclarationName . ParameterTypeComparer . TypePrinter = typePrinter ;
161
+ return base . VisitASTContext ( context ) ;
162
+ }
163
+
142
164
public override bool VisitProperty ( Property decl )
143
165
{
144
166
if ( ! VisitDeclaration ( decl ) )
0 commit comments