public string GetName(CppSharp.AST.Type type, TypeNameKind kind = TypeNameKind.Native) { if (kind == TypeNameKind.Native) { return(type.Visit(NativePrinter)); } string retVal = type switch { TypedefType tdt when tdt.Declaration.Name == "LLVMBool" => "bool", PointerType pt when pt.Pointee is BuiltinType => $"{base.ToString( pt.Pointee )}*", // shouldn't see this... Should be caught as an error... TypedefType tdt when tdt.Declaration.Name == "intptr_t" => "global::System.IntPtr", TypedefType tdt when tdt.Declaration.Name == "uintptr_t" => "global::System.UIntPtr", TypedefType tdt when tdt.Declaration.Name == "uint8_t" => "global::System.Byte", TypedefType tdt when(ShouldBeUInt32(tdt)) => "global::System.UInt32", TypedefType tdt when(ShouldBeUInt64(tdt)) => "global::System.UInt64", TypedefType tdt when tdt.Declaration.Name == "int8_t" => "global::System.SByte", TypedefType tdt when tdt.Declaration.Name == "int32_t" => "global::System.Int32", TypedefType tdt when tdt.Declaration.Name == "int64_t" => "global::System.Int64", TypedefType tdt => tdt.Declaration.Name, BuiltinType bit when bit.Type == PrimitiveType.IntPtr => "global::System.IntPtr", CppSharp.AST.Type t when t.TryGetHandleDecl(out TypedefNameDecl decl) => decl.Name, ArrayType at => $"{GetName( at.Type, kind )}[]", _ => base.ToString(type), }; return(retVal); }
public static string GetName(this IType type, TypeNameKind kind) { switch (kind) { case TypeNameKind.DisplayName: return(type.DisplayName); case TypeNameKind.FullName: return(type.FullName); case TypeNameKind.Key: return(type.Key); case TypeNameKind.Name: return(type.Name); case TypeNameKind.NestedName: return(type.NestedName); case TypeNameKind.SigName: return(type.SigName); case TypeNameKind.CSharpKeyword: return(type.CSharpKeyword()); } return(type.FullName); }
string GetCachedName(TypeNameKind kind) { switch (kind) { case TypeNameKind.SerializationName: return(ToString()); default: throw new NotImplementedException(); } }
internal static string BuildString <T>(this IEnumerable <T> args, TypeNameKind kind, bool clr) where T : IType { bool sig = kind == TypeNameKind.SigName; string prefix, suffix, sep; if (sig) { prefix = SigPrefix; suffix = SigSuffix; sep = "_"; } else { prefix = clr ? "[" : "<"; suffix = clr ? "]" : ">"; sep = ","; } return(args.Join(prefix, suffix, sep, x => x.GetName(kind))); }
private string EvalNameBase(TypeNameKind kind) { switch (kind) { case TypeNameKind.DisplayName: return(TypeNameExtensions.ToDisplayName(Type.FullName)); case TypeNameKind.FullName: return(Type.FullName); case TypeNameKind.SigName: return(Type.SigName); case TypeNameKind.Key: return(Type.FullName); case TypeNameKind.Name: return(Type.Name); case TypeNameKind.NestedName: return(Type.NestedName); } return(Type.FullName); }
string GetCachedName (TypeNameKind kind) { switch (kind) { case TypeNameKind.SerializationName: return ToString (); default: throw new NotImplementedException (); } }
private string EvalName(TypeNameKind kind, TypeNameKind argKind, bool clr) { return(EvalNameBase(kind) + _args.BuildString(argKind, clr)); }
private string EvalName(TypeNameKind kind, TypeNameKind argKind) { return(EvalName(kind, argKind, true)); }