示例#1
0
 public CLITypePrinter(Driver driver)
 {
     Driver          = driver;
     TypeMapDatabase = driver.TypeDatabase;
     Options         = driver.Options;
     Context         = new CLITypePrinterContext();
 }
示例#2
0
        public static void CheckTypeForSpecialization(Type type, Declaration container,
                                                      Action <ClassTemplateSpecialization> addSpecialization,
                                                      ITypeMapDatabase typeMaps, bool internalOnly = false)
        {
            type = type.Desugar();
            type = (type.GetFinalPointee() ?? type).Desugar();
            ClassTemplateSpecialization specialization = GetParentSpecialization(type);

            if (specialization == null)
            {
                return;
            }

            if (IsSpecializationNeeded(container, typeMaps, internalOnly, specialization))
            {
                return;
            }

            if (!internalOnly)
            {
                if (IsSpecializationSelfContained(specialization, container))
                {
                    return;
                }

                if (IsMappedToPrimitive(typeMaps, type, specialization))
                {
                    return;
                }
            }

            addSpecialization(specialization);
        }
示例#3
0
 public CLITypeReferenceCollector(ITypeMapDatabase typeMapDatabase, DriverOptions driverOptions)
 {
     TypeMapDatabase       = typeMapDatabase;
     DriverOptions         = driverOptions;
     typeReferences        = new Dictionary <Declaration, CLITypeReference>();
     GeneratedDeclarations = new HashSet <Declaration>();
 }
 public TypeIgnoreChecker(ITypeMapDatabase database,
                          GeneratorKind generatorKind = GeneratorKind.CSharp)
 {
     TypeMapDatabase = database;
     VisitOptions.ClearFlags(VisitFlags.ClassBases | VisitFlags.TemplateArguments);
     this.generatorKind = generatorKind;
 }
示例#5
0
        public static void CheckTypeForSpecialization(Type type, Declaration container,
                                                      Action <ClassTemplateSpecialization> addSpecialization,
                                                      ITypeMapDatabase typeMaps, bool internalOnly = false)
        {
            type = type.Desugar();
            type = type.GetFinalPointee() ?? type;
            ClassTemplateSpecialization specialization;

            type.TryGetDeclaration(out specialization);
            if (specialization == null || specialization.IsExplicitlyGenerated)
            {
                if (specialization != null)
                {
                    addSpecialization(specialization);
                }
                return;
            }

            TypeMap typeMap;

            typeMaps.FindTypeMap(specialization, out typeMap);

            if ((!internalOnly && (((specialization.Ignore ||
                                     specialization.TemplatedDecl.TemplatedClass.Ignore) && typeMap == null) ||
                                   specialization.Arguments.Any(a => UnsupportedTemplateArgument(
                                                                    specialization, a, typeMaps)))) ||
                specialization.IsIncomplete ||
                (!internalOnly && specialization.TemplatedDecl.TemplatedClass.IsIncomplete) ||
                specialization is ClassTemplatePartialSpecialization ||
                container.Namespace == specialization)
            {
                return;
            }

            while (container.Namespace != null)
            {
                if (container.Namespace == specialization)
                {
                    return;
                }
                container = container.Namespace;
            }

            if (!internalOnly && typeMaps.FindTypeMap(specialization, out typeMap))
            {
                var typePrinterContext = new TypePrinterContext {
                    Type = type
                };
                var mappedTo = typeMap.CSharpSignatureType(typePrinterContext);
                mappedTo = mappedTo.Desugar();
                mappedTo = (mappedTo.GetFinalPointee() ?? mappedTo);
                if (mappedTo.IsPrimitiveType() || mappedTo.IsPointerToPrimitiveType() || mappedTo.IsEnum())
                {
                    return;
                }
            }

            addSpecialization(specialization);
        }
示例#6
0
 public TypeIgnoreChecker(ITypeMapDatabase database,
                          GeneratorKind generatorKind = GeneratorKind.CSharp)
 {
     TypeMapDatabase = database;
     VisitOptions.VisitClassBases        = false;
     VisitOptions.VisitTemplateArguments = false;
     this.generatorKind = generatorKind;
 }
