Пример #1
0
        private RecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind)
            : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastRecord or < CX_DeclKind.CX_DeclKind_FirstRecord)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            if (handle.Kind is not CXCursorKind.CXCursor_StructDecl and not CXCursorKind.CXCursor_UnionDecl and not CXCursorKind.CXCursor_ClassDecl and not CXCursorKind.CXCursor_ClassTemplatePartialSpecialization)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _fields = new Lazy<IReadOnlyList<FieldDecl>>(() => {
                var numFields = Handle.NumFields;
                var fields = new List<FieldDecl>(numFields);

                for (var i = 0; i < numFields; i++)
                {
                    var field = TranslationUnit.GetOrCreate<FieldDecl>(Handle.GetField(unchecked((uint)i)));
                    fields.Add(field);
                }

                return fields;
            });

            _anonymousFields = new Lazy<IReadOnlyList<FieldDecl>>(() => Decls.OfType<FieldDecl>().Where(decl => decl.IsAnonymousField).ToList());
            _anonymousRecords = new Lazy<IReadOnlyList<RecordDecl>>(() => Decls.OfType<RecordDecl>().Where(decl => decl.IsAnonymousStructOrUnion && !decl.IsInjectedClassName).ToList());
            _indirectFields = new Lazy<IReadOnlyList<IndirectFieldDecl>>(() => Decls.OfType<IndirectFieldDecl>().ToList());
            _injectedClassName = new Lazy<RecordDecl>(() => Decls.OfType<RecordDecl>().Where(decl => decl.IsInjectedClassName).SingleOrDefault());
        }
Пример #2
0
        private protected TagDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastTag < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstTag))
            {
                throw new ArgumentException(nameof(handle));
            }

            _definition = new Lazy <TagDecl>(() => TranslationUnit.GetOrCreate <TagDecl>(Handle.Definition));

            _templateParameterLists = new Lazy <IReadOnlyList <IReadOnlyList <NamedDecl> > >(() => {
                var numTemplateParameterLists = Handle.NumTemplateParameterLists;
                var templateParameterLists    = new List <IReadOnlyList <NamedDecl> >(numTemplateParameterLists);

                for (var listIndex = 0; listIndex < numTemplateParameterLists; listIndex++)
                {
                    var numTemplateParameters = Handle.GetNumTemplateParameters(unchecked ((uint)listIndex));
                    var templateParameterList = new List <NamedDecl>(numTemplateParameters);

                    for (var parameterIndex = 0; parameterIndex < numTemplateParameters; parameterIndex++)
                    {
                        var templateParameter = TranslationUnit.GetOrCreate <NamedDecl>(Handle.GetTemplateParameter(unchecked ((uint)listIndex), unchecked ((uint)parameterIndex)));
                        templateParameterList.Add(templateParameter);
                    }

                    templateParameterLists.Add(templateParameterList);
                }

                return(templateParameterLists);
            });

            _typedefNameForAnonDecl = new Lazy <TypedefNameDecl>(() => TranslationUnit.GetOrCreate <TypedefNameDecl>(Handle.TypedefNameForAnonDecl));
        }
Пример #3
0
        private protected TypeDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastType or < CX_DeclKind.CX_DeclKind_FirstType)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _typeForDecl = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.Type));
        }
Пример #4
0
        private protected TagDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastTag < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstTag))
            {
                throw new ArgumentException(nameof(handle));
            }

            _decls      = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList());
            _definition = new Lazy <TagDecl>(() => TranslationUnit.GetOrCreate <TagDecl>(Handle.Definition));
        }
Пример #5
0
        private protected VarDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastVar < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstVar))
            {
                throw new ArgumentException(nameof(handle));
            }

            _definition = new Lazy <VarDecl>(() => TranslationUnit.GetOrCreate <VarDecl>(Handle.Definition));
            _init       = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(handle.InitExpr));
            _instantiatedFromStaticDataMember = new Lazy <VarDecl>(() => TranslationUnit.GetOrCreate <VarDecl>(Handle.InstantiatedFromMember));
        }
