[Serialization] [Feature] Add experimental C++26 reflection support#6859
[Serialization] [Feature] Add experimental C++26 reflection support#6859hkaiser merged 48 commits intoTheHPXProject:masterfrom
Conversation
|
Can one of the admins verify this patch? |
b1e3990 to
4c26be6
Compare
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesFootnotes
|
hkaiser
left a comment
There was a problem hiding this comment.
@ujjwal-shekhar Sorry for spamming with a long list of comments, I went over the PR from a formal standpoint for now. I have not done a deep review of the implementation yet.
Generally, thank you so much for working on this! This is marvelous.
Thank you! It is a really interesting feature indeed. No worries about the long list; I'll go through the comments soon and green out the failing checks as well. |
23c54d8 to
9e8686b
Compare
| template <> | ||
| struct register_types<> | ||
| { | ||
| static void ensure_instantiated() {} |
There was a problem hiding this comment.
I think these functions can be constexpr and noexcept.
There was a problem hiding this comment.
I am considering shifting ensure_instantiated and other improvements to the core auto-serialization facility to a future PR (which will also include a DFS of polymorphic types for semi-automation of polymorphic types, compile-time checks to see if the user missed a register; etc).
6c9ea93 to
5b78342
Compare
hkaiser
left a comment
There was a problem hiding this comment.
This starts looking really nice! Just some mostly minor comments below...
|
|
edeb250 to
c877a23
Compare
|
Thank you for the comments @hkaiser ! I have made some changes addressing most of the comments. Before wrapping up the rest, I will focus on fixing the new CI script with cpp26 reflection (as I expect there to be some bugs when testing the full suite under enabled reflection changes |
67659aa to
3a172bb
Compare
hkaiser
left a comment
There was a problem hiding this comment.
Just some food for thought: what can be made consteval instead of being constexpr?
At a glance, I am inclined to believe that anything that must be evaluated within the |
d4d906d to
ce9670f
Compare
|
@hkaiser, In the CI job with reflection enabled, would you recommend we run the full suite or just the serialization tests? The full suite would turn it into a long job so I have limited it to just the serialization tests for now. |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesFootnotes
|
Just the serialization tests for now, I guess. We will soon move this repository to a new github organization where we will have access to an enterprise license. We can re-evaluate the CI situation then. |
|
@ujjwal-shekhar Overall, this PR seems to be almost complete - excellent work! |
@hkaiser Thanks! I'm really happy with how the reflection logic is holding up. Once we've addressed the remaining comments, I'll move this from a draft to an open PR. Super excited to get this merged! |
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
… code, macro can be improved, test CRTP serialization Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
…tcast instead Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
…so far) Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
Signed-off-by: Ujjwal Shekhar <ujjwal.shekhar@research.iiit.ac.in>
f42e937 to
b095cd4
Compare
Done @hkaiser ! Apologies for having missed this, I had accidentally removed this line while adding the new trait file to the CMakeList. |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesFootnotes
|
|
@ujjwal-shekhar thank you again for your persistence and effort! This is a major milestone for HPX! |
…ialize [Serialization] [Feature] Add experimental C++26 reflection support
This PR introduces support for C++26 reflection-based serialization (based on the P2996 proposal). It adds a new reflection-based dispatch mechanism in
access.hppthat allows for the automatic serialization of user-defined structs without requiring manualserializefunctions. The code generation pertaining to (semi-)automatic polymorphic type registration, serialization lambdas (with and without captures) and compile-time compression ofqualified_name_ofwill be done in the next PR(s).Proposed Changes
HPX_SERIALIZATION_WITH_ALLOW_AUTO_GENERATEto allow users to toggle reflection codegen.refl_serialize_impl.hppusingstd::meta.std::meta::access_context::unchecked()and compile-time pointer arithmetic (offset_of) to serialize private members without requiringfrienddeclarations.qualified_name_ofutility to generate compiler-agnostic type identifiers by walking the scope tree. This generates portable and unique names for each type*struct_serializationis superseded, as the reflection branch natively handles brace-initializable structs.HPX_POLYMORPHIC_AUTO_REGISTERmacro to enable polymorphic type registration.Any background context you want to provide?
Current HPX serialization requires users to manually list every member in a serialize function, leading to high maintenance overhead and error-prone edits. Encapsulation is also a hurdle, as non-intrusive methods cannot access private data easily.
Goals:
Checklist
Not all points below apply to all pull requests.