Browse Source

Changed the code generation to write to a stream in preparation for Roslyn.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
roslyn
Dimitar Dobrev 10 years ago
parent
commit
8ea2ab2fc8
  1. 3
      src/Generator/Driver.cs
  2. 5
      src/Generator/Generators/Template.cs

3
src/Generator/Driver.cs

@ -343,7 +343,8 @@ namespace CppSharp @@ -343,7 +343,8 @@ namespace CppSharp
Diagnostics.Message("Generated '{0}'", fileRelativePath);
var file = Path.Combine(outputPath, fileRelativePath);
File.WriteAllText(file, template.Generate());
using (var streamWriter = new StreamWriter(file))
template.Generate(streamWriter);
Options.CodeFiles.Add(file);
}
}

5
src/Generator/Generators/Template.cs

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using CppSharp.AST;
@ -265,9 +266,9 @@ namespace CppSharp.Generators @@ -265,9 +266,9 @@ namespace CppSharp.Generators
public abstract void Process();
public string Generate()
public virtual void Generate(TextWriter textWriter)
{
return RootBlock.Generate(Options);
textWriter.Write(RootBlock.Generate(Options));
}
#region Block helpers

Loading…
Cancel
Save