diff --git a/chore/_xtool/llcppsigfetch/parse/cvt.go b/chore/_xtool/llcppsigfetch/parse/cvt.go index 5e5a84c0..00cbbac5 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt.go +++ b/chore/_xtool/llcppsigfetch/parse/cvt.go @@ -271,7 +271,9 @@ func (ct *Converter) ProcessBuiltinType(t clang.Type) *ast.BuiltinType { kind = ast.Float128 default: // like IBM128,NullPtr,Accum - fmt.Fprintln(os.Stderr, "todo: unknown builtin type:", c.GoString(t.Kind.String().CStr())) + kindStr := t.Kind.String() + defer kindStr.Dispose() + fmt.Fprintln(os.Stderr, "todo: unknown builtin type:", c.GoString(kindStr.CStr())) } if IsExplicitSigned(t) { diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/llgo.expect index f39f47d7..266d5992 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/llgo.expect +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/llgo.expect @@ -2,7 +2,7 @@ Test Case 1: { "temp.h": { - "Path": "temp.h", + "path": "temp.h", "decls": [{ "Loc": null, "Doc": null, @@ -28,7 +28,7 @@ Test Case 1: Test Case 2: { "temp.h": { - "Path": "temp.h", + "path": "temp.h", "decls": [{ "Loc": null, "Doc": null, @@ -64,7 +64,7 @@ Test Case 2: Test Case 3: { "temp.h": { - "Path": "temp.h", + "path": "temp.h", "decls": [{ "Loc": null, "Doc": null, @@ -110,7 +110,7 @@ Test Case 3: Test Case 4: { "temp.h": { - "Path": "temp.h", + "path": "temp.h", "decls": [{ "Loc": null, "Doc": null, @@ -158,7 +158,7 @@ Test Case 4: Test Case 5: { "temp.h": { - "Path": "temp.h", + "path": "temp.h", "decls": [{ "Loc": null, "Doc": null, @@ -208,7 +208,7 @@ Test Case 5: Test Case 6: { "temp.h": { - "Path": "temp.h", + "path": "temp.h", "decls": [{ "Loc": null, "Doc": null, @@ -262,7 +262,7 @@ Test Case 6: Test Case 7: { "temp.h": { - "Path": "temp.h", + "path": "temp.h", "decls": [{ "Loc": null, "Doc": null, @@ -313,7 +313,7 @@ Test Case 7: Test Case 8: { "temp.h": { - "Path": "temp.h", + "path": "temp.h", "decls": [{ "Loc": null, "Doc": null, diff --git a/chore/_xtool/llcppsigfetch/parse/dump.go b/chore/_xtool/llcppsigfetch/parse/dump.go index 5b0ce8ac..21616892 100644 --- a/chore/_xtool/llcppsigfetch/parse/dump.go +++ b/chore/_xtool/llcppsigfetch/parse/dump.go @@ -9,15 +9,13 @@ import ( func (ct *Converter) GetFilesJSON() *cjson.JSON { root := cjson.Object() for _, file := range ct.files { - f := cjson.Object() - f.SetItem(c.Str("Path"), cjson.String(c.AllocaCStr(file.Path))) - ct.FileJSON(file, f) - root.SetItem(c.AllocaCStr(file.Path), f) + root.SetItem(c.AllocaCStr(file.Path), ct.FileJSON(file)) } return root } -func (ct *Converter) FileJSON(file *ast.File, root *cjson.JSON) { +func (ct *Converter) FileJSON(file *ast.File) *cjson.JSON { + root := cjson.Object() decls := cjson.Array() includes := cjson.Array() macros := cjson.Array() @@ -26,9 +24,11 @@ func (ct *Converter) FileJSON(file *ast.File, root *cjson.JSON) { decls.AddItem(ct.DeclJSON(decl)) } + root.SetItem(c.Str("path"), cjson.String(c.AllocaCStr(file.Path))) root.SetItem(c.Str("decls"), decls) root.SetItem(c.Str("includes"), includes) root.SetItem(c.Str("macros"), macros) + return root } func (ct *Converter) DeclJSON(decl ast.Decl) *cjson.JSON { @@ -106,7 +106,6 @@ func (ct *Converter) TypeJSON(t ast.Expr) *cjson.JSON { } list := cjson.Array() for _, c := range d.List { - println(c.Text) list.AddItem(ct.TypeJSON(c)) } root.SetItem(c.Str("List"), list)