示例#7
0
        public CSharpTypePrinter(ITypeMapDatabase database, Library library)
        {
            TypeMapDatabase = database;
            Library         = library;

            contexts = new Stack <CSharpTypePrinterContextKind>();
            PushContext(CSharpTypePrinterContextKind.Managed);

            Context = new CSharpTypePrinterContext();
        }
示例#8
0
        public CSharpTypePrinter(ITypeMapDatabase database, ASTContext context)
        {
            TypeMapDatabase = database;
            AstContext      = context;

            contexts = new Stack <CSharpTypePrinterContextKind>();
            PushContext(CSharpTypePrinterContextKind.Managed);

            Context = new CSharpTypePrinterContext();
        }
示例#9
0
        public CSharpTypePrinter(ITypeMapDatabase database, DriverOptions driverOptions, ASTContext context)
        {
            TypeMapDatabase    = database;
            this.driverOptions = driverOptions;
            AstContext         = context;

            contexts = new Stack <CSharpTypePrinterContextKind>();
            PushContext(CSharpTypePrinterContextKind.Managed);

            Context = new CSharpTypePrinterContext();
        }
示例#10
0
        private static bool IsSpecializationNeeded(Declaration container,
                                                   ITypeMapDatabase typeMaps, bool internalOnly, Type type,
                                                   ClassTemplateSpecialization specialization)
        {
            typeMaps.FindTypeMap(type, out var typeMap);

            return((!internalOnly && (((specialization.Ignore ||
                                        specialization.TemplatedDecl.TemplatedClass.Ignore) && typeMap == null) ||
                                      specialization.Arguments.Any(a => specialization.UnsupportedTemplateArgument(a, typeMaps)) ||
                                      container.Namespace == specialization)) ||
                   (!internalOnly && specialization.TemplatedDecl.TemplatedClass.IsIncomplete) ||
                   specialization is ClassTemplatePartialSpecialization);
        }
示例#11
0
        private static bool UnsupportedTemplateArgument(
            ClassTemplateSpecialization specialization, TemplateArgument a, ITypeMapDatabase typeMaps)
        {
            if (a.Type.Type == null ||
                IsTypeExternal(specialization.TranslationUnit.Module, a.Type.Type))
            {
                return(true);
            }

            var typeIgnoreChecker = new TypeIgnoreChecker(typeMaps);

            a.Type.Type.Visit(typeIgnoreChecker);
            return(typeIgnoreChecker.IsIgnored);
        }
示例#12
0
        public static bool IsMappedToPrimitive(ITypeMapDatabase typeMaps, Type type)
        {
            if (!typeMaps.FindTypeMap(type, out var typeMap))
            {
                return(false);
            }

            var typePrinterContext = new TypePrinterContext {
                Type = type
            };
            var mappedTo = typeMap.CSharpSignatureType(typePrinterContext);

            mappedTo = mappedTo.Desugar();
            mappedTo = (mappedTo.GetFinalPointee() ?? mappedTo).Desugar();
            return(mappedTo.IsPrimitiveType() ||
                   mappedTo.IsPointerToPrimitiveType() || mappedTo.IsEnum());
        }
示例#13
0
        public static bool CheckTypeForSpecialization(Type type, Declaration container,
                                                      Action <ClassTemplateSpecialization> addSpecialization,
                                                      ITypeMapDatabase typeMaps, bool internalOnly = false)
        {
            type = type.Desugar();
            type = (type.GetFinalPointee() ?? type).Desugar();
            ClassTemplateSpecialization specialization = GetParentSpecialization(type);

            if (specialization == null)
            {
                return(true);
            }

            if (IsSpecializationNeeded(container, typeMaps, internalOnly,
                                       type, specialization))
            {
                return(false);
            }

            if (!internalOnly)
            {
                if (IsSpecializationSelfContained(specialization, container))
                {
                    return(true);
                }

                if (IsMappedToPrimitive(typeMaps, type))
                {
                    return(true);
                }
            }

            if (specialization.Arguments.Select(
                    a => a.Type.Type).Any(t => t != null &&
                                          !CheckTypeForSpecialization(t, specialization, addSpecialization,
                                                                      typeMaps, internalOnly)))
            {
                return(false);
            }

            addSpecialization(specialization);
            return(true);
        }
