コード例 #1
0
        void ProcessEnumDetail(Enumeration @enum, CXCursor cursor, CXCursor parent)
        {
            // unscoped name
            @enum.UnscopedName = clang.getCursorSpelling(cursor).ToString();

            // underlying type
            CXType    underlyingType = clang.getEnumDeclIntegerType(cursor);
            BasicType type           = ClangTraits.ToBasicType(underlyingType);

            @enum.Type = type;

            // is scoped
            @enum.IsEnumClass = clang.EnumDecl_isScoped(cursor) != 0;

            // check is parent is a class
            if (OwnerClass_ != null)
            {
                Debug.Assert(ClangTraits.IsUserDefinedTypeDecl(parent));
                OwnerClass_.AddSubEnum(new SubEnum
                {
                    Access = ClangTraits.ToAccessSpecifier(clang.getCXXAccessSpecifier(cursor)),
                    Enum   = @enum
                });
            }
        }
コード例 #2
0
        private void ProcessClassDetail(
            NativeClass thisClass,              // this class to parse
            CXCursor cursor,                    // current cursor
            CXType type,                        // current cursor type
            CXCursor parent                     // parent cursor
            )
        {
            // set unscoped name
            thisClass.UnscopedName = clang.getCursorSpelling(cursor).ToString();

            // set struct or class
            thisClass.ClassTag = ClangTraits.ToStructOrClass(cursor.kind);

            // abstract
            thisClass.IsAbstract = clang.CXXRecord_isAbstract(cursor) != 0;

            // virtual base
            thisClass.IsVirtualBase = clang.isVirtualBase(cursor) != 0;

            // set template instance info
            if (TemplateHelper.VisitTemplate(cursor, thisClass, AST_))
            {
                thisClass.IsFullSpecialization = true;

                TypeVisitContext context = new TypeVisitContext(cursor);
                TemplateHelper.VisitTemplateParameter(cursor, type, thisClass, AST_, context);
            }

            // set subclass
            if (ClangTraits.IsUserDefinedTypeDecl(parent))
            {
                Debug.Assert(OwnerClass_ != null);
                thisClass.IsEmbedded = true;
                thisClass.OwnerClass = OwnerClass_;

                SubClass subClass = new SubClass
                {
                    Access = ClangTraits.ToAccessSpecifier(clang.getCXXAccessSpecifier(cursor)),
                    Class  = thisClass
                };

                OwnerClass_.AddSubClass(subClass);
            }
        }