Exemplo n.º 1
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            var type = Type as TemplateSpecializationType;

            return(string.Format("System.Collections.Generic.Dictionary<{0}, {1}>",
                                 type.Arguments[0].Type, type.Arguments[1].Type));
        }
Exemplo n.º 2
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
                return "Std.Vector";

            return string.Format("Std.Vector<{0}>", ctx.GetTemplateParameterList());
        }
Exemplo n.º 3
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            TemplateArgument templateArgument =
                ((TemplateSpecializationType)ctx.Type.Desugar()).Arguments[0];

            return(templateArgument.Type.Type.ToString());
        }
Exemplo n.º 4
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
     {
         return(string.Format("QtCore.QString.{0}{1}", Helpers.InternalStruct, ctx.Type.IsAddress() ? "*" : string.Empty));
     }
     return("string");
 }
Exemplo n.º 5
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
     {
         return string.Format("QtCore.QString.{0}{1}", Helpers.InternalStruct, ctx.Type.IsAddress() ? "*" : string.Empty);
     }
     return "string";
 }
Exemplo n.º 6
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
                return Type.IsAddress() ? "QList.Internal*" : "QList.Internal";

            return string.Format("System.Collections.Generic.{0}<{1}>",
                ctx.MarshalKind == CSharpMarshalKind.DefaultExpression ? "List" : "IList",
                ctx.GetTemplateParameterList());
        }
Exemplo n.º 7
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     if (ctx.CSharpKind == CSharpTypePrinterContextKind.Managed)
         return "string";
     ClassTemplateSpecialization basicString = GetBasicString(ctx.Type);
     var typePrinter = new CSharpTypePrinter(null);
     typePrinter.PushContext(CSharpTypePrinterContextKind.Native);
     return basicString.Visit(typePrinter).Type;
 }
Exemplo n.º 8
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     if (ctx.CSharpKind == CSharpTypePrinterContextKind.Managed)
         return "string";
     ClassTemplateSpecialization basicString = GetBasicString(ctx.Type);
     var typePrinter = new CSharpTypePrinter(null);
     typePrinter.PushContext(CSharpTypePrinterContextKind.Native);
     return basicString.Visit(typePrinter).Type;
 }
Exemplo n.º 9
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
                return "Std.Map";

            var type = Type as TemplateSpecializationType;
            return string.Format("System.Collections.Generic.Dictionary<{0}, {1}>",
                type.Arguments[0].Type, type.Arguments[1].Type);
        }
        private bool?CheckForDefaultConstruct(Type desugared, Parameter parameter)
        {
            Method ctor = parameter.DefaultArgument.Declaration as Method;

            if (ctor == null || !ctor.IsConstructor)
            {
                return(false);
            }

            Type type;

            desugared.IsPointerTo(out type);
            type = type ?? desugared;
            Class decl;

            if (!type.TryGetClass(out decl))
            {
                return(false);
            }
            TypeMap typeMap;

            if (Driver.TypeDatabase.FindTypeMap(decl, type, out typeMap))
            {
                string mappedTo;
                if (Driver.Options.IsCSharpGenerator)
                {
                    var typePrinterContext = new CSharpTypePrinterContext
                    {
                        CSharpKind = CSharpTypePrinterContextKind.Managed,
                        Type       = type
                    };
                    mappedTo = typeMap.CSharpSignature(typePrinterContext);
                }
                else
                {
                    var typePrinterContext = new CLITypePrinterContext
                    {
                        Type = type
                    };
                    mappedTo = typeMap.CLISignature(typePrinterContext);
                }
                if (mappedTo == "string" && ctor.Parameters.Count == 0)
                {
                    parameter.DefaultArgument.String = "\"\"";
                    return(true);
                }
            }

            parameter.DefaultArgument.String = string.Format("new {0}", parameter.DefaultArgument.String);
            if (ctor.Parameters.Count > 0 && ctor.Parameters[0].OriginalName == "_0")
            {
                parameter.DefaultArgument.String = parameter.DefaultArgument.String.Replace("(0)", "()");
            }

            return(decl.IsValueType ? true : (bool?)null);
        }
