Browse Source

Restored the option for generating one C# file per unit.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/914/head
Dimitar Dobrev 8 years ago
parent
commit
20fcb19436
  1. 10
      src/Generator/Generator.cs
  2. 5
      src/Generator/Options.cs

10
src/Generator/Generator.cs

@ -39,7 +39,7 @@ namespace CppSharp.Generators @@ -39,7 +39,7 @@ namespace CppSharp.Generators
/// </summary>
public abstract class Generator : IDisposable
{
public BindingContext Context { get; private set; }
public BindingContext Context { get; }
protected Generator(BindingContext context)
{
@ -74,7 +74,8 @@ namespace CppSharp.Generators @@ -74,7 +74,8 @@ namespace CppSharp.Generators
var units = Context.ASTContext.TranslationUnits.GetGenerated().ToList();
if (Context.Options.IsCSharpGenerator)
if (Context.Options.IsCSharpGenerator &&
Context.Options.GenerateSingleCSharpFile)
GenerateSingleTemplate(outputs);
else
GenerateTemplates(outputs, units.Where(u => !u.IsSystemHeader));
@ -115,7 +116,7 @@ namespace CppSharp.Generators @@ -115,7 +116,7 @@ namespace CppSharp.Generators
{
TranslationUnit = new TranslationUnit
{
FilePath = string.Format("{0}.cs", module.LibraryName),
FilePath = $"{module.LibraryName}.cs",
Module = module
},
Outputs = Generate(module.Units.GetGenerated())
@ -128,8 +129,9 @@ namespace CppSharp.Generators @@ -128,8 +129,9 @@ namespace CppSharp.Generators
}
/// <summary>
/// Generates the outputs for a given translation unit.
/// Generates the outputs for the given translation units.
/// </summary>
/// <param name="units">The units to generate outputs for.</param>
public abstract List<CodeGenerator> Generate(IEnumerable<TranslationUnit> units);
protected abstract string TypePrinterDelegate(CppSharp.AST.Type type);

5
src/Generator/Options.cs

@ -144,6 +144,11 @@ namespace CppSharp @@ -144,6 +144,11 @@ namespace CppSharp
public readonly List<string> DependentNameSpaces = new List<string>();
public bool MarshalCharAsManagedChar { get; set; }
/// <summary>
/// Generates a single C# file.
/// </summary>
public bool GenerateSingleCSharpFile { get; set; } = true;
/// <summary>
/// Generates default values of arguments in the C# code.
/// </summary>

Loading…
Cancel
Save