Пример #6
0
        private protected Decl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind)
        {
            if ((handle.DeclKind == CX_DeclKind.CX_DeclKind_Invalid) || (handle.DeclKind != expectedDeclKind))
            {
                throw new ArgumentException(nameof(handle));
            }

            _attrs               = new Lazy <IReadOnlyList <Attr> >(() => CursorChildren.OfType <Attr>().ToList());
            _canonicalDecl       = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.CanonicalCursor));
            _declContext         = new Lazy <IDeclContext>(() => TranslationUnit.GetOrCreate <Decl>(Handle.SemanticParent) as IDeclContext);
            _lexicalDeclContext  = new Lazy <IDeclContext>(() => TranslationUnit.GetOrCreate <Decl>(Handle.LexicalParent) as IDeclContext);
            _translationUnitDecl = new Lazy <TranslationUnitDecl>(() => TranslationUnit.GetOrCreate <TranslationUnitDecl>(Handle.TranslationUnit.Cursor));
        }
Пример #7
0
        private protected Decl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind)
        {
            if ((handle.DeclKind == CX_DeclKind.CX_DeclKind_Invalid) || (handle.DeclKind != expectedDeclKind))
            {
                throw new ArgumentException(nameof(handle));
            }

            _asFunction = new Lazy <FunctionDecl>(() => TranslationUnit.GetOrCreate <FunctionDecl>(Handle.AsFunction));

            _attrs = new Lazy <IReadOnlyList <Attr> >(() => {
                var attrCount = Handle.NumAttrs;
                var attrs     = new List <Attr>(attrCount);

                for (int i = 0; i < attrCount; i++)
                {
                    var attr = TranslationUnit.GetOrCreate <Attr>(Handle.GetAttr(unchecked ((uint)i)));
                    attrs.Add(attr);
                }

                return(attrs);
            });

            _body          = new Lazy <Stmt>(() => TranslationUnit.GetOrCreate <Stmt>(Handle.Body));
            _canonicalDecl = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.CanonicalCursor));

            _decls = new Lazy <IReadOnlyList <Decl> >(() => {
                var declCount = Handle.NumDecls;
                var decls     = new List <Decl>(declCount);

                for (int i = 0; i < declCount; i++)
                {
                    var decl = TranslationUnit.GetOrCreate <Decl>(Handle.GetDecl(unchecked ((uint)i)));
                    decls.Add(decl);
                }

                return(decls);
            });

            _declContext            = new Lazy <IDeclContext>(() => TranslationUnit.GetOrCreate <Decl>(Handle.SemanticParent) as IDeclContext);
            _describedTemplate      = new Lazy <TemplateDecl>(() => TranslationUnit.GetOrCreate <TemplateDecl>(Handle.DescribedTemplate));
            _lexicalDeclContext     = new Lazy <IDeclContext>(() => TranslationUnit.GetOrCreate <Decl>(Handle.LexicalParent) as IDeclContext);
            _mostRecentDecl         = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.MostRecentDecl));
            _nextDeclInContext      = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.NextDeclInContext));
            _nonClosureContext      = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.NonClosureContext));
            _parentFunctionOrMethod = new Lazy <IDeclContext>(() => TranslationUnit.GetOrCreate <Decl>(Handle.ParentFunctionOrMethod) as IDeclContext);
            _previousDecl           = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.PreviousDecl));
            _redeclContext          = new Lazy <IDeclContext>(() => TranslationUnit.GetOrCreate <Decl>(Handle.RedeclContext) as IDeclContext);
            _translationUnitDecl    = new Lazy <TranslationUnitDecl>(() => TranslationUnit.GetOrCreate <TranslationUnitDecl>(Handle.TranslationUnit.Cursor));
        }