示例#14
0
        private static bool IsMappedToPrimitive(ITypeMapDatabase typeMaps,
                                                Type type, ClassTemplateSpecialization specialization)
        {
            TypeMap typeMap;

            if (!typeMaps.FindTypeMap(specialization, out typeMap))
            {
                return(false);
            }

            var typePrinterContext = new TypePrinterContext {
                Type = type
            };
            var mappedTo = typeMap.CSharpSignatureType(typePrinterContext);

            mappedTo = mappedTo.Desugar();
            mappedTo = (mappedTo.GetFinalPointee() ?? mappedTo).Desugar();
            return(mappedTo.IsPrimitiveType() ||
                   mappedTo.IsPointerToPrimitiveType() || mappedTo.IsEnum());
        }
示例#15
0
 public CppTypePrinter(ITypeMapDatabase database)
 {
 }
示例#16
0
 private static bool FindTypeMap(ITypeMapDatabase typeMapDatabase,
                                 Class @class, out TypeMap typeMap)
 {
     return(typeMapDatabase.FindTypeMap(@class, out typeMap) ||
            (@class.HasBase && FindTypeMap(typeMapDatabase, @class.Bases[0].Class, out typeMap)));
 }
示例#17
0
 public TypeIgnoreChecker(ITypeMapDatabase database)
 {
     TypeMapDatabase = database;
     VisitOptions.VisitClassBases        = false;
     VisitOptions.VisitTemplateArguments = false;
 }
示例#18
0
文件: Flood.cs 项目: tritao/flood
 public FindEventsPass(ITypeMapDatabase typeMapDatabase)
 {
     this.typeMapDatabase = typeMapDatabase;
 }
示例#19
0
 public CLITypeReferenceCollector(ITypeMapDatabase typeMapDatabase)
 {
     TypeMapDatabase = typeMapDatabase;
     typeReferences = new Dictionary<Declaration,CLITypeReference>();
 }
示例#20
0
 public CppTypePrinter(ITypeMapDatabase database, bool printTypeQualifiers = true)
 {
     PrintScopeKind      = CppTypePrintScopeKind.GlobalQualified;
     PrintTypeQualifiers = printTypeQualifiers;
 }
示例#21
0
 public CLITypeReferenceCollector(ITypeMapDatabase typeMapDatabase, DriverOptions driverOptions)
 {
     TypeMapDatabase = typeMapDatabase;
     DriverOptions = driverOptions;
     typeReferences = new Dictionary<Declaration,CLITypeReference>();
 }
示例#22
0
 public CLITypeReferenceCollector(ITypeMapDatabase typeMapDatabase)
 {
     TypeMapDatabase = typeMapDatabase;
     typeReferences  = new Dictionary <Declaration, CLITypeReference>();
 }
示例#23
0
 private static bool FindTypeMap(ITypeMapDatabase typeMapDatabase,
     Class @class, out TypeMap typeMap)
 {
     return typeMapDatabase.FindTypeMap(@class, out typeMap) ||
            (@class.HasBase && FindTypeMap(typeMapDatabase, @class.Bases[0].Class, out typeMap));
 }
示例#24
0
文件: Types.cs 项目: jijamw/CppSharp
 public TypeIgnoreChecker(ITypeMapDatabase database)
 {
     TypeMapDatabase = database;
     Options.VisitClassBases = false;
     Options.VisitTemplateArguments = false;
 }
示例#25
0
 public CppTypePrinter(ITypeMapDatabase database)
 {
     PrintKind = CppTypePrintKind.GlobalQualified;
 }
示例#26
0
文件: Flood.cs 项目: aldyjepara/flood
 public FindEventsPass(ITypeMapDatabase typeMapDatabase)
 {
     this.typeMapDatabase = typeMapDatabase;
 }