llcppsymg:filter public method
This commit is contained in:
@@ -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 {
|
||||||
if cursor.Kind == clang.CursorNamespace {
|
switch cursor.Kind {
|
||||||
|
case clang.CursorNamespace, clang.CursorClassDecl:
|
||||||
nameStr := cursor.String()
|
nameStr := cursor.String()
|
||||||
defer nameStr.Dispose()
|
defer nameStr.Dispose()
|
||||||
|
|
||||||
context.setNamespaceName(c.GoString(nameStr.CStr()))
|
name := c.GoString(nameStr.CStr())
|
||||||
clang.VisitChildren(cursor, visit, nil)
|
if cursor.Kind == clang.CursorNamespace {
|
||||||
context.setNamespaceName("")
|
context.setNamespaceName(name)
|
||||||
} else if cursor.Kind == clang.CursorClassDecl {
|
} else {
|
||||||
nameStr := cursor.String()
|
context.setClassName(name)
|
||||||
defer nameStr.Dispose()
|
}
|
||||||
|
|
||||||
context.setClassName(c.GoString(nameStr.CStr()))
|
|
||||||
clang.VisitChildren(cursor, visit, nil)
|
clang.VisitChildren(cursor, visit, nil)
|
||||||
context.setClassName("")
|
|
||||||
} else if cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorFunctionDecl || cursor.Kind == clang.CursorConstructor || cursor.Kind == clang.CursorDestructor {
|
if cursor.Kind == clang.CursorNamespace {
|
||||||
|
context.setNamespaceName("")
|
||||||
|
} else {
|
||||||
|
context.setClassName("")
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user