From 9a7927613e0f272de032637bee54df0c8931b722 Mon Sep 17 00:00:00 2001 From: Abhinav Tripathi Date: Sun, 6 Mar 2016 18:20:00 +0530 Subject: [PATCH] Fix generation of functions with union params --- .../Passes/CleanInvalidDeclNamesPass.cs | 19 ------------------- tests/Common/Common.Tests.cs | 10 +++++++++- tests/Common/Common.h | 7 +++++++ 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs index b79901fc..6c9804f6 100644 --- a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs +++ b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs @@ -108,25 +108,6 @@ namespace CppSharp.Passes return ret; } - public override bool VisitTypedefDecl(TypedefDecl typedef) - { - if (base.VisitTypedefDecl(typedef)) - return false; - - var @class = typedef.Namespace.FindClass(typedef.Name); - - // Clang will walk the typedef'd tag decl and the typedef decl, - // so we ignore the class and process just the typedef. - - if (@class != null) - typedef.ExplicitlyIgnore(); - - if (typedef.Type == null) - typedef.ExplicitlyIgnore(); - - return true; - } - private void CheckEnumName(Enumeration @enum) { // If we still do not have a valid name, then try to guess one diff --git a/tests/Common/Common.Tests.cs b/tests/Common/Common.Tests.cs index 4ab717be..24223db2 100644 --- a/tests/Common/Common.Tests.cs +++ b/tests/Common/Common.Tests.cs @@ -619,5 +619,13 @@ public class CommonTests : GeneratorTestFixture { } } + + [Test] + public void TestFuncWithUnionParam() + { + var ut = new union_t(); + ut.c = 20; + var v = common.func_union(ut); + Assert.AreEqual(20, v); + } } - \ No newline at end of file diff --git a/tests/Common/Common.h b/tests/Common/Common.h index d1bdcb68..910f6286 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -1072,3 +1072,10 @@ public: DerivedFromTemplateInstantiationWithVirtual(); }; +typedef DLL_API union { + int c; +} union_t; + +int DLL_API func_union(union_t u) { + return u.c; +}