Browse Source

Added better support for namespaces in the C# generator.

pull/1/head
triton 12 years ago
parent
commit
689fd2332f
  1. 11
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

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

@ -85,6 +85,14 @@ namespace Cxxi.Generators.CSharp
private void GenerateNamespace(Namespace @namespace) private void GenerateNamespace(Namespace @namespace)
{ {
bool isGlobalNamespace = @namespace is TranslationUnit;
if (!isGlobalNamespace)
{
WriteLine("namespace {0}", @namespace.Name);
WriteStartBraceIndent();
}
// Generate all the enum declarations for the module. // Generate all the enum declarations for the module.
foreach (var @enum in @namespace.Enums) foreach (var @enum in @namespace.Enums)
{ {
@ -129,6 +137,9 @@ namespace Cxxi.Generators.CSharp
foreach(var childNamespace in @namespace.Namespaces) foreach(var childNamespace in @namespace.Namespaces)
GenerateNamespace(childNamespace); GenerateNamespace(childNamespace);
if (!isGlobalNamespace)
WriteCloseBraceIndent();
} }
public void GenerateDeclarationCommon(Declaration T) public void GenerateDeclarationCommon(Declaration T)

Loading…
Cancel
Save