Browse Source

Add new property modes to the CLI driver.

pull/1714/head
Joao Matos 2 years ago
parent
commit
63ca51ae9a
  1. 23
      src/CLI/CLI.cs
  2. 1
      src/CLI/Generator.cs
  3. 2
      src/CLI/Options.cs

23
src/CLI/CLI.cs

@ -3,6 +3,7 @@ using System.Collections.Generic; @@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using CppSharp.Generators;
using CppSharp.Passes;
using Mono.Options;
namespace CppSharp
@ -34,6 +35,7 @@ namespace CppSharp @@ -34,6 +35,7 @@ namespace CppSharp
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 @@ namespace CppSharp @@ -269,6 +271,27 @@ namespace CppSharp
Defaulting to {options.Architecture}");
}
static void GetPropertyMode(string mode, List<string> 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<string> errorMessages)
{
foreach (string m in errorMessages)

1
src/CLI/Generator.cs

@ -129,6 +129,7 @@ namespace CppSharp @@ -129,6 +129,7 @@ namespace CppSharp
var driverOptions = driver.Options;
driverOptions.GeneratorKind = options.Kind;
driverOptions.PropertyDetectionMode = options.PropertyMode;
var module = driverOptions.AddModule(options.OutputFileName);
if (!string.IsNullOrEmpty(options.InputLibraryName))

2
src/CLI/Options.cs

@ -44,7 +44,7 @@ namespace CppSharp @@ -44,7 +44,7 @@ namespace CppSharp
public GeneratorKind Kind { get; set; } = GeneratorKind.CSharp;
public PropertyDetectionMode PropertyMode = PropertyDetectionMode.Keywords;
public PropertyDetectionMode PropertyMode { get; set; } = PropertyDetectionMode.Keywords;
public bool CheckSymbols { get; set; }

Loading…
Cancel
Save