示例#1
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     var type = Type as TemplateSpecializationType;
     return string.Format(
         "System::Collections::Generic::Dictionary<{0}, {1}>^",
         type.Arguments[0].Type, type.Arguments[1].Type);
 }
示例#2
0
文件: Stdlib.cs 项目: cDoru/CppSharp
        public override string CLISignature(CLITypePrinterContext ctx)
        {
            var type = Type as TemplateSpecializationType;

            return(string.Format("System::Collections::Generic::Dictionary<{0}, {1}>^",
                                 type.Arguments[0].Type, type.Arguments[1].Type));
        }
示例#3
0
文件: Flood.cs 项目: chartly/flood
        public override string CLISignature(CLITypePrinterContext ctx)
        {
            var type = Type.Desugar() as TemplateSpecializationType;
            var arg = type.Arguments[0].Type.ToString();
            if (string.IsNullOrEmpty(arg))
                arg = type.Template.Parameters[0].Name;

            return string.Format("Flood::ResourceHandle<{0}>", arg);
        }
        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);
        }
示例#5
0
文件: Flood.cs 项目: aldyjepara/flood
        public override string CLISignature(CLITypePrinterContext ctx)
        {
            var type = Type.Desugar() as TemplateSpecializationType;
            var arg  = type.Arguments[0].Type.ToString();

            if (string.IsNullOrEmpty(arg))
            {
                arg = type.Template.Parameters[0].Name;
            }

            return(string.Format("Flood::ResourceHandle<{0}>", arg));
        }
示例#6
0
文件: Flood.cs 项目: chartly/flood
        public override string CLISignature(CLITypePrinterContext 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));

            output += "^";

            return output;
        }
示例#7
0
文件: Flood.cs 项目: aldyjepara/flood
        public override string CLISignature(CLITypePrinterContext 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));
            }

            output += "^";

            return(output);
        }
        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);
        }
示例#9
0
文件: Flood.cs 项目: aldyjepara/flood
        public override string CLISignature(CLITypePrinterContext ctx)
        {
            var type = Type as TemplateSpecializationType;

            return(string.Format("{0}", type.Arguments[0].Type));
        }
示例#10
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return "System::IO::TextWriter^";
 }
示例#11
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return "System::String^";
 }
示例#12
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return "va_list";
 }
示例#13
0
        public void GenerateClassGenericMethods(Class @class)
        {
            var printer = TypePrinter;
            var oldCtx = printer.Context;

            PushIndent();
            foreach (var template in @class.Templates)
            {
                if (!template.IsGenerated) continue;

                var functionTemplate = template as FunctionTemplate;
                if (functionTemplate == null) continue;

                PushBlock(CLIBlockKind.Template);

                var function = functionTemplate.TemplatedFunction;

                var typeCtx = new CLITypePrinterContext()
                    {
                        Kind = TypePrinterContextKind.Template,
                        Declaration = template
                    };

                printer.Context = typeCtx;

                var typePrinter = new CLITypePrinter(Driver, typeCtx);
                var retType = function.ReturnType.Type.Visit(typePrinter,
                    function.ReturnType.Qualifiers);

                var typeNames = "";
                var paramNames = template.Parameters.Select(param => param.Name).ToList();
                if (paramNames.Any())
                    typeNames = "typename " + string.Join(", typename ", paramNames);

                Write("generic<{0}>", typeNames);

                // Process the generic type constraints
                var constraints = new List<string>();
                foreach (var param in template.Parameters.OfType<TypeTemplateParameter>())
                {
                    if (string.IsNullOrWhiteSpace(param.Constraint))
                        continue;
                    constraints.Add(string.Format("{0} : {1}", param.Name,
                        param.Constraint));
                }

                if (constraints.Any())
                    Write(" where {0}", string.Join(", ", constraints));

                NewLine();

                WriteLine("{0} {1}({2});", retType, function.Name,
                    GenerateParametersList(function.Parameters));

                PopBlock(NewLineKind.BeforeNextBlock);
            }
            PopIndent();

            printer.Context = oldCtx;
        }
示例#14
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return("TypeMaps::QList^");
 }
        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;
        }
示例#16
0
文件: Flood.cs 项目: chartly/flood
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     var type = Type as TemplateSpecializationType;
     return string.Format("{0}", type.Arguments[0].Type);
 }
示例#17
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return("TypedefFn3");
 }
示例#18
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return("va_list");
 }
示例#19
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return("System::IO::TextWriter^");
 }
示例#20
0
文件: QList.cs 项目: daxiazh/CppSharp
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return "TypeMaps::QList^";
 }
示例#21
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return("unsigned short");
 }
示例#22
0
 public virtual Type CLISignatureType(CLITypePrinterContext ctx)
 {
     return new CILType(typeof(object));
 }
示例#23
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return string.Format("System::Collections::Generic::List<{0}>^",
         ctx.GetTemplateParameterList());
 }
示例#24
0
文件: Common.cs 项目: tritao/CppSharp
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return "unsigned short";
 }
示例#25
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     throw new System.NotImplementedException();
 }
示例#26
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     throw new System.NotImplementedException();
 }
示例#27
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return(string.Format("System::Collections::Generic::List<{0}>^",
                          ctx.GetTemplateParameterList()));
 }
示例#28
0
 public virtual Type CLISignatureType(CLITypePrinterContext ctx)
 {
     return(new CILType(typeof(object)));
 }
示例#29
0
 public override string CLISignature(CLITypePrinterContext ctx)
 {
     return("System::String^");
 }
示例#30
0
 public virtual string CLISignature(CLITypePrinterContext ctx)
 {
     throw new NotImplementedException();
 }
示例#31
0
 public virtual string CLISignature(CLITypePrinterContext ctx)
 {
     throw new NotImplementedException();
 }
        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;
        }