Пример #8
0
        private protected VarDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastVar < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstVar))
            {
                throw new ArgumentException(nameof(handle));
            }

            _init = new Lazy <Expr>(() => {
                var exprs = CursorChildren.OfType <Expr>();

                if (Type is ArrayType)
                {
                    exprs = exprs.Skip(1);
                }

                return(exprs.SingleOrDefault());
            });
            _instantiatedFromStaticDataMember = new Lazy <VarDecl>(() => TranslationUnit.GetOrCreate <VarDecl>(Handle.SpecializedCursorTemplate));
        }
Пример #9
0
        private protected Decl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind)
        {
            if ((handle.DeclKind == CX_DeclKind.CX_DeclKind_Invalid) || (handle.DeclKind != expectedDeclKind))
            {
                throw new ArgumentException(nameof(handle));
            }

            _asFunction             = new Lazy <FunctionDecl>(() => TranslationUnit.GetOrCreate <FunctionDecl>(Handle.AsFunction));
            _attrs                  = new Lazy <IReadOnlyList <Attr> >(() => CursorChildren.OfType <Attr>().ToList());
            _body                   = new Lazy <Stmt>(() => TranslationUnit.GetOrCreate <Stmt>(Handle.Body));
            _canonicalDecl          = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.CanonicalCursor));
            _declContext            = new Lazy <IDeclContext>(() => TranslationUnit.GetOrCreate <Decl>(Handle.SemanticParent) as IDeclContext);
            _describedTemplate      = new Lazy <TemplateDecl>(() => TranslationUnit.GetOrCreate <TemplateDecl>(Handle.DescribedTemplate));
            _lexicalDeclContext     = new Lazy <IDeclContext>(() => TranslationUnit.GetOrCreate <Decl>(Handle.LexicalParent) as IDeclContext);
            _mostRecentDecl         = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.MostRecentDecl));
            _nextDeclInContext      = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.NextDeclInContext));
            _nonClosureContext      = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.NonClosureContext));
            _parentFunctionOrMethod = new Lazy <IDeclContext>(() => TranslationUnit.GetOrCreate <Decl>(Handle.ParentFunctionOrMethod) as IDeclContext);
            _previousDecl           = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.PreviousDecl));
            _translationUnitDecl    = new Lazy <TranslationUnitDecl>(() => TranslationUnit.GetOrCreate <TranslationUnitDecl>(Handle.TranslationUnit.Cursor));
        }
Пример #10
0
        private protected ObjCContainerDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastObjCContainer < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstObjCContainer))
            {
                throw new ArgumentException(nameof(handle));
            }

            _decls = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList());
        }
Пример #11
0
        private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastCXXRecord < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXRecord))
            {
                throw new ArgumentException(nameof(handle));
            }

            _bases      = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => CursorChildren.OfType <CXXBaseSpecifier>().ToList());
            _ctors      = new Lazy <IReadOnlyList <CXXConstructorDecl> >(() => Methods.OfType <CXXConstructorDecl>().ToList());
            _destructor = new Lazy <CXXDestructorDecl>(() => Methods.OfType <CXXDestructorDecl>().SingleOrDefault());
            _friends    = new Lazy <IReadOnlyList <FriendDecl> >(() => Decls.OfType <FriendDecl>().ToList());
            _methods    = new Lazy <IReadOnlyList <CXXMethodDecl> >(() => Decls.OfType <CXXMethodDecl>().ToList());
            _vbases     = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => Bases.Where((@base) => @base.IsVirtual).ToList());
        }
