Exemplo n.º 1
0
        private void GenerateInclude(ASTRecord <Declaration> record)
        {
            var decl = record.Value;

            if (decl.Namespace == null)
            {
                return;
            }

            var typedefType = record.Value as TypedefNameDecl;

            // Find a type map for the declaration and use it if it exists.
            TypeMap typeMap;

            if (TypeMapDatabase.FindTypeMap(record.Value, out typeMap) ||
                (typedefType != null && TypeMapDatabase.FindTypeMap(typedefType.Type.Desugar(), out typeMap)))
            {
                typeMap.CLITypeReference(this, record);
                return;
            }

            var typeRef = GetTypeReference(decl);

            if (typeRef != null)
            {
                typeRef.Include.InHeader |= IsIncludeInHeader(record);
            }
        }
Exemplo n.º 2
0
 private bool IsIncludeInHeader(ASTRecord <Declaration> record)
 {
     if (TranslationUnit == record.Value.Namespace.TranslationUnit)
     {
         return(false);
     }
     return(record.IsBaseClass() || record.IsFieldValueType());
 }
Exemplo n.º 3
0
        private bool IsIncludeInHeader(ASTRecord <Declaration> record)
        {
            if (TranslationUnit == record.Value.Namespace.TranslationUnit)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        public bool IsIncludeInHeader(ASTRecord <Declaration> record)
        {
            if (TranslationUnit == record.Value.Namespace.TranslationUnit)
            {
                return(false);
            }

            return(record.IsBaseClass() || record.IsFieldValueType() || record.IsDelegate() ||
                   record.IsEnumNestedInClass() || record.FunctionReturnsClassByValue());
        }
Exemplo n.º 5
0
        private void GenerateInclude(ASTRecord <Declaration> record)
        {
            var decl = record.Value;

            if (decl.Namespace == null)
            {
                return;
            }

            // Find a type map for the declaration and use it if it exists.
            TypeMap typeMap;

            if (TypeMapDatabase.FindTypeMap(record.Value, out typeMap))
            {
                typeMap.Declaration = record.Value;
                typeMap.CLITypeReference(this, record);
                return;
            }

            var translationUnit = decl.Namespace.TranslationUnit;

            if (translationUnit.IsSystemHeader)
            {
                return;
            }

            if (!decl.IsGenerated)
            {
                return;
            }

            if (IsBuiltinTypedef(decl))
            {
                return;
            }

            var typeRef = GetTypeReference(decl);

            if (typeRef.Include.TranslationUnit == null)
            {
                typeRef.Include = new Include
                {
                    File            = GetIncludePath(translationUnit),
                    TranslationUnit = translationUnit,
                    Kind            = translationUnit.IsGenerated
                            ? Include.IncludeKind.Quoted
                            : Include.IncludeKind.Angled,
                };
            }

            typeRef.Include.InHeader |= IsIncludeInHeader(record);
        }
Exemplo n.º 6
0
        public override void CLITypeReference(CLITypeReferenceCollector collector,
            ASTRecord<Declaration> loc)
        {
            var typeRef = collector.GetTypeReference(loc.Value);

            var include = new Include
            {
                File = "cstddef",
                Kind = Include.IncludeKind.Angled,
            };

            typeRef.Include = include;
        }
Exemplo n.º 7
0
        public override void CLITypeReference(CLITypeReferenceCollector collector,
                                              ASTRecord <Declaration> loc)
        {
            var typeRef = collector.GetTypeReference(loc.Value);

            var include = new CInclude
            {
                File = "cstddef",
                Kind = CInclude.IncludeKind.Angled,
            };

            typeRef.Include = include;
        }
Exemplo n.º 8
0
        private void ProcessTypeMap(ASTRecord <Declaration> record)
        {
            TypeMap typeMap;

            if (!TypeMapDatabase.FindTypeMap(record.Value, out typeMap))
            {
                return;
            }

            // Typemap must explicitly set the include file when one is required.
            GetTypeReference(record.Value).Include.File = "";

            typeMap.Declaration = record.Value;
            typeMap.CLITypeReference(this, record);
        }
Exemplo n.º 9
0
        private void GenerateInclude(ASTRecord <Declaration> record)
        {
            var decl = record.Value;

            if (decl.Namespace == null)
            {
                return;
            }

            var declFile = decl.Namespace.TranslationUnit.FileName;

            if (decl.Namespace.TranslationUnit.IsSystemHeader)
            {
                return;
            }

            if (decl.Ignore)
            {
                return;
            }

            if (IsBuiltinTypedef(decl))
            {
                return;
            }

            if (declFile.Contains("String"))
            {
                return;
            }

            var typeRef = GetTypeReference(decl);

            typeRef.Include = new Include()
            {
                File            = declFile,
                TranslationUnit = decl.Namespace.TranslationUnit,
                Kind            = Include.IncludeKind.Quoted,
                InHeader        = IsIncludeInHeader(record)
            };
        }
Exemplo n.º 10
0
        public override void CLITypeReference(CLITypeReferenceCollector collector, ASTRecord <Declaration> loc)
        {
            if (!(Declaration is ClassTemplate))
            {
                return;
            }

            var typeRef = collector.GetTypeReference(Declaration);

            typeRef.Include = new Include()
            {
                File     = "ResourceHandle.h",
                Kind     = Include.IncludeKind.Quoted,
                InHeader = true
            };

            Debug.Assert(loc.Parent != null);

            var type         = loc.Parent.Object as CppSharp.AST.Type;
            var templateType = type.Desugar() as TemplateSpecializationType;
            var tag          = templateType.Arguments[0].Type.Type as TagType;

            if (tag == null)
            {
                return; // TODO Fix this
            }
            var argDecl    = tag.Declaration;
            var argTypeDef = collector.GetTypeReference(argDecl);

            argTypeDef.Include = new Include()
            {
                File     = argDecl.Namespace.TranslationUnit.FileName,
                Kind     = Include.IncludeKind.Quoted,
                InHeader = true
            };
        }
Exemplo n.º 11
0
 public override void CLITypeReference(CLITypeReferenceCollector collector,
     ASTRecord<Declaration> loc)
 {
     var typeRef = collector.GetTypeReference(Declaration);
     typeRef.Include = new Include()
     {
         File = "StringConverter.h",
         Kind = Include.IncludeKind.Quoted,
         InHeader = true
     };
 }
Exemplo n.º 12
0
        public override void CLITypeReference(CLITypeReferenceCollector collector, ASTRecord<Declaration> loc)
        {
            if(!(Declaration is ClassTemplate))
                return;

            var typeRef = collector.GetTypeReference(Declaration);
            typeRef.Include = new Include()
            {
                File = "ResourceHandle.h",
                Kind = Include.IncludeKind.Quoted,
                InHeader = true
            };

            Debug.Assert(loc.Parent != null);

            var type = loc.Parent.Object as CppSharp.AST.Type;
            var templateType = type.Desugar() as TemplateSpecializationType;
            var tag = templateType.Arguments[0].Type.Type as TagType;
            if(tag == null)
                return; // TODO Fix this

            var argDecl = tag.Declaration;
            var argTypeDef = collector.GetTypeReference(argDecl);
            argTypeDef.Include = new Include()
            {
                File = argDecl.Namespace.TranslationUnit.FileName,
                Kind = Include.IncludeKind.Quoted,
                InHeader = true
            };
        }
Exemplo n.º 13
0
 public virtual void CLITypeReference(CLITypeReferenceCollector collector, ASTRecord <Declaration> loc)
 {
 }
Exemplo n.º 14
0
 public virtual void CLITypeReference(CLITypeReferenceCollector collector, ASTRecord<Declaration> loc)
 {
 }
Exemplo n.º 15
0
        private void GenerateInclude(ASTRecord<Declaration> record)
        {
            var decl = record.Value;
            if(decl.Namespace == null)
                return;

            var declFile = decl.Namespace.TranslationUnit.FileName;

            if(decl.Namespace.TranslationUnit.IsSystemHeader)
                return;

            if(decl.Ignore)
                return;

            if(IsBuiltinTypedef(decl))
                return;

            var typeRef = GetTypeReference(decl);
            typeRef.Include = new Include()
            {
                File = declFile,
                TranslationUnit = decl.Namespace.TranslationUnit,
                Kind = Include.IncludeKind.Quoted,
                InHeader = IsIncludeInHeader(record)
            };
        }
Exemplo n.º 16
0
        private void GenerateInclude(ASTRecord<Declaration> record)
        {
            var decl = record.Value;
            if(decl.Namespace == null)
                return;

            // Find a type map for the declaration and use it if it exists.
            TypeMap typeMap;
            if (TypeMapDatabase.FindTypeMap(record.Value, out typeMap))
            {
                typeMap.Declaration = record.Value;
                typeMap.CLITypeReference(this, record);
                return;
            }

            var translationUnit = decl.Namespace.TranslationUnit;

            if (translationUnit.IsSystemHeader)
                return;

            if (!decl.IsGenerated)
                return;

            if(IsBuiltinTypedef(decl))
                return;

            var typeRef = GetTypeReference(decl);
            if (typeRef.Include.TranslationUnit == null)
            {
                typeRef.Include = new Include
                    {
                        File = GetIncludePath(translationUnit),
                        TranslationUnit = translationUnit,
                        Kind = translationUnit.IsGenerated
                            ? Include.IncludeKind.Quoted
                            : Include.IncludeKind.Angled,
                    };
            }

            typeRef.Include.InHeader |= IsIncludeInHeader(record);
        }
Exemplo n.º 17
0
        private bool IsIncludeInHeader(ASTRecord<Declaration> record)
        {
            if (TranslationUnit == record.Value.Namespace.TranslationUnit)
                return false;

            return record.IsBaseClass() || record.IsFieldValueType() || record.IsDelegate();
        }
Exemplo n.º 18
0
 public virtual void CppTypeReference(CLITypeReference collector, ASTRecord <Declaration> record)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 19
0
        private void ProcessTypeMap(ASTRecord<Declaration> record)
        {
            TypeMap typeMap;
            if (!TypeMapDatabase.FindTypeMap(record.Value, out typeMap))
                return;

            typeMap.Declaration = record.Value;
            typeMap.CLITypeReference(this, record);
        }