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