Skip to content

fix: remove remaining anonymous namespaces for unity build compat#247

Merged
webern merged 2 commits into
mainfrom
unity-fix
Jun 27, 2026
Merged

fix: remove remaining anonymous namespaces for unity build compat#247
webern merged 2 commits into
mainfrom
unity-fix

Conversation

@webern

@webern webern commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #246. The previous PR fixed the generated enum, number, string, and smufl_prefixed
templates. This PR covers the remaining cases found by doing an actual unity build
(CMAKE_UNITY_BUILD=ON, BATCH_SIZE=0):

  • src/private/mx/core/Token.cpp and NameToken.cpp — both defined isNameChar in an anonymous
    namespace inside mx::core. Renamed to tokenIsNameChar / nameTokenIsNameChar.
  • gen/cpp/templates/nmtoken_string.cpp.tmpl and smufl_wavy.cpp.tmpl — same pattern, both
    generating isNameChar in anonymous namespaces. Renamed to isNameChar{{ident}}.
  • AGENTS.md — added a project-wide rule prohibiting anonymous namespaces, with the unity build
    test command so contributors can verify.

No CMake changes are needed by contributors wanting unity builds. The standard CMake flags work
as-is:

cmake -S . -B build/unity -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=0
cmake --build build/unity --target mx

Testing

  • Unity build passes clean (cmake --build with CMAKE_UNITY_BUILD=ON BATCH_SIZE=0, target mx)
  • make test passes

References

webern added 2 commits June 27, 2026 19:27
Token.cpp and NameToken.cpp both defined isNameChar in an anonymous
namespace inside mx::core; nmtoken_string.cpp.tmpl and smufl_wavy.cpp.tmpl
did the same. All four collide in a unity build.

Rename the helpers to per-file names (tokenIsNameChar, nameTokenIsNameChar,
isNameChar{{ident}}) and drop the anonymous namespaces. Add a coding rule
to AGENTS.md prohibiting anonymous namespaces project-wide.
@webern webern added bug software defect non-breaking fixes or implementation that do not require breaking changes area/mx::core area/codegen ai Issues opened by, or through, a coding agent. labels Jun 27, 2026
@github-actions

Copy link
Copy Markdown

gen-quality gen/

gen-quality: 84.5 / 100   (floor 84.5, +0.0)

  structure     86.5  x0.50   [fn 90.5 / file 82.6]
  cyclomatic    88.4  x0.25
  cognitive     76.6  x0.25

  409 functions across 31 files, 7702 lines (largest file 1044)
  max cc 56  max cognitive 44  max fn loc 152

Worst offenders (top 5 per axis; full lists in score.json):
  cyclomatic gen/xsd/analyze.py:311     report                             56
  cyclomatic gen/plates/build.py:956    _validate_config_against_ir        35
  cyclomatic gen/press/context.py:145   plate_context                      34
  cyclomatic gen/__main__.py:46         _ir                                23
  cyclomatic gen/tests/test_ir.py:102   _check_references                  20
  cognitive  gen/xsd/analyze.py:311     report                             44
  cognitive  gen/ir/resolve.py:119      flat_elements                      40
  cognitive  gen/tests/test_ir.py:102   _check_references                  38
  cognitive  gen/press/context.py:145   plate_context                      37
  cognitive  gen/xsd/analyze.py:207     _sccs                              37
  size       gen/xsd/analyze.py:311     report                             152
  size       gen/press/context.py:145   plate_context                      96
  size       gen/plates/build.py:533    _value_plate                       89
  size       gen/plates/build.py:956    _validate_config_against_ir        89
  size       gen/ir/resolve.py:119      flat_elements                      78

Commit 024dff106dcce45e1af840f1439cd7e243a260ec.

@github-actions

Copy link
Copy Markdown

Coverage report

Core-dev coverage src/private/mx/core/

Metric Coverage Covered / Total
Lines 77.8% 28487 / 36624
Functions 74.3% 6349 / 8550
Branches 50.6% 22632 / 44725

API coverage src/private/mx/{api,impl,utility}/

Metric Coverage Covered / Total
Lines 78.5% 5913 / 7535
Functions 63.5% 2006 / 3159
Branches 47.8% 4998 / 10455

Core HTML report | API HTML report

Commit 024dff106dcce45e1af840f1439cd7e243a260ec.

@webern webern merged commit f0bd98e into main Jun 27, 2026
7 checks passed
@webern webern deleted the unity-fix branch June 27, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Issues opened by, or through, a coding agent. area/codegen area/mx::core bug software defect non-breaking fixes or implementation that do not require breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for unity builds

1 participant