Пример #12
0
        private protected ClassTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastClassTemplateSpecialization < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstClassTemplateSpecialization))
            {
                throw new ArgumentException(nameof(handle));
            }

            _specializedTemplate = new Lazy <ClassTemplateDecl>(() => TranslationUnit.GetOrCreate <ClassTemplateDecl>(Handle.SpecializedCursorTemplate));
            _templateArgs        = new Lazy <IReadOnlyList <Type> >(() => {
                var templateArgsSize = TemplateArgsSize;
                var templateArgs     = new List <Type>(templateArgsSize);

                for (var index = 0; index < templateArgsSize; index++)
                {
                    var templateArg = TypeForDecl.Handle.GetTemplateArgumentAsType((uint)index);
                    templateArgs.Add(TranslationUnit.GetOrCreate <Type>(templateArg));
                }

                return(templateArgs);
            });
        }
Пример #13
0
        private protected DeclaratorDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastDeclarator < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstDeclarator))
            {
                throw new ArgumentException(nameof(handle));
            }

            _templateParameterLists = new Lazy <IReadOnlyList <IReadOnlyList <NamedDecl> > >(() => {
                var numTemplateParameterLists = Handle.NumTemplateParameterLists;
                var templateParameterLists    = new List <IReadOnlyList <NamedDecl> >(numTemplateParameterLists);

                for (var listIndex = 0; listIndex < numTemplateParameterLists; listIndex++)
                {
                    var numTemplateParameters = Handle.GetNumTemplateParameters(unchecked ((uint)listIndex));
                    var templateParameterList = new List <NamedDecl>(numTemplateParameters);

                    for (var parameterIndex = 0; parameterIndex < numTemplateParameters; parameterIndex++)
                    {
                        var templateParameter = TranslationUnit.GetOrCreate <NamedDecl>(Handle.GetTemplateParameter(unchecked ((uint)listIndex), unchecked ((uint)parameterIndex)));
                        templateParameterList.Add(templateParameter);
                    }

                    templateParameterLists.Add(templateParameterList);
                }

                return(templateParameterLists);
            });

            _trailingRequiresClause = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.TrailingRequiresClause));
        }
        private protected VarTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastVarTemplateSpecialization < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstVarTemplateSpecialization))
            {
                throw new ArgumentException(nameof(handle));
            }

            _specializedTemplate = new Lazy <VarTemplateDecl>(() => TranslationUnit.GetOrCreate <VarTemplateDecl>(Handle.SpecializedCursorTemplate));
            _templateArgs        = new Lazy <IReadOnlyList <TemplateArgument> >(() => {
                var templateArgCount = Handle.NumTemplateArguments;
                var templateArgs     = new List <TemplateArgument>(templateArgCount);

                for (int i = 0; i < templateArgCount; i++)
                {
                    var templateArg = new TemplateArgument(this, unchecked ((uint)i));
                    templateArgs.Add(templateArg);
                }

                return(templateArgs);
            });
        }
        private protected RedeclarableTemplateDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastRedeclarableTemplate or < CX_DeclKind.CX_DeclKind_FirstRedeclarableTemplate)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _instantiatedFromMemberTemplate = new Lazy <RedeclarableTemplateDecl>(() => TranslationUnit.GetOrCreate <RedeclarableTemplateDecl>(Handle.SpecializedCursorTemplate));
        }
        private protected ClassTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastClassTemplateSpecialization or < CX_DeclKind.CX_DeclKind_FirstClassTemplateSpecialization)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _specializedTemplate = new Lazy <ClassTemplateDecl>(() => TranslationUnit.GetOrCreate <ClassTemplateDecl>(Handle.SpecializedCursorTemplate));
            _templateArgs        = new Lazy <IReadOnlyList <TemplateArgument> >(() => {
                var templateArgCount = Handle.NumTemplateArguments;
                var templateArgs     = new List <TemplateArgument>(templateArgCount);

                for (var i = 0; i < templateArgCount; i++)
                {
                    var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked ((uint)i)));
                    templateArgs.Add(templateArg);
                }

                return(templateArgs);
            });
        }
Пример #17
0
        private protected CXXMethodDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastCXXMethod < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXMethod))
            {
                throw new ArgumentException(nameof(handle));
            }

            _thisType       = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ThisType));
            _thisObjectType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ThisObjectType));
        }