Exemplo n.º 11
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
                return "Std.Map";

            var type = Type as TemplateSpecializationType;
            return string.Format(
                "System.Collections.Generic.Dictionary<{0}, {1}>",
                type.Arguments[0].Type, type.Arguments[1].Type);
        }
Exemplo n.º 12
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
            {
                return(Type.IsAddress() ? "QList.Internal*" : "QList.Internal");
            }

            return(string.Format("System.Collections.Generic.{0}<{1}>",
                                 ctx.CSharpKind == CSharpTypePrinterContextKind.DefaultExpression ? "List" : "IList",
                                 ctx.GetTemplateParameterList()));
        }
Exemplo n.º 13
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
            {
                return(string.Format("QList.{0}{1}", Helpers.InternalStruct,
                                     Type.IsAddress() ? "*" : string.Empty));
            }

            return(string.Format("System.Collections.Generic.{0}<{1}>",
                                 ctx.MarshalKind == CSharpMarshalKind.DefaultExpression ? "List" : "IList",
                                 ctx.GetTemplateParameterList()));
        }
Exemplo n.º 14
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
     {
         if (Type.IsAddress())
         {
             return("QList.Internal*");
         }
         return("QList.Internal");
     }
     return("QList");
 }
Exemplo n.º 15
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
     {
         if (ctx.Type.IsAddress())
         {
             return "QtCore.QString.Internal*";
         }
         return "QtCore.QString.Internal";
     }
     return "string";
 }
Exemplo n.º 16
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
            {
                // pointless, put just so that the generated code compiles
                return("global::System.IntPtr");
            }

            return(string.Format("System.Collections.Generic.{0}<{1}>",
                                 ctx.CSharpKind == CSharpTypePrinterContextKind.DefaultExpression ? "List" : "IList",
                                 ctx.GetTemplateParameterList()));
        }
Exemplo n.º 17
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            var type = Type as TemplateSpecializationType;
            var args = type.Arguments.Select(arg => arg.Type.ToString()).
                ToList();

            var output = "System.Action";

            if (args.Count > 0)
                output += string.Format("<{0}>", string.Join(", ", args));

            return output;
        }
Exemplo n.º 18
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            var type = Type as TemplateSpecializationType;
            var args = type.Arguments.Select(arg => arg.Type.ToString()).
                       ToList();

            var output = "System.Action";

            if (args.Count > 0)
            {
                output += string.Format("<{0}>", string.Join(", ", args));
            }

            return(output);
        }
Exemplo n.º 19
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            var fullType  = ctx.FullType.Type;
            var isPointer = (fullType != null) && (fullType is PointerType ||
                                                   fullType.Desugar() is TemplateSpecializationType);

            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native && isPointer)
            {
                return("global::System.IntPtr");
            }

            var type = Type as TemplateSpecializationType;

            return(string.Format("{0}", type.Arguments[0].Type));
        }
Exemplo n.º 20
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
            {
                if (ctx.FullType.Type is PointerType)
                {
                    return("Flood.ResourceHandle*");
                }

                // Handles only contain a single 32-bit unsigned int handle id.
                return("Flood.ResourceHandle");
            }

            var type = Type.Desugar() as TemplateSpecializationType;

            return(string.Format("Flood.ResourceHandle<{0}>",
                                 type.Arguments[0].Type));
        }
Exemplo n.º 21
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
            {
                if (Type.IsAddress())
                {
                    return("QList.Internal*");
                }
                return("QList.Internal");
            }

            TemplateSpecializationType templateSpecialization = (TemplateSpecializationType)ctx.Type.Desugar();
            TemplateArgument           templateArgument       = templateSpecialization.Arguments[0];

            if (templateArgument.Type.Type.IsPointerToPrimitiveType())
            {
                return("System.Collections.Generic.IList<global::System.IntPtr>");
            }
            return(string.Format("System.Collections.Generic.IList<{0}>", ctx.GetTemplateParameterList()));
        }
Exemplo n.º 22
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     return(CSharpSignatureType(ctx).ToString());
 }
