@@ -20,25 +20,32 @@ public class GeneratorKind : IEquatable<GeneratorKind>
2020
2121 public string ID { get ; }
2222 public string Name { get ; }
23- public System . Type Type { get ; }
23+ public System . Type GeneratorType { get ; }
24+ public System . Type TypePrinterType { get ; }
2425 public string [ ] CLIOptions { get ; }
2526
26- public GeneratorKind ( string id , string name , System . Type type , string [ ] cLIOptions = null )
27+ public GeneratorKind ( string id , string name , System . Type generatorType , System . Type typePrinterType , string [ ] cLIOptions = null )
2728 {
2829 if ( Registered . Any ( kind => kind . ID == id ) )
2930 {
3031 throw new Exception ( $ "GeneratorKind has an already registered ID: { ID } ") ;
3132 }
3233 ID = id ;
3334 Name = name ;
34- Type = type ;
35+ GeneratorType = generatorType ;
36+ TypePrinterType = typePrinterType ;
3537 CLIOptions = cLIOptions ;
3638 Registered . Add ( this ) ;
3739 }
3840
3941 public Generator CreateGenerator ( BindingContext context )
4042 {
41- return ( Generator ) Activator . CreateInstance ( Type , context ) ;
43+ return ( Generator ) Activator . CreateInstance ( GeneratorType , context ) ;
44+ }
45+
46+ public TypePrinter CreateTypePrinter ( BindingContext context )
47+ {
48+ return ( TypePrinter ) Activator . CreateInstance ( TypePrinterType , context ) ;
4249 }
4350
4451 public bool IsCLIOptionMatch ( string cliOption )
@@ -93,37 +100,44 @@ public override int GetHashCode()
93100 }
94101
95102 public const string CLI_ID = "CLI" ;
96- public static readonly GeneratorKind CLI = new ( CLI_ID , "C++/CLI" , typeof ( CLIGenerator ) , new [ ] { "cli" } ) ;
103+ public static readonly GeneratorKind CLI = new ( CLI_ID , "C++/CLI" , typeof ( CLIGenerator ) , typeof ( CLITypePrinter ) , new [ ] { "cli" } ) ;
97104
98105 public const string CSharp_ID = "CSharp" ;
99- public static readonly GeneratorKind CSharp = new ( CSharp_ID , "C#" , typeof ( CSharpGenerator ) , new [ ] { "csharp" } ) ;
106+ public static readonly GeneratorKind CSharp = new ( CSharp_ID , "C#" , typeof ( CSharpGenerator ) , typeof ( CSharpTypePrinter ) , new [ ] { "csharp" } ) ;
100107
101108 public const string C_ID = "C" ;
102- public static readonly GeneratorKind C = new ( C_ID , "C" , typeof ( CGenerator ) , new [ ] { "c" } ) ;
109+ public static readonly GeneratorKind C = new ( C_ID , "C" , typeof ( CGenerator ) , typeof ( CppTypePrinter ) , new [ ] { "c" } ) ;
103110
104111 public const string CPlusPlus_ID = "CPlusPlus" ;
105- public static readonly GeneratorKind CPlusPlus = new ( CPlusPlus_ID , "CPlusPlus" , typeof ( CppGenerator ) , new [ ] { "cpp" } ) ;
112+ public static readonly GeneratorKind CPlusPlus = new ( CPlusPlus_ID , "CPlusPlus" , typeof ( CppGenerator ) , typeof ( CppTypePrinter ) , new [ ] { "cpp" } ) ;
106113
107114 public const string Emscripten_ID = "Emscripten" ;
108- public static readonly GeneratorKind Emscripten = new ( Emscripten_ID , "Emscripten" , typeof ( EmscriptenGenerator ) , new [ ] { "emscripten" } ) ;
115+ public static readonly GeneratorKind Emscripten = new ( Emscripten_ID , "Emscripten" , typeof ( EmscriptenGenerator ) , typeof ( EmscriptenTypePrinter ) , new [ ] { "emscripten" } ) ;
109116
110117 public const string ObjectiveC_ID = "ObjectiveC" ;
111- public static readonly GeneratorKind ObjectiveC = new ( ObjectiveC_ID , "ObjectiveC" , typeof ( NotImplementedGenerator ) ) ;
118+ public static readonly GeneratorKind ObjectiveC = new ( ObjectiveC_ID , "ObjectiveC" , typeof ( NotImplementedGenerator ) , typeof ( NotImplementedTypePrinter ) ) ;
112119
113120 public const string Java_ID = "Java" ;
114- public static readonly GeneratorKind Java = new ( Java_ID , "Java" , typeof ( NotImplementedGenerator ) ) ;
121+ public static readonly GeneratorKind Java = new ( Java_ID , "Java" , typeof ( NotImplementedGenerator ) , typeof ( NotImplementedTypePrinter ) ) ;
115122
116123 public const string Swift_ID = "Swift" ;
117- public static readonly GeneratorKind Swift = new ( Swift_ID , "Swift" , typeof ( NotImplementedGenerator ) ) ;
124+ public static readonly GeneratorKind Swift = new ( Swift_ID , "Swift" , typeof ( NotImplementedGenerator ) , typeof ( NotImplementedTypePrinter ) ) ;
118125
119126 public const string QuickJS_ID = "QuickJS" ;
120- public static readonly GeneratorKind QuickJS = new ( QuickJS_ID , "QuickJS" , typeof ( QuickJSGenerator ) , new [ ] { "qjs" } ) ;
127+ public static readonly GeneratorKind QuickJS = new ( QuickJS_ID , "QuickJS" , typeof ( QuickJSGenerator ) , typeof ( QuickJSTypePrinter ) , new [ ] { "qjs" } ) ;
121128
122129 public const string NAPI_ID = "NAPI" ;
123- public static readonly GeneratorKind NAPI = new ( NAPI_ID , "N-API" , typeof ( NAPIGenerator ) , new [ ] { "napi" } ) ;
130+ public static readonly GeneratorKind NAPI = new ( NAPI_ID , "N-API" , typeof ( NAPIGenerator ) , typeof ( NAPITypePrinter ) , new [ ] { "napi" } ) ;
124131
125132 public const string TypeScript_ID = "TypeScript" ;
126- public static readonly GeneratorKind TypeScript = new ( TypeScript_ID , "TypeScript" , typeof ( TSGenerator ) , new [ ] { "ts" , "typescript" } ) ;
133+ public static readonly GeneratorKind TypeScript = new ( TypeScript_ID , "TypeScript" , typeof ( TSGenerator ) , typeof ( TSTypePrinter ) , new [ ] { "ts" , "typescript" } ) ;
134+ }
135+
136+ public class NotImplementedTypePrinter : TypePrinter
137+ {
138+ public NotImplementedTypePrinter ( BindingContext context ) : base ( context )
139+ {
140+ }
127141 }
128142
129143 public class NotImplementedGenerator : Generator
@@ -142,10 +156,5 @@ public override bool SetupPasses()
142156 {
143157 throw new NotImplementedException ( ) ;
144158 }
145-
146- protected override string TypePrinterDelegate ( CppSharp . AST . Type type )
147- {
148- throw new NotImplementedException ( ) ;
149- }
150159 }
151160}
0 commit comments