Browse Source

Ignored inlined name-spaces in the C# gen only.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/916/merge
Dimitar Dobrev 8 years ago
parent
commit
f33b162f6f
  1. 3
      src/AST/Declaration.cs
  2. 4
      src/Generator/Generators/CLI/CLIHeaders.cs
  3. 5
      src/Generator/Generators/CLI/CLITemplate.cs
  4. 2
      tests/CSharp/CSharp.Tests.cs
  5. 4
      tests/CSharp/CSharp.cpp
  6. 6
      tests/CSharp/CSharp.h
  7. 6
      tests/Common/Common.Tests.cs

3
src/AST/Declaration.cs

@ -144,7 +144,8 @@ namespace CppSharp.AST @@ -144,7 +144,8 @@ namespace CppSharp.AST
var currentNamespace = @namespace;
while (currentNamespace != null)
{
var isInlineNamespace = currentNamespace is Namespace && ((Namespace)currentNamespace).IsInline;
var isInlineNamespace = currentNamespace is Namespace &&
((Namespace) currentNamespace).IsInline;
if (!isInlineNamespace)
namespaces.Push(currentNamespace);
currentNamespace = currentNamespace.Namespace;

4
src/Generator/Generators/CLI/CLIHeaders.cs

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

5
src/Generator/Generators/CLI/CLITemplate.cs

@ -54,10 +54,9 @@ namespace CppSharp.Generators.CLI @@ -54,10 +54,9 @@ namespace CppSharp.Generators.CLI
if (!string.IsNullOrEmpty(TranslationUnit.Module.OutputNamespace))
{
if (string.IsNullOrEmpty(decl.QualifiedName))
return string.Format("{0}", decl.TranslationUnit.Module.OutputNamespace);
return $"{decl.TranslationUnit.Module.OutputNamespace}";
return string.Format("{0}::{1}",
decl.TranslationUnit.Module.OutputNamespace, decl.QualifiedName);
return $"{decl.TranslationUnit.Module.OutputNamespace}::{decl.QualifiedName}";
}
return decl.QualifiedName;

2
tests/CSharp/CSharp.Tests.cs

@ -71,6 +71,8 @@ public unsafe class CSharpTests : GeneratorTestFixture @@ -71,6 +71,8 @@ public unsafe class CSharpTests : GeneratorTestFixture
{
}
CSharp.CSharp.FunctionInsideInlineNamespace();
#pragma warning restore 0168
#pragma warning restore 0219
}

4
tests/CSharp/CSharp.cpp

@ -1381,3 +1381,7 @@ int funcWithTypedefedFuncPtrAsParam(typedefedFuncPtr* func) @@ -1381,3 +1381,7 @@ int funcWithTypedefedFuncPtrAsParam(typedefedFuncPtr* func)
Bar b;
return func(a, b);
}
void InlineNamespace::FunctionInsideInlineNamespace()
{
}

6
tests/CSharp/CSharp.h

@ -1224,3 +1224,9 @@ void useStdStringJustAsParameter(std::string s); @@ -1224,3 +1224,9 @@ void useStdStringJustAsParameter(std::string s);
typedef int (typedefedFuncPtr)(Foo* a, Bar b);
int DLL_API funcWithTypedefedFuncPtrAsParam(typedefedFuncPtr* func);
inline namespace InlineNamespace
{
DLL_API void FunctionInsideInlineNamespace();
}

6
tests/Common/Common.Tests.cs

@ -807,10 +807,4 @@ This is a very long string. This is a very long string. This is a very long stri @@ -807,10 +807,4 @@ This is a very long string. This is a very long string. This is a very long stri
Assert.That(testProperties.RefToPrimitiveInSetter, Is.EqualTo(value));
}
}
[Test]
public void TestInlineNamespaces()
{
Common.FunctionInsideInlineNamespace();
}
}

Loading…
Cancel
Save