Beispiel #1
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> >(() => {
                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());
        }
Beispiel #2
0
 private protected FunctionDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
 {
     _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));
 }
        internal ObjCCategoryDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCCategoryDecl, CX_DeclKind.CX_DeclKind_ObjCCategory)
        {
            _classInterface       = new Lazy <ObjCInterfaceDecl>(() => TranslationUnit.GetOrCreate <ObjCInterfaceDecl>(Handle.GetSubDecl(0)));
            _implementation       = new Lazy <ObjCCategoryImplDecl>(() => TranslationUnit.GetOrCreate <ObjCCategoryImplDecl>(Handle.GetSubDecl(1)));
            _ivars                = new Lazy <IReadOnlyList <ObjCIvarDecl> >(() => Decls.OfType <ObjCIvarDecl>().ToList());
            _nextClassCategory    = new Lazy <ObjCCategoryDecl>(() => TranslationUnit.GetOrCreate <ObjCCategoryDecl>(Handle.GetSubDecl(2)));
            _nextClassCategoryRaw = new Lazy <ObjCCategoryDecl>(() => TranslationUnit.GetOrCreate <ObjCCategoryDecl>(Handle.GetSubDecl(3)));

            _protocols = new Lazy <IReadOnlyList <ObjCProtocolDecl> >(() => {
                var numProtocols = Handle.NumProtocols;
                var protocols    = new List <ObjCProtocolDecl>(numProtocols);

                for (int i = 0; i < numProtocols; i++)
                {
                    var protocol = TranslationUnit.GetOrCreate <ObjCProtocolDecl>(Handle.GetProtocol(unchecked ((uint)i)));
                    protocols.Add(protocol);
                }

                return(protocols);
            });

            _typeParamList = new Lazy <IReadOnlyList <ObjCTypeParamDecl> >(() => {
                var numTypeParams = Handle.NumArguments;
                var typeParams    = new List <ObjCTypeParamDecl>(numTypeParams);

                for (int i = 0; i < numTypeParams; i++)
                {
                    var typeParam = TranslationUnit.GetOrCreate <ObjCTypeParamDecl>(Handle.GetArgument(unchecked ((uint)i)));
                    typeParams.Add(typeParam);
                }

                return(typeParams);
            });
        }
Beispiel #4
0
 internal CXXRecordDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
 {
     _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());
 }
        private protected ObjCImplDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastObjCImpl or < CX_DeclKind.CX_DeclKind_FirstObjCImpl)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _classInterface = new Lazy <ObjCInterfaceDecl>(() => TranslationUnit.GetOrCreate <ObjCInterfaceDecl>(Handle.GetSubDecl(0)));
            _propertyImpls  = new Lazy <IReadOnlyList <ObjCPropertyImplDecl> >(() => Decls.OfType <ObjCPropertyImplDecl>().ToList());
        }
        internal ObjCInterfaceDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCInterfaceDecl, CX_DeclKind.CX_DeclKind_ObjCInterface)
        {
            _categoryList = new Lazy <IReadOnlyList <ObjCCategoryDecl> >(() => {
                var categories = new List <ObjCCategoryDecl>();

                ObjCCategoryDecl category = TranslationUnit.GetOrCreate <ObjCCategoryDecl>(handle.GetSubDecl(0));

                while (category != null)
                {
                    categories.Add(category);
                    category = category.NextClassCategoryRaw;
                }

                return(categories);
            });

            _definition      = new Lazy <ObjCInterfaceDecl>(() => TranslationUnit.GetOrCreate <ObjCInterfaceDecl>(Handle.Definition));
            _implementation  = new Lazy <ObjCImplementationDecl>(() => TranslationUnit.GetOrCreate <ObjCImplementationDecl>(Handle.GetSubDecl(1)));
            _ivars           = new Lazy <IReadOnlyList <ObjCIvarDecl> >(() => Decls.OfType <ObjCIvarDecl>().ToList());
            _knownExtensions = new Lazy <IReadOnlyList <ObjCCategoryDecl> >(() => CategoryList.Where((category) => category.IsClassExtension).ToList());

            _protocols = new Lazy <IReadOnlyList <ObjCProtocolDecl> >(() => {
                var numProtocols = Handle.NumProtocols;
                var protocols    = new List <ObjCProtocolDecl>(numProtocols);

                for (int i = 0; i < numProtocols; i++)
                {
                    var protocol = TranslationUnit.GetOrCreate <ObjCProtocolDecl>(Handle.GetProtocol(unchecked ((uint)i)));
                    protocols.Add(protocol);
                }

                return(protocols);
            });

            _superClass     = new Lazy <ObjCInterfaceDecl>(() => TranslationUnit.GetOrCreate <ObjCInterfaceDecl>(Handle.GetSubDecl(2)));
            _superClassType = new Lazy <ObjCObjectType>(() => TranslationUnit.GetOrCreate <ObjCObjectType>(Handle.TypeOperand));
            _typeForDecl    = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ThisType));

            _typeParamList = new Lazy <IReadOnlyList <ObjCTypeParamDecl> >(() => {
                var numTypeParams = Handle.NumArguments;
                var typeParams    = new List <ObjCTypeParamDecl>(numTypeParams);

                for (int i = 0; i < numTypeParams; i++)
                {
                    var typeParam = TranslationUnit.GetOrCreate <ObjCTypeParamDecl>(Handle.GetArgument(unchecked ((uint)i)));
                    typeParams.Add(typeParam);
                }

                return(typeParams);
            });

            _visibleCategories = new Lazy <IReadOnlyList <ObjCCategoryDecl> >(() => CategoryList.Where((category) => category.IsUnconditionallyVisible).ToList());
            _visibleExtensions = new Lazy <IReadOnlyList <ObjCCategoryDecl> >(() => CategoryList.Where((category) => category.IsClassExtension && category.IsUnconditionallyVisible).ToList());
        }
        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));
        }
Beispiel #8
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());
        }
        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());
        }
Beispiel #10
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());
        }
Beispiel #11
0
        internal ObjCImplementationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCImplementationDecl, CX_DeclKind.CX_DeclKind_ObjCImplementation)
        {
            _initExprs = new Lazy <IReadOnlyList <Expr> >(() => {
                var numInitExprs = Handle.NumExprs;
                var initExprs    = new List <Expr>(numInitExprs);

                for (var i = 0; i < numInitExprs; i++)
                {
                    var initExpr = TranslationUnit.GetOrCreate <Expr>(Handle.GetExpr(unchecked ((uint)i)));
                    initExprs.Add(initExpr);
                }

                return(initExprs);
            });

            _ivars      = new Lazy <IReadOnlyList <ObjCIvarDecl> >(() => Decls.OfType <ObjCIvarDecl>().ToList());
            _superClass = new Lazy <ObjCInterfaceDecl>(() => TranslationUnit.GetOrCreate <ObjCInterfaceDecl>(Handle.GetSubDecl(1)));
        }
Beispiel #12
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());
        }
Beispiel #13
0
 internal EnumDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumDecl, CX_DeclKind.CX_DeclKind_Enum)
 {
     _enumerators = new Lazy <IReadOnlyList <EnumConstantDecl> >(() => Decls.OfType <EnumConstantDecl>().ToList());
     _integerType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.EnumDecl_IntegerType));
 }
Beispiel #14
0
 internal RecordDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
 {
     _fields = new Lazy <IReadOnlyList <FieldDecl> >(() => Decls.OfType <FieldDecl>().ToList());
 }