Skip to content

Commit c87c8c7

Browse files
committed
chore:_xtool->xtool
1 parent 3f30897 commit c87c8c7

File tree

10 files changed

+26
-17
lines changed

10 files changed

+26
-17
lines changed

_xtool/llcppsigfetch/llcppsigfetch.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os"
2323
"path/filepath"
2424
"strings"
25+
"unsafe"
2526

2627
"github.com/goplus/llcppg/_xtool/llcppsigfetch/dbg"
2728
"github.com/goplus/llcppg/_xtool/llcppsigfetch/parse"
@@ -30,7 +31,7 @@ import (
3031
"github.com/goplus/llcppg/_xtool/llcppsymg/config"
3132
"github.com/goplus/llcppg/llcppg"
3233
"github.com/goplus/llgo/c"
33-
"github.com/goplus/llgo/c/cjson"
34+
"github.com/goplus/llpkg/cjson"
3435
)
3536

3637
func main() {
@@ -166,7 +167,7 @@ func runFromConfig(cfgFile string, useStdin bool, outputToFile bool, verbose boo
166167
check(err)
167168
info := converter.Output()
168169
str := info.Print()
169-
defer cjson.FreeCStr(str)
170+
defer cjson.FreeCStr(unsafe.Pointer(str))
170171
defer info.Delete()
171172
outputResult(str, outputToFile)
172173
}
@@ -200,7 +201,7 @@ func runExtract(content string, isTemp bool, isCpp bool, outToFile bool, otherAr
200201
result := converter.Output()
201202
cstr := result.Print()
202203
outputResult(cstr, outToFile)
203-
cjson.FreeCStr(cstr)
204+
cjson.FreeCStr(unsafe.Pointer(cstr))
204205
result.Delete()
205206
converter.Dispose()
206207
}

_xtool/llcppsigfetch/parse/cvt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"github.com/goplus/llcppg/llcppg"
1515
"github.com/goplus/llcppg/token"
1616
"github.com/goplus/llgo/c"
17-
"github.com/goplus/llgo/c/cjson"
1817
"github.com/goplus/llgo/c/clang"
18+
"github.com/goplus/llpkg/cjson"
1919
)
2020

