Browse Source

Bunch of fixes to the newline handling in the C# generator.

pull/1/head
triton 12 years ago
parent
commit
de800edda9
  1. 19
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

19
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -143,8 +143,9 @@ namespace Cxxi.Generators.CSharp
if (@enum.Ignore || @enum.IsIncomplete) if (@enum.Ignore || @enum.IsIncomplete)
continue; continue;
NewLineIfNeeded();
GenerateEnum(@enum); GenerateEnum(@enum);
NewLine(); NeedNewLine();
} }
// Generate all the typedef declarations for the module. // Generate all the typedef declarations for the module.
@ -152,10 +153,12 @@ namespace Cxxi.Generators.CSharp
{ {
if (typedef.Ignore) continue; if (typedef.Ignore) continue;
NewLineIfNeeded();
if (!GenerateTypedef(typedef)) if (!GenerateTypedef(typedef))
continue; continue;
NewLineIfNeeded(); NeedNewLine();
} }
// Generate all the struct/class declarations for the module. // Generate all the struct/class declarations for the module.
@ -164,12 +167,14 @@ namespace Cxxi.Generators.CSharp
if (@class.Ignore || @class.IsIncomplete) if (@class.Ignore || @class.IsIncomplete)
continue; continue;
NewLineIfNeeded();
GenerateClass(@class); GenerateClass(@class);
NewLine(); NeedNewLine();
} }
if (@namespace.HasFunctions) if (@namespace.HasFunctions)
{ {
NewLineIfNeeded();
WriteLine("public partial class {0}{1}", SafeIdentifier(Options.LibraryName), WriteLine("public partial class {0}{1}", SafeIdentifier(Options.LibraryName),
TranslationUnit.FileNameWithoutExtension); TranslationUnit.FileNameWithoutExtension);
WriteStartBraceIndent(); WriteStartBraceIndent();
@ -247,8 +252,9 @@ namespace Cxxi.Generators.CSharp
if (ShouldGenerateClassNativeField(@class)) if (ShouldGenerateClassNativeField(@class))
{ {
NewLineIfNeeded();
WriteLine("public System.IntPtr Instance { get; protected set; }"); WriteLine("public System.IntPtr Instance { get; protected set; }");
NewLine(); NeedNewLine();
} }
GenerateClassConstructors(@class); GenerateClassConstructors(@class);
@ -322,6 +328,7 @@ namespace Cxxi.Generators.CSharp
} }
WriteCloseBraceIndent(); WriteCloseBraceIndent();
NeedNewLine();
typePrinter.PopContext(); typePrinter.PopContext();
} }
@ -617,8 +624,6 @@ namespace Cxxi.Generators.CSharp
public void GenerateClassMethods(Class @class) public void GenerateClassMethods(Class @class)
{ {
NewLineIfNeeded();
var staticMethods = new List<Method>(); var staticMethods = new List<Method>();
foreach (var method in @class.Methods) foreach (var method in @class.Methods)
{ {
@ -639,8 +644,6 @@ namespace Cxxi.Generators.CSharp
NeedNewLine(); NeedNewLine();
} }
ResetNewLine();
foreach (var method in staticMethods) foreach (var method in staticMethods)
{ {
NewLineIfNeeded(); NewLineIfNeeded();

Loading…
Cancel
Save