Пример #1
0
        internal Capture(Decl parentDecl, uint index)
        {
            _parentDecl = parentDecl;
            _index      = index;

            _copyExpr = new Lazy <Expr>(() => _parentDecl.TranslationUnit.GetOrCreate <Expr>(_parentDecl.Handle.GetCaptureCopyExpr(_index)));
            _variable = new Lazy <VarDecl>(() => _parentDecl.TranslationUnit.GetOrCreate <VarDecl>(_parentDecl.Handle.GetCaptureVariable(_index)));
        }
Пример #2
0
 internal TemplateArgument(Decl parentDecl, uint index)
 {
     _parentDecl   = parentDecl;
     _index        = index;
     _asDecl       = new Lazy <ValueDecl>(() => _parentDecl.TranslationUnit.GetOrCreate <ValueDecl>(_parentDecl.Handle.GetTemplateArgumentAsDecl(_index)));
     _asExpr       = new Lazy <Expr>(() => _parentDecl.TranslationUnit.GetOrCreate <Expr>(_parentDecl.Handle.GetTemplateArgumentAsExpr(_index)));
     _asType       = new Lazy <Type>(() => _parentDecl.TranslationUnit.GetOrCreate <Type>(_parentDecl.Handle.GetTemplateArgumentAsType(_index)));
     _integralType = new Lazy <Type>(() => _parentDecl.TranslationUnit.GetOrCreate <Type>(_parentDecl.Handle.GetTemplateArgumentIntegralType(_index)));
     _nullPtrType  = new Lazy <Type>(() => _parentDecl.TranslationUnit.GetOrCreate <Type>(_parentDecl.Handle.GetTemplateArgumentNullPtrType(_index)));
 }
Пример #3
0
        internal TemplateArgumentLoc(Decl parentDecl, uint index)
        {
            _argument   = new TemplateArgument(parentDecl, index);
            _parentDecl = parentDecl;
            _index      = index;

            _sourceDeclExpression     = new Lazy <Expr>(() => _parentDecl.TranslationUnit.GetOrCreate <Expr>(_parentDecl.Handle.GetTemplateArgumentLocSourceDeclExpression(_index)));
            _sourceExpression         = new Lazy <Expr>(() => _parentDecl.TranslationUnit.GetOrCreate <Expr>(_parentDecl.Handle.GetTemplateArgumentLocSourceExpression(_index)));
            _sourceIntegralExpression = new Lazy <Expr>(() => _parentDecl.TranslationUnit.GetOrCreate <Expr>(_parentDecl.Handle.GetTemplateArgumentLocSourceIntegralExpression(_index)));
            _sourceNullPtrExpression  = new Lazy <Expr>(() => _parentDecl.TranslationUnit.GetOrCreate <Expr>(_parentDecl.Handle.GetTemplateArgumentLocSourceNullPtrExpression(_index)));
        }
Пример #4
0
        internal static new Decl Create(CXCursor handle)
        {
            Decl result;

            switch (handle.Kind)
            {
            case CXCursorKind.CXCursor_UnexposedDecl:
            {
                result = new Decl(handle, CXCursorKind.CXCursor_UnexposedDecl);
                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, CXCursorKind.CXCursor_FunctionDecl);
                break;
            }

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

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

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

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

            case CXCursorKind.CXCursor_Namespace:
            {
                result = new NamespaceDecl(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_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_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}.");
                Debugger.Break();

                result = new Decl(handle, handle.Kind);
                break;
            }
            }

            return(result);
        }
Пример #5
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);
        }