Пример #18
0
        private protected DeclaratorDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastDeclarator < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstDeclarator))
            {
                throw new ArgumentException(nameof(handle));
            }

            _trailingRequiresClause = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.TrailingRequiresClause));
        }
Пример #19
0
        private protected FunctionDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastFunction < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstFunction))
            {
                throw new ArgumentException(nameof(handle));
            }

            _callResultType     = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.CallResultType));
            _declaredReturnType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.DeclaredReturnType));
            _decls      = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList());
            _definition = new Lazy <FunctionDecl>(() => TranslationUnit.GetOrCreate <FunctionDecl>(Handle.Definition));
            _instantiatedFromMemberFunction = new Lazy <FunctionDecl>(() => TranslationUnit.GetOrCreate <FunctionDecl>(Handle.InstantiatedFromMember));
            _parameters = new Lazy <IReadOnlyList <ParmVarDecl> >(() => {
                var parameterCount = Handle.NumArguments;
                var parameters     = new List <ParmVarDecl>(parameterCount);

                for (int i = 0; i < parameterCount; i++)
                {
                    var parameter = TranslationUnit.GetOrCreate <ParmVarDecl>(Handle.GetArgument(unchecked ((uint)i)));
                    parameters.Add(parameter);
                }

                return(parameters);
            });
            _primaryTemplate = new Lazy <FunctionTemplateDecl>(() => TranslationUnit.GetOrCreate <FunctionTemplateDecl>(Handle.PrimaryTemplate));
            _returnType      = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ReturnType));
            _templateInstantiationPattern = new Lazy <FunctionDecl>(() => TranslationUnit.GetOrCreate <FunctionDecl>(Handle.TemplateInstantiationPattern));
        }
Пример #20
0
        private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastCXXRecord < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXRecord))
            {
                throw new ArgumentException(nameof(handle));
            }

            _bases = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => CursorChildren.OfType <CXXBaseSpecifier>().ToList());
            _ctors = new Lazy <IReadOnlyList <CXXConstructorDecl> >(() => Methods.OfType <CXXConstructorDecl>().ToList());
            _dependentLambdaCallOperator = new Lazy <FunctionTemplateDecl>(() => TranslationUnit.GetOrCreate <FunctionTemplateDecl>(Handle.DependentLambdaCallOperator));
            _describedClassTemplate      = new Lazy <ClassTemplateDecl>(() => TranslationUnit.GetOrCreate <ClassTemplateDecl>(Handle.DescribedClassTemplate));
            _destructor = new Lazy <CXXDestructorDecl>(() => TranslationUnit.GetOrCreate <CXXDestructorDecl>(Handle.Destructor));
            _friends    = new Lazy <IReadOnlyList <FriendDecl> >(() => Decls.OfType <FriendDecl>().ToList());
            _instantiatedFromMemberClass = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.InstantiatedFromMember));
            _lambdaCallOperator          = new Lazy <CXXMethodDecl>(() => TranslationUnit.GetOrCreate <CXXMethodDecl>(Handle.LambdaCallOperator));
            _lambdaContextDecl           = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.LambdaContextDecl));
            _lambdaStaticInvoker         = new Lazy <CXXMethodDecl>(() => TranslationUnit.GetOrCreate <CXXMethodDecl>(Handle.LambdaStaticInvoker));
            _methods = new Lazy <IReadOnlyList <CXXMethodDecl> >(() => Decls.OfType <CXXMethodDecl>().ToList());
            _mostRecentNonInjectedDecl    = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.MostRecentNonInjectedDecl));
            _templateInstantiationPattern = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.TemplateInstantiationPattern));
            _vbases = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => Bases.Where((@base) => @base.IsVirtual).ToList());
        }
Пример #21
0
        private protected FieldDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastField or < CX_DeclKind.CX_DeclKind_FirstField)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _bitWidth           = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.BitWidth));
            _inClassInitializer = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.InClassInitializer));
        }
