Browse Source

Fixed the generated code when specialising types represented the same way in C#.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/661/head
Dimitar Dobrev 9 years ago
parent
commit
00441bb300
  1. 11
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  2. 2
      src/Generator/Passes/DelegatesPass.cs
  3. 3
      tests/Common/Common.h

11
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -67,9 +67,10 @@ namespace CppSharp.Generators.CSharp @@ -67,9 +67,10 @@ namespace CppSharp.Generators.CSharp
}
}
public static StringBuilder FormatTypesStringForIdentifier(StringBuilder types)
public static string FormatTypesStringForIdentifier(StringBuilder types)
{
return types.Replace("global::System.", string.Empty).Replace("*", "Ptr").Replace('.', '_');
return types.Replace("global::System.", string.Empty).Replace("*", "Ptr")
.Replace('.', '_').Replace(' ', '_').Replace("::", "_").ToString();
}
public static string GetSuffixForInternal(ClassTemplateSpecialization specialization,
@ -90,6 +91,7 @@ namespace CppSharp.Generators.CSharp @@ -90,6 +91,7 @@ namespace CppSharp.Generators.CSharp
typePrinter.PushContext(CSharpTypePrinterContextKind.Managed);
typePrinter.PushMarshalKind(CSharpMarshalKind.Unknown);
}
var cppTypePrinter = new CppTypePrinter(false) { PrintScopeKind = CppTypePrintScopeKind.Qualified };
CSharpTypePrinter.AppendGlobal = false;
var suffix = new StringBuilder();
foreach (var argType in from argType in specialization.Arguments
@ -119,7 +121,7 @@ namespace CppSharp.Generators.CSharp @@ -119,7 +121,7 @@ namespace CppSharp.Generators.CSharp
continue;
}
}
suffix.Append(argType);
suffix.Append(argType.Visit(cppTypePrinter));
}
if (!nested)
{
@ -127,8 +129,7 @@ namespace CppSharp.Generators.CSharp @@ -127,8 +129,7 @@ namespace CppSharp.Generators.CSharp
typePrinter.PopMarshalKind();
}
CSharpTypePrinter.AppendGlobal = true;
FormatTypesStringForIdentifier(suffix);
return suffix.ToString();
return FormatTypesStringForIdentifier(suffix);
}
}

2
src/Generator/Passes/DelegatesPass.cs

@ -179,7 +179,7 @@ namespace CppSharp.Passes @@ -179,7 +179,7 @@ namespace CppSharp.Passes
}
if (typesBuilder.Length > 0)
typesBuilder.Remove(typesBuilder.Length - 1, 1);
var delegateName = Helpers.FormatTypesStringForIdentifier(typesBuilder).ToString();
var delegateName = Helpers.FormatTypesStringForIdentifier(typesBuilder);
if (returnType.Type.IsPrimitiveType(PrimitiveType.Void))
delegateName = "Action_" + delegateName;
else

3
tests/Common/Common.h

@ -1131,6 +1131,9 @@ class UsesSpecialisationOfVoid @@ -1131,6 +1131,9 @@ class UsesSpecialisationOfVoid
private:
SpecialisesVoid<void>* s;
SpecialisesVoidInUnion<void>* h;
SpecialisesVoid<int> i;
SpecialisesVoid<long> l;
SpecialisesVoid<unsigned int> u;
};
class DLL_API HasAbstractOperator

Loading…
Cancel
Save