Browse Source

Changed the renaming not to remove the underscores from all-capital names.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/696/head
Dimitar Dobrev 9 years ago
parent
commit
9da51c1e16
  1. 14
      src/Generator/Passes/RenamePass.cs
  2. 5
      tests/CSharp/CSharp.Tests.cs
  3. 2
      tests/CSharp/CSharp.h

14
src/Generator/Passes/RenamePass.cs

@ -128,7 +128,7 @@ namespace CppSharp.Passes
declarations.AddRange(decl.Namespace.Variables); declarations.AddRange(decl.Namespace.Variables);
declarations.AddRange(from typedefDecl in decl.Namespace.Typedefs declarations.AddRange(from typedefDecl in decl.Namespace.Typedefs
let pointerType = typedefDecl.Type.Desugar() as PointerType let pointerType = typedefDecl.Type.Desugar() as PointerType
where pointerType != null && pointerType.Pointee is FunctionType where pointerType != null && pointerType.GetFinalPointee() is FunctionType
select typedefDecl); select typedefDecl);
var specialization = decl as ClassTemplateSpecialization; var specialization = decl as ClassTemplateSpecialization;
if (specialization != null) if (specialization != null)
@ -347,12 +347,16 @@ namespace CppSharp.Passes
if (sb[0] == '@') if (sb[0] == '@')
sb.Remove(0, 1); sb.Remove(0, 1);
for (int i = sb.Length - 1; i >= 0; i--) // do not remove underscores from ALL_CAPS names
if (!decl.Name.Where(char.IsLetter).All(char.IsUpper))
{ {
if (sb[i] == '_' && i < sb.Length - 1) for (int i = sb.Length - 1; i >= 0; i--)
{ {
sb[i + 1] = char.ToUpperInvariant(sb[i + 1]); if (sb[i] == '_' && i < sb.Length - 1)
sb.Remove(i, 1); {
sb[i + 1] = char.ToUpperInvariant(sb[i + 1]);
sb.Remove(i, 1);
}
} }
} }

5
tests/CSharp/CSharp.Tests.cs

@ -19,6 +19,7 @@ public unsafe class CSharpTests : GeneratorTestFixture
[Test] [Test]
public void TestUncompilableCode() public void TestUncompilableCode()
{ {
ALLCAPS_UNDERSCORES a;
new ForceCreationOfInterface().Dispose(); new ForceCreationOfInterface().Dispose();
new InheritsProtectedVirtualFromSecondaryBase().Dispose(); new InheritsProtectedVirtualFromSecondaryBase().Dispose();
new InheritanceBuffer().Dispose(); new InheritanceBuffer().Dispose();
@ -285,11 +286,11 @@ public unsafe class CSharpTests : GeneratorTestFixture
[Test] [Test]
public void TestPrimarySecondaryBase() public void TestPrimarySecondaryBase()
{ {
var a = new MIA0(); var a = new MI_A0();
var resa = a.Get(); var resa = a.Get();
Assert.That(resa, Is.EqualTo(50)); Assert.That(resa, Is.EqualTo(50));
var c = new MIC(); var c = new MI_C();
var res = c.Get(); var res = c.Get();
Assert.That(res, Is.EqualTo(50)); Assert.That(res, Is.EqualTo(50));
} }

2
tests/CSharp/CSharp.h

@ -982,3 +982,5 @@ public:
}; };
extern const unsigned char DLL_API variableWithFixedPrimitiveArray[2]; extern const unsigned char DLL_API variableWithFixedPrimitiveArray[2];
typedef void (*ALLCAPS_UNDERSCORES)(int i);

Loading…
Cancel
Save