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. 38
      src/Generator/Passes/CheckIgnoredDecls.cs

38
src/Generator/Passes/CheckIgnoredDecls.cs

@ -5,19 +5,40 @@ namespace CppSharp.Passes
{ {
public class CheckIgnoredDeclsPass : TranslationUnitPass 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) public override bool VisitDeclaration(Declaration decl)
{ {
if (decl.ExplicityIgnored) if (AlreadyVisited(decl))
return false; return false;
if (decl.Access == AccessSpecifier.Private) if (decl.ExplicityIgnored)
return true;
if (!CheckDeclarationAccess(decl))
{ {
Method method = decl as Method; Log.Debug("Decl '{0}' was ignored due to invalid access",
if (method == null || !method.IsOverride) decl.Name);
{ decl.ExplicityIgnored = true;
decl.ExplicityIgnored = true; return true;
return false;
}
} }
if (decl.IsDependent) if (decl.IsDependent)
@ -25,6 +46,7 @@ namespace CppSharp.Passes
decl.ExplicityIgnored = true; decl.ExplicityIgnored = true;
Log.Debug("Decl '{0}' was ignored due to dependent context", Log.Debug("Decl '{0}' was ignored due to dependent context",
decl.Name); decl.Name);
return true;
} }
return true; return true;

Loading…
Cancel
Save