llcppsigfetch:basic cjson dump for ast.File

This commit is contained in:
luoliwoshang
2024-08-12 18:20:15 +08:00
parent a796f9f8a8
commit 6297f69e70
3 changed files with 124 additions and 6 deletions

View File

@@ -0,0 +1,26 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/chore/_xtool/llcppsigfetch/parse"
)
func main() {
TestFuncDecl()
}
func TestFuncDecl() {
content := `int foo(int a, int b);`
converter, err := parse.NewConverter(content, true)
if err != nil {
panic(err)
}
defer converter.Dispose()
converter.Convert()
if err != nil {
panic(err)
}
json := converter.GetFilesJSON()
c.Printf(c.Str("%s\n"), json.Print())
}

View File

@@ -0,0 +1,30 @@
#stdout
{
"Files": {
"temp.h": {
"Path": "temp.h",
"decls": [{
"Name": "foo",
"Type": {
"Params": [{
"Kind": 6,
"Flags": 0
}, {
"Kind": 6,
"Flags": 0
}],
"Ret": {
"Kind": 6,
"Flags": 0
}
}
}],
"includes": [],
"macros": []
}
}
}
#stderr
#exit 0