Skip to content

Commit 6b9d31e

Browse files
xaionaro@dx.centerxaionaro@dx.center
authored andcommitted
fix: correct type casting in cligen for int, uint16, and builtin types
- Use GetInt/Int for Go int params (not GetInt32/Int32) - Cast builtin types (uint16, int) directly without package qualifier - Fixes: binderprocess.StartThreadPool(int) and font.SetStyle(uint16) Verified locally: arm64 build, examples, unit tests all pass.
1 parent a30990a commit 6b9d31e

4 files changed

Lines changed: 45 additions & 35 deletions

File tree

cmd/ndkcli/android_gen.go

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/ndkcli/binderprocess_gen.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/ndkcli/input_gen.go

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/cmd/cligen/main.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,10 @@ func isCLIType(goType string) string {
338338
switch goType {
339339
case "string":
340340
return "GetString"
341-
case "int32", "int":
341+
case "int32":
342342
return "GetInt32"
343+
case "int":
344+
return "GetInt"
343345
case "int64":
344346
return "GetInt64"
345347
case "uint16":
@@ -367,8 +369,10 @@ func flagRegister(goType string) string {
367369
switch goType {
368370
case "string":
369371
return "String"
370-
case "int32", "int":
372+
case "int32":
371373
return "Int32"
374+
case "int":
375+
return "Int"
372376
case "int64":
373377
return "Int64"
374378
case "uint16":
@@ -672,7 +676,13 @@ func genParamCode(
672676

673677
// If the original type differs from resolved, cast.
674678
if p.goType != resolved && !strings.HasPrefix(p.goType, "*") {
675-
callArgs = append(callArgs, pkgRef+"."+p.goType+"("+varName+")")
679+
if isPrimitive(p.goType) {
680+
// Builtin type (uint16, int, etc.) — direct cast.
681+
callArgs = append(callArgs, p.goType+"("+varName+")")
682+
} else {
683+
// Package-defined type — qualified cast.
684+
callArgs = append(callArgs, pkgRef+"."+p.goType+"("+varName+")")
685+
}
676686
} else {
677687
callArgs = append(callArgs, varName)
678688
}

0 commit comments

Comments
 (0)