Repository navigation
feat(cl): conf.EnumAlwaysUntyped - #1104
Conversation
There was a problem hiding this comment.
FennoAI Review — EnumAlwaysUntyped config option
This is a clean, well-scoped PR. The core change in initEnumvals is a single hoisted guard (if !ctx.enumAlwaysUntyped) around the enumType assignment, so named enums keep their Go named type while their constants become untyped. The new field is threaded consistently through every layer (cl.Config, tool.Config, cltest.Config, both test harnesses) with matching field positions, and the raylib MouseButton fixture is a realistic reflection of the motivating case.
No blocking issues and no security/performance concerns found. A few documentation/accuracy notes below.
Inline comments
- Stale
loadEnumdoc comment now contradicts the new behavior. ForceCamelCasedoc comment understates the keep-as-is rules.
Non-inline notes
- Issue URL org (informational, pre-existing): the new comments cite
github.com/xgo-dev/llcppg/issues/1103, while the module path and README usegoplus/llcppg. This matches the dominant existing convention in these files (xgo-devappears ~31 times vs. 2 forgoplus) and GitHub redirects the link, so nothing regressed here — flagging only as a candidate for a separate repo-wide normalization pass. - Named type still emitted when
EnumAlwaysUntypedis set (confirmed non-issue): with the flag on, a named enum still emitstype MouseButton c.Uintand only the constants become untyped (seecl/_testc/raylib1/out.go). This is the intended design — the named type must survive so function signatures and struct fields referencing it still compile. The fixture is correct and internally consistent.
| typDecl.defs.SetComments(doc) | ||
| } | ||
| enumType = typDecl.Type() | ||
| if !ctx.enumAlwaysUntyped { |
There was a problem hiding this comment.
The loadEnum doc comment above (lines 31-34) still states unconditionally that a named enum emits "a const block whose constants are typed with that named type." With enumAlwaysUntyped set, that is no longer true: the named type is still emitted but its constants are now untyped (this guard). Since this is the most authoritative in-code description of enum handling, consider updating it to note the enumAlwaysUntyped case so the comment no longer contradicts the code.
| // See https://github.com/xgo-dev/llcppg/issues/1103. | ||
| EnumAlwaysUntyped bool | ||
|
|
||
| // ForceCamelCase converts capitalized, underscore-joined names to camel case (optional), |
There was a problem hiding this comment.
Minor accuracy nit (also mirrored in tool/config.go and cl/cltest/cltest.go): the comment says names are kept as-is only when "the final segment is all-uppercase," but shouldKeepCStyle (cl/name.go:318-329) also keeps a name C-style when any non-final segment ends in uppercase (isAnyUpperEnd(parts[:last])) or when the first segment is all-uppercase (isAllUpper(parts[0])). ForceCamelCase only flips the all-upper-start case. Consider softening the "except" clause (e.g. "except certain all-uppercase / acronym-like segments") so it doesn't imply the final-segment rule is the only exception. Update the three copies together.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1104 +/- ##
=======================================
Coverage 90.26% 90.27%
=======================================
Files 26 26
Lines 3276 3279 +3
=======================================
+ Hits 2957 2960 +3
Misses 319 319
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
EnumAlwaysUntypedconfig option #1103