Switch to custom reflection (MrDocs.Describe)#1171
Switch to custom reflection (MrDocs.Describe)#1171gennaroprota wants to merge 4 commits intocppalliance:developfrom
Conversation
ℹ️ InfoNote Commit 🧾 Changes by Scope
🔝 Top Files
|
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (89.05%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #1171 +/- ##
===========================================
+ Coverage 78.26% 78.32% +0.06%
===========================================
Files 348 345 -3
Lines 32540 32511 -29
Branches 6525 6512 -13
===========================================
- Hits 25468 25465 -3
+ Misses 4676 4656 -20
+ Partials 2396 2390 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
An automated preview of the documentation is available at https://1171.mrdocs.prtest2.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-03-27 17:09:25 UTC |
33415f8 to
8488bb2
Compare
eb2cc4a to
59b60d5
Compare
Introduces include/mrdocs/Support/Describe.hpp — a minimal, C++23-only replacement for Boost.Describe and Boost.Mp11. Provides MRDOCS_DESCRIBE_STRUCT and MRDOCS_DESCRIBE_ENUM macros with compile-time member/base/enum descriptors and a fold-expression-based for_each. Adds MRDOCS_DESCRIBE_* calls next to every type definition. This moves reflection metadata from the private Reflection.hpp registry into the public headers, enabling future single-template operations (e.g. merge) that eliminate per-type boilerplate. Both descriptor systems coexist in this commit — no consumers are changed yet.
f464cdf to
d79dd24
Compare
8864258 to
8b25b3a
Compare
| requires boost::describe::has_describe_enumerators<Enum>::value | ||
| requires describe::has_describe_enumerators<Enum>::value | ||
| std::string | ||
| toString(Enum e) |
There was a problem hiding this comment.
Shouldn't this be with other reflection functions? What makes this one special?
include/mrdocs/Support/Merge.hpp
Outdated
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| // Copyright (c) 2026 Gennaro Prota (gennaro.prota@gmail.com) | ||
| // Copyright (c) 2025 Gennaro Prota (gennaro.prota@gmail.com) |
src/lib/Metadata/Symbol/Enum.cpp
Outdated
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| // Copyright (c) 2025 Alan de Freitas (alandefreitas@gmail.com) | ||
| // Copyright (c) 2025 Gennaro Prota (gennaro.prota@gmail.com) |
There was a problem hiding this comment.
Heeeeeey! They would blame you now hehe
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| // Copyright (c) 2025 Alan de Freitas (alandefreitas@gmail.com) | ||
| // Copyright (c) 2025 Gennaro Prota (gennaro.prota@gmail.com) |
There was a problem hiding this comment.
Please review all of these...
src/lib/Metadata/Symbol/Friend.cpp
Outdated
| #include <mrdocs/Platform.hpp> | ||
| #include <mrdocs/Metadata/Symbol/Friend.hpp> | ||
| #include <mrdocs/Support/DomMapping.hpp> | ||
| #include <mrdocs/Support/Merge.hpp> |
There was a problem hiding this comment.
I'm put "boost.describe" in <mrdocs/Support/Describe.hpp> and everything that uses the descriptions in <mrdocs/Support/Reflection.hpp> instead of one header per extra function (and some extra functions are actually going into Describe.hpp right now, which is confusing). But if you like it this way, that's also fine.
|
|
||
| template <typename IO> | ||
| void | ||
| tag_invoke( |
There was a problem hiding this comment.
Can't all of these tag_invokes be defined with reflection yet?
There was a problem hiding this comment.
I tried that, but I was blocked by type erasure in LazyObject. Its virtual functions (get, visit, size, exists) are defined in LazyObject.hpp and call tag_invoke through lambdas. When the compiler instantiates LazyObjectImpl<ConceptSymbol, ... in DomCorpus.cpp, the generic tag_invoke template (from DomMapping.hpp) needs to be visible; but including it from LazyObject.hpp creates a circular dependency, and two-phase lookup doesn't find it, because LazyObjectIO lives in mrdocs::dom::detail, not in the type's namespace.
Removing the type erasure (making LazyObjectImpl see the tag_invoke directly) is the next step.
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| // Copyright (c) 2025 Alan de Freitas (alandefreitas@gmail.com) | ||
| // Copyright (c) 2025 Gennaro Prota (gennaro.prota@gmail.com) |
8b25b3a to
5df1a0b
Compare
Switches toString(Enum), mapReflectedType, mergeReflectedType, and XMLWriter from Boost.Describe/Boost.Mp11 to the custom MrDocs.Describe facility introduced in the previous commit. Removes #include <lib/Support/Reflection/Reflection.hpp> from all .cpp files that depended on it for BOOST_DESCRIBE macros (now superseded by per-header MRDOCS_DESCRIBE_* calls). Updates Reflection.cpp with direct includes and moves the Optional<DocComment> tag_invoke there. Deletes the now-unreferenced Reflection.hpp registry.
…emplate Adds a constrained merge(T&, T&&) template in MergeReflectedType.hpp that works for any type with MRDOCS_DESCRIBE_STRUCT. Non-template overloads (DocComment, SourceInfo, TemplateInfo, ExtractionMode, etc.) are still preferred by overload resolution. This eliminates a bunch of merge() functions that did nothing but forward to mergeReflected(), along with their MRDOCS_DECL declarations in public headers. Three .cpp files that existed solely for those one-liners are deleted entirely (Enum.cpp, EnumConstant.cpp, NamespaceAlias.cpp). Cleans up unused #include <mrdocs/Platform.hpp> from several .cpp files that only needed it for MRDOCS_ASSERT in the deleted functions.
The five private headers from src/lib/Support/Reflection/ are consolidated into a single public include/mrdocs/Support/Reflection.hpp. Shared type traits (is_optional, is_vector) move to the existing Support/TypeTraits.hpp. The tag_invoke overloads from the centralized Reflection.cpp are distributed into per-type .cpp files. The src/lib/Support/Reflection/ directory is deleted entirely.
5df1a0b to
937aab7
Compare
This introduces our own (public) reflection facilities (replacing Boost.Describe/Boost.Mp11) and leverages them to eliminate per-type boilerplate.