Browse Source

Merge pull request #465 from ddobrev/master

Fixed the naming of multiple anonymous types in a union
pull/467/head
João Matos 10 years ago
parent
commit
5d4875982e
  1. 2
      src/Generator/Options.cs
  2. 11
      src/Generator/Passes/CleanInvalidDeclNamesPass.cs
  3. 13
      tests/Basic/Basic.h

2
src/Generator/Options.cs

@ -133,7 +133,7 @@ namespace CppSharp
public List<string> NoGenIncludeDirs; public List<string> NoGenIncludeDirs;
/// <summary> /// <summary>
/// Wether the generated C# code should be automatically compiled. /// Whether the generated C# code should be automatically compiled.
/// </summary> /// </summary>
public bool CompileCode; public bool CompileCode;

11
src/Generator/Passes/CleanInvalidDeclNamesPass.cs

@ -74,6 +74,17 @@ namespace CppSharp.Passes
var ret = base.VisitClassDecl(@class); var ret = base.VisitClassDecl(@class);
this.uniqueName = currentUniqueName; this.uniqueName = currentUniqueName;
if (@class.Namespace.Classes.Any(d => d != @class && d.Name == @class.Name))
{
StringBuilder str = new StringBuilder();
str.Append(@class.Name);
do
{
str.Append('_');
} while (@class.Classes.Any(d => d != @class && d.Name == str.ToString()));
@class.Name = str.ToString();
}
return ret; return ret;
} }

13
tests/Basic/Basic.h

@ -728,3 +728,16 @@ public:
bool operator ==(const DifferentConstOverloads& other); bool operator ==(const DifferentConstOverloads& other);
bool operator ==(int number) const; bool operator ==(int number) const;
}; };
class TestNamingAnonymousTypesInUnion
{
public:
union {
struct {
} argb;
struct {
} ahsv;
struct {
} acmyk;
} ct;
};

Loading…
Cancel
Save