From de800edda998e486b4bf3607322852a1ce27c239 Mon Sep 17 00:00:00 2001 From: triton Date: Mon, 6 May 2013 02:37:41 +0100 Subject: [PATCH] Bunch of fixes to the newline handling in the C# generator. --- .../Generators/CSharp/CSharpTextTemplate.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 013bed6e..3130fadb 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -143,8 +143,9 @@ namespace Cxxi.Generators.CSharp if (@enum.Ignore || @enum.IsIncomplete) continue; + NewLineIfNeeded(); GenerateEnum(@enum); - NewLine(); + NeedNewLine(); } // Generate all the typedef declarations for the module. @@ -152,10 +153,12 @@ namespace Cxxi.Generators.CSharp { if (typedef.Ignore) continue; + NewLineIfNeeded(); + if (!GenerateTypedef(typedef)) continue; - NewLineIfNeeded(); + NeedNewLine(); } // Generate all the struct/class declarations for the module. @@ -164,12 +167,14 @@ namespace Cxxi.Generators.CSharp if (@class.Ignore || @class.IsIncomplete) continue; + NewLineIfNeeded(); GenerateClass(@class); - NewLine(); + NeedNewLine(); } if (@namespace.HasFunctions) { + NewLineIfNeeded(); WriteLine("public partial class {0}{1}", SafeIdentifier(Options.LibraryName), TranslationUnit.FileNameWithoutExtension); WriteStartBraceIndent(); @@ -247,8 +252,9 @@ namespace Cxxi.Generators.CSharp if (ShouldGenerateClassNativeField(@class)) { + NewLineIfNeeded(); WriteLine("public System.IntPtr Instance { get; protected set; }"); - NewLine(); + NeedNewLine(); } GenerateClassConstructors(@class); @@ -322,6 +328,7 @@ namespace Cxxi.Generators.CSharp } WriteCloseBraceIndent(); + NeedNewLine(); typePrinter.PopContext(); } @@ -617,8 +624,6 @@ namespace Cxxi.Generators.CSharp public void GenerateClassMethods(Class @class) { - NewLineIfNeeded(); - var staticMethods = new List(); foreach (var method in @class.Methods) { @@ -639,8 +644,6 @@ namespace Cxxi.Generators.CSharp NeedNewLine(); } - ResetNewLine(); - foreach (var method in staticMethods) { NewLineIfNeeded();