Пример #22
0
        private protected ObjCContainerDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastObjCContainer or < CX_DeclKind.CX_DeclKind_FirstObjCContainer)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _classMethods       = new Lazy <IReadOnlyList <ObjCMethodDecl> >(() => Methods.Where((method) => method.IsClassMethod).ToList());
            _classProperties    = new Lazy <IReadOnlyList <ObjCPropertyDecl> >(() => Properties.Where((property) => property.IsClassProperty).ToList());
            _instanceMethods    = new Lazy <IReadOnlyList <ObjCMethodDecl> >(() => Methods.Where((method) => method.IsInstanceMethod).ToList());
            _instanceProperties = new Lazy <IReadOnlyList <ObjCPropertyDecl> >(() => Properties.Where((property) => property.IsInstanceProperty).ToList());
            _methods            = new Lazy <IReadOnlyList <ObjCMethodDecl> >(() => Decls.OfType <ObjCMethodDecl>().ToList());
            _properties         = new Lazy <IReadOnlyList <ObjCPropertyDecl> >(() => Decls.OfType <ObjCPropertyDecl>().ToList());
        }
Пример #23
0
        private protected FunctionDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastFunction or < CX_DeclKind.CX_DeclKind_FirstFunction)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _callResultType                 = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.CallResultType));
            _declaredReturnType             = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.DeclaredReturnType));
            _definition                     = new Lazy <FunctionDecl>(() => TranslationUnit.GetOrCreate <FunctionDecl>(Handle.Definition));
            _describedFunctionDecl          = new Lazy <FunctionTemplateDecl>(() => TranslationUnit.GetOrCreate <FunctionTemplateDecl>(Handle.DescribedCursorTemplate));
            _instantiatedFromMemberFunction = new Lazy <FunctionDecl>(() => TranslationUnit.GetOrCreate <FunctionDecl>(Handle.InstantiatedFromMember));

            _parameters = new Lazy <IReadOnlyList <ParmVarDecl> >(() => {
                var parameterCount = Handle.NumArguments;
                var parameters     = new List <ParmVarDecl>(parameterCount);

                for (var i = 0; i < parameterCount; i++)
                {
                    var parameter = TranslationUnit.GetOrCreate <ParmVarDecl>(Handle.GetArgument(unchecked ((uint)i)));
                    parameters.Add(parameter);
                }

                return(parameters);
            });

            _primaryTemplate = new Lazy <FunctionTemplateDecl>(() => TranslationUnit.GetOrCreate <FunctionTemplateDecl>(Handle.PrimaryTemplate));
            _returnType      = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ReturnType));
            _templateInstantiationPattern = new Lazy <FunctionDecl>(() => TranslationUnit.GetOrCreate <FunctionDecl>(Handle.TemplateInstantiationPattern));

            _templateSpecializationArgs = new Lazy <IReadOnlyList <TemplateArgument> >(() => {
                var templateArgCount = Handle.NumTemplateArguments;
                var templateArgs     = new List <TemplateArgument>(templateArgCount);

                for (var i = 0; i < templateArgCount; i++)
                {
                    var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked ((uint)i)));
                    templateArgs.Add(templateArg);
                }

                return(templateArgs);
            });
        }
Пример #24
0
        private protected FunctionDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastFunction < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstFunction))
            {
                throw new ArgumentException(nameof(handle));
            }

            _body       = new Lazy <Stmt>(() => CursorChildren.OfType <Stmt>().SingleOrDefault());
            _decls      = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList());
            _parameters = new Lazy <IReadOnlyList <ParmVarDecl> >(() => Decls.OfType <ParmVarDecl>().ToList());
            _returnType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ResultType));
        }
