Browse Source

Fix generation of functions with union params

pull/635/head
Abhinav Tripathi 10 years ago
parent
commit
9a7927613e
  1. 19
      src/Generator/Passes/CleanInvalidDeclNamesPass.cs
  2. 10
      tests/Common/Common.Tests.cs
  3. 7
      tests/Common/Common.h

19
src/Generator/Passes/CleanInvalidDeclNamesPass.cs

@ -108,25 +108,6 @@ namespace CppSharp.Passes @@ -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

10
tests/Common/Common.Tests.cs

@ -619,5 +619,13 @@ public class CommonTests : GeneratorTestFixture @@ -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);
}
}

7
tests/Common/Common.h

@ -1072,3 +1072,10 @@ public: @@ -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;
}

Loading…
Cancel
Save