Permalink
Browse files

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

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information...
ddobrev committed Aug 20, 2017
1 parent 2748128 commit 20fcb1943631d865b467c13be1a11da1cdc19915
Showing with 11 additions and 4 deletions.
  1. +6 −4 src/Generator/Generator.cs
  2. +5 −0 src/Generator/Options.cs
@@ -39,7 +39,7 @@ public struct GeneratorOutput
/// </summary>
public abstract class Generator : IDisposable
{
public BindingContext Context { get; private set; }
public BindingContext Context { get; }
protected Generator(BindingContext context)
{
@@ -74,7 +74,8 @@ public virtual List<GeneratorOutput> Generate()
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 @@ private void GenerateSingleTemplate(ICollection<GeneratorOutput> outputs)
{
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 @@ private void GenerateSingleTemplate(ICollection<GeneratorOutput> outputs)
}
/// <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);
@@ -144,6 +144,11 @@ public Module AddModule(string libraryName)
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>

0 comments on commit 20fcb19

Please sign in to comment.