llcppsigfetch:collect public methods

This commit is contained in:
luoliwoshang
2024-08-26 14:17:33 +08:00
parent b1225951f2
commit fc04083cb2
3 changed files with 14 additions and 2 deletions

View File

@@ -300,7 +300,7 @@ func (ct *Converter) ProcessFuncDecl(cursor clang.Cursor) *ast.FuncDecl {
fn.IsInline = true
}
if cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorDestructor || cursor.Kind == clang.CursorConstructor {
if isMethod(cursor) {
if cursor.Kind == clang.CursorDestructor {
fn.IsDestructor = true
}
@@ -466,7 +466,7 @@ type visitMethodsContext struct {
func visitMethods(cursor, parent clang.Cursor, clientData unsafe.Pointer) clang.ChildVisitResult {
ctx := (*visitMethodsContext)(clientData)
if cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorConstructor || cursor.Kind == clang.CursorDestructor {
if isMethod(cursor) && cursor.CXXAccessSpecifier() != clang.CXXPrivate {
method := ctx.converter.ProcessFuncDecl(cursor)
if method != nil {
*ctx.methods = append(*ctx.methods, method)
@@ -653,6 +653,9 @@ func toToken(tok clang.Token) token.Token {
return token.Token(tok.Kind() + 1)
}
}
func isMethod(cursor clang.Cursor) bool {
return cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorConstructor || cursor.Kind == clang.CursorDestructor
}
func qualifiedExpr(name string) ast.Expr {
parts := strings.Split(name, "::")