Browse Source

Moved the change of order when visiting properties to just the renaming pass.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/696/head
Dimitar Dobrev 9 years ago
parent
commit
b16bb0a979
  1. 6
      src/AST/ASTVisitor.cs
  2. 16
      src/Generator/Passes/RenamePass.cs
  3. 6
      tests/CSharp/CSharp.Tests.cs
  4. 21
      tests/CSharp/CSharp.cpp
  5. 6
      tests/CSharp/CSharp.h

6
src/AST/ASTVisitor.cs

@ -1,6 +1,4 @@ @@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
namespace CppSharp.AST
{
@ -309,7 +307,7 @@ namespace CppSharp.AST @@ -309,7 +307,7 @@ namespace CppSharp.AST
VisitFieldDecl(field);
if (VisitOptions.VisitClassProperties)
foreach (var property in @class.Properties.OrderByDescending(p => p.Access))
foreach (var property in @class.Properties)
VisitProperty(property);
if (VisitOptions.VisitClassMethods)

16
src/Generator/Passes/RenamePass.cs

@ -33,6 +33,9 @@ namespace CppSharp.Passes @@ -33,6 +33,9 @@ namespace CppSharp.Passes
VisitOptions.VisitFunctionReturnType = false;
VisitOptions.VisitFunctionParameters = false;
VisitOptions.VisitTemplateArguments = false;
// properties need to be visited but in a different order (see VisitClassDecl) so disable the default order
VisitOptions.VisitClassProperties = false;
VisitOptions.VisitClassMethods = false;
}
protected RenamePass(RenameTargets targets)
@ -176,6 +179,19 @@ namespace CppSharp.Passes @@ -176,6 +179,19 @@ namespace CppSharp.Passes
return true;
}
public override bool VisitClassDecl(Class @class)
{
var result = base.VisitClassDecl(@class);
foreach (var property in @class.Properties.OrderByDescending(p => p.Access))
VisitProperty(property);
foreach (var method in @class.Methods)
VisitMethodDecl(method);
return result;
}
public override bool VisitFieldDecl(Field field)
{
if (!Targets.HasFlag(RenameTargets.Field))

6
tests/CSharp/CSharp.Tests.cs

@ -20,6 +20,12 @@ public unsafe class CSharpTests : GeneratorTestFixture @@ -20,6 +20,12 @@ public unsafe class CSharpTests : GeneratorTestFixture
public void TestUncompilableCode()
{
ALLCAPS_UNDERSCORES a;
using (var testRenaming = new TestRenaming())
{
testRenaming.name();
testRenaming.Name();
testRenaming.Property.GetHashCode();
}
new ForceCreationOfInterface().Dispose();
new InheritsProtectedVirtualFromSecondaryBase().Dispose();
new InheritanceBuffer().Dispose();

21
tests/CSharp/CSharp.cpp

@ -363,6 +363,27 @@ TestCopyConstructorVal::TestCopyConstructorVal(const TestCopyConstructorVal& oth @@ -363,6 +363,27 @@ TestCopyConstructorVal::TestCopyConstructorVal(const TestCopyConstructorVal& oth
B = other.B;
}
TestRenaming::TestRenaming()
{
}
TestRenaming::~TestRenaming()
{
}
void TestRenaming::name()
{
}
void TestRenaming::Name()
{
}
int TestRenaming::property()
{
return 1;
}
UsesPointerToEnumInParamOfVirtual::UsesPointerToEnumInParamOfVirtual()
{
}

6
tests/CSharp/CSharp.h

@ -30,7 +30,6 @@ public: @@ -30,7 +30,6 @@ public:
protected:
int P;
int _method;
TemplateInAnotherUnit<int> templateInAnotherUnit;
};
@ -262,8 +261,13 @@ public: @@ -262,8 +261,13 @@ public:
class DLL_API TestRenaming
{
public:
TestRenaming();
~TestRenaming();
void name();
void Name();
int property();
protected:
int _property;
};
enum class Flags

Loading…
Cancel
Save