From 82db3c29c0f9c80f46a400a5fe40b9664cb8aac4 Mon Sep 17 00:00:00 2001 From: triton Date: Fri, 15 Mar 2013 14:13:52 +0000 Subject: [PATCH] Added proper support for namespaces in the C# backend. --- .../Generators/CSharp/CSharpTextTemplate.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index cead6345..67767ed1 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -75,9 +75,14 @@ namespace Cxxi.Generators.CSharp } public void GenerateDeclarations() + { + GenerateNamespace(TranslationUnit); + } + + private void GenerateNamespace(Namespace @namespace) { // 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) continue; @@ -87,7 +92,7 @@ namespace Cxxi.Generators.CSharp } // Generate all the typedef declarations for the module. - foreach (var typedef in TranslationUnit.Typedefs) + foreach (var typedef in @namespace.Typedefs) { if (typedef.Ignore) continue; @@ -98,7 +103,7 @@ namespace Cxxi.Generators.CSharp } // 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; @@ -106,17 +111,20 @@ namespace Cxxi.Generators.CSharp NewLine(); } - if (TranslationUnit.HasFunctions) + if (@namespace.HasFunctions) { WriteLine("public partial class " + SafeIdentifier(Options.LibraryName)); WriteStartBraceIndent(); // Generate all the function declarations for the module. - foreach (var function in TranslationUnit.Functions) + foreach (var function in @namespace.Functions) GenerateFunction(function); WriteCloseBraceIndent(); } + + foreach(var childNamespace in @namespace.Namespaces) + GenerateNamespace(childNamespace); } public void GenerateDeclarationCommon(Declaration T)