This PR resolves issue #17 by extending the per-definition type cache to enum, array, and scalar $defs so multiple $refs reuse the same C++ type.
Closes #17
This PR resolves issue #17 by extending the per-definition type cache to enum, array, and scalar $defs so multiple $refs reuse the same C++ type.
Extend the existing per-definition cache (`self._building`) to enum,
array, and scalar $defs, not just object definitions. This ensures
that multiple $refs to the same non-object definition reuse the same
C++ type instead of generating Role, Role2, Role3, etc.
- Cache the built (type, nullable) tuple under defname for enum,
scalar, and array definitions.
- Pre-register array definitions before recursing into items so $ref
cycles resolve to the same TArr instance.
- Store object definitions as (TObj, nullable) tuples so nullable object
$defs also preserve their nullability when referenced.
Add a regression test for issue #17 covering reused enum and array-of-enum
$defs.
weaselbot
changed title from WIP: test to WIP: schemagen: cache non-object $defs entries to avoid duplicate types2026-06-24 02:17:40 +00:00
weaselbot
marked the pull request as ready for review 2026-06-24 02:17:44 +00:00
The previous change to cache object definitions started returning the
bare TObj from build_type for object schemas, discarding the nullable
flag. This caused nullable root objects to be emitted as plain structs
instead of std::optional<RootInner>, breaking the nullable root tests.
Return the (TObj, nullable) tuple so callers (including the root
emitter) see the correct nullability again.
andrew
merged commit e5cbaac401 into main2026-06-24 17:02:39 +00:00
andrew
deleted branch weaselbot/issue-172026-06-24 17:02:39 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #17
This PR resolves issue #17 by extending the per-definition type cache to enum, array, and scalar $defs so multiple $refs reuse the same C++ type.
WIP: testto WIP: schemagen: cache non-object $defs entries to avoid duplicate types