From de8b3fc00e1998b54f6b52d8f990c548a6b7e7a3 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Sat, 7 Sep 2013 03:16:24 +0300 Subject: [PATCH] Corrected the checks for private methods because overrides must be allowed through regardless of access. Signed-off-by: Dimitar Dobrev --- src/Generator/AST/Utils.cs | 2 +- .../Generators/CSharp/CSharpTextTemplate.cs | 5 ++--- src/Generator/Passes/CheckIgnoredDecls.cs | 2 +- src/Generator/Passes/GenerateInlinesCodePass.cs | 12 +++++++++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Generator/AST/Utils.cs b/src/Generator/AST/Utils.cs index 40dd92b1..ef905fe2 100644 --- a/src/Generator/AST/Utils.cs +++ b/src/Generator/AST/Utils.cs @@ -37,7 +37,7 @@ namespace CppSharp.AST if (method.Kind == CXXMethodKind.Conversion) return true; - if (method.Access == AccessSpecifier.Private) + if (method.Access == AccessSpecifier.Private && !method.IsOverride) return true; return false; diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 9deb05d9..2c715c22 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -1585,11 +1585,10 @@ namespace CppSharp.Generators.CSharp case AccessSpecifier.Public: return @class.IsAbstract && method.IsConstructor ? AccessSpecifier.Protected : AccessSpecifier.Public; - case AccessSpecifier.Protected: + default: return method.IsOverride ? - @class.GetRootBaseMethod(method).Access : AccessSpecifier.Protected; + @class.GetRootBaseMethod(method).Access : method.Access; } - return AccessSpecifier.Private; } private void GenerateVirtualTableFunctionCall(Function method, Class @class) diff --git a/src/Generator/Passes/CheckIgnoredDecls.cs b/src/Generator/Passes/CheckIgnoredDecls.cs index fd888e26..e1810b4a 100644 --- a/src/Generator/Passes/CheckIgnoredDecls.cs +++ b/src/Generator/Passes/CheckIgnoredDecls.cs @@ -109,7 +109,7 @@ namespace CppSharp.Passes if (!VisitDeclaration(method)) return false; - if (method.Access == AccessSpecifier.Private) + if (method.Access == AccessSpecifier.Private && !method.IsOverride) { method.ExplicityIgnored = true; return false; diff --git a/src/Generator/Passes/GenerateInlinesCodePass.cs b/src/Generator/Passes/GenerateInlinesCodePass.cs index b194efa8..28dc0b5b 100644 --- a/src/Generator/Passes/GenerateInlinesCodePass.cs +++ b/src/Generator/Passes/GenerateInlinesCodePass.cs @@ -65,7 +65,7 @@ namespace CppSharp.Passes { string symbol = mangled.Mangled; var declaration = (Declaration) mangled; - if (!declaration.Ignore && declaration.Access != AccessSpecifier.Private && + if (!declaration.Ignore && AccessValid(declaration) && !Driver.LibrarySymbols.FindSymbol(ref symbol) && !currentUnit.FilePath.EndsWith("_impl.h") && !currentUnit.FilePath.EndsWith("_p.h")) @@ -76,5 +76,15 @@ namespace CppSharp.Passes mangledInlines.Add(mangled.Mangled); } } + + private static bool AccessValid(Declaration declaration) + { + if (declaration.Access == AccessSpecifier.Private) + { + var method = declaration as Method; + return method != null && method.IsOverride; + } + return true; + } } }