Exemplo n.º 23
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
            {
                if (ctx.FullType.Type is PointerType)
                    return "Flood.ResourceHandle*";

                // Handles only contain a single 32-bit unsigned int handle id.
                return "Flood.ResourceHandle";
            }

            var type = Type.Desugar() as TemplateSpecializationType;
            return string.Format("Flood.ResourceHandle<{0}>",
                type.Arguments[0].Type);
        }
        private bool? CheckForDefaultConstruct(Type desugared, Parameter parameter)
        {
            Method ctor = parameter.DefaultArgument.Declaration as Method;
            if (ctor == null || !ctor.IsConstructor)
                return false;

            Type type;
            desugared.IsPointerTo(out type);
            type = type ?? desugared;
            Class decl;
            if (!type.TryGetClass(out decl))
                return false;
            TypeMap typeMap;

            if (Driver.TypeDatabase.FindTypeMap(decl, type, out typeMap))
            {
                string mappedTo;
                if (Driver.Options.IsCSharpGenerator)
                {
                    var typePrinterContext = new CSharpTypePrinterContext
                    {
                        CSharpKind = CSharpTypePrinterContextKind.Managed,
                        Type = type
                    };
                    mappedTo = typeMap.CSharpSignature(typePrinterContext);
                }
                else
                {
                    var typePrinterContext = new CLITypePrinterContext
                    {
                        Type = type
                    };
                    mappedTo = typeMap.CLISignature(typePrinterContext);
                }
                if (mappedTo == "string" && ctor.Parameters.Count == 0)
                {
                    parameter.DefaultArgument.String = "\"\"";
                    return true;
                }
            }

            parameter.DefaultArgument.String = string.Format("new {0}", parameter.DefaultArgument.String);
            if (ctor.Parameters.Count > 0 && ctor.Parameters[0].OriginalName == "_0")
                parameter.DefaultArgument.String = parameter.DefaultArgument.String.Replace("(0)", "()");

            return decl.IsValueType ? true : (bool?) null;
        }
Exemplo n.º 25
0
        public override Type CSharpSignatureType(CSharpTypePrinterContext ctx)
        {
            var templateArgument = ((TemplateSpecializationType)ctx.Type.Desugar()).Arguments[0];

            return(templateArgument.Type.Type);
        }
        private bool? CheckForDefaultConstruct(Type desugared, Expression arg)
        {
            // Unwrapping the underlying type behind a possible pointer/reference
            Type type;
            desugared.IsPointerTo(out type);
            type = type ?? desugared;

            Class decl;
            if (!type.TryGetClass(out decl))
                return false;

            var ctor = arg.Declaration as Method;

            TypeMap typeMap;
            if (Driver.TypeDatabase.FindTypeMap(decl, type, out typeMap))
            {
                Type typeInSignature;
                string mappedTo;
                if (Driver.Options.IsCSharpGenerator)
                {
                    var typePrinterContext = new CSharpTypePrinterContext
                    {
                        CSharpKind = CSharpTypePrinterContextKind.Managed,
                        Type = type
                    };
                    typeInSignature = typeMap.CSharpSignatureType(typePrinterContext).SkipPointerRefs();
                    mappedTo = typeMap.CSharpSignature(typePrinterContext);
                }
                else
                {
                    var typePrinterContext = new CLITypePrinterContext
                    {
                        Type = type
                    };
                    typeInSignature = typeMap.CLISignatureType(typePrinterContext).SkipPointerRefs();
                    mappedTo = typeMap.CLISignature(typePrinterContext);
                }
                Enumeration @enum;
                if (typeInSignature.TryGetEnum(out @enum))
                {
                    return false;
                }

                if (ctor == null || !ctor.IsConstructor)
                    return false;
                if (mappedTo == "string" && ctor.Parameters.Count == 0)
                {
                    arg.String = "\"\"";
                    return true;
                }
            }

            if (regexCtor.IsMatch(arg.String))
            {
                arg.String = string.Format("new {0}", arg.String);
                if (ctor != null && ctor.Parameters.Count > 0 && ctor.Parameters[0].Type.IsAddress())
                {
                    arg.String = arg.String.Replace("(0)", "()");
                    return decl.IsValueType ? true : (bool?) null;
                }
            }
            else
            {
                if (ctor != null && ctor.Parameters.Count > 0)
                {
                    var finalPointee = ctor.Parameters[0].Type.SkipPointerRefs().Desugar();
                    Enumeration @enum;
                    if (finalPointee.TryGetEnum(out @enum))
                        TranslateEnumExpression(arg, finalPointee, arg.String);
                }
            }

            return decl.IsValueType ? true : (bool?) null;
        }
