diff --git a/chore/_xtool/llcppinfofetch/llcppinfofetch.go b/chore/_xtool/llcppinfofetch/llcppinfofetch.go index 333dd7dd..a7b2c9c4 100644 --- a/chore/_xtool/llcppinfofetch/llcppinfofetch.go +++ b/chore/_xtool/llcppinfofetch/llcppinfofetch.go @@ -70,7 +70,13 @@ func collectFuncInfo(cursor clang.Cursor) ASTInformation { symbol := cursor.Mangling() info.Name = c.GoString(cursorStr.CStr()) + info.Symbol = c.GoString(symbol.CStr()) + if len(info.Symbol) >= 1 { + if info.Symbol[0] == '_' { + info.Symbol = info.Symbol[1:] + } + } defer symbol.Dispose() defer cursorStr.Dispose() @@ -212,6 +218,7 @@ func main() { fmt.Fprintln(os.Stderr, "Usage: \n") return } else { + // sourceFile := *c.Advance(c.Argv, 1) printJson(parse(c.Index(c.Argv, 1))) // fmt.Println("Json end") diff --git a/chore/_xtool/llcppsymg/llcppg.cfg b/chore/_xtool/llcppsymg/llcppg.cfg index b5335e2c..163284b3 100644 --- a/chore/_xtool/llcppsymg/llcppg.cfg +++ b/chore/_xtool/llcppsymg/llcppg.cfg @@ -2,8 +2,7 @@ "name": "inih", "cflags": "$(pkg-config --cflags INIReader)", "include": [ - "INIReader.h", - "AnotherHeaderFile.h" + "INIReader.h" ], "libs": "$(pkg-config --libs INIReader)", "trimPrefixes": ["Ini", "INI"] diff --git a/chore/_xtool/llcppsymg/llcppsymg.go b/chore/_xtool/llcppsymg/llcppsymg.go index db4bc1e4..dafd21d8 100644 --- a/chore/_xtool/llcppsymg/llcppsymg.go +++ b/chore/_xtool/llcppsymg/llcppsymg.go @@ -22,8 +22,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/goplus/llgo/chore/_xtool/llcppsymg/common" - "github.com/goplus/llgo/chore/llcppg/types" "io" "os" "os/exec" @@ -31,6 +29,9 @@ import ( "regexp" "strconv" "strings" + + "github.com/goplus/llgo/chore/_xtool/llcppsymg/common" + "github.com/goplus/llgo/chore/llcppg/types" ) func main() { @@ -161,11 +162,16 @@ func decodeSymbolName(symbolName string) (string, error) { // parseHeaderFile func parseHeaderFile(config types.Config) ([]common.ASTInformation, error) { files := generateHeaderFilePath(config.CFlags, config.Include) + fmt.Println(files) headerFileCmd := exec.Command("llcppinfofetch", files...) + + fmt.Println("Executing command:", headerFileCmd.String()) + headerFileOutput, err := headerFileCmd.Output() if err != nil { return nil, errors.New("failed to execute header file command") } + fmt.Println("headerFileOutput:", string(headerFileOutput), len(headerFileOutput)) t := make([]common.ASTInformation, 0) err = json.Unmarshal(headerFileOutput, &t) if err != nil { @@ -234,11 +240,14 @@ func generateMangle(astInfo common.ASTInformation, count int) string { res += "__" + strconv.Itoa(count-1) } } else { - res = "(*" + astInfo.Class + ")." + astInfo.Name + "__" + string(rune(count)) + res = "(*" + astInfo.Class + ")." + astInfo.Name + if count > 1 { + res += "__" + strconv.Itoa(count-1) + } } } else { res = astInfo.Name - if count > 0 { + if count > 1 { res += "__" + strconv.Itoa(count-1) } }