示例#1
0
 private protected OMPExecutableDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
     if ((CX_StmtClass.CX_StmtClass_LastOMPExecutableDirective < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstOMPExecutableDirective))
     {
         throw new ArgumentException(nameof(handle));
     }
 }
        public CXChildVisitResult Visit(CXCursor cursor, CXCursor parent, IntPtr data)
        {
            if (cursor.IsInSystemHeader())
            {
                return(CXChildVisitResult.CXChildVisit_Continue);
            }

            CXCursorKind curKind = clang.getCursorKind(cursor);

            if (curKind == CXCursorKind.CXCursor_StructDecl)
            {
                this.fieldPosition = 0;
                var structName = clang.getCursorSpelling(cursor).ToString();

                // struct names can be empty, and so we visit its sibling to find the name
                if (string.IsNullOrEmpty(structName))
                {
                    var forwardDeclaringVisitor = new ForwardDeclarationVisitor(cursor);
                    clang.visitChildren(clang.getCursorSemanticParent(cursor), forwardDeclaringVisitor.Visit, new CXClientData(IntPtr.Zero));
                    structName = clang.getCursorSpelling(forwardDeclaringVisitor.ForwardDeclarationCursor).ToString();

                    if (string.IsNullOrEmpty(structName))
                    {
                        structName = "_";
                    }
                }

                if (!this.visitedStructs.Contains(structName))
                {
                    this.IndentedWriteLine("public partial struct " + structName);
                    this.IndentedWriteLine("{");

                    this.indentLevel++;
                    clang.visitChildren(cursor, this.Visit, new CXClientData(IntPtr.Zero));
                    this.indentLevel--;

                    this.IndentedWriteLine("}");
                    this.tw.WriteLine();

                    this.visitedStructs.Add(structName);
                }

                return(CXChildVisitResult.CXChildVisit_Continue);
            }

            if (curKind == CXCursorKind.CXCursor_FieldDecl)
            {
                var fieldName = clang.getCursorSpelling(cursor).ToString();
                if (string.IsNullOrEmpty(fieldName))
                {
                    fieldName = "field" + this.fieldPosition; // what if they have fields called field*? :)
                }

                this.fieldPosition++;
                this.IndentedWriteLine(cursor.ToMarshalString(fieldName));
                return(CXChildVisitResult.CXChildVisit_Continue);
            }

            return(CXChildVisitResult.CXChildVisit_Recurse);
        }
示例#3
0
 private protected OMPLoopDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
     if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastOMPLoopDirective or < CX_StmtClass.CX_StmtClass_FirstOMPLoopDirective)
     {
         throw new ArgumentOutOfRangeException(nameof(handle));
     }
 }
示例#4
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());
        }
示例#5
0
        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 ArgumentOutOfRangeException(nameof(handle));
            }

            _children = new Lazy <IReadOnlyList <Stmt> >(() => {
                var numChildren = Handle.NumChildren;
                var children    = new List <Stmt>(numChildren);

                for (var i = 0; i < numChildren; i++)
                {
                    var child = TranslationUnit.GetOrCreate <Stmt>(Handle.GetChild(unchecked ((uint)i)));
                    children.Add(child);
                }

                return(children);
            });

            _declContext = new Lazy <IDeclContext>(() => {
                var semanticParent = TranslationUnit.GetOrCreate <Cursor>(Handle.SemanticParent);

                while (semanticParent is not IDeclContext and not null)
                {
                    semanticParent = TranslationUnit.GetOrCreate <Cursor>(semanticParent.Handle.SemanticParent);
                }

                return((IDeclContext)semanticParent);
            });
        }
示例#6
0
 public CXString GetParent(out CXCursorKind kind)
 {
     fixed(CXCursorKind *pKind = &kind)
     {
         return(clang.getCompletionParent(this, pKind));
     }
 }
示例#7
0
        private protected TemplateDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastTemplate or < CX_DeclKind.CX_DeclKind_FirstTemplate)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _associatedConstraints = new Lazy <IReadOnlyList <Expr> >(() => {
                var associatedConstraintCount = Handle.NumAssociatedConstraints;
                var associatedConstraints     = new List <Expr>(associatedConstraintCount);

                for (var i = 0; i < associatedConstraintCount; i++)
                {
                    var parameter = TranslationUnit.GetOrCreate <Expr>(Handle.GetAssociatedConstraint(unchecked ((uint)i)));
                    associatedConstraints.Add(parameter);
                }

                return(associatedConstraints);
            });
            _templatedDecl      = new Lazy <NamedDecl>(() => TranslationUnit.GetOrCreate <NamedDecl>(Handle.TemplatedDecl));
            _templateParameters = new Lazy <IReadOnlyList <NamedDecl> >(() => {
                var parameterCount = Handle.GetNumTemplateParameters(0);
                var parameters     = new List <NamedDecl>(parameterCount);

                for (var i = 0; i < parameterCount; i++)
                {
                    var parameter = TranslationUnit.GetOrCreate <NamedDecl>(Handle.GetTemplateParameter(0, unchecked ((uint)i)));
                    parameters.Add(parameter);
                }

                return(parameters);
            });
        }
