Browse Source

Fixed all passes for the new ASTVisitor behavior.

Added ignore and method checking code to the MoveFunctionToClass pass.
pull/144/head
triton 12 years ago
parent
commit
5817f58cd4
  1. 2
      src/Generator/Passes/CheckAbiParameters.cs
  2. 2
      src/Generator/Passes/CheckAmbiguousFunctions.cs
  3. 20
      src/Generator/Passes/CheckDuplicatedNamesPass.cs
  4. 3
      src/Generator/Passes/CheckIgnoredDecls.cs
  5. 6
      src/Generator/Passes/CheckOperatorsOverloads.cs
  6. 6
      src/Generator/Passes/CheckVTableComponentsPass.cs
  7. 2
      src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs
  8. 2
      src/Generator/Passes/FieldToPropertyPass.cs
  9. 2
      src/Generator/Passes/GenerateAbstractImplementationsPass.cs
  10. 2
      src/Generator/Passes/GetterSetterToPropertyPass.cs
  11. 16
      src/Generator/Passes/MoveFunctionToClassPass.cs
  12. 3
      src/Generator/Passes/ObjectOverridesPass.cs
  13. 6
      src/Generator/Passes/ResolveIncompleteDeclsPass.cs
  14. 7
      src/Generator/Types/Types.cs

2
src/Generator/Passes/CheckAbiParameters.cs