Exemplo n.º 27
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
                return "Std.Vector";

            return string.Format("Std.Vector<{0}>", ctx.GetTemplateParameterList());
        }
Exemplo n.º 28
0
 public override Type CSharpSignatureType(CSharpTypePrinterContext ctx)
 {
     return GetEnumType(ctx.Type);
 }
Exemplo n.º 29
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     return string.Empty;
 }
Exemplo n.º 30
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
                // pointless, put just so that the generated code compiles
                return "global::System.IntPtr";

            return string.Format("System.Collections.Generic.{0}<{1}>",
                ctx.CSharpKind == CSharpTypePrinterContextKind.DefaultExpression ? "List" : "IList",
                ctx.GetTemplateParameterList());
        }
Exemplo n.º 31
0
 public override Type CSharpSignatureType(CSharpTypePrinterContext ctx)
 {
     var type = ctx.Type.Desugar();
     ClassTemplateSpecialization classTemplateSpecialization;
     var templateSpecializationType = type as TemplateSpecializationType;
     if (templateSpecializationType != null)
         classTemplateSpecialization = templateSpecializationType.GetClassTemplateSpecialization();
     else
         classTemplateSpecialization = (ClassTemplateSpecialization) ((TagType) type).Declaration;
     return classTemplateSpecialization.Arguments[0].Type.Type;
 }
Exemplo n.º 32
0
 public virtual Type CSharpSignatureType(CSharpTypePrinterContext ctx)
 {
     return new CILType(typeof(object));
 }
Exemplo n.º 33
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     return "global::System.IntPtr";
 }
Exemplo n.º 34
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     return("global::System.IntPtr");
 }
Exemplo n.º 35
0
        private bool? CheckForDefaultConstruct(Type desugared, Statement arg,
            TypeQualifiers qualifiers)
        {
            // Unwrapping the underlying type behind a possible pointer/reference
            Type type = desugared.GetFinalPointee() ?? desugared;

            Class decl;
            if (!type.TryGetClass(out decl))
                return false;

            var ctor = arg.Declaration as Method;

            TypeMap typeMap;
            var typePrinterContext = new CSharpTypePrinterContext
            {
                CSharpKind = CSharpTypePrinterContextKind.DefaultExpression,
                Type = type
            };

            string typePrinterResult = null;
            if (Driver.TypeDatabase.FindTypeMap(decl, type, out typeMap))
            {
                var typeInSignature = typeMap.CSharpSignatureType(
                    typePrinterContext).SkipPointerRefs().Desugar();
                Enumeration @enum;
                if (typeInSignature.TryGetEnum(out @enum))
                    return false;

                if (ctor == null || !ctor.IsConstructor)
                    return false;

                typePrinterResult = typeMap.CSharpSignature(typePrinterContext);
                if (typePrinterResult == "string" && ctor.Parameters.Count == 0)
                {
                    arg.String = "\"\"";
                    return true;
                }
            }

            var match = regexCtor.Match(arg.String);
            if (match.Success)
            {
                if (ctor != null)
                {
                    var templateSpecializationType = type as TemplateSpecializationType;
                    var typePrinter = new CSharpTypePrinter(Driver);
                    typePrinterResult = typePrinterResult ?? (templateSpecializationType != null
                        ? typePrinter.VisitTemplateSpecializationType(
                            templateSpecializationType, qualifiers)
                        : typePrinter.VisitClassDecl((Class) ctor.Namespace)).Type;

                    arg.String = string.Format("new {0}{1}", typePrinterResult,
                        match.Groups[2].Value);
                    if (ctor.Parameters.Count > 0 && ctor.Parameters[0].Type.IsAddress())
                        arg.String = arg.String.Replace("(0)", "()");
                }
                else
                    arg.String = string.Format("new {0}", arg.String);
            }
            else
            {
                if (ctor != null && ctor.Parameters.Count > 0)
                {
                    var finalPointee = ctor.Parameters[0].Type.SkipPointerRefs().Desugar();
                    Enumeration @enum;
                    if (finalPointee.TryGetEnum(out @enum))
                        TranslateEnumExpression(ctor, arg, finalPointee, arg.String);
                }
            }

            return decl.IsValueType ? true : (bool?) null;
        }
