diff --git a/src/CLI/CLI.cs b/src/CLI/CLI.cs index a589bbf49..6a31df01c 100644 --- a/src/CLI/CLI.cs +++ b/src/CLI/CLI.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using CppSharp.Generators; +using CppSharp.Passes; using Mono.Options; namespace CppSharp @@ -34,6 +35,7 @@ static bool ParseCommandLineArgs(string[] args, List errorMessages, ref optionSet.Add("p=|platform=", "the {PLATFORM} that the generated code will target: 'win', 'osx' or 'linux' or 'emscripten'", p => { GetDestinationPlatform(p, errorMessages); }); optionSet.Add("a=|arch=", "the {ARCHITECTURE} that the generated code will target: 'x86' or 'x64' or 'wasm32' or 'wasm64'", a => { GetDestinationArchitecture(a, errorMessages); }); optionSet.Add("prefix=", "sets a string prefix to the names of generated files", a => { options.Prefix = a; }); + optionSet.Add("property=", "the property detection mode to use: 'all', 'none' or 'keywords' or 'heuristics'", p => { GetPropertyMode(p, errorMessages); }); optionSet.Add("exceptions", "enables support for C++ exceptions in the parser", v => { options.EnableExceptions = true; }); optionSet.Add("rtti", "enables support for C++ RTTI in the parser", v => { options.EnableRTTI = true; }); @@ -269,6 +271,27 @@ public static void GetDestinationArchitecture(string architecture, List Defaulting to {options.Architecture}"); } + static void GetPropertyMode(string mode, List errorMessages) + { + switch (mode.ToLower()) + { + case "all": + options.PropertyMode = PropertyDetectionMode.All; + return; + case "none": + options.PropertyMode = PropertyDetectionMode.None; + return; + case "dictionary": + options.PropertyMode = PropertyDetectionMode.Dictionary; + return; + case "keywords": + options.PropertyMode = PropertyDetectionMode.Keywords; + return; + } + + errorMessages.Add($"Unknown property detection mode: {mode}. Defaulting to {options.PropertyMode}"); + } + static void PrintErrorMessages(List errorMessages) { foreach (string m in errorMessages) diff --git a/src/CLI/Generator.cs b/src/CLI/Generator.cs index 4da7c5380..ab90cf9b6 100644 --- a/src/CLI/Generator.cs +++ b/src/CLI/Generator.cs @@ -129,6 +129,7 @@ public void Setup(Driver driver) var driverOptions = driver.Options; driverOptions.GeneratorKind = options.Kind; + driverOptions.PropertyDetectionMode = options.PropertyMode; var module = driverOptions.AddModule(options.OutputFileName); if (!string.IsNullOrEmpty(options.InputLibraryName)) diff --git a/src/CLI/Options.cs b/src/CLI/Options.cs index 00dfd700d..239093879 100644 --- a/src/CLI/Options.cs +++ b/src/CLI/Options.cs @@ -44,7 +44,7 @@ class Options public GeneratorKind Kind { get; set; } = GeneratorKind.CSharp; - public PropertyDetectionMode PropertyMode = PropertyDetectionMode.Keywords; + public PropertyDetectionMode PropertyMode { get; set; } = PropertyDetectionMode.Keywords; public bool CheckSymbols { get; set; }