Пример #1
0
        public static bool VisitTemplate(CXCursor cursor, NativeClass c, AST ast)
        {
            CXType   type           = clang.getCursorType(cursor);
            CXCursor templateCursor = clang.getSpecializedCursorTemplate(cursor);

            if (ClangTraits.IsInvalid(templateCursor))
            {
                return(false);
            }

            string        templateID = clang.getCursorUSR(templateCursor).ToString();
            ClassTemplate template   = ast.GetClassTemplate(templateID);

            CXCursor      originalTemplateCursor = clang.getSpecializedCursorTemplate(templateCursor);
            ClassTemplate originalTemplate;

            if (ClangTraits.IsInvalid(originalTemplateCursor))
            {
                originalTemplate = template;
            }
            else
            {
                string originalTemplateID = clang.getCursorUSR(originalTemplateCursor).ToString();
                originalTemplate = ast.GetClassTemplate(originalTemplateID);
            }

            c.SetTemplate(template, originalTemplate);
            return(true);
        }
Пример #2
0
        public bool DoVisit(CXCursor cursor, CXCursor parent)
        {
            string        id       = clang.getCursorUSR(cursor).ToString();
            ClassTemplate template = AST_.GetClassTemplate(id);

            bool isDefinition = clang.isCursorDefinition(cursor) != 0;

            if (!template.Parsed)
            {
                if (template.TP == null)
                {
                    // proto
                    template.TP = GetTemplateProto(cursor);

                    // name
                    template.Name = visitor_.GetCurrentScopeName(
                        clang.getCursorDisplayName(cursor).ToString()
                        );

                    // spelling
                    template.Spelling = visitor_.GetCurrentScopeName(
                        clang.getCursorSpelling(cursor).ToString()
                        );
                }

                // do parse for template definition
                if (isDefinition)
                {
                    template.Parsed = true;
                    GCHandle classTemplateHandle = GCHandle.Alloc(template);
                    clang.visitChildren(cursor, Visitor, new CXClientData((IntPtr)classTemplateHandle));
                }
            }
            return(true);
        }