Browse Source

Shortened the delegates used in the C# end.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/818/head
Dimitar Dobrev 9 years ago
parent
commit
d9ffb1b5af
  1. 6
      src/Generator/Generators/CSharp/CSharpSources.cs
  2. 14
      src/Generator/Passes/DelegatesPass.cs

6
src/Generator/Generators/CSharp/CSharpSources.cs

@ -67,12 +67,6 @@ namespace CppSharp.Generators.CSharp @@ -67,12 +67,6 @@ namespace CppSharp.Generators.CSharp
}
}
public static string FormatTypesStringForIdentifier(StringBuilder types)
{
return types.Replace("global::System.", string.Empty).Replace("*", "Ptr")
.Replace('.', '_').Replace(' ', '_').Replace("::", "_").ToString();
}
public static string GetSuffixForInternal(Declaration context)
{
var specialization = context as ClassTemplateSpecialization;

14
src/Generator/Passes/DelegatesPass.cs

@ -155,13 +155,19 @@ namespace CppSharp.Passes @@ -155,13 +155,19 @@ namespace CppSharp.Passes
}
if (typesBuilder.Length > 0)
typesBuilder.Remove(typesBuilder.Length - 1, 1);
var delegateName = Helpers.FormatTypesStringForIdentifier(typesBuilder);
var delegateName = FormatTypesStringForIdentifier(typesBuilder);
if (returnType.Type.IsPrimitiveType(PrimitiveType.Void))
delegateName = "Action_" + delegateName;
delegateName.Insert(0, "Action_");
else
delegateName = "Func_" + delegateName;
delegateName.Insert(0, "Func_");
return delegateName;
return delegateName.ToString();
}
private static StringBuilder FormatTypesStringForIdentifier(StringBuilder types)
{
return types.Replace("global::System.", string.Empty).Replace("global::", string.Empty)
.Replace("*", "Ptr").Replace('.', '_').Replace(' ', '_').Replace("::", "_");
}
private CSharpTypePrinter TypePrinter

Loading…
Cancel
Save