Skip to content

Commit 63ca51a

Browse files
committed
Add new property modes to the CLI driver.
1 parent b04bf1d commit 63ca51a

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Diff for: src/CLI/CLI.cs

+23
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using CppSharp.Generators;
6+
using CppSharp.Passes;
67
using Mono.Options;
78

89
namespace CppSharp
@@ -34,6 +35,7 @@ static bool ParseCommandLineArgs(string[] args, List<string> errorMessages, ref
3435
optionSet.Add("p=|platform=", "the {PLATFORM} that the generated code will target: 'win', 'osx' or 'linux' or 'emscripten'", p => { GetDestinationPlatform(p, errorMessages); });
3536
optionSet.Add("a=|arch=", "the {ARCHITECTURE} that the generated code will target: 'x86' or 'x64' or 'wasm32' or 'wasm64'", a => { GetDestinationArchitecture(a, errorMessages); });
3637
optionSet.Add("prefix=", "sets a string prefix to the names of generated files", a => { options.Prefix = a; });
38+
optionSet.Add("property=", "the property detection mode to use: 'all', 'none' or 'keywords' or 'heuristics'", p => { GetPropertyMode(p, errorMessages); });
3739

3840
optionSet.Add("exceptions", "enables support for C++ exceptions in the parser", v => { options.EnableExceptions = true; });
3941
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<string>
269271
Defaulting to {options.Architecture}");
270272
}
271273

274+
static void GetPropertyMode(string mode, List<string> errorMessages)
275+
{
276+
switch (mode.ToLower())
277+
{
278+
case "all":
279+
options.PropertyMode = PropertyDetectionMode.All;
280+
return;
281+
case "none":
282+
options.PropertyMode = PropertyDetectionMode.None;
283+
return;
284+
case "dictionary":
285+
options.PropertyMode = PropertyDetectionMode.Dictionary;
286+
return;
287+
case "keywords":
288+
options.PropertyMode = PropertyDetectionMode.Keywords;
289+
return;
290+
}
291+
292+
errorMessages.Add($"Unknown property detection mode: {mode}. Defaulting to {options.PropertyMode}");
293+
}
294+
272295
static void PrintErrorMessages(List<string> errorMessages)
273296
{
274297
foreach (string m in errorMessages)

Diff for: src/CLI/Generator.cs

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public void Setup(Driver driver)
129129

130130
var driverOptions = driver.Options;
131131
driverOptions.GeneratorKind = options.Kind;
132+
driverOptions.PropertyDetectionMode = options.PropertyMode;
132133
var module = driverOptions.AddModule(options.OutputFileName);
133134

134135
if (!string.IsNullOrEmpty(options.InputLibraryName))

Diff for: src/CLI/Options.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Options
4444

4545
public GeneratorKind Kind { get; set; } = GeneratorKind.CSharp;
4646

47-
public PropertyDetectionMode PropertyMode = PropertyDetectionMode.Keywords;
47+
public PropertyDetectionMode PropertyMode { get; set; } = PropertyDetectionMode.Keywords;
4848

4949
public bool CheckSymbols { get; set; }
5050

0 commit comments

Comments
 (0)