private bool IsTypeComplete(Type type) { TypeMap typeMap; if (TypeMaps.FindTypeMap(type, out typeMap) && !typeMap.IsIgnored) { return(true); } var desugared = type.Desugar(); var finalType = (desugared.GetFinalPointee() ?? desugared).Desugar(); var templateSpecializationType = finalType as TemplateSpecializationType; if (templateSpecializationType != null) { finalType = templateSpecializationType.Desugared.Type; } Declaration decl; if (!finalType.TryGetDeclaration(out decl)) { return(true); } var @class = (decl as Class); if (@class != null && @class.IsOpaque && [email protected] && !(@class is ClassTemplateSpecialization)) { return(true); } return(!decl.IsIncomplete || decl.CompleteDeclaration != null); }
private string TranslateEnumExpression(Function function, Type desugared, string @params) { TypeMap typeMap; if ((function.Parameters.Count == 0 || HasSingleZeroArgExpression(function)) && TypeMaps.FindTypeMap(desugared, out typeMap)) { var typePrinterContext = new TypePrinterContext { MarshalKind = MarshalKind.DefaultExpression, Type = desugared }; var typeInSignature = typeMap.CSharpSignatureType(typePrinterContext) .SkipPointerRefs().Desugar(); Enumeration @enum; if (typeInSignature.TryGetEnum(out @enum)) { return("0"); } } if (@params.Contains("::")) { return(regexDoubleColon.Replace(@params, desugared + ".")); } return(regexName.Replace(@params, desugared + ".$1")); }
private bool IsDeclIgnored(Declaration decl) { var parameter = decl as Parameter; if (parameter != null) { if (parameter.Type.Desugar().IsPrimitiveType(PrimitiveType.Null)) { return(true); } TypeMap typeMap; if (TypeMaps.FindTypeMap(parameter.Type, out typeMap)) { return(typeMap.IsIgnored); } } if (decl.Ignore) { return(true); } decl.Visit(this); return(decl.Ignore); }
private bool IsTypeComplete(Type type) { TypeMap typeMap; if (TypeMaps.FindTypeMap(type, out typeMap) && !typeMap.IsIgnored) { return(true); } var desugared = type.Desugar(); var finalType = (desugared.GetFinalPointee() ?? desugared).Desugar(); var templateSpecializationType = finalType as TemplateSpecializationType; if (templateSpecializationType != null) { finalType = templateSpecializationType.Desugared.Type; } Declaration decl; if (!finalType.TryGetDeclaration(out decl)) { return(true); } return(!decl.IsIncomplete); }
private bool IsDeclIgnored(Declaration decl) { var parameter = decl as Parameter; if (parameter != null && parameter.Type.Desugar().IsPrimitiveType(PrimitiveType.Null)) { return(true); } TypeMap typeMap; return(TypeMaps.FindTypeMap(decl, out typeMap) ? typeMap.IsIgnored : decl.Ignore); }
private bool?CheckForDefaultConstruct(Type desugared, Expression expression, ref string result) { var type = desugared.GetFinalPointee() ?? desugared; Class decl; if (!type.TryGetClass(out decl)) { return(false); } var ctor = expression as CXXConstructExpr; var typePrinter = new CSharpTypePrinter(Context); typePrinter.PushMarshalKind(MarshalKind.DefaultExpression); var typePrinterResult = type.Visit(typePrinter).Type; TypeMap typeMap; if (TypeMaps.FindTypeMap(decl, 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('(')) { 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); }