@@ -38,17 +38,46 @@ public CppTypePrinter(BindingContext context) : base(TypePrinterContextKind.Mana
38
38
public bool ResolveTypeMaps { get ; set ; } = true ;
39
39
public bool ResolveTypedefs { get ; set ; }
40
40
41
- public override TypePrinterResult VisitTagType ( TagType tag ,
42
- TypeQualifiers quals )
41
+ public bool FindTypeMap ( CppSharp . AST . Type type , out TypePrinterResult result )
43
42
{
43
+ result = null ;
44
+
45
+ if ( ! ResolveTypeMaps )
46
+ return false ;
47
+
44
48
TypeMap typeMap ;
45
- if ( ResolveTypeMaps && TypeMapDatabase . FindTypeMap ( tag , out typeMap ) &&
46
- ! typeMap . IsIgnored )
49
+ if ( ! TypeMapDatabase . FindTypeMap ( type , out typeMap ) || typeMap . IsIgnored )
50
+ return false ;
51
+
52
+ var typePrinterContext = new TypePrinterContext
47
53
{
48
- var typePrinterContext = new TypePrinterContext { Type = tag } ;
49
- var type = typeMap . CppSignatureType ( typePrinterContext ) . ToString ( ) ;
50
- return new TypePrinterResult ( type ) { TypeMap = typeMap } ;
51
- }
54
+ Type = type ,
55
+ Kind = Kind ,
56
+ MarshalKind = MarshalKind
57
+ } ;
58
+
59
+ var typePrinter = new CppTypePrinter ( Context )
60
+ {
61
+ PrintFlavorKind = PrintFlavorKind ,
62
+ ScopeKind = ScopeKind ,
63
+ PrintTypeQualifiers = PrintTypeQualifiers ,
64
+ PrintTypeModifiers = PrintTypeModifiers ,
65
+ ResolveTypeMaps = false
66
+ } ;
67
+ typePrinter . PushContext ( ContextKind ) ;
68
+
69
+ var typeName = typeMap . CppSignatureType ( typePrinterContext ) . Visit ( typePrinter ) ;
70
+ result = new TypePrinterResult ( typeName ) { TypeMap = typeMap } ;
71
+
72
+ return true ;
73
+ }
74
+
75
+ public override TypePrinterResult VisitTagType ( TagType tag ,
76
+ TypeQualifiers quals )
77
+ {
78
+ TypePrinterResult result ;
79
+ if ( FindTypeMap ( tag , out result ) )
80
+ return result ;
52
81
53
82
var qual = GetStringQuals ( quals ) ;
54
83
return $ "{ qual } { tag . Declaration . Visit ( this ) } ";
0 commit comments