llcppsigfetch:Decl Comment
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
@@ -126,12 +127,30 @@ func (ct *Converter) UpdateCurFile(cursor clang.Cursor) {
|
||||
}
|
||||
|
||||
func (ct *Converter) CreateDeclBase(cursor clang.Cursor) ast.DeclBase {
|
||||
rawComment := cursor.RawCommentText()
|
||||
defer rawComment.Dispose()
|
||||
|
||||
commentGroup := &ast.CommentGroup{}
|
||||
if rawComment.CStr() != nil {
|
||||
commentGroup = ct.ParseComment(c.GoString(rawComment.CStr()))
|
||||
}
|
||||
|
||||
return ast.DeclBase{
|
||||
Loc: &ct.curLoc,
|
||||
Parent: ct.GetCurScope(),
|
||||
Doc: commentGroup,
|
||||
}
|
||||
}
|
||||
|
||||
func (ct *Converter) ParseComment(rawComment string) *ast.CommentGroup {
|
||||
lines := strings.Split(rawComment, "\n")
|
||||
commentGroup := &ast.CommentGroup{}
|
||||
for _, line := range lines {
|
||||
commentGroup.List = append(commentGroup.List, &ast.Comment{Text: line})
|
||||
}
|
||||
return commentGroup
|
||||
}
|
||||
|
||||
// visit top decls (struct,class,function,enum & marco,include)
|
||||
func visit(cursor, parent clang.Cursor, clientData unsafe.Pointer) clang.ChildVisitResult {
|
||||
ct := (*Converter)(clientData)
|
||||
|
||||
Reference in New Issue
Block a user