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); }
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)); }
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); }
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)); }
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; }
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); }
public override string CLISignature(CLITypePrinterContext ctx) { var type = Type as TemplateSpecializationType; return(string.Format("{0}", type.Arguments[0].Type)); }
public override string CLISignature(CLITypePrinterContext ctx) { return "System::IO::TextWriter^"; }
public override string CLISignature(CLITypePrinterContext ctx) { return "System::String^"; }
public override string CLISignature(CLITypePrinterContext ctx) { return "va_list"; }
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; }
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; }
public override string CLISignature(CLITypePrinterContext ctx) { var type = Type as TemplateSpecializationType; return string.Format("{0}", type.Arguments[0].Type); }
public override string CLISignature(CLITypePrinterContext ctx) { return("TypedefFn3"); }
public override string CLISignature(CLITypePrinterContext ctx) { return("va_list"); }
public override string CLISignature(CLITypePrinterContext ctx) { return("System::IO::TextWriter^"); }
public override string CLISignature(CLITypePrinterContext ctx) { return "TypeMaps::QList^"; }
public override string CLISignature(CLITypePrinterContext ctx) { return("unsigned short"); }
public virtual Type CLISignatureType(CLITypePrinterContext ctx) { return new CILType(typeof(object)); }
public override string CLISignature(CLITypePrinterContext ctx) { return string.Format("System::Collections::Generic::List<{0}>^", ctx.GetTemplateParameterList()); }
public override string CLISignature(CLITypePrinterContext ctx) { return "unsigned short"; }
public override string CLISignature(CLITypePrinterContext ctx) { throw new System.NotImplementedException(); }
public override string CLISignature(CLITypePrinterContext ctx) { return(string.Format("System::Collections::Generic::List<{0}>^", ctx.GetTemplateParameterList())); }
public virtual Type CLISignatureType(CLITypePrinterContext ctx) { return(new CILType(typeof(object))); }
public override string CLISignature(CLITypePrinterContext ctx) { return("System::String^"); }
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; }