Exemplo n.º 36
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     var type = Type as TemplateSpecializationType;
     return string.Format("System.Collections.Generic.List<{0}>",
         type.Arguments[0].Type);
 }
Exemplo n.º 37
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     return "va_list";
 }
Exemplo n.º 38
0
 public virtual string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 39
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     return CSharpTypePrinter.IntPtrType;
 }
Exemplo n.º 40
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     return this.CSharpSignatureType(ctx).ToString();
 }
Exemplo n.º 41
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     return("string");
 }
Exemplo n.º 42
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     TemplateArgument templateArgument =
         ((TemplateSpecializationType) ctx.Type.Desugar()).Arguments[0];
     return templateArgument.Type.Type.ToString();
 }
Exemplo n.º 43
0
 public override Type CSharpSignatureType(CSharpTypePrinterContext ctx)
 {
     return(new TagType(new Enumeration()));
 }
Exemplo n.º 44
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     // doesn't matter, we just need it to compile
     return("int");
 }
Exemplo n.º 45
0
 public virtual Type CSharpSignatureType(CSharpTypePrinterContext ctx)
 {
     return(new CILType(typeof(object)));
 }
Exemplo n.º 46
0
        private bool?CheckForDefaultConstruct(Type desugared, Expression arg, TypeQualifiers qualifiers)
        {
            // Unwrapping the underlying type behind a possible pointer/reference
            Type type = desugared.GetFinalPointee() ?? desugared;

            Class decl;

            if (!type.TryGetClass(out decl))
            {
                return(false);
            }

            var ctor = arg.Declaration as Method;

            TypeMap typeMap;
            var     typePrinterContext = new CSharpTypePrinterContext
            {
                CSharpKind = CSharpTypePrinterContextKind.DefaultExpression,
                Type       = type
            };

            string typePrinterResult = null;

            if (Driver.TypeDatabase.FindTypeMap(decl, type, out typeMap))
            {
                var         typeInSignature = typeMap.CSharpSignatureType(typePrinterContext).SkipPointerRefs();
                Enumeration @enum;
                if (typeInSignature.TryGetEnum(out @enum))
                {
                    return(false);
                }

                if (ctor == null || !ctor.IsConstructor)
                {
                    return(false);
                }

                typePrinterResult = typeMap.CSharpSignature(typePrinterContext);
                if (typePrinterResult == "string" && ctor.Parameters.Count == 0)
                {
                    arg.String = "\"\"";
                    return(true);
                }
            }

            var match = regexCtor.Match(arg.String);

            if (match.Success)
            {
                if (ctor != null)
                {
                    var templateSpecializationType = type as TemplateSpecializationType;
                    var typePrinter = new CSharpTypePrinter(Driver);
                    typePrinterResult = typePrinterResult ?? (templateSpecializationType != null
                        ? typePrinter.VisitTemplateSpecializationType(templateSpecializationType, qualifiers)
                        : typePrinter.VisitClassDecl((Class)ctor.Namespace)).Type;

                    arg.String = string.Format("new {0}{1}", typePrinterResult, match.Groups[2].Value);
                    if (ctor.Parameters.Count > 0 && ctor.Parameters[0].Type.IsAddress())
                    {
                        arg.String = arg.String.Replace("(0)", "()");
                    }
                }
                else
                {
                    arg.String = string.Format("new {0}", arg.String);
                }
            }
            else
            {
                if (ctor != null && ctor.Parameters.Count > 0)
                {
                    var         finalPointee = ctor.Parameters[0].Type.SkipPointerRefs().Desugar();
                    Enumeration @enum;
                    if (finalPointee.TryGetEnum(out @enum))
                    {
                        TranslateEnumExpression(arg, finalPointee, arg.String);
                    }
                }
            }

            return(decl.IsValueType ? true : (bool?)null);
        }
Exemplo n.º 47
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     // doesn't matter, we just need it to compile
     return "int";
 }
Exemplo n.º 48
0
 public virtual string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 49
