Browse Source

Fixed the finding of functions to work in name-spaces too.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/816/head
Dimitar Dobrev 8 years ago
parent
commit
0f0f6172f0
  1. 8
      src/AST/Namespace.cs
  2. 13
      src/Generator.Tests/AST/TestAST.cs
  3. 2
      tests/Native/AST.h

8
src/AST/Namespace.cs

@ -234,14 +234,6 @@ namespace CppSharp.AST @@ -234,14 +234,6 @@ namespace CppSharp.AST
return @namespace.FindFunction(funcName, createDecl);
}
public Function FindFunction(string name)
{
return Functions
.Concat(Templates.OfType<FunctionTemplate>()
.Select(t => t.TemplatedFunction))
.FirstOrDefault(f => f.Name == name);
}
public Function FindFunctionByUSR(string usr)
{
return Functions

13
src/Generator.Tests/AST/TestAST.cs

@ -303,13 +303,13 @@ namespace CppSharp.Generator.Tests.AST @@ -303,13 +303,13 @@ namespace CppSharp.Generator.Tests.AST
[Test]
public void TestLineNumber()
{
Assert.AreEqual(65, AstContext.FindClass("HiddenInNamespace").First().LineNumberStart);
Assert.AreEqual(67, AstContext.FindClass("HiddenInNamespace").First().LineNumberStart);
}
[Test]
public void TestLineNumberOfFriend()
{
Assert.AreEqual(88, AstContext.FindFunction("operator+").First().LineNumberStart);
Assert.AreEqual(90, AstContext.FindFunction("operator+").First().LineNumberStart);
}
static string StripWindowsNewLines(string text)
@ -351,7 +351,7 @@ namespace CppSharp.Generator.Tests.AST @@ -351,7 +351,7 @@ namespace CppSharp.Generator.Tests.AST
[Test]
public void TestMacroLineNumber()
{
Assert.AreEqual(98, AstContext.FindClass("HasAmbiguousFunctions").First().Specifiers.Last().LineNumberStart);
Assert.AreEqual(100, AstContext.FindClass("HasAmbiguousFunctions").First().Specifiers.Last().LineNumberStart);
}
[Test]
@ -488,5 +488,12 @@ namespace CppSharp.Generator.Tests.AST @@ -488,5 +488,12 @@ namespace CppSharp.Generator.Tests.AST
var type = pointee.Visit(cppTypePrinter);
Assert.That(type, Is.EqualTo("const volatile char"));
}
[Test]
public void TestFindFunctionInNamespace()
{
var function = AstContext.FindFunction("Math::function").FirstOrDefault();
Assert.That(function, Is.Not.Null);
}
}
}

2
tests/Native/AST.h

@ -21,6 +21,8 @@ namespace Math @@ -21,6 +21,8 @@ namespace Math
Complex Complex::operator+(Complex &other) {
return Complex(re + other.re, im + other.im);
}
void function();
}
// Tests Enum.ItemByName

Loading…
Cancel
Save