Example #1
0
        internal AutoType(CXType handle) : base(handle, CXTypeKind.CXType_Auto, CX_TypeClass.CX_TypeClass_Auto)
        {
            _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);
            });
        }
        internal DependentTemplateSpecializationType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentTemplateSpecialization)
        {
            _desugaredType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.Desugar()));
            _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 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 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 <TemplateArgument> >(() => {
                var templateArgsSize = TemplateArgsSize;
                var templateArgs     = new List <TemplateArgument>((int)templateArgsSize);

                for (var index = 0u; index < templateArgsSize; index++)
                {
                    var templateArg = new TemplateArgument(this, index);
                    templateArgs.Add(templateArg);
                }

                return(templateArgs);
            });
        }