Merge pull request #787 from luoliwoshang/llcppsymg/filter

llcppsymg:filter public method
This commit is contained in:
xushiwei
2024-09-20 15:51:57 +08:00
committed by GitHub

View File

@@ -101,33 +101,41 @@ func collectFuncInfo(cursor clang.Cursor) {
} }
func visit(cursor, parent clang.Cursor, clientData c.Pointer) clang.ChildVisitResult { func visit(cursor, parent clang.Cursor, clientData c.Pointer) clang.ChildVisitResult {
switch cursor.Kind {
case clang.CursorNamespace, clang.CursorClassDecl:
nameStr := cursor.String()
defer nameStr.Dispose()
name := c.GoString(nameStr.CStr())
if cursor.Kind == clang.CursorNamespace { if cursor.Kind == clang.CursorNamespace {
nameStr := cursor.String() context.setNamespaceName(name)
defer nameStr.Dispose() } else {
context.setClassName(name)
}
context.setNamespaceName(c.GoString(nameStr.CStr()))
clang.VisitChildren(cursor, visit, nil) clang.VisitChildren(cursor, visit, nil)
if cursor.Kind == clang.CursorNamespace {
context.setNamespaceName("") context.setNamespaceName("")
} else if cursor.Kind == clang.CursorClassDecl { } else {
nameStr := cursor.String()
defer nameStr.Dispose()
context.setClassName(c.GoString(nameStr.CStr()))
clang.VisitChildren(cursor, visit, nil)
context.setClassName("") context.setClassName("")
} else if cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorFunctionDecl || cursor.Kind == clang.CursorConstructor || cursor.Kind == clang.CursorDestructor { }
case clang.CursorCXXMethod, clang.CursorFunctionDecl, clang.CursorConstructor, clang.CursorDestructor:
loc := cursor.Location() loc := cursor.Location()
var file clang.File var file clang.File
var line, column c.Uint var line, column c.Uint
loc.SpellingLocation(&file, &line, &column, nil) loc.SpellingLocation(&file, &line, &column, nil)
filename := file.FileName() filename := file.FileName()
defer filename.Dispose()
if c.Strcmp(filename.CStr(), c.AllocaCStr(context.currentFile)) == 0 { isCurrentFile := c.Strcmp(filename.CStr(), c.AllocaCStr(context.currentFile)) == 0
isPublicMethod := (cursor.CXXAccessSpecifier() == clang.CXXPublic) && cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorConstructor || cursor.Kind == clang.CursorDestructor
if isCurrentFile && (cursor.Kind == clang.CursorFunctionDecl || isPublicMethod) {
collectFuncInfo(cursor) collectFuncInfo(cursor)
} }
defer filename.Dispose()
} }
return clang.ChildVisit_Continue return clang.ChildVisit_Continue