22using System . Collections . Generic ;
33using CppSharp . AST ;
44using CppSharp . AST . Extensions ;
5- using CppSharp . Generators ;
65using Type = CppSharp . AST . Type ;
76
87namespace CppSharp . Types
@@ -11,15 +10,18 @@ public class TypeMapDatabase : ITypeMapDatabase
1110 {
1211 public IDictionary < string , TypeMap > TypeMaps { get ; set ; }
1312
14- public TypeMapDatabase ( ASTContext astContext , GeneratorKind generatorKind )
13+ public DriverOptions Options { get ; }
14+
15+ public TypeMapDatabase ( ASTContext astContext , DriverOptions options )
1516 {
1617 TypeMaps = new Dictionary < string , TypeMap > ( ) ;
18+ this . Options = options ;
1719 foreach ( var assembly in AppDomain . CurrentDomain . GetAssemblies ( ) )
1820 {
1921 try
2022 {
2123 var types = assembly . FindDerivedTypes ( typeof ( TypeMap ) ) ;
22- SetupTypeMaps ( types , generatorKind , astContext ) ;
24+ SetupTypeMaps ( types , astContext ) ;
2325 }
2426 catch ( System . Reflection . ReflectionTypeLoadException ex )
2527 {
@@ -29,18 +31,18 @@ public TypeMapDatabase(ASTContext astContext, GeneratorKind generatorKind)
2931 }
3032 }
3133
32- private void SetupTypeMaps ( IEnumerable < System . Type > types ,
33- GeneratorKind generatorKind , ASTContext astContext )
34+ private void SetupTypeMaps ( IEnumerable < System . Type > types , ASTContext astContext )
3435 {
3536 foreach ( var type in types )
3637 {
3738 var attrs = type . GetCustomAttributes ( typeof ( TypeMapAttribute ) , true ) ;
3839 foreach ( TypeMapAttribute attr in attrs )
3940 {
40- if ( attr . GeneratorKind == 0 || attr . GeneratorKind == generatorKind )
41+ if ( attr . GeneratorKind == 0 || attr . GeneratorKind == Options . GeneratorKind )
4142 {
4243 var typeMap = ( TypeMap ) Activator . CreateInstance ( type ) ;
4344 typeMap . ASTContext = astContext ;
45+ typeMap . Options = Options ;
4446 typeMap . TypeMapDatabase = this ;
4547 this . TypeMaps [ attr . Type ] = typeMap ;
4648 }
@@ -108,10 +110,13 @@ public bool FindTypeMap(Type type, out TypeMap typeMap)
108110 return typeMap . IsEnabled ;
109111 }
110112
113+ Type desugared = type . Desugar ( ) ;
114+ bool printExtra = desugared . GetPointee ( ) != null &&
115+ desugared . GetFinalPointee ( ) . Desugar ( ) . IsPrimitiveType ( ) ;
111116 var typePrinter = new CppTypePrinter
112117 {
113- PrintTypeQualifiers = false ,
114- PrintTypeModifiers = false ,
118+ PrintTypeQualifiers = printExtra ,
119+ PrintTypeModifiers = printExtra ,
115120 PrintLogicalNames = true
116121 } ;
117122
0 commit comments