Browse Source

Added proper support for namespaces in the C# backend.

pull/1/head
triton 12 years ago
parent
commit
82db3c29c0
  1. 18
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

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

@ -75,9 +75,14 @@ namespace Cxxi.Generators.CSharp
} }
public void GenerateDeclarations() public void GenerateDeclarations()
{
GenerateNamespace(TranslationUnit);
}
private void GenerateNamespace(Namespace @namespace)
{ {
// Generate all the enum declarations for the module. // Generate all the enum declarations for the module.
foreach (var @enum in TranslationUnit.Enums) foreach (var @enum in @namespace.Enums)
{ {
if (@enum.Ignore || @enum.IsIncomplete) if (@enum.Ignore || @enum.IsIncomplete)
continue; continue;
@ -87,7 +92,7 @@ namespace Cxxi.Generators.CSharp
} }
// Generate all the typedef declarations for the module. // Generate all the typedef declarations for the module.
foreach (var typedef in TranslationUnit.Typedefs) foreach (var typedef in @namespace.Typedefs)
{ {
if (typedef.Ignore) continue; if (typedef.Ignore) continue;
@ -98,7 +103,7 @@ namespace Cxxi.Generators.CSharp
} }
// Generate all the struct/class declarations for the module. // Generate all the struct/class declarations for the module.
foreach (var @class in TranslationUnit.Classes) foreach (var @class in @namespace.Classes)
{ {
if (@class.Ignore) continue; if (@class.Ignore) continue;
@ -106,17 +111,20 @@ namespace Cxxi.Generators.CSharp
NewLine(); NewLine();
} }
if (TranslationUnit.HasFunctions) if (@namespace.HasFunctions)
{ {
WriteLine("public partial class " + SafeIdentifier(Options.LibraryName)); WriteLine("public partial class " + SafeIdentifier(Options.LibraryName));
WriteStartBraceIndent(); WriteStartBraceIndent();
// Generate all the function declarations for the module. // Generate all the function declarations for the module.
foreach (var function in TranslationUnit.Functions) foreach (var function in @namespace.Functions)
GenerateFunction(function); GenerateFunction(function);
WriteCloseBraceIndent(); WriteCloseBraceIndent();
} }
foreach(var childNamespace in @namespace.Namespaces)
GenerateNamespace(childNamespace);
} }
public void GenerateDeclarationCommon(Declaration T) public void GenerateDeclarationCommon(Declaration T)

Loading…
Cancel
Save