public override string CLISignature(TypePrinterContext ctx) { return("System::IO::TextWriter^"); }
public override string CLISignature(TypePrinterContext ctx) { return("System::String^"); }
public override string CLISignature(TypePrinterContext ctx) { throw new System.NotImplementedException(); }
public override Type CLISignatureType(TypePrinterContext ctx) { return(new CILType(typeof(string))); }
public override TypePrinterResult VisitPointerType(PointerType pointer, TypeQualifiers quals) { if (MarshalKind == MarshalKind.NativeField && !pointer.Pointee.IsEnumType()) { return(IntPtrType); } if (pointer.Pointee is FunctionType) { return(pointer.Pointee.Visit(this, quals)); } var isManagedContext = ContextKind == TypePrinterContextKind.Managed; if (allowStrings && pointer.IsConstCharString()) { TypeMap typeMap; TypeMapDatabase.FindTypeMap(pointer, out typeMap); var typePrinterContext = new TypePrinterContext() { Kind = Kind, MarshalKind = MarshalKind, Type = pointer.Pointee, Parameter = Parameter }; return(typeMap.CSharpSignatureType(typePrinterContext).Visit(this)); } var pointee = pointer.Pointee.Desugar(); if (isManagedContext && new QualifiedType(pointer, quals).IsConstRefToPrimitive()) { return(pointee.Visit(this)); } // From http://msdn.microsoft.com/en-us/library/y31yhkeb.aspx // Any of the following types may be a pointer type: // * sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, // decimal, or bool. // * Any enum type. // * Any pointer type. // * Any user-defined struct type that contains fields of unmanaged types only. var finalPointee = (pointee.GetFinalPointee() ?? pointee).Desugar(); Enumeration @enum; if (finalPointee.IsPrimitiveType() || finalPointee.TryGetEnum(out @enum)) { // Skip one indirection if passed by reference bool isRefParam = Parameter != null && (Parameter.IsOut || Parameter.IsInOut); if (isManagedContext && isRefParam) { return(pointer.QualifiedPointee.Visit(this)); } if (pointee.IsPrimitiveType(PrimitiveType.Void)) { return(IntPtrType); } if (pointee.IsConstCharString() && isRefParam) { return(IntPtrType + "*"); } // Do not allow strings inside primitive arrays case, else we'll get invalid types // like string* for const char **. allowStrings = isRefParam; var result = pointer.QualifiedPointee.Visit(this); allowStrings = true; string @ref = Parameter != null && Parameter.IsIndirect ? string.Empty : "*"; return(!isRefParam && result.Type == this.IntPtrType ? "void**" : result + @ref); } Class @class; if ((pointee.IsDependent || pointee.TryGetClass(out @class)) && ContextKind == TypePrinterContextKind.Native) { return(IntPtrType); } return(pointer.QualifiedPointee.Visit(this)); }
public override Type CSharpSignatureType(TypePrinterContext ctx) { return(new CILType(ctx.Kind == TypePrinterContextKind.Native || !Options.MarshalCharAsManagedChar ? typeof(sbyte) : typeof(char))); }
public override Type CLISignatureType(TypePrinterContext ctx) { return(new CustomType( $"::System::Collections::Generic::List<{ctx.GetTemplateParameterList()}>^")); }
public override Type CSharpSignatureType(TypePrinterContext ctx) { return(new BuiltinType(PrimitiveType.Bool)); }
public override Type CSharpSignatureType(TypePrinterContext ctx) { return(GetEnumType(ctx.Type)); }
public override string CSharpSignature(TypePrinterContext ctx) { // doesn't matter, we just need it to compile return("int"); }
public override Type CLISignatureType(TypePrinterContext ctx) { return(new CustomType("CLI::Employee^")); }
public override Type CSharpSignatureType(TypePrinterContext ctx) { return(new TagType(new Enumeration())); }
public override string CSharpSignature(TypePrinterContext ctx) { return(CSharpSignatureType(ctx).ToString()); }
public override Type CLISignatureType(TypePrinterContext ctx) { return(new BuiltinType(PrimitiveType.UShort)); }
public override string CSharpSignature(TypePrinterContext ctx) { return(CSharpTypePrinter.IntPtrType); }
public override Type CSharpSignatureType(TypePrinterContext ctx) { return(new TagType(flags ?? (flags = Context.ASTContext.FindEnum("Flags").First()))); }
private bool?CheckForDefaultConstruct(Type desugared, ExpressionObsolete expression, ref string result) { var type = desugared.GetFinalPointee() ?? desugared; Class decl; if (!type.TryGetClass(out decl)) { return(false); } var ctor = expression as CXXConstructExprObsolete; var typePrinter = new CSharpTypePrinter(Context); typePrinter.PushMarshalKind(MarshalKind.DefaultExpression); var typePrinterResult = type.Visit(typePrinter).Type; TypeMap typeMap; if (TypeMaps.FindTypeMap(type, out typeMap)) { var typePrinterContext = new TypePrinterContext() { Kind = typePrinter.Kind, MarshalKind = typePrinter.MarshalKind, Type = type }; var typeInSignature = typeMap.CSharpSignatureType(typePrinterContext) .SkipPointerRefs().Desugar(); Enumeration @enum; if (typeInSignature.TryGetEnum(out @enum)) { if (ctor != null && (ctor.Arguments.Count == 0 || HasSingleZeroArgExpression((Function)ctor.Declaration))) { result = "0"; return(true); } return(false); } if (ctor != null && typePrinterResult == "string" && ctor.Arguments.Count == 0) { result = "\"\""; return(true); } } if (ctor == null) { CheckForSimpleExpressions(expression, ref result, desugared); return(decl.IsValueType ? (bool?)false : null); } var method = (Method)expression.Declaration; var expressionSupported = decl.IsValueType && method.Parameters.Count == 0; if (expression.String.Contains('(') || expression.String.StartsWith("{")) { var argsBuilder = new StringBuilder("new "); argsBuilder.Append(typePrinterResult); argsBuilder.Append('('); for (var i = 0; i < ctor.Arguments.Count; i++) { var argument = ctor.Arguments[i]; var argResult = argument.String; expressionSupported &= PrintExpression(method, method.Parameters[i].Type.Desugar(), argument, ref argResult) ?? false; argsBuilder.Append(argResult); if (i < ctor.Arguments.Count - 1) { argsBuilder.Append(", "); } } argsBuilder.Append(')'); result = argsBuilder.ToString(); } return(expressionSupported ? true : (bool?)null); }
public override Type CSharpSignatureType(TypePrinterContext ctx) { // doesn't matter, we just need it to compile return(new BuiltinType(PrimitiveType.Int)); }
public override Type CSharpSignatureType(TypePrinterContext ctx) { return(new CILType(typeof(char))); }
public override string CSharpSignature(TypePrinterContext ctx) { return("va_list"); }
public override Type CLISignatureType(TypePrinterContext ctx) { return(new CILType(typeof(System.IO.TextWriter))); }
public override string CLISignature(TypePrinterContext ctx) { return(string.Format("System::Collections::Generic::List<{0}>^", ctx.GetTemplateParameterList())); }
public override Type CSharpSignatureType(TypePrinterContext ctx) => CSharpTypePrinter.GetUnsignedType(Context.TargetInfo.LongWidth);
public override TypePrinterResult VisitPointerType(PointerType pointer, TypeQualifiers quals) { TypeMap typeMap; if (Context.TypeMaps.FindTypeMap(pointer.Desugar(), out typeMap)) { var typePrinterContext = new TypePrinterContext { Kind = ContextKind, MarshalKind = MarshalKind, Type = pointer }; return(typeMap.CLISignatureType(typePrinterContext).Visit(this)); } var pointee = pointer.Pointee.Desugar(); if (pointee is FunctionType) { var function = pointee as FunctionType; return($"{function.Visit(this, quals)}^"); } // From http://msdn.microsoft.com/en-us/library/y31yhkeb.aspx // Any of the following types may be a pointer type: // * sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, decimal, or bool. // * Any enum type. // * Any pointer type. // * Any user-defined struct type that contains fields of unmanaged types only. var finalPointee = pointer.GetFinalPointee(); if (finalPointee.IsPrimitiveType()) { // Skip one indirection if passed by reference bool isRefParam = Parameter != null && (Parameter.IsOut || Parameter.IsInOut); if (isRefParam) { return(pointer.QualifiedPointee.Visit(this)); } if (pointee.IsPrimitiveType(PrimitiveType.Void)) { return("::System::IntPtr"); } var result = pointer.QualifiedPointee.Visit(this).ToString(); return(!isRefParam && result == "::System::IntPtr" ? "void**" : result + (pointer.IsReference ? "" : "*")); } Enumeration @enum; if (pointee.TryGetEnum(out @enum)) { var typeName = VisitDeclaration(@enum, quals); // Skip one indirection if passed by reference if (Parameter != null && (Parameter.Type.IsReference() || ((Parameter.IsOut || Parameter.IsInOut) && pointee == finalPointee))) { return(typeName); } return($"{typeName}*"); } return(pointer.QualifiedPointee.Visit(this)); }