@@ -13,30 +13,13 @@ namespace CppSharp
1313{
1414 class Generator : ILibrary
1515 {
16- private Options options = null ;
16+ private readonly Options options ;
1717 private string triple = "" ;
1818 private CppAbi abi = CppAbi . Microsoft ;
1919
2020 public Generator ( Options options )
2121 {
22- if ( options == null )
23- throw new ArgumentNullException ( nameof ( options ) ) ;
24-
25- this . options = options ;
26- }
27-
28- static TargetPlatform GetCurrentPlatform ( )
29- {
30- if ( Platform . IsWindows )
31- return TargetPlatform . Windows ;
32-
33- if ( Platform . IsMacOS )
34- return TargetPlatform . MacOS ;
35-
36- if ( Platform . IsLinux )
37- return TargetPlatform . Linux ;
38-
39- throw new System . NotImplementedException ( "Unknown host platform" ) ;
22+ this . options = options ?? throw new ArgumentNullException ( nameof ( options ) ) ;
4023 }
4124
4225 void SetupTargetTriple ( )
@@ -78,8 +61,7 @@ public bool ValidateOptions(List<string> messages)
7861 return false ;
7962 }
8063
81- if ( ! options . Platform . HasValue )
82- options . Platform = GetCurrentPlatform ( ) ;
64+ options . Platform ??= Platform . Host ;
8365
8466 if ( string . IsNullOrEmpty ( options . OutputDir ) )
8567 {
@@ -189,7 +171,7 @@ public void Postprocess(Driver driver, ASTContext ctx)
189171
190172 public void Run ( )
191173 {
192- StringBuilder messageBuilder = new StringBuilder ( ) ;
174+ var messageBuilder = new StringBuilder ( ) ;
193175 messageBuilder . Append ( $ "Generating { GetGeneratorKindName ( options . Kind ) } ") ;
194176 messageBuilder . Append ( $ " bindings for { GetPlatformName ( options . Platform ) } { options . Architecture } ") ;
195177
0 commit comments