示例#8
0
 internal FunctionDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
 {
     _body       = new Lazy <Stmt>(() => CursorChildren.Where((cursor) => cursor is Stmt).Cast <Stmt>().SingleOrDefault());
     _decls      = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.Where((cursor) => cursor is Decl).Cast <Decl>().ToList());
     _parameters = new Lazy <IReadOnlyList <ParmVarDecl> >(() => Decls.Where((decl) => decl is ParmVarDecl).Cast <ParmVarDecl>().ToList());
     _returnType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ResultType));
 }
        public CXChildVisitResult Visit(CXCursor cursor, CXCursor parent, IntPtr data)
        {
            if (cursor.IsInSystemHeader())
            {
                return(CXChildVisitResult.CXChildVisit_Continue);
            }

            CXCursorKind curKind = clang.getCursorKind(cursor);

            // look only at function decls
            if (curKind == CXCursorKind.CXCursor_FunctionDecl)
            {
                var functionName = clang.getCursorSpelling(cursor).ToString();

                if (this.visitedFunctions.Contains(functionName))
                {
                    return(CXChildVisitResult.CXChildVisit_Continue);
                }

                this.visitedFunctions.Add(functionName);

                Extensions.WriteFunctionInfoHelper(cursor, this.tw, this.prefixStrip);

                return(CXChildVisitResult.CXChildVisit_Continue);
            }

            return(CXChildVisitResult.CXChildVisit_Recurse);
        }
示例#10
0
        public CXChildVisitResult VisitClass(CXCursor cursor, CXCursor parent, IntPtr data)
        {
            CXCursorKind curKind = clang.getCursorKind(cursor);

            if (curKind == CXCursorKind.CXCursor_CXXMethod || curKind == CXCursorKind.CXCursor_Constructor || curKind == CXCursorKind.CXCursor_Destructor)
            {
                if (this.current != null)
                {
                    var lines = FileVisitor.NumLines(cursor);
                    this.current.LOC += lines;
                }
            }
            else if (curKind == CXCursorKind.CXCursor_TypeRef || curKind == CXCursorKind.CXCursor_VarDecl || curKind == CXCursorKind.CXCursor_CXXBaseSpecifier || curKind == CXCursorKind.CXCursor_TemplateRef || curKind == CXCursorKind.CXCursor_DeclRefExpr || curKind == CXCursorKind.CXCursor_ClassTemplate)
            {
                this.References(FullName(cursor));
            }
            else if (curKind == CXCursorKind.CXCursor_EnumDecl)
            {
                if (this.current != null)
                {
                    this.leaves[FullName(cursor)] = this.current;
                }
            }

            return(CXChildVisitResult.CXChildVisit_Recurse);
        }
示例#11
0
        private protected OverloadExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastOverloadExpr or < CX_StmtClass.CX_StmtClass_FirstOverloadExpr)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _decls = new Lazy <IReadOnlyList <Decl> >(() => {
                var numDecls = Handle.NumDecls;
                var decls    = new List <Decl>(numDecls);

                for (var i = 0; i < numDecls; i++)
                {
                    var decl = TranslationUnit.GetOrCreate <Decl>(Handle.GetDecl(unchecked ((uint)i)));
                    decls.Add(decl);
                }

                return(decls);
            });

            _namingClass = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.Referenced));

            _templateArgs = new Lazy <IReadOnlyList <TemplateArgumentLoc> >(() => {
                var templateArgCount = Handle.NumTemplateArguments;
                var templateArgs     = new List <TemplateArgumentLoc>(templateArgCount);

                for (var i = 0; i < templateArgCount; i++)
                {
                    var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked ((uint)i)));
                    templateArgs.Add(templateArg);
                }

                return(templateArgs);
            });
        }