@ -29,7 +29,7 @@ namespace CppSharp.Passes @@ -29,7 +29,7 @@ namespace CppSharp.Passes
public override bool VisitFunctionDecl(Function function)
{
if (AlreadyVisited(function))
if (!VisitDeclaration(function))
return false;
if (function.IsReturnIndirect)

2
src/Generator/Passes/CheckAmbiguousFunctions.cs

@ -25,7 +25,7 @@ namespace CppSharp.Passes @@ -25,7 +25,7 @@ namespace CppSharp.Passes
{
public override bool VisitFunctionDecl(AST.Function function)
{
if (AlreadyVisited(function))
if (!VisitDeclaration(function))
return false;
if (function.IsAmbiguous)

20
src/Generator/Passes/CheckDuplicatedNamesPass.cs

@ -94,18 +94,22 @@ namespace CppSharp.Passes @@ -94,18 +94,22 @@ namespace CppSharp.Passes
public override bool VisitFieldDecl(Field decl)
{
if (!VisitDeclaration(decl))
return false;
if (ASTUtils.CheckIgnoreField(decl))
return false;
if(!AlreadyVisited(decl))
CheckDuplicate(decl);
return false;
}
public override bool VisitProperty(Property decl)
{
if(!AlreadyVisited(decl) && decl.ExplicitInterfaceImpl == null)
if (!VisitDeclaration(decl))
return false;
if (decl.ExplicitInterfaceImpl == null)
CheckDuplicate(decl);
return false;
@ -113,10 +117,13 @@ namespace CppSharp.Passes @@ -113,10 +117,13 @@ namespace CppSharp.Passes
public override bool VisitMethodDecl(Method decl)
{
if (!VisitDeclaration(decl))
return false;
if (ASTUtils.CheckIgnoreMethod(decl))
return false;
if (!AlreadyVisited(decl) && decl.ExplicitInterfaceImpl == null)
if (decl.ExplicitInterfaceImpl == null)
CheckDuplicate(decl);
return false;
@ -124,7 +131,10 @@ namespace CppSharp.Passes @@ -124,7 +131,10 @@ namespace CppSharp.Passes
public override bool VisitClassDecl(Class @class)
{
if (AlreadyVisited(@class) || @class.IsIncomplete)
if (!VisitDeclaration(@class))
return false;
if (@class.IsIncomplete)
return false;
// DeclarationName should always process methods first,

3
src/Generator/Passes/CheckIgnoredDecls.cs

@ -108,9 +108,6 @@ namespace CppSharp.Passes @@ -108,9 +108,6 @@ namespace CppSharp.Passes
public override bool VisitMethodDecl(Method method)
{
if (!VisitDeclaration(method))
return false;
if (!CheckIgnoredBaseOverridenMethod(method))
return false;

6
src/Generator/Passes/CheckOperatorsOverloads.cs

@ -14,12 +14,6 @@ namespace CppSharp.Passes @@ -14,12 +14,6 @@ namespace CppSharp.Passes
if (@class.CompleteDeclaration != null)
return VisitClassDecl(@class.CompleteDeclaration as Class);
if (!VisitDeclaration(@class))
return false;
if (AlreadyVisited(@class))
return false;
if (!VisitDeclarationContext(@class))
return false;

6
src/Generator/Passes/CheckVTableComponentsPass.cs

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using CppSharp.AST;
using CppSharp.Utils;
@ -13,9 +12,6 @@ namespace CppSharp.Passes @@ -13,9 +12,6 @@ namespace CppSharp.Passes
{
public override bool VisitClassDecl(AST.Class @class)
{
if (AlreadyVisited(@class))
return false;
foreach (var vfptr in @class.Layout.VFTables)
{
var uniqueEntries = new OrderedSet<VTableComponent>();

2
src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs

@ -247,7 +247,7 @@ namespace CppSharp.Passes @@ -247,7 +247,7 @@ namespace CppSharp.Passes
{
public override bool VisitMethodDecl(AST.Method method)
{
if (AlreadyVisited(method))
if (!VisitDeclaration(method))
return false;
if (!method.IsOverride)

2
src/Generator/Passes/FieldToPropertyPass.cs

@ -7,7 +7,7 @@ namespace CppSharp.Passes @@ -7,7 +7,7 @@ namespace CppSharp.Passes
{
public override bool VisitFieldDecl(Field field)
{
if (AlreadyVisited(field))
if (!VisitDeclaration(field))
return false;
var @class = field.Namespace as Class;

2
src/Generator/Passes/GenerateAbstractImplementationsPass.cs

@ -33,7 +33,7 @@ namespace CppSharp.Passes @@ -33,7 +33,7 @@ namespace CppSharp.Passes
if (@class.CompleteDeclaration != null)
return VisitClassDecl(@class.CompleteDeclaration as Class);
if (!VisitDeclaration(@class) || AlreadyVisited(@class))
if (!VisitDeclaration(@class))
return false;
if (@class.IsAbstract)

2
src/Generator/Passes/GetterSetterToPropertyPass.cs

@ -73,7 +73,7 @@ namespace CppSharp.Passes @@ -73,7 +73,7 @@ namespace CppSharp.Passes
public override bool VisitMethodDecl(Method method)
{
if (AlreadyVisited(method))
if (!VisitDeclaration(method))
return false;
if (ASTUtils.CheckIgnoreMethod(method))

16
src/Generator/Passes/MoveFunctionToClassPass.cs

@ -10,20 +10,22 @@ namespace CppSharp.Passes @@ -10,20 +10,22 @@ namespace CppSharp.Passes
{
public override bool VisitFunctionDecl(Function function)
{
if (AlreadyVisited(function) || function.Ignore || function.Namespace is Class)
return base.VisitFunctionDecl(function);
if (!VisitDeclaration(function))
return false;
Class @class = FindClassToMoveFunctionTo(function.Namespace);
if (function.Ignore || function.Namespace is Class)
return false;
var @class = FindClassToMoveFunctionTo(function.Namespace);
if (@class != null)
{
MoveFunction(function, @class);
}
return base.VisitFunctionDecl(function);
return true;
}
private Class FindClassToMoveFunctionTo(INamedDecl @namespace)
{
TranslationUnit unit = @namespace as TranslationUnit;
var unit = @namespace as TranslationUnit;
if (unit == null)
{
return Driver.ASTContext.FindClass(

3
src/Generator/Passes/ObjectOverridesPass.cs

@ -67,9 +67,6 @@ namespace CppSharp @@ -67,9 +67,6 @@ namespace CppSharp
if (!VisitDeclaration(@class))
return false;
if (AlreadyVisited(@class))
return true;
if (@class.IsValueType)
return false;

6
src/Generator/Passes/ResolveIncompleteDeclsPass.cs

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
using System;
using CppSharp.AST;
using CppSharp.AST;
namespace CppSharp.Passes
{
@ -18,9 +17,6 @@ namespace CppSharp.Passes @@ -18,9 +17,6 @@ namespace CppSharp.Passes
public override bool VisitClassDecl(Class @class)
{
if (!VisitDeclaration(@class))
return false;
if (!@class.IsIncomplete)
goto Out;

7
src/Generator/Types/Types.cs

@ -16,6 +16,9 @@ namespace CppSharp @@ -16,6 +16,9 @@ namespace CppSharp
public override bool VisitDeclaration(Declaration decl)
{
if (AlreadyVisited(decl))
return false;
if (decl.CompleteDeclaration != null)
return true;
@ -45,6 +48,9 @@ namespace CppSharp @@ -45,6 +48,9 @@ namespace CppSharp
public override bool VisitDeclaration(Declaration decl)
{
if (AlreadyVisited(decl))
return false;
if (decl.CompleteDeclaration != null)
return VisitDeclaration(decl.CompleteDeclaration);
@ -103,6 +109,7 @@ namespace CppSharp @@ -103,6 +109,7 @@ namespace CppSharp
Ignore();
return false;
}
return base.VisitMemberPointerType(member, quals);
}

Loading…
Cancel
Save