2121
type Converter struct {

_xtool/llcppsigfetch/parse/cvt_test/cvt.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import (
44
"fmt"
55
"os"
66
"sort"
7+
"unsafe"
78

89
"github.com/goplus/llcppg/_xtool/llcppsigfetch/parse"
910
"github.com/goplus/llcppg/_xtool/llcppsymg/clangutils"
1011
"github.com/goplus/llcppg/llcppg"
1112
"github.com/goplus/llgo/c"
12-
"github.com/goplus/llgo/c/cjson"
1313
"github.com/goplus/llgo/c/clang"
14+
"github.com/goplus/llpkg/cjson"
1415
)
1516

1617
func RunTest(testName string, testCases []string) {
@@ -41,7 +42,7 @@ func RunTestWithConfig(config *parse.ParseConfig) {
4142
result := MarshalPkg(cvt.Pkg)
4243
str := result.Print()
4344
c.Printf(c.Str("%s\n\n"), str)
44-
cjson.FreeCStr(str)
45+
cjson.FreeCStr(unsafe.Pointer(str))
4546
result.Delete()
4647
}
4748

_xtool/llcppsigfetch/parse/cvt_test/type_test/type.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package main
33
import (
44
"fmt"
55
"os"
6+
"unsafe"
67

78
"github.com/goplus/llcppg/_xtool/llcppsigfetch/parse"
89
test "github.com/goplus/llcppg/_xtool/llcppsigfetch/parse/cvt_test"
910
"github.com/goplus/llcppg/ast"
1011
"github.com/goplus/llgo/c"
11-
"github.com/goplus/llgo/c/cjson"
1212
"github.com/goplus/llgo/c/clang"
13+
"github.com/goplus/llpkg/cjson"
1314
)
1415

1516
func main() {
@@ -166,7 +167,7 @@ func TestNonBuiltinTypes() {
166167
c.Printf(c.Str("%s\n"), str)
167168

168169
typstr.Dispose()
169-
cjson.FreeCStr(str)
170+
cjson.FreeCStr(unsafe.Pointer(str))
170171
json.Delete()
171172
index.Dispose()
172173
unit.Dispose()

_xtool/llcppsigfetch/parse/dump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"github.com/goplus/llcppg/ast"
55
"github.com/goplus/llcppg/llcppg"
66
"github.com/goplus/llgo/c"
7-
"github.com/goplus/llgo/c/cjson"
7+
"github.com/goplus/llpkg/cjson"
88
)
99

1010
func MarshalPkg(pkg *llcppg.Pkg) *cjson.JSON {

_xtool/llcppsymg/config/config.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"github.com/goplus/llcppg/_xtool/llcppsymg/clangutils"
1111
"github.com/goplus/llcppg/llcppg"
1212
"github.com/goplus/llgo/c"
13-
"github.com/goplus/llgo/c/cjson"
1413
"github.com/goplus/llgo/c/clang"
14+
"github.com/goplus/llpkg/cjson"
1515
)
1616

1717
type Conf struct {
@@ -20,7 +20,7 @@ type Conf struct {
2020
}
2121

2222
func GetConf(data []byte) (Conf, error) {
23-
parsedConf := cjson.ParseBytes(data)
23+
parsedConf := ParseBytes(data)
2424
if parsedConf == nil {
2525
return Conf{}, errors.New("failed to parse config")
2626
}
@@ -195,3 +195,7 @@ func commonParentDir(paths []string) string {
195195
}
196196
return filepath.Dir(paths[0])
197197
}
198+
199+
func ParseBytes(value []byte) *cjson.JSON {
200+
return cjson.ParseWithLength((*c.Char)(unsafe.Pointer(unsafe.SliceData(value))), uintptr(len(value)))
201+
}

_xtool/llcppsymg/symbol/symbol.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
"github.com/goplus/llcppg/_xtool/llcppsymg/syspath"
1717
"github.com/goplus/llcppg/llcppg"
1818
"github.com/goplus/llgo/c"
19-
"github.com/goplus/llgo/c/cjson"
2019
"github.com/goplus/llgo/xtool/nm"
20+
"github.com/goplus/llpkg/cjson"
2121
)
2222

2323
// ParseDylibSymbols parses symbols from dynamic libraries specified in the lib string.
@@ -137,7 +137,7 @@ func ReadExistingSymbolTable(fileName string) (map[string]llcppg.SymbolInfo, boo
137137
return nil, false
138138
}
139139

140-
parsedJSON := cjson.ParseBytes(data)
140+
parsedJSON := config.ParseBytes(data)
141141
if parsedJSON == nil {
142142
return nil, false
143143
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/google/go-cmp v0.6.0
77
github.com/goplus/gogen v1.16.4
88
github.com/goplus/llgo v0.10.0
9+
github.com/goplus/llpkg/cjson v1.0.0
910
github.com/goplus/mod v0.13.12
1011
)
1112

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
22
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
33
github.com/goplus/gogen v1.16.4 h1:RyU4KhJ8qmdJQwuHKpCYPh3hTFN4wSaPRwXa9syY4R8=
44
github.com/goplus/gogen v1.16.4/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
5-
github.com/goplus/llgo v0.9.10-0.20250110015923-745eff07836d h1:4dIS7c7Q/o9X+RFIvlxm/2WRmKPoHOpuxKdbACNgiv0=
6-
github.com/goplus/llgo v0.9.10-0.20250110015923-745eff07836d/go.mod h1:DzFcPtfJ+ZHY8H30FpLAutsEOe3U0qMoGiYYisI4oeI=
7-
github.com/goplus/llgo v0.10.0-pre.1.0.20250206090032-a345746cbd89 h1:kT5Ts/B+fiMYVMsxf/SZpPkQJeJgdo8Vr2oL5kEM/iA=
8-
github.com/goplus/llgo v0.10.0-pre.1.0.20250206090032-a345746cbd89/go.mod h1:YfOHsT/g3lc9b4GclLj812YzdSsJr0kd3CCB830TqHE=
95
github.com/goplus/llgo v0.10.0 h1:s3U3cnO3cploF1xCCJleAb16NQFAmHxdUmdrNhRH3hY=
106
github.com/goplus/llgo v0.10.0/go.mod h1:YfOHsT/g3lc9b4GclLj812YzdSsJr0kd3CCB830TqHE=
7+
github.com/goplus/llpkg/cjson v1.0.0 h1:yPKe1E976qfimxh0m+IWEZwEtJn91zMMKBYZFQwfZy0=
8+
github.com/goplus/llpkg/cjson v1.0.0/go.mod h1:NxW/zhLMO1phlim2DxyoV3VJ5Nb+nAlUAx4WrdCPUgs=
119
github.com/goplus/mod v0.13.12 h1:Trwk6j3i9VvBuW6/9ZxmkoFlEL2v3HKQu0Na1c6DAdw=
1210
github.com/goplus/mod v0.13.12/go.mod h1:fyCcoiL02uUQK9CWxGK9pQzuJT+rZIvRKaaG+hSa2bk=
1311
github.com/qiniu/x v1.13.10 h1:J4Z3XugYzAq85SlyAfqlKVrbf05glMbAOh+QncsDQpE=

llcppg.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ import (
2828
"github.com/goplus/llcppg/cmd/gogensig/config"
2929
"github.com/goplus/llcppg/llcppg"
3030
"github.com/goplus/llgo/xtool/env"
31+
32+
// import cjson to make it linked in go.mod
33+
_ "github.com/goplus/llpkg/cjson"
3134
)
3235

3336
type modeFlags int

0 commit comments

Comments
 (0)