示例#12
0
        public CXChildVisitResult Visit(CXCursor cursor, CXCursor parent)
        {
            if (!cursor.Location.IsFromMainFile)
            {
                return(CXChildVisitResult.CXChildVisit_Continue);
            }

            CXCursorKind curKind = cursor.Kind;

            if (curKind == CXCursorKind.CXCursor_TypedefDecl)
            {
                var nativeName = cursor.Spelling.CString;
                var clrName    = NameConversions.ToClrName(nativeName, NameConversion.Type);

                // if we've printed these previously, skip them
                if (this.generator.NameMapping.ContainsKey(nativeName))
                {
                    return(CXChildVisitResult.CXChildVisit_Continue);
                }

                CXType type = cursor.TypedefDeclUnderlyingType.CanonicalType;

                // we handle enums and records in struct and enum visitors with forward declarations also
                if (type.kind == CXTypeKind.CXType_Record || type.kind == CXTypeKind.CXType_Enum)
                {
                    return(CXChildVisitResult.CXChildVisit_Continue);
                }

                if (type.kind == CXTypeKind.CXType_Pointer)
                {
                    var pointee = type.PointeeType;
                    if (pointee.kind == CXTypeKind.CXType_Record || pointee.kind == CXTypeKind.CXType_Void)
                    {
                        var types = Handles.CreateSafeHandle(clrName, this.generator).ToArray();
                        this.generator.AddType(nativeName, types[0]);

                        for (int i = 1; i < types.Length; i++)
                        {
                            this.generator.AddType(types[i].Name, types[i]);
                        }

                        return(CXChildVisitResult.CXChildVisit_Continue);
                    }

                    if (pointee.kind == CXTypeKind.CXType_FunctionProto)
                    {
                        var functionType = cursor.TypedefDeclUnderlyingType;
                        var pt           = functionType.PointeeType;
                        CodeTypeDelegate delegateType = pt.ToDelegate(nativeName, cursor, this.generator);
                        this.generator.AddType(nativeName, new CodeDomGeneratedType(delegateType));

                        return(CXChildVisitResult.CXChildVisit_Continue);
                    }
                }

                return(CXChildVisitResult.CXChildVisit_Continue);
            }

            return(CXChildVisitResult.CXChildVisit_Recurse);
        }
示例#13
0
 private protected OverloadExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
     if ((CX_StmtClass.CX_StmtClass_LastOverloadExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstOverloadExpr))
     {
         throw new ArgumentException(nameof(handle));
     }
 }
示例#14
0
        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));
            }

            _definition = new Lazy <TagDecl>(() => TranslationUnit.GetOrCreate <TagDecl>(Handle.Definition));

            _templateParameterLists = new Lazy <IReadOnlyList <IReadOnlyList <NamedDecl> > >(() => {
                var numTemplateParameterLists = Handle.NumTemplateParameterLists;
                var templateParameterLists    = new List <IReadOnlyList <NamedDecl> >(numTemplateParameterLists);

                for (var listIndex = 0; listIndex < numTemplateParameterLists; listIndex++)
                {
                    var numTemplateParameters = Handle.GetNumTemplateParameters(unchecked ((uint)listIndex));
                    var templateParameterList = new List <NamedDecl>(numTemplateParameters);

                    for (var parameterIndex = 0; parameterIndex < numTemplateParameters; parameterIndex++)
                    {
                        var templateParameter = TranslationUnit.GetOrCreate <NamedDecl>(Handle.GetTemplateParameter(unchecked ((uint)listIndex), unchecked ((uint)parameterIndex)));
                        templateParameterList.Add(templateParameter);
                    }

                    templateParameterLists.Add(templateParameterList);
                }

                return(templateParameterLists);
            });

            _typedefNameForAnonDecl = new Lazy <TypedefNameDecl>(() => TranslationUnit.GetOrCreate <TypedefNameDecl>(Handle.TypedefNameForAnonDecl));
        }
示例#15
0
 private protected CXXMethodDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
 {
     if ((CX_DeclKind.CX_DeclKind_LastCXXMethod < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXMethod))
     {
         throw new ArgumentException(nameof(handle));
     }
 }
示例#16
0
 private protected UsingShadowDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
 {
     if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastUsingShadow or < CX_DeclKind.CX_DeclKind_FirstUsingShadow)
     {
         throw new ArgumentOutOfRangeException(nameof(handle));
     }
 }
 private protected CXXNamedCastExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
     if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCXXNamedCastExpr or < CX_StmtClass.CX_StmtClass_FirstCXXNamedCastExpr)
     {
         throw new ArgumentOutOfRangeException(nameof(handle));
     }
 }
示例#18
0
 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));
     }
 }
示例#19
0
 private protected ValueStmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
     if ((CX_StmtClass.CX_StmtClass_LastValueStmt < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstValueStmt))
     {
         throw new ArgumentException(nameof(handle));
     }
 }
示例#20
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));
 }
示例#21
0
        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));
        }
