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)); }
internal BlockDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Block) { _blockManglingContextDecl = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.BlockManglingContextDecl)); _captures = new Lazy <IReadOnlyList <Capture> >(() => { var captureCount = Handle.NumCaptures; var captures = new List <Capture>(captureCount); for (int i = 0; i < captureCount; i++) { var capture = new Capture(this, unchecked ((uint)i)); captures.Add(capture); } return(captures); }); _decls = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList()); _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); }); }
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)); }
private protected Decl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) { _attrs = new Lazy <IReadOnlyList <Attr> >(() => CursorChildren.OfType <Attr>().ToList()); _canonicalDecl = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.CanonicalCursor)); _declContext = new Lazy <IDeclContext>(() => Create(Handle.SemanticParent) as IDeclContext); _lexicalDeclContext = new Lazy <IDeclContext>(() => Create(Handle.LexicalParent) as IDeclContext); _translationUnitDecl = new Lazy <TranslationUnitDecl>(() => TranslationUnit.GetOrCreate <TranslationUnitDecl>(Handle.TranslationUnit.Cursor)); }
internal EnumDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumDecl, CX_DeclKind.CX_DeclKind_Enum) { _enumerators = new Lazy <IReadOnlyList <EnumConstantDecl> >(() => CursorChildren.OfType <EnumConstantDecl>().ToList()); _instantiatedFromMemberEnum = new Lazy <EnumDecl>(() => TranslationUnit.GetOrCreate <EnumDecl>(Handle.InstantiatedFromMember)); _integerType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.EnumDecl_IntegerType)); _promotionType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.EnumDecl_PromotionType)); _templateInstantiationPattern = new Lazy <EnumDecl>(() => TranslationUnit.GetOrCreate <EnumDecl>(Handle.TemplateInstantiationPattern)); }
internal LinkageSpecDecl(CXCursor handle) : base(handle, handle.Kind, CX_DeclKind.CX_DeclKind_LinkageSpec) { if ((handle.Kind != CXCursorKind.CXCursor_LinkageSpec) && (handle.Kind != CXCursorKind.CXCursor_UnexposedDecl)) { throw new ArgumentException(nameof(handle)); } _decls = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList()); }
internal ObjCMethodDecl(CXCursor handle) : base(handle, handle.Kind, CX_DeclKind.CX_DeclKind_ObjCMethod) { if ((handle.Kind != CXCursorKind.CXCursor_ObjCInstanceMethodDecl) && (handle.Kind != CXCursorKind.CXCursor_ObjCClassMethodDecl)) { throw new ArgumentException(nameof(handle)); } _decls = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList()); }
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()); }
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 Stmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind) { if ((handle.StmtClass == CX_StmtClass.CX_StmtClass_Invalid) || (handle.StmtClass != expectedStmtClass)) { throw new ArgumentException(nameof(handle)); } _children = new Lazy <IReadOnlyList <Stmt> >(() => CursorChildren.OfType <Stmt>().ToList()); }
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)); }
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)); }
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)); }
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()); }
internal CapturedDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Captured) { _contextParam = new Lazy <ImplicitParamDecl>(() => TranslationUnit.GetOrCreate <ImplicitParamDecl>(Handle.ContextParam)); _decls = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList()); _parameters = new Lazy <IReadOnlyList <ImplicitParamDecl> >(() => { var parameterCount = Handle.NumArguments; var parameters = new List <ImplicitParamDecl>(parameterCount); for (int i = 0; i < parameterCount; i++) { var parameter = TranslationUnit.GetOrCreate <ImplicitParamDecl>(Handle.GetArgument(unchecked ((uint)i))); parameters.Add(parameter); } return(parameters); }); }
private protected Stmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind) { if ((handle.StmtClass == CX_StmtClass.CX_StmtClass_Invalid) || (handle.StmtClass != expectedStmtClass)) { throw new ArgumentException(nameof(handle)); } _children = new Lazy <IReadOnlyList <Stmt> >(() => CursorChildren.OfType <Stmt>().ToList()); _declContext = new Lazy <IDeclContext>(() => { var cursorParent = CursorParent; while (!(cursorParent is IDeclContext) && (cursorParent != null)) { cursorParent = cursorParent.CursorParent; } return((IDeclContext)cursorParent); }); }
private protected Stmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind) { if ((handle.StmtClass == CX_StmtClass.CX_StmtClass_Invalid) || (handle.StmtClass != expectedStmtClass)) { throw new ArgumentException(nameof(handle)); } _children = new Lazy <IReadOnlyList <Stmt> >(() => CursorChildren.OfType <Stmt>().ToList()); _declContext = new Lazy <IDeclContext>(() => { var semanticParent = TranslationUnit.GetOrCreate <Cursor>(Handle.SemanticParent); while (!(semanticParent is IDeclContext) && (semanticParent != null)) { semanticParent = TranslationUnit.GetOrCreate <Cursor>(semanticParent.Handle.SemanticParent); } return((IDeclContext)semanticParent); }); }
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)); }
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)); }
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()); }
internal UnaryExprOrTypeTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnaryExpr, CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr) { _argumentExpr = new Lazy <Expr>(() => CursorChildren.OfType <Expr>().SingleOrDefault()); _argumentType = new Lazy <Ref>(() => CursorChildren.OfType <Ref>().SingleOrDefault()); _kind = new Lazy <CX_UnaryExprOrTypeTrait>(() => { var translationUnitHandle = TranslationUnit.Handle; var tokens = translationUnitHandle.Tokenize(Handle.RawExtent); var firstTokenSpelling = (tokens.Length > 0) ? tokens[0].GetSpelling(translationUnitHandle).CString : string.Empty; switch (firstTokenSpelling) { case "sizeof": { return(CX_UnaryExprOrTypeTrait.CX_UETT_SizeOf); } default: { return(CX_UnaryExprOrTypeTrait.CX_UETT_Invalid); } } }); }
internal TranslationUnitDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TranslationUnit, CX_DeclKind.CX_DeclKind_TranslationUnit) { _decls = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList()); }
internal NamespaceDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Namespace, CX_DeclKind.CX_DeclKind_Namespace) { _decls = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList()); }
private protected Stmt(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) { _children = new Lazy <IReadOnlyList <Stmt> >(() => CursorChildren.OfType <Stmt>().ToList()); }
internal DeclStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclStmt, CX_StmtClass.CX_StmtClass_DeclStmt) { _decls = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList()); }
internal EnumConstantDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumConstantDecl, CX_DeclKind.CX_DeclKind_EnumConstant) { _initExpr = new Lazy <Expr>(() => CursorChildren.OfType <Expr>().SingleOrDefault()); }
internal RequiresExprBodyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_RequiresExprBody) { _decls = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList()); }
internal OMPDeclareReductionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPDeclareReduction) { _decls = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList()); }
internal CapturedDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Captured) { _decls = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList()); }
private protected TagDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) { _decls = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList()); _definition = new Lazy <TagDecl>(() => TranslationUnit.GetOrCreate <TagDecl>(Handle.Definition)); }