Ejemplo n.º 1
0
        private static void ProcessTypeEntity(
            AST ast,
            NativeType type,
            CXType cxType,
            TypeVisitContext context)
        {
            type.IsConst = ClangTraits.IsConst(cxType);
            if (ClangTraits.IsBuiltInType(cxType))
            {
                type.SetBuiltin(ClangTraits.ToBasicType(cxType));
            }
            else
            {
                CXCursor cursor              = clang.getTypeDeclaration(cxType);
                CXType   theType             = clang.getCursorType(cursor);
                string   removeQualifierName = clang.getTypeSpelling(theType).ToString();

                if (ClangTraits.IsEnum(cxType))
                {
                    type.SetEnum(ast.GetEnum(removeQualifierName));
                }
                else if (ClangTraits.IsFunction(cxType))
                {
                    type.SetFunction(GetFunctionProto(ast, cxType, context));
                }
                else if (ClangTraits.IsUserDefiendType(cxType))
                {
                    NativeClass nativeClass = ast.GetClass(removeQualifierName);

                    // if native class is parsed already, the native class is a full specialization
                    // or the native class is a instantiation of a template or partial specialization
                    if (!nativeClass.IsClassEntity && !nativeClass.Parsed)
                    {
                        nativeClass.Parsed = true;
                        if (TemplateHelper.VisitTemplate(cursor, nativeClass, ast))
                        {
                            TemplateHelper.VisitTemplateParameter(cursor, theType, nativeClass, ast, context);
                        }
                    }

                    type.SetClass(nativeClass);
                }
            }
        }
Ejemplo n.º 2
0
        public bool DoVisit(CXCursor cursor, CXCursor parent)
        {
            //string name = clang.getCursorSpelling(cursor).ToString();
            string name = clang.getTypeSpelling(clang.getCursorType(cursor)).ToString();

            Enumeration @enum = AST_.GetEnum(name);

            if ([email protected])
            {
                @enum.Parsed = true;

                ProcessEnumDetail(@enum, cursor, parent);

                // create IntPtr for context
                GCHandle enumHandle = GCHandle.Alloc(@enum);

                // visit children
                clang.visitChildren(cursor, Visitor, new CXClientData((IntPtr)enumHandle));
            }

            return(true);
        }