|
|
|
@ -29,8 +29,12 @@ namespace CppSharp.Passes
@@ -29,8 +29,12 @@ namespace CppSharp.Passes
|
|
|
|
|
{ |
|
|
|
|
if (decl is Class) return true; |
|
|
|
|
if (decl is Field) return true; |
|
|
|
|
if (decl is Method) return true; |
|
|
|
|
if (decl is Function) return true; |
|
|
|
|
var function = decl as Function; |
|
|
|
|
if (function != null) |
|
|
|
|
{ |
|
|
|
|
// special case the IDisposable.Dispose that could be added later
|
|
|
|
|
return !function.IsOperator && function.Name != "dispose"; |
|
|
|
|
} |
|
|
|
|
if (decl is Parameter) return true; |
|
|
|
|
if (decl is Enumeration) return true; |
|
|
|
|
if (decl is Property) return true; |
|
|
|
@ -46,7 +50,7 @@ namespace CppSharp.Passes
@@ -46,7 +50,7 @@ namespace CppSharp.Passes
|
|
|
|
|
// this is why this pass has to rename entries in the v-table as well;
|
|
|
|
|
// this should be fixed in the parser: it should reuse method objects
|
|
|
|
|
foreach (var method in VTables.GatherVTableMethodEntries(@class).Where( |
|
|
|
|
e => e.Method != null && !e.Method.IsOperator).Select(e => e.Method)) |
|
|
|
|
e => e.Method != null && IsRenameableDecl(e.Method)).Select(e => e.Method)) |
|
|
|
|
{ |
|
|
|
|
Rename(method); |
|
|
|
|
} |
|
|
|
@ -65,7 +69,7 @@ namespace CppSharp.Passes
@@ -65,7 +69,7 @@ namespace CppSharp.Passes
|
|
|
|
|
|
|
|
|
|
Visited.Add(decl); |
|
|
|
|
|
|
|
|
|
if (decl.Name == null || (decl is Function && ((Function) decl).IsOperator)) |
|
|
|
|
if (decl.Name == null) |
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
return Rename(decl); |
|
|
|
@ -74,8 +78,12 @@ namespace CppSharp.Passes
@@ -74,8 +78,12 @@ namespace CppSharp.Passes
|
|
|
|
|
private bool Rename(Declaration decl) |
|
|
|
|
{ |
|
|
|
|
string newName; |
|
|
|
|
// special case the IDisposable.Dispose that could be added later
|
|
|
|
|
if (Rename(decl.Name, out newName) && newName != "Dispose") |
|
|
|
|
if (Rename(decl.Name, out newName) && AreThereConflicts(decl, newName)) |
|
|
|
|
decl.Name = newName; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static bool AreThereConflicts(Declaration decl, string newName) |
|
|
|
|
{ |
|
|
|
|
List<Declaration> declarations = new List<Declaration>(); |
|
|
|
|
declarations.AddRange(decl.Namespace.Classes); |
|
|
|
@ -83,10 +91,7 @@ namespace CppSharp.Passes
@@ -83,10 +91,7 @@ namespace CppSharp.Passes
|
|
|
|
|
declarations.AddRange(decl.Namespace.Events); |
|
|
|
|
declarations.AddRange(decl.Namespace.Functions); |
|
|
|
|
declarations.AddRange(decl.Namespace.Variables); |
|
|
|
|
if (declarations.All(d => d == decl || d.Name != newName)) |
|
|
|
|
decl.Name = newName; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
return declarations.All(d => d == decl || d.Name != newName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override bool VisitEnumItem(Enumeration.Item item) |
|
|
|
|