コード例 #1
0
        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());
        }
コード例 #2
0
        internal static new Decl Create(CXCursor handle)
        {
            Decl result;

            switch (handle.Kind)
            {
            case CXCursorKind.CXCursor_UnexposedDecl:
            {
                result = new Decl(handle, handle.Kind);
                break;
            }

            case CXCursorKind.CXCursor_StructDecl:
            case CXCursorKind.CXCursor_UnionDecl:
            case CXCursorKind.CXCursor_ClassDecl:
            {
                if (handle.Language == CXLanguageKind.CXLanguage_CPlusPlus)
                {
                    result = new CXXRecordDecl(handle, handle.Kind);
                }
                else
                {
                    result = new RecordDecl(handle, handle.Kind);
                }
                break;
            }

            case CXCursorKind.CXCursor_EnumDecl:
            {
                result = new EnumDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_FieldDecl:
            {
                result = new FieldDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_EnumConstantDecl:
            {
                result = new EnumConstantDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_FunctionDecl:
            {
                result = new FunctionDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_VarDecl:
            {
                result = new VarDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_ParmDecl:
            {
                result = new ParmVarDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_ObjCInterfaceDecl:
            {
                result = new ObjCInterfaceDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_ObjCCategoryDecl:
            {
                result = new ObjCCategoryDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_ObjCProtocolDecl:
            {
                result = new ObjCProtocolDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_ObjCPropertyDecl:
            {
                result = new ObjCPropertyDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_ObjCIvarDecl:
            {
                result = new ObjCIvarDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_ObjCInstanceMethodDecl:
            case CXCursorKind.CXCursor_ObjCClassMethodDecl:
            {
                result = new ObjCMethodDecl(handle, handle.Kind);
                break;
            }

            case CXCursorKind.CXCursor_ObjCImplementationDecl:
            {
                result = new ObjCImplementationDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_ObjCCategoryImplDecl:
            {
                result = new ObjCCategoryImplDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_TypedefDecl:
            {
                result = new TypedefDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_CXXMethod:
            {
                result = new CXXMethodDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_Namespace:
            {
                result = new NamespaceDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_LinkageSpec:
            {
                result = new LinkageSpecDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_Constructor:
            {
                result = new CXXConstructorDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_Destructor:
            {
                result = new CXXDestructorDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_ConversionFunction:
            {
                result = new CXXConversionDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_TemplateTypeParameter:
            {
                result = new TemplateTypeParmDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_NonTypeTemplateParameter:
            {
                result = new NonTypeTemplateParmDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_TemplateTemplateParameter:
            {
                result = new TemplateTemplateParmDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_FunctionTemplate:
            {
                result = new FunctionTemplateDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_ClassTemplate:
            {
                result = new ClassTemplateDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_ClassTemplatePartialSpecialization:
            {
                result = new ClassTemplatePartialSpecializationDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_NamespaceAlias:
            {
                result = new NamespaceAliasDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_UsingDirective:
            {
                result = new UsingDirectiveDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_UsingDeclaration:
            {
                result = new UsingDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_TypeAliasDecl:
            {
                result = new TypeAliasDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_CXXAccessSpecifier:
            {
                result = new AccessSpecDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_ObjCSynthesizeDecl:
            case CXCursorKind.CXCursor_ObjCDynamicDecl:
            {
                result = new ObjCPropertyImplDecl(handle, handle.Kind);
                break;
            }

            case CXCursorKind.CXCursor_ModuleImportDecl:
            {
                result = new ImportDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_TypeAliasTemplateDecl:
            {
                result = new TypeAliasTemplateDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_StaticAssert:
            {
                result = new StaticAssertDecl(handle);
                break;
            }

            case CXCursorKind.CXCursor_FriendDecl:
            {
                result = new FriendDecl(handle);
                break;
            }

            default:
            {
                Debug.WriteLine($"Unhandled declaration kind: {handle.KindSpelling}.");
                result = new Decl(handle, handle.Kind);
                break;
            }
            }

            return(result);
        }