Browse Source

Reworked and improved checking of ignored declarations.

It improves the logic to work when certain options are enabled. We would previously accept some declarations that should be ignored.
pull/144/head
triton 12 years ago
parent
commit
f743db743d
  1. 36
      src/Generator/Passes/CheckIgnoredDecls.cs

36
src/Generator/Passes/CheckIgnoredDecls.cs

@ -5,19 +5,40 @@ namespace CppSharp.Passes @@ -5,19 +5,40 @@ namespace CppSharp.Passes
{
public class CheckIgnoredDeclsPass : TranslationUnitPass
{
public bool CheckDeclarationAccess(Declaration decl)
{
var generateAbstractImpls = Driver.Options.IsCSharpGenerator
&& Driver.Options.GenerateAbstractImpls;
switch (decl.Access)
{
case AccessSpecifier.Public:
return true;
case AccessSpecifier.Protected:
return generateAbstractImpls;
case AccessSpecifier.Private:
var method = decl as Method;
var isOverride = method != null && method.IsOverride;
return generateAbstractImpls && isOverride;
}
return true;
}
public override bool VisitDeclaration(Declaration decl)
{
if (decl.ExplicityIgnored)
if (AlreadyVisited(decl))
return false;
if (decl.Access == AccessSpecifier.Private)
{
Method method = decl as Method;
if (method == null || !method.IsOverride)
if (decl.ExplicityIgnored)
return true;
if (!CheckDeclarationAccess(decl))
{
Log.Debug("Decl '{0}' was ignored due to invalid access",
decl.Name);
decl.ExplicityIgnored = true;
return false;
}
return true;
}
if (decl.IsDependent)
@ -25,6 +46,7 @@ namespace CppSharp.Passes @@ -25,6 +46,7 @@ namespace CppSharp.Passes
decl.ExplicityIgnored = true;
Log.Debug("Decl '{0}' was ignored due to dependent context",
decl.Name);
return true;
}
return true;

Loading…
Cancel
Save