0
 public override Type CSharpSignatureType(CSharpTypePrinterContext ctx)
 {
     var templateArgument = ((TemplateSpecializationType) ctx.Type.Desugar()).Arguments[0];
     return templateArgument.Type.Type;
 }
        private bool?CheckForDefaultConstruct(Type desugared, Expression arg)
        {
            // Unwrapping the underlying type behind a possible pointer/reference
            Type type;

            desugared.IsPointerTo(out type);
            type = type ?? desugared;

            Class decl;

            if (!type.TryGetClass(out decl))
            {
                return(false);
            }

            var ctor = arg.Declaration as Method;

            TypeMap typeMap;

            if (Driver.TypeDatabase.FindTypeMap(decl, type, out typeMap))
            {
                Type   typeInSignature;
                string mappedTo;
                if (Driver.Options.IsCSharpGenerator)
                {
                    var typePrinterContext = new CSharpTypePrinterContext
                    {
                        CSharpKind = CSharpTypePrinterContextKind.Managed,
                        Type       = type
                    };
                    typeInSignature = typeMap.CSharpSignatureType(typePrinterContext).SkipPointerRefs();
                    mappedTo        = typeMap.CSharpSignature(typePrinterContext);
                }
                else
                {
                    var typePrinterContext = new CLITypePrinterContext
                    {
                        Type = type
                    };
                    typeInSignature = typeMap.CLISignatureType(typePrinterContext).SkipPointerRefs();
                    mappedTo        = typeMap.CLISignature(typePrinterContext);
                }
                Enumeration @enum;
                if (typeInSignature.TryGetEnum(out @enum))
                {
                    return(false);
                }

                if (ctor == null || !ctor.IsConstructor)
                {
                    return(false);
                }
                if (mappedTo == "string" && ctor.Parameters.Count == 0)
                {
                    arg.String = "\"\"";
                    return(true);
                }
            }

            if (regexCtor.IsMatch(arg.String))
            {
                arg.String = string.Format("new {0}", arg.String);
                if (ctor != null && ctor.Parameters.Count > 0 && ctor.Parameters[0].Type.IsAddress())
                {
                    arg.String = arg.String.Replace("(0)", "()");
                    return(decl.IsValueType ? true : (bool?)null);
                }
            }
            else
            {
                if (ctor != null && ctor.Parameters.Count > 0)
                {
                    var         finalPointee = ctor.Parameters[0].Type.SkipPointerRefs().Desugar();
                    Enumeration @enum;
                    if (finalPointee.TryGetEnum(out @enum))
                    {
                        TranslateEnumExpression(arg, finalPointee, arg.String);
                    }
                }
            }

            return(decl.IsValueType ? true : (bool?)null);
        }
Exemplo n.º 51
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     return "va_list";
 }
Exemplo n.º 52
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     return "Std.String";
 }
Exemplo n.º 53
0
 public override Type CSharpSignatureType(CSharpTypePrinterContext ctx)
 {
     return(GetEnumType(ctx.Type));
 }
Exemplo n.º 54
0
 public override string CSharpSignature(CSharpTypePrinterContext ctx)
 {
     return(CSharpTypePrinter.IntPtrType);
 }
Exemplo n.º 55
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
            {
                if (Type.IsAddress())
                {
                    return "QList.Internal*";
                }
                return "QList.Internal";
            }

            TemplateSpecializationType templateSpecialization = (TemplateSpecializationType) ctx.Type.Desugar();
            TemplateArgument templateArgument = templateSpecialization.Arguments[0];
            if (templateArgument.Type.Type.IsPointerToPrimitiveType())
            {
                return "System.Collections.Generic.IList<global::System.IntPtr>";
            }
            return string.Format("System.Collections.Generic.IList<{0}>", ctx.GetTemplateParameterList());
        }
Exemplo n.º 56
0
        public override string CSharpSignature(CSharpTypePrinterContext ctx)
        {
            var fullType = ctx.FullType.Type;
            var isPointer = (fullType != null) && (fullType is PointerType
                || fullType.Desugar() is TemplateSpecializationType);

            if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native && isPointer)
                return "global::System.IntPtr";

            var type = Type as TemplateSpecializationType;
            return string.Format("{0}", type.Arguments[0].Type);
        }