From afa12be71568a9b99740e392e6cac82045a5ad88 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Fri, 24 Jun 2016 16:35:11 +0100 Subject: [PATCH] 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. --- src/CppParser/Parser.cpp | 3 ++- tests/Common/Common.Tests.cs | 2 ++ tests/Common/Common.cpp | 4 ++++ tests/Common/Common.h | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/CppParser/Parser.cpp b/src/CppParser/Parser.cpp index 9c301e65..8addf689 100644 --- a/src/CppParser/Parser.cpp +++ b/src/CppParser/Parser.cpp @@ -3184,8 +3184,9 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D, break; } case Decl::Typedef: + case Decl::TypeAlias: { - auto TD = cast(D); + auto TD = cast(D); auto NS = GetNamespace(TD); auto Name = GetDeclName(TD); diff --git a/tests/Common/Common.Tests.cs b/tests/Common/Common.Tests.cs index 7b01ed3a..04e6aa04 100644 --- a/tests/Common/Common.Tests.cs +++ b/tests/Common/Common.Tests.cs @@ -383,6 +383,8 @@ public class CommonTests : GeneratorTestFixture { var ret = common.Function(); Assert.That(ret, Is.EqualTo(5)); + + common.FuncWithTypeAlias(0); } [Test] diff --git a/tests/Common/Common.cpp b/tests/Common/Common.cpp index c972c89c..715762d4 100644 --- a/tests/Common/Common.cpp +++ b/tests/Common/Common.cpp @@ -618,3 +618,7 @@ HasProtectedEnum::HasProtectedEnum() void HasProtectedEnum::function(ProtectedEnum param) { } + +void FuncWithTypeAlias(custom_int_t i) +{ +} diff --git a/tests/Common/Common.h b/tests/Common/Common.h index fe967f44..437c073e 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -1103,6 +1103,9 @@ protected: void function(ProtectedEnum param); }; +using custom_int_t = int; +void FuncWithTypeAlias(custom_int_t i); + struct TestsTypes { int(*FunctionNoProto)();