Пример #25
0
        private protected CXXMethodDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastCXXMethod < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXMethod))
            {
                throw new ArgumentException(nameof(handle));
            }

            _overloadIndex = new Lazy <uint>(() => {
                var index = 0u;
                var name  = Name;

                foreach (var methodDecl in Parent.Methods)
                {
                    if (methodDecl == this)
                    {
                        break;
                    }
                    else if (methodDecl.Name == name)
                    {
                        index++;
                    }
                }

                return(index);
            });

            _overriddenMethods = new Lazy <IReadOnlyList <CXXMethodDecl> >(() => {
                var numOverriddenMethods = Handle.NumMethods;
                var overriddenMethods    = new List <CXXMethodDecl>(numOverriddenMethods);

                for (int i = 0; i < numOverriddenMethods; i++)
                {
                    var overriddenMethod = TranslationUnit.GetOrCreate <CXXMethodDecl>(Handle.GetMethod(unchecked ((uint)i)));
                    overriddenMethods.Add(overriddenMethod);
                }

                return(overriddenMethods);
            });

            _thisType       = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ThisType));
            _thisObjectType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ThisObjectType));
        }
Пример #26
0
        private protected TemplateDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastTemplate or < CX_DeclKind.CX_DeclKind_FirstTemplate)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _associatedConstraints = new Lazy <IReadOnlyList <Expr> >(() => {
                var associatedConstraintCount = Handle.NumAssociatedConstraints;
                var associatedConstraints     = new List <Expr>(associatedConstraintCount);

                for (var i = 0; i < associatedConstraintCount; i++)
                {
                    var parameter = TranslationUnit.GetOrCreate <Expr>(Handle.GetAssociatedConstraint(unchecked ((uint)i)));
                    associatedConstraints.Add(parameter);
                }

                return(associatedConstraints);
            });
            _templatedDecl      = new Lazy <NamedDecl>(() => TranslationUnit.GetOrCreate <NamedDecl>(Handle.TemplatedDecl));
            _templateParameters = new Lazy <IReadOnlyList <NamedDecl> >(() => {
                var parameterCount = Handle.GetNumTemplateParameters(0);
                var parameters     = new List <NamedDecl>(parameterCount);

                for (var i = 0; i < parameterCount; i++)
                {
                    var parameter = TranslationUnit.GetOrCreate <NamedDecl>(Handle.GetTemplateParameter(0, unchecked ((uint)i)));
                    parameters.Add(parameter);
                }

                return(parameters);
            });
        }
Пример #27
0
 private protected VarTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
 {
     if ((CX_DeclKind.CX_DeclKind_LastVarTemplateSpecialization < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstVarTemplateSpecialization))
     {
         throw new ArgumentException(nameof(handle));
     }
 }
Пример #28
0
        private protected TypedefNameDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastTypedefName < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstTypedefName))
            {
                throw new ArgumentException(nameof(handle));
            }

            _underlyingType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.TypedefDeclUnderlyingType));
        }
Пример #29
0
        private protected RecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastRecord < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstRecord))
            {
                throw new ArgumentException(nameof(handle));
            }

            if ((handle.Kind != CXCursorKind.CXCursor_StructDecl) && (handle.Kind != CXCursorKind.CXCursor_UnionDecl) && (handle.Kind != CXCursorKind.CXCursor_ClassDecl) && (handle.Kind != CXCursorKind.CXCursor_ClassTemplatePartialSpecialization))
            {
                throw new ArgumentException(nameof(handle));
            }

            _fields         = new Lazy <IReadOnlyList <FieldDecl> >(() => Decls.OfType <FieldDecl>().ToList());
            _anonymousDecls = new Lazy <IReadOnlyList <Decl> >(() => Decls.Where(decl => ((decl is FieldDecl field) && field.IsAnonymousField) || ((decl is RecordDecl record) && record.IsAnonymousStructOrUnion)).ToList());
        }
Пример #30
0
 private protected CXXMethodDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
 {
     if ((CX_DeclKind.CX_DeclKind_LastCXXMethod < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXMethod))
     {
         throw new ArgumentException(nameof(handle));
     }
 }