using System; using System.Collections.Generic; using System.IO; using System.Text; using CppSharp.AST; using CppSharp.Generators; using CppSharp.Parser; using CppAbi = CppSharp.Parser.AST.CppAbi; namespace CppSharp { public class DriverOptions : ParserOptions { public static bool IsUnixPlatform { get { var platform = Environment.OSVersion.Platform; return platform == PlatformID.Unix || platform == PlatformID.MacOSX; } } public DriverOptions() { Abi = IsUnixPlatform ? CppAbi.Itanium : CppAbi.Microsoft; MicrosoftMode = !IsUnixPlatform; OutputDir = Directory.GetCurrentDirectory(); Modules = new List(); GeneratorKind = GeneratorKind.CSharp; GenerateLibraryNamespace = true; GeneratePartialClasses = true; GenerateClassMarshals = false; OutputInteropIncludes = true; MaxIndent = 80; CommentPrefix = "///"; Encoding = Encoding.ASCII; StripLibPrefix = true; ExplicitlyPatchedVirtualFunctions = new List(); } // General options public bool Quiet; public bool ShowHelpText; public bool OutputDebug; /// /// Set to true to simulate generating without actually writing /// any output to disk. This can be useful to activate while /// debugging the parser generator so generator bugs do not get /// in the way while iterating. /// public bool DryRun; public List Modules { get; private set; } public Module MainModule { get { if (Modules.Count == 0) Modules.Add(new Module()); return Modules[0]; } } // Parser options public List Headers { get { return MainModule.Headers; } } public bool IgnoreParseWarnings; public bool IgnoreParseErrors; public bool IsItaniumLikeAbi { get { return Abi != CppAbi.Microsoft; } } public bool IsMicrosoftAbi { get { return Abi == CppAbi.Microsoft; } } // Library options public List Libraries { get { return MainModule.Libraries; } } public bool CheckSymbols; public string SharedLibraryName { get { return MainModule.SharedLibraryName; } set { MainModule.SharedLibraryName = value; } } // Generator options public GeneratorKind GeneratorKind; public string OutputNamespace { get { return MainModule.OutputNamespace; } set { MainModule.OutputNamespace = value; } } public string OutputDir; public string LibraryName { get { return MainModule.LibraryName; } set { MainModule.LibraryName = value; } } public bool OutputInteropIncludes; public bool GenerateLibraryNamespace; public bool GenerateFunctionTemplates; public bool GeneratePartialClasses; public bool GenerateInterfacesForMultipleInheritance; public bool GenerateInternalImports; public bool GenerateClassMarshals; public bool GenerateInlines; public bool UseHeaderDirectories; /// /// If set to true the generator will use GetterSetterToPropertyPass to /// convert matching getter/setter pairs to properties. /// public bool GenerateProperties; /// /// If set to true the generator will use GetterSetterToPropertyAdvancedPass to /// convert matching getter/setter pairs to properties. This pass has slightly /// different semantics from GetterSetterToPropertyPass, it will more agressively /// try to match for matching properties. /// public bool GeneratePropertiesAdvanced; /// /// If set to true the generator will use ConstructorToConversionOperatorPass to /// create implicit and explicit conversion operators out of single argument /// constructors. /// public bool GenerateConversionOperators; /// /// If set to true the CLI generator will use ObjectOverridesPass to create /// Equals, GetHashCode and (if the insertion operator << is overloaded) ToString /// methods. /// public bool GenerateObjectOverrides; //List of include directories that are used but not generated public List NoGenIncludeDirs; /// /// Whether the generated C# code should be automatically compiled. /// public bool CompileCode; /// /// Enable this option to enable generation of finalizers. /// Works in both CLI and C# backends. /// public bool GenerateFinalizers; public string IncludePrefix; public bool WriteOnlyWhenChanged; public Func GenerateName; public int MaxIndent; public string CommentPrefix; public Encoding Encoding { get; set; } public string InlinesLibraryName { get { return MainModule.InlinesLibraryName; } set { MainModule.InlinesLibraryName = value; } } public string TemplatesLibraryName { get { return MainModule.TemplatesLibraryName; } set { MainModule.TemplatesLibraryName = value; } } public bool IsCSharpGenerator { get { return GeneratorKind == GeneratorKind.CSharp; } } public bool IsCLIGenerator { get { return GeneratorKind == GeneratorKind.CLI; } } public readonly List DependentNameSpaces = new List(); public bool MarshalCharAsManagedChar { get; set; } /// /// Generates a single C# file. /// public bool GenerateSingleCSharpFile { get; set; } /// /// Generates default values of arguments in the C# code. /// public bool GenerateDefaultValuesForArguments { get; set; } public bool StripLibPrefix { get; set; } /// /// C# end only: force patching of the virtual entries of the functions in this list. /// public List ExplicitlyPatchedVirtualFunctions { get; private set; } } public class InvalidOptionException : Exception { public InvalidOptionException(string message) : base(message) { } } }