Skip to content

feat(cl): conf.EnumAlwaysUntyped - #1104

Merged
xushiwei merged 1 commit into
goplus:mainfrom
xushiwei:q
Oct 26, 2026
Merged

xushiwei merged 1 commit into
goplus:mainfrom
xushiwei:q

Conversation

@xushiwei

Copy link
Copy Markdown
Member

@fennoai fennoai Bot left a comment

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.

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 loadEnum doc comment now contradicts the new behavior.
  • ForceCamelCase doc 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 use goplus/llcppg. This matches the dominant existing convention in these files (xgo-dev appears ~31 times vs. 2 for goplus) 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 EnumAlwaysUntyped is set (confirmed non-issue): with the flag on, a named enum still emits type MouseButton c.Uint and only the constants become untyped (see cl/_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.

Comment thread cl/enum.go
typDecl.defs.SetComments(doc)
}
enumType = typDecl.Type()
if !ctx.enumAlwaysUntyped {

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.

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.

Comment thread cl/compile.go
// See https://github.com/xgo-dev/llcppg/issues/1103.
EnumAlwaysUntyped bool

// ForceCamelCase converts capitalized, underscore-joined names to camel case (optional),

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.

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

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.27%. Comparing base (1168c01) to head (3aa2e72).
⚠️ Report is 2 commits behind head on main.

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           
Flag Coverage Δ
llgo-tests 90.27% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xushiwei
xushiwei merged commit d0ce613 into goplus:main Oct 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant