|
|
@ -75,61 +75,23 @@ namespace CppSharp.Generators.CSharp |
|
|
|
public static string GetSuffixForInternal(ClassTemplateSpecialization specialization, |
|
|
|
public static string GetSuffixForInternal(ClassTemplateSpecialization specialization, |
|
|
|
CSharpTypePrinter typePrinter, bool nested = false) |
|
|
|
CSharpTypePrinter typePrinter, bool nested = false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!nested && |
|
|
|
if (specialization.TemplatedDecl.TemplatedClass.Fields.All( |
|
|
|
specialization.TemplatedDecl.TemplatedClass.Fields.All( |
|
|
|
f => !(f.Type.Desugar() is TemplateParameterType))) |
|
|
|
f => !(f.Type.Desugar() is TemplateParameterType))) |
|
|
|
|
|
|
|
return string.Empty; |
|
|
|
return string.Empty; |
|
|
|
|
|
|
|
|
|
|
|
if (!nested && |
|
|
|
if (specialization.Arguments.All( |
|
|
|
specialization.Arguments.All( |
|
|
|
|
|
|
|
a => a.Type.Type != null && a.Type.Type.IsAddress())) |
|
|
|
a => a.Type.Type != null && a.Type.Type.IsAddress())) |
|
|
|
return "_Ptr"; |
|
|
|
return "_Ptr"; |
|
|
|
|
|
|
|
|
|
|
|
// we don't want internals in the names of internals :)
|
|
|
|
var suffixBuilder = new StringBuilder(specialization.USR); |
|
|
|
if (!nested) |
|
|
|
for (int i = 0; i < suffixBuilder.Length; i++) |
|
|
|
{ |
|
|
|
if (!char.IsLetterOrDigit(suffixBuilder[i])) |
|
|
|
typePrinter.PushContext(CSharpTypePrinterContextKind.Managed); |
|
|
|
suffixBuilder[i] = '_'; |
|
|
|
typePrinter.PushMarshalKind(CSharpMarshalKind.Unknown); |
|
|
|
const int maxCSharpIdentifierLength = 480; |
|
|
|
} |
|
|
|
if (suffixBuilder.Length > maxCSharpIdentifierLength) |
|
|
|
var cppTypePrinter = new CppTypePrinter(false) { PrintScopeKind = CppTypePrintScopeKind.Qualified }; |
|
|
|
return suffixBuilder.Remove(maxCSharpIdentifierLength, |
|
|
|
CSharpTypePrinter.AppendGlobal = false; |
|
|
|
suffixBuilder.Length - maxCSharpIdentifierLength).ToString(); |
|
|
|
var suffix = new StringBuilder(); |
|
|
|
return suffixBuilder.ToString(); |
|
|
|
foreach (var argType in from argType in specialization.Arguments |
|
|
|
|
|
|
|
where argType.Type.Type != null |
|
|
|
|
|
|
|
select argType.Type.Type) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
suffix.Append('_'); |
|
|
|
|
|
|
|
ClassTemplateSpecialization nestedSpecialization; |
|
|
|
|
|
|
|
if (argType.TryGetDeclaration(out nestedSpecialization)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
suffix.Append(typePrinter.GetNestedQualifiedName(nestedSpecialization)); |
|
|
|
|
|
|
|
suffix.Append(GetSuffixForInternal(nestedSpecialization, typePrinter, true)); |
|
|
|
|
|
|
|
CSharpTypePrinter.AppendGlobal = false; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Class @class; |
|
|
|
|
|
|
|
if (argType.TryGetClass(out @class)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
nestedSpecialization = @class.Namespace as ClassTemplateSpecialization; |
|
|
|
|
|
|
|
if (nestedSpecialization != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
suffix.Append(typePrinter.GetNestedQualifiedName(nestedSpecialization)); |
|
|
|
|
|
|
|
suffix.Append(GetSuffixForInternal(nestedSpecialization, typePrinter, true)); |
|
|
|
|
|
|
|
CSharpTypePrinter.AppendGlobal = false; |
|
|
|
|
|
|
|
suffix.Append('_'); |
|
|
|
|
|
|
|
suffix.Append(@class.Name); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
suffix.Append(argType.Visit(cppTypePrinter)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!nested) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
typePrinter.PopContext(); |
|
|
|
|
|
|
|
typePrinter.PopMarshalKind(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
CSharpTypePrinter.AppendGlobal = true; |
|
|
|
|
|
|
|
return FormatTypesStringForIdentifier(suffix); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|