示例#22
0
        private protected DeclaratorDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastDeclarator < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstDeclarator))
            {
                throw new ArgumentException(nameof(handle));
            }

            _templateParameterLists = new Lazy <IReadOnlyList <IReadOnlyList <NamedDecl> > >(() => {
                var numTemplateParameterLists = Handle.NumTemplateParameterLists;
                var templateParameterLists    = new List <IReadOnlyList <NamedDecl> >(numTemplateParameterLists);

                for (var listIndex = 0; listIndex < numTemplateParameterLists; listIndex++)
                {
                    var numTemplateParameters = Handle.GetNumTemplateParameters(unchecked ((uint)listIndex));
                    var templateParameterList = new List <NamedDecl>(numTemplateParameters);

                    for (var parameterIndex = 0; parameterIndex < numTemplateParameters; parameterIndex++)
                    {
                        var templateParameter = TranslationUnit.GetOrCreate <NamedDecl>(Handle.GetTemplateParameter(unchecked ((uint)listIndex), unchecked ((uint)parameterIndex)));
                        templateParameterList.Add(templateParameter);
                    }

                    templateParameterLists.Add(templateParameterList);
                }

                return(templateParameterLists);
            });

            _trailingRequiresClause = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.TrailingRequiresClause));
        }
示例#23
0
 private protected AbstractConditionalOperator(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
     if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastAbstractConditionalOperator or < CX_StmtClass.CX_StmtClass_FirstAbstractConditionalOperator)
     {
         throw new ArgumentOutOfRangeException(nameof(handle));
     }
 }
示例#24
0
 public LocationItem(File file, Position position, string name, CXCursorKind kind)
 {
     this.File     = file;
     this.Position = position;
     this.Name     = name;
     this.Kind     = kind;
 }
示例#25
0
        private protected BinaryOperator(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
        {
            Debug.Assert(Children.Where((cursor) => cursor is Expr).Count() == 2);

            _lhs    = new Lazy <Expr>(() => Children.OfType <Expr>().First());
            _opcode = new Lazy <string>(GetOpcode);
            _rhs    = new Lazy <Expr>(() => Children.OfType <Expr>().Last());
        }
示例#26
0
文件: Decl.cs 项目: xen2/ClangSharp
 private protected Decl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
 {
     _attrs               = new Lazy <IReadOnlyList <Attr> >(() => CursorChildren.Where((cursor) => cursor is Attr).Cast <Attr>().ToList());
     _canonicalDecl       = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.CanonicalCursor));
     _declContext         = new Lazy <IDeclContext>(() => (IDeclContext)Create(Handle.SemanticParent));
     _lexicalDeclContext  = new Lazy <IDeclContext>(() => (IDeclContext)Create(Handle.LexicalParent));
     _translationUnitDecl = new Lazy <TranslationUnitDecl>(() => TranslationUnit.GetOrCreate <TranslationUnitDecl>(Handle.TranslationUnit.Cursor));
 }
示例#27
0
        private protected TypedefNameDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastTypedefName or < CX_DeclKind.CX_DeclKind_FirstTypedefName)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _underlyingType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.TypedefDeclUnderlyingType));
        }
示例#28
0
        private protected FullExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastFullExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstFullExpr))
            {
                throw new ArgumentException(nameof(handle));
            }

            _subExpr = new Lazy <Expr>(() => Children.OfType <Expr>().Single());
        }
        private protected RedeclarableTemplateDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastRedeclarableTemplate or < CX_DeclKind.CX_DeclKind_FirstRedeclarableTemplate)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _instantiatedFromMemberTemplate = new Lazy <RedeclarableTemplateDecl>(() => TranslationUnit.GetOrCreate <RedeclarableTemplateDecl>(Handle.SpecializedCursorTemplate));
        }
示例#30
0
        private protected Expr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastExpr or < CX_StmtClass.CX_StmtClass_FirstExpr)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _type = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.Type));
        }
示例#31
0
 public static extern CXString getCompletionParent(CXCompletionString @completion_string, out CXCursorKind @kind);
示例#32
0
 public static extern CXString getCursorKindSpelling(CXCursorKind @Kind);
示例#33
0
 public static extern uint isUnexposed(CXCursorKind @param0);
示例#34
0
 public static extern uint isPreprocessing(CXCursorKind @param0);
示例#35
0
 public static extern uint isTranslationUnit(CXCursorKind @param0);
示例#36
0
 public static extern uint isInvalid(CXCursorKind @param0);
示例#37
0
 public static extern uint isAttribute(CXCursorKind @param0);
示例#38
0
 public static extern uint isStatement(CXCursorKind @param0);
示例#39
0
 public static extern uint isExpression(CXCursorKind @param0);
示例#40
0
 public static extern uint isReference(CXCursorKind @param0);
示例#41
0
 public static extern uint isDeclaration(CXCursorKind @param0);