コード例 #1
0
ファイル: CLITypePrinter.cs プロジェクト: gpetrou/CppSharp
 public CLITypePrinter(Driver driver)
 {
     Driver          = driver;
     TypeMapDatabase = driver.TypeDatabase;
     Options         = driver.Options;
     Context         = new CLITypePrinterContext();
 }
コード例 #2
0
ファイル: Utils.cs プロジェクト: roscopecoltran/CppSharp
        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>();
 }
コード例 #4
0
 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
ファイル: CSharpTypePrinter.cs プロジェクト: gpetrou/CppSharp
        public CSharpTypePrinter(ITypeMapDatabase database, ASTContext context)
        {
            TypeMapDatabase = database;
            AstContext      = context;

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

            Context = new CSharpTypePrinterContext();
        }
コード例 #9
0
ファイル: CSharpTypePrinter.cs プロジェクト: UIKit0/CppSharp
        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
ファイル: Utils.cs プロジェクト: tornado12345/CppSharp
        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
ファイル: Utils.cs プロジェクト: sbertout/CppSharp
        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
ファイル: CLITypeReferences.cs プロジェクト: kidleon/CppSharp
 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
ファイル: CLITypeReferences.cs プロジェクト: tritao/CppSharp
 public CLITypeReferenceCollector(ITypeMapDatabase typeMapDatabase, DriverOptions driverOptions)
 {
     TypeMapDatabase = typeMapDatabase;
     DriverOptions = driverOptions;
     typeReferences = new Dictionary<Declaration,CLITypeReference>();
 }
コード例 #22
0
ファイル: CLITypeReferences.cs プロジェクト: cDoru/CppSharp
 public CLITypeReferenceCollector(ITypeMapDatabase typeMapDatabase)
 {
     TypeMapDatabase = typeMapDatabase;
     typeReferences  = new Dictionary <Declaration, CLITypeReference>();
 }
コード例 #23
0
ファイル: CSharpMarshal.cs プロジェクト: vovkasm/CppSharp
 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;
 }