Skip to content

Commit

Permalink
Merge pull request goplus#667 from luoliwoshang/c/clang/type
Browse files Browse the repository at this point in the history
c/clang:cursor enum & type kind
  • Loading branch information
xushiwei authored Aug 6, 2024
2 parents 52af22b + ca14637 commit 9ac0c06
Show file tree
Hide file tree
Showing 3 changed files with 488 additions and 294 deletions.
10 changes: 5 additions & 5 deletions c/clang/_demo/symboldump/symboldump.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func printFuncInfo(cursor clang.Cursor) {
}
c.Printf(c.Str("%s\n"), cursorStr.CStr())

if cursor.Kind == clang.CXXMethod || cursor.Kind == clang.FunctionDecl {
if cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorFunctionDecl {
c.Printf(c.Str("symbol:%s\n"), symbol.CStr())

typeStr := cursor.ResultType().String()
Expand All @@ -107,19 +107,19 @@ func printFuncInfo(cursor clang.Cursor) {
}

func visit(cursor, parent clang.Cursor, clientData c.Pointer) clang.ChildVisitResult {
if cursor.Kind == clang.MacroDefinition {
if cursor.Kind == clang.CursorMacroDefinition {
printMarcoInfo(cursor)
} else if cursor.Kind == clang.Namespace {
} else if cursor.Kind == clang.CursorNamespace {
nameStr := cursor.String()
context.setNamespaceName(c.GoString(nameStr.CStr()))
clang.VisitChildren(cursor, visit, nil)
context.setNamespaceName("")
} else if cursor.Kind == clang.ClassDecl {
} else if cursor.Kind == clang.CursorClassDecl {
nameStr := cursor.String()
context.setClassName(c.GoString(nameStr.CStr()))
clang.VisitChildren(cursor, visit, nil)
context.setClassName("")
} else if cursor.Kind == clang.CXXMethod || cursor.Kind == clang.FunctionDecl {
} else if cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorFunctionDecl {
printFuncInfo(cursor)
}

Expand Down
4 changes: 4 additions & 0 deletions c/clang/_wrap/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ void wrap_clang_getSpellingLocation(CXSourceLocation *loc, CXFile *file, unsigne
clang_getSpellingLocation(*loc, file, line, column, offset);
}

enum CX_CXXAccessSpecifier wrap_clang_getCXXAccessSpecifier(CXCursor *cursor) {
return clang_getCXXAccessSpecifier(*cursor);
}

void wrap_clang_getCursorExtent(CXCursor *cur, CXSourceRange *range) { *range = clang_getCursorExtent(*cur); }

void wrap_clang_tokenize(CXTranslationUnit unit, CXSourceRange *Range, CXToken **Tokens, unsigned *NumTokens) {
Expand Down
Loading

0 comments on commit 9ac0c06

Please sign in to comment.