Browse Source

Fixed the option for output name-spaces to allow eliminating them.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/661/head
Dimitar Dobrev 9 years ago
parent
commit
9b51e30643
  1. 2
      src/CppParser/Bindings/ParserGen.cs
  2. 1
      src/Generator.Tests/GeneratorTest.cs
  3. 2
      src/Generator/Driver.cs
  4. 2
      src/Generator/Generator.cs
  5. 3
      src/Generator/Generators/CLI/CLIHeadersTemplate.cs
  6. 2
      src/Generator/Generators/CLI/CLIMarshal.cs
  7. 2
      src/Generator/Generators/CLI/CLITextTemplate.cs
  8. 2
      src/Generator/Generators/CLI/CLITypePrinter.cs
  9. 4
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  10. 2
      src/Generator/Options.cs

2
src/CppParser/Bindings/ParserGen.cs

@ -83,7 +83,7 @@ namespace CppSharp @@ -83,7 +83,7 @@ namespace CppSharp
if (Kind == GeneratorKind.CSharp)
options.OutputDir = Path.Combine(options.OutputDir, options.TargetTriple + extraTriple);
options.GenerateLibraryNamespace = false;
options.OutputNamespace = string.Empty;
options.CheckSymbols = false;
}

1
src/Generator.Tests/GeneratorTest.cs

@ -29,7 +29,6 @@ namespace CppSharp.Utils @@ -29,7 +29,6 @@ namespace CppSharp.Utils
options.GeneratorKind = kind;
options.OutputDir = Path.Combine(GetOutputDirectory(), "gen", name);
options.SharedLibraryName = name + ".Native";
options.GenerateLibraryNamespace = true;
options.Quiet = true;
options.IgnoreParseWarnings = true;

2
src/Generator/Driver.cs

@ -72,7 +72,7 @@ namespace CppSharp @@ -72,7 +72,7 @@ namespace CppSharp
if (string.IsNullOrWhiteSpace(module.LibraryName))
throw new InvalidOptionException("One of your modules has no library name.");
if (string.IsNullOrWhiteSpace(module.OutputNamespace))
if (module.OutputNamespace == null)
module.OutputNamespace = module.LibraryName;
}

2
src/Generator/Generator.cs

@ -115,7 +115,7 @@ namespace CppSharp.Generators @@ -115,7 +115,7 @@ namespace CppSharp.Generators
{
TranslationUnit = new TranslationUnit
{
FilePath = string.Format("{0}.cs", module.OutputNamespace ?? module.LibraryName),
FilePath = string.Format("{0}.cs", module.LibraryName),
Module = module
},
Templates = Generate(module.Units)

3
src/Generator/Generators/CLI/CLIHeadersTemplate.cs

@ -187,7 +187,8 @@ namespace CppSharp.Generators.CLI @@ -187,7 +187,8 @@ namespace CppSharp.Generators.CLI
public void GenerateNamespace(Namespace @namespace)
{
var isTopLevel = @namespace is TranslationUnit;
var generateNamespace = !isTopLevel || Options.GenerateLibraryNamespace;
var generateNamespace = !isTopLevel ||
!string.IsNullOrEmpty(@namespace.TranslationUnit.Module.OutputNamespace);
if (generateNamespace)
{

2
src/Generator/Generators/CLI/CLIMarshal.cs

@ -313,7 +313,7 @@ namespace CppSharp.Generators.CLI @@ -313,7 +313,7 @@ namespace CppSharp.Generators.CLI
public string QualifiedIdentifier(Declaration decl)
{
if (Context.Driver.Options.GenerateLibraryNamespace)
if (!string.IsNullOrEmpty(decl.TranslationUnit.Module.OutputNamespace))
return string.Format("{0}::{1}", decl.TranslationUnit.Module.OutputNamespace,
decl.QualifiedName);
return string.Format("{0}", decl.QualifiedName);

2
src/Generator/Generators/CLI/CLITextTemplate.cs

@ -81,7 +81,7 @@ namespace CppSharp.Generators.CLI @@ -81,7 +81,7 @@ namespace CppSharp.Generators.CLI
public string QualifiedIdentifier(Declaration decl)
{
if (Options.GenerateLibraryNamespace)
if (!string.IsNullOrEmpty(TranslationUnit.Module.OutputNamespace))
{
if (string.IsNullOrEmpty(decl.QualifiedName))
return string.Format("{0}", decl.TranslationUnit.Module.OutputNamespace);

2
src/Generator/Generators/CLI/CLITypePrinter.cs

@ -327,7 +327,7 @@ namespace CppSharp.Generators.CLI @@ -327,7 +327,7 @@ namespace CppSharp.Generators.CLI
var names = new List<string>();
string rootNamespace = null;
if (Options.GenerateLibraryNamespace)
if (!string.IsNullOrEmpty(decl.TranslationUnit.Module.OutputNamespace))
names.Add(rootNamespace = decl.TranslationUnit.Module.OutputNamespace);
if (!string.IsNullOrEmpty(decl.Namespace.QualifiedName))

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

@ -198,7 +198,7 @@ namespace CppSharp.Generators.CSharp @@ -198,7 +198,7 @@ namespace CppSharp.Generators.CSharp
}
PopBlock(NewLineKind.BeforeNextBlock);
if (Options.GenerateLibraryNamespace)
if (!string.IsNullOrEmpty(TranslationUnit.Module.OutputNamespace))
{
PushBlock(CSharpBlockKind.Namespace);
WriteLine("namespace {0}", TranslationUnit.Module.OutputNamespace);
@ -210,7 +210,7 @@ namespace CppSharp.Generators.CSharp @@ -210,7 +210,7 @@ namespace CppSharp.Generators.CSharp
GenerateDeclContext(unit);
}
if (Options.GenerateLibraryNamespace)
if (!string.IsNullOrEmpty(TranslationUnit.Module.OutputNamespace))
{
WriteCloseBraceIndent();
PopBlock(NewLineKind.BeforeNextBlock);

2
src/Generator/Options.cs

@ -30,7 +30,6 @@ namespace CppSharp @@ -30,7 +30,6 @@ namespace CppSharp
Modules = new List<Module>();
GeneratorKind = GeneratorKind.CSharp;
GenerateLibraryNamespace = true;
GeneratePartialClasses = true;
GenerateClassMarshals = false;
OutputInteropIncludes = true;
@ -105,7 +104,6 @@ namespace CppSharp @@ -105,7 +104,6 @@ namespace CppSharp
}
public bool OutputInteropIncludes;
public bool GenerateLibraryNamespace;
public bool GenerateFunctionTemplates;
public bool GeneratePartialClasses;
public bool GenerateInterfacesForMultipleInheritance;

Loading…
Cancel
Save