public override TypePrinterResult VisitTemplateSpecializationType( TemplateSpecializationType template, TypeQualifiers quals) { var decl = template.GetClassTemplateSpecialization() ?? template.Template.TemplatedDecl; TypeMap typeMap; if (!TypeMapDatabase.FindTypeMap(template, out typeMap)) { return(decl.Visit(this)); } typeMap.Declaration = decl; typeMap.Type = template; TypePrinterContext.Type = template; TypePrinterContext.CSharpKind = ContextKind; TypePrinterContext.MarshalKind = MarshalKind; var type = GetCSharpSignature(typeMap); if (!string.IsNullOrEmpty(type)) { return(new TypePrinterResult { Type = type, TypeMap = typeMap }); } return(decl.Visit(this)); }
public override TypePrinterResult VisitTemplateSpecializationType( TemplateSpecializationType template, TypeQualifiers quals) { var decl = template.GetClassTemplateSpecialization() ?? template.Template.TemplatedDecl; TypeMap typeMap; if (!TypeMapDatabase.FindTypeMap(template, out typeMap)) { if (ContextKind == TypePrinterContextKind.Managed && decl == template.Template.TemplatedDecl && template.Arguments.All(IsValid)) { List <TemplateArgument> args = template.Arguments; var @class = (Class)template.Template.TemplatedDecl; TemplateArgument lastArg = args.Last(); return($@"{VisitDeclaration(decl)}<{string.Join(", ", args.Concat(Enumerable.Range(0, @class.TemplateParameters.Count - args.Count).Select( i => lastArg)).Select(this.VisitTemplateArgument))}>"); } if (ContextKind == TypePrinterContextKind.Native) { return(template.Desugared.Visit(this)); } return(decl.Visit(this)); } typeMap.Declaration = decl; typeMap.Type = template; var typePrinterContext = new TypePrinterContext { Type = template, Kind = ContextKind, MarshalKind = MarshalKind }; var type = typeMap.CSharpSignature(typePrinterContext); if (!string.IsNullOrEmpty(type)) { return(new TypePrinterResult { Type = type, TypeMap = typeMap }); } return(decl.Visit(this)); }
public override TypePrinterResult VisitTemplateSpecializationType(TemplateSpecializationType template, TypeQualifiers quals) { var specialization = template.GetClassTemplateSpecialization(); if (specialization == null) { return(string.Empty); } var qual = GetStringQuals(quals); return($"{qual}{VisitClassTemplateSpecializationDecl(specialization)}"); }
public override TypePrinterResult VisitTemplateSpecializationType( TemplateSpecializationType template, TypeQualifiers quals) { var decl = template.GetClassTemplateSpecialization() ?? template.Template.TemplatedDecl; TypeMap typeMap; if (!TypeMapDatabase.FindTypeMap(template, out typeMap)) { if (ContextKind == TypePrinterContextKind.Managed && decl == template.Template.TemplatedDecl && template.Arguments.All(IsValid)) { return($@"{VisitDeclaration(decl)}<{string.Join(", ", template.Arguments.Select(VisitTemplateArgument))}>"); } if (ContextKind == TypePrinterContextKind.Native) { return(template.Desugared.Visit(this)); } return(decl.Visit(this)); } typeMap.Declaration = decl; typeMap.Type = template; var typePrinterContext = new TypePrinterContext { Type = template, Kind = ContextKind, MarshalKind = MarshalKind }; var type = typeMap.CSharpSignature(typePrinterContext); if (!string.IsNullOrEmpty(type)) { return(new TypePrinterResult { Type = type, TypeMap = typeMap }); } return(decl.Visit(this)); }
public virtual bool VisitTemplateSpecializationType(TemplateSpecializationType template, TypeQualifiers quals) { if (!VisitType(template, quals)) { return(false); } if (VisitOptions.VisitTemplateArguments) { foreach (var arg in template.Arguments) { switch (arg.Kind) { case TemplateArgument.ArgumentKind.Type: var type = arg.Type.Type; if (type != null) { type.Visit(this, arg.Type.Qualifiers); } break; case TemplateArgument.ArgumentKind.Declaration: arg.Declaration.Visit(this); break; } } } if (template.IsDependent && template.Template != null) { var @class = template.Template.TemplatedDecl as Class; if (@class != null) { return(@class.Specializations.Any(s => s.Visit(this))); } return(template.Template.Visit(this)); } var specialization = template.GetClassTemplateSpecialization(); return(specialization != null && specialization.Visit(this)); }
public CSharpTypePrinterResult VisitTemplateSpecializationType( TemplateSpecializationType template, TypeQualifiers quals) { var decl = template.Template.TemplatedDecl; TypeMap typeMap; if (!TypeMapDatabase.FindTypeMap(template, out typeMap)) { if (ContextKind != CSharpTypePrinterContextKind.Native) { return(GetNestedQualifiedName(decl)); } if (template.Desugared.Type.IsAddress()) { return(template.Desugared.Type.ToString()); } var specialization = template.GetClassTemplateSpecialization(); return(specialization.Visit(this)); } typeMap.Declaration = decl; typeMap.Type = template; TypePrinterContext.Type = template; TypePrinterContext.CSharpKind = ContextKind; TypePrinterContext.MarshalKind = MarshalKind; var type = GetCSharpSignature(typeMap); if (!string.IsNullOrEmpty(type)) { return(new CSharpTypePrinterResult { Type = type, TypeMap = typeMap }); } return(GetNestedQualifiedName(decl) + (ContextKind == CSharpTypePrinterContextKind.Native ? Helpers.InternalStruct : string.Empty)); }
public override bool VisitTemplateSpecializationType( TemplateSpecializationType template, TypeQualifiers quals) { TypeMap typeMap; if (TypeMapDatabase.FindTypeMap(template, out typeMap)) { if (typeMap.IsIgnored) { Ignore(); } return(false); } var specialization = template.GetClassTemplateSpecialization(); if (specialization == null || specialization.Ignore) { Ignore(); } return(base.VisitTemplateSpecializationType(template, quals)); }
public override bool VisitTemplateSpecializationType( TemplateSpecializationType template, TypeQualifiers quals) { TypeMap typeMap; if (TypeMapDatabase.FindTypeMap(template, out typeMap)) { if (typeMap.IsIgnored) Ignore(); return false; } var specialization = template.GetClassTemplateSpecialization(); if (specialization == null || specialization.Ignore) Ignore(); return base.VisitTemplateSpecializationType(template, quals); }