From b9042d72b55582dcf76ed0038414a8a17eaf4172 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Sun, 2 Nov 2014 16:36:14 +0200 Subject: [PATCH 1/2] Fixed a regression causing ignored types with bases without empty ctors to fail. Signed-off-by: Dimitar Dobrev --- src/Generator/Generators/CSharp/CSharpTextTemplate.cs | 2 +- tests/CSharpTemp/CSharpTemp.cs | 2 ++ tests/CSharpTemp/CSharpTemp.h | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 89c330a3..39bcd7af 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -744,7 +744,7 @@ namespace CppSharp.Generators.CSharp var bases = new List(); - var needsBase = @class.HasGeneratedBase; + var needsBase = @class.HasGeneratedBase && @class.IsGenerated; if (needsBase) { diff --git a/tests/CSharpTemp/CSharpTemp.cs b/tests/CSharpTemp/CSharpTemp.cs index 2efe4a09..6119a9e5 100644 --- a/tests/CSharpTemp/CSharpTemp.cs +++ b/tests/CSharpTemp/CSharpTemp.cs @@ -82,6 +82,8 @@ namespace CppSharp.Tests { ctx.SetClassAsValueType("TestCopyConstructorVal"); ctx.SetClassAsValueType("QGenericArgument"); + + ctx.IgnoreClassWithName("IgnoredTypeInheritingNonIgnoredWithNoEmptyCtor"); } public override void Postprocess(Driver driver, ASTContext ctx) diff --git a/tests/CSharpTemp/CSharpTemp.h b/tests/CSharpTemp/CSharpTemp.h index c16c148d..09b0669e 100644 --- a/tests/CSharpTemp/CSharpTemp.h +++ b/tests/CSharpTemp/CSharpTemp.h @@ -20,6 +20,7 @@ public: Qux(); Qux(Foo foo); int farAwayFunc() const; + int array[3]; void obsolete(); }; @@ -253,6 +254,10 @@ class DLL_API IgnoredType { }; +class DLL_API IgnoredTypeInheritingNonIgnoredWithNoEmptyCtor : public P +{ +}; + class DLL_API PropertyWithIgnoredType { public: From 88293d5c84102287d5d40461bb58ea0c380b9c94 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Sun, 2 Nov 2014 22:12:34 +0200 Subject: [PATCH 2/2] Fixed invalid names of static field (variables). Signed-off-by: Dimitar Dobrev --- src/Generator/Passes/CleanInvalidDeclNamesPass.cs | 6 ++++++ tests/CSharpTemp/CSharpTemp.h | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs index 70ecfc9b..9bd526e9 100644 --- a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs +++ b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs @@ -123,6 +123,12 @@ namespace CppSharp.Passes return base.VisitTypedefDecl(typedef); } + public override bool VisitVariableDecl(Variable variable) + { + variable.Name = CheckName(variable.Name); + return base.VisitVariableDecl(variable); + } + private static void CheckEnumName(Enumeration @enum) { // If we still do not have a valid name, then try to guess one diff --git a/tests/CSharpTemp/CSharpTemp.h b/tests/CSharpTemp/CSharpTemp.h index 09b0669e..969ea700 100644 --- a/tests/CSharpTemp/CSharpTemp.h +++ b/tests/CSharpTemp/CSharpTemp.h @@ -10,6 +10,8 @@ public: int& operator[](int i); int A; + static int null; + protected: int P; }; @@ -265,4 +267,4 @@ public: void setIgnoredType(const IgnoredType& value); private: IgnoredType _ignoredType; -}; \ No newline at end of file +};