Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cl/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func compileFuncOrMethod(ctx *pkgCtx, obj *overloadObj, this *classCtx) {
if creator != "" {
if newResults, ok := tryNewResults(pkgTypes, obj, results); ok {
results = newResults
creator = ctx.cstyleToGo(creator, false, true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Co-locate creator normalization in name.go with creatorCheck

Every other Go-name derivation co-locates cstyleToGo with its derivation in cl/name.go (globalName, localName, varName, typeName, funcName all return a ready-to-use identifier). Here the token is derived in creatorCheck (name.go) but normalized in func.go, so the caller must remember to normalize. Consider moving this cstyleToGo call into creatorCheck (or a small creatorName helper) so it returns an already-normalized creator, matching the established pattern and keeping func.go focused on compilation logic. Non-blocking — current placement is functionally correct (it sits after results = newResults and before both fnName = creator consumers, and only runs when tryNewResults succeeds).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] underscoreStart hardcoded to false diverges from other callers

Every other cstyleToGo caller computes underscoreStart (via rmPrefixAndUnderscoreStart / checkUnderscoreStart) so a leading _ is preserved through goNameOf. This call pins it to false. For the intended use (an exported creator such as AsByteArray) false is correct, but if a $N wildcard expansion ever yields a creator starting with _, that underscore would be silently dropped unlike every other name path. Low probability given creators are author-controlled exported names. If false is intentional, a one-line comment stating creators are always treated as exported, non-underscore names would prevent a future reader from assuming it's a copy-paste oversight.

if mayMethod {
params, recv, typRecv, typName = tryToMethod(ctx, pkgTypes, params)
if typRecv != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/goplus/gogen v1.26.0
github.com/goplus/lib v0.5.12
github.com/goplus/mod v0.22.1
github.com/llarhub/clang-c v0.8.0
github.com/llarhub/clang-c v0.9.0
github.com/qiniu/x v1.19.1
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/goplus/lib v0.5.12 h1:LZ31xPTvuchVI1lqsKlCRHJIzqSFhXDjWTA1pLoaWb0=
github.com/goplus/lib v0.5.12/go.mod h1:Ucw7fZlTqrcuHgUvZHP8Oce6IwxULgASlzJxLt8E4p8=
github.com/goplus/mod v0.22.1 h1:3GQZqKlcQAiMpRUDAHvFryGYie+mT0JMjguEqOtIjkE=
github.com/goplus/mod v0.22.1/go.mod h1:APrczG2FtFcQelU4vTq9xw+GrVs4sPPKnRfGidWBlXY=
github.com/llarhub/clang-c v0.8.0 h1:2JPW4ZiaYPwdI9G7LIiBAaFfI1fLzsJlmJe/3eWtdtQ=
github.com/llarhub/clang-c v0.8.0/go.mod h1:os8efa2pPUOT8LmMprrndHWqlaFffYhxYwtxpH5SBR4=
github.com/llarhub/clang-c v0.9.0 h1:aBSsL43vVUM1y8V3Su8IHlUy91vxmJJP4rkDg/tc+Bo=
github.com/llarhub/clang-c v0.9.0/go.mod h1:os8efa2pPUOT8LmMprrndHWqlaFffYhxYwtxpH5SBR4=
github.com/qiniu/x v1.19.1 h1:Z6ZALlHMrZw/AImYjYnYKMXemasVdUF2o7riwm9TZTs=
github.com/qiniu/x v1.19.1/go.mod h1:Sx3Wy+0GI9OsX4a53mYj6A0o7mHJ94PUvraqGYb4EIs=
golang.org/x/mod v0.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs=
Expand Down
Loading