From c5e9008b477264d15b688e2384e6be9c9530ecdf Mon Sep 17 00:00:00 2001 From: triton Date: Sun, 13 Oct 2013 21:32:01 +0100 Subject: [PATCH] Extracted the Options class to its own file. --- src/Generator/Driver.cs | 122 ------------------------------------ src/Generator/Options.cs | 132 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 122 deletions(-) create mode 100644 src/Generator/Options.cs diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs index 7fa742a8..834ec0f7 100644 --- a/src/Generator/Driver.cs +++ b/src/Generator/Driver.cs @@ -209,128 +209,6 @@ namespace CppSharp } } - public class DriverOptions - { - public DriverOptions() - { - Defines = new List(); - IncludeDirs = new List(); - SystemIncludeDirs = new List(); - Headers = new List(); - - OutputDir = Directory.GetCurrentDirectory(); - - var platform = Environment.OSVersion.Platform; - var isUnix = platform == PlatformID.Unix || platform == PlatformID.MacOSX; - MicrosoftMode = !isUnix; - Abi = isUnix ? CppAbi.Itanium : CppAbi.Microsoft; - - LibraryDirs = new List(); - Libraries = new List(); - CheckSymbols = true; - - GeneratorKind = LanguageGeneratorKind.CSharp; - GenerateLibraryNamespace = true; - GeneratePartialClasses = true; - OutputInteropIncludes = true; - MaxIndent = 80; - CommentPrefix = "///"; - - Encoding = Encoding.ASCII; - } - - // General options - public bool Verbose; - public bool Quiet; - public bool ShowHelpText; - public bool OutputDebug; - - // Parser options - public List Defines; - public List IncludeDirs; - public List SystemIncludeDirs; - public List Headers; - public bool NoStandardIncludes; - public bool NoBuiltinIncludes; - public bool MicrosoftMode; - public string TargetTriple; - public int ToolsetToUse; - public bool IgnoreParseWarnings; - public bool IgnoreParseErrors; - public CppAbi Abi; - public bool IsItaniumAbi { get { return Abi == CppAbi.Itanium; } } - public bool IsMicrosoftAbi { get { return Abi == CppAbi.Microsoft; } } - - // Library options - public List LibraryDirs; - public List Libraries; - public bool CheckSymbols; - - private string sharedLibraryName; - public string SharedLibraryName - { - get - { - if (string.IsNullOrEmpty(sharedLibraryName)) - return LibraryName; - return sharedLibraryName; - } - set { sharedLibraryName = value; } - } - - // Generator options - public LanguageGeneratorKind GeneratorKind; - public string OutputNamespace; - public string OutputDir; - public string LibraryName; - public bool OutputInteropIncludes; - public bool GenerateLibraryNamespace; - public bool GenerateFunctionTemplates; - public bool GeneratePartialClasses; - public bool GenerateVirtualTables; - public bool GenerateAbstractImpls; - public bool GenerateInterfacesForMultipleInheritance; - public bool GenerateProperties; - public bool GenerateInternalImports; - public string IncludePrefix; - public bool WriteOnlyWhenChanged; - public Func GenerateName; - public int MaxIndent; - public string CommentPrefix; - - public Encoding Encoding { get; set; } - - private string inlinesLibraryName; - public string InlinesLibraryName - { - get - { - if (string.IsNullOrEmpty(inlinesLibraryName)) - { - return string.Format("{0}-inlines", OutputNamespace); - } - return inlinesLibraryName; - } - set { inlinesLibraryName = value; } - } - - public bool IsCSharpGenerator - { - get { return GeneratorKind == LanguageGeneratorKind.CSharp; } - } - - public bool IsCLIGenerator - { - get { return GeneratorKind == LanguageGeneratorKind.CLI; } - } - - public bool Is32Bit { get { return true; } } - } - - public class InvalidOptionException : Exception - { - } - public static class ConsoleDriver { public static void Run(ILibrary library) diff --git a/src/Generator/Options.cs b/src/Generator/Options.cs new file mode 100644 index 00000000..61365343 --- /dev/null +++ b/src/Generator/Options.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using CppSharp.AST; +using CppSharp.Generators; + +namespace CppSharp +{ + public class DriverOptions + { + public DriverOptions() + { + Defines = new List(); + IncludeDirs = new List(); + SystemIncludeDirs = new List(); + Headers = new List(); + + var platform = Environment.OSVersion.Platform; + var isUnix = platform == PlatformID.Unix || platform == PlatformID.MacOSX; + + Parser = new ParserOptions + { + Abi = isUnix ? CppAbi.Itanium : CppAbi.Microsoft, + MicrosoftMode = !isUnix + }; + + OutputDir = Directory.GetCurrentDirectory(); + + LibraryDirs = new List(); + Libraries = new List(); + CheckSymbols = true; + + GeneratorKind = GeneratorKind.CSharp; + GenerateLibraryNamespace = true; + GeneratePartialClasses = true; + OutputInteropIncludes = true; + MaxIndent = 80; + CommentPrefix = "///"; + + Encoding = Encoding.ASCII; + } + + // General options + public bool Verbose; + public bool Quiet; + public bool ShowHelpText; + public bool OutputDebug; + + // Parser options + public List Defines; + public List IncludeDirs; + public List SystemIncludeDirs; + public List Headers; + + public ParserOptions Parser; + public bool IgnoreParseWarnings; + public bool IgnoreParseErrors; + + public bool IsItaniumAbi { get { return Parser.Abi == CppAbi.Itanium; } } + public bool IsMicrosoftAbi { get { return Parser.Abi == CppAbi.Microsoft; } } + + // Library options + public List LibraryDirs; + public List Libraries; + public bool CheckSymbols; + + private string sharedLibraryName; + public string SharedLibraryName + { + get + { + if (string.IsNullOrEmpty(sharedLibraryName)) + return LibraryName; + return sharedLibraryName; + } + set { sharedLibraryName = value; } + } + + // Generator options + public GeneratorKind GeneratorKind; + public string OutputNamespace; + public string OutputDir; + public string LibraryName; + public bool OutputInteropIncludes; + public bool GenerateLibraryNamespace; + public bool GenerateFunctionTemplates; + public bool GeneratePartialClasses; + public bool GenerateVirtualTables; + public bool GenerateAbstractImpls; + public bool GenerateInterfacesForMultipleInheritance; + public bool GenerateProperties; + public bool GenerateInternalImports; + public string IncludePrefix; + public bool WriteOnlyWhenChanged; + public Func GenerateName; + public int MaxIndent; + public string CommentPrefix; + + public Encoding Encoding { get; set; } + + private string inlinesLibraryName; + public string InlinesLibraryName + { + get + { + if (string.IsNullOrEmpty(inlinesLibraryName)) + { + return string.Format("{0}-inlines", OutputNamespace); + } + return inlinesLibraryName; + } + set { inlinesLibraryName = value; } + } + + public bool IsCSharpGenerator + { + get { return GeneratorKind == GeneratorKind.CSharp; } + } + + public bool IsCLIGenerator + { + get { return GeneratorKind == GeneratorKind.CLI; } + } + + public bool Is32Bit { get { return true; } } + } + + public class InvalidOptionException : Exception + { + } +}