Browse Source

Added support for C++11 type-alias type declarations.

In the future, we might want to add a TypeAliasDecl AST node,
but for now this simple approach is enough for typedef-like using declarations.

Won't be enough to support partial template using syntax (TypeAliasTemplateDecl).

Partial fix for https://github.com/mono/CppSharp/issues/664.
pull/667/head
Joao Matos 10 years ago
parent
commit
afa12be715
  1. 3
      src/CppParser/Parser.cpp
  2. 2
      tests/Common/Common.Tests.cs
  3. 4
      tests/Common/Common.cpp
  4. 3
      tests/Common/Common.h

3
src/CppParser/Parser.cpp

@ -3184,8 +3184,9 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D, @@ -3184,8 +3184,9 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D,
break;
}
case Decl::Typedef:
case Decl::TypeAlias:
{
auto TD = cast<clang::TypedefDecl>(D);
auto TD = cast<clang::TypedefNameDecl>(D);
auto NS = GetNamespace(TD);
auto Name = GetDeclName(TD);

2
tests/Common/Common.Tests.cs

@ -383,6 +383,8 @@ public class CommonTests : GeneratorTestFixture @@ -383,6 +383,8 @@ public class CommonTests : GeneratorTestFixture
{
var ret = common.Function();
Assert.That(ret, Is.EqualTo(5));
common.FuncWithTypeAlias(0);
}
[Test]

4
tests/Common/Common.cpp

@ -618,3 +618,7 @@ HasProtectedEnum::HasProtectedEnum() @@ -618,3 +618,7 @@ HasProtectedEnum::HasProtectedEnum()
void HasProtectedEnum::function(ProtectedEnum param)
{
}
void FuncWithTypeAlias(custom_int_t i)
{
}

3
tests/Common/Common.h

@ -1103,6 +1103,9 @@ protected: @@ -1103,6 +1103,9 @@ protected:
void function(ProtectedEnum param);
};
using custom_int_t = int;
void FuncWithTypeAlias(custom_int_t i);
struct TestsTypes
{
int(*FunctionNoProto)();

Loading…
Cancel
Save