refactor: introduce macro-based serialization for core structs#415
Draft
kisielewski wants to merge 2 commits intodevelfrom
Draft
refactor: introduce macro-based serialization for core structs#415kisielewski wants to merge 2 commits intodevelfrom
kisielewski wants to merge 2 commits intodevelfrom
Conversation
Replace per-struct boilerplate in VarSerializer/VarDeserializer with a macro-driven approach in VarSerialization.hpp. Standard types use VAR_DEFINE_TYPE which generates both serialize and deserialize inline specializations from a field list. Non-standard types (PagingList<T>, events, ContainerPolicy, enum deserializers) are moved as-is as inline specializations. VarSerializationMacros.hpp is rewritten using the GET_MACRO count-based dispatch pattern (1–20 fields) to replace the broken recursive macro that the preprocessor could not expand. VarSerializer.hpp and VarDeserializer.hpp now include VarSerialization.hpp so all callers get the specializations automatically.
Converts PagingList<Context> and PagingList<UserInfo> from manual inline specializations to VAR_DEFINE_TYPE, accepting the __type string change from "core$PagingList<core$X>" to "PagingList<X>". Old implementations left commented out as reference, marked with FIXME pending a decision on the __type format.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VarSerializationMacros.hpp— the original_VAR_SER_FIELDSwas a self-recursive macro that the C preprocessor cannot expand (blue-painting rule). Replaced with theGET_MACROcount-based dispatch pattern: explicit_VAR_SER_N/_VAR_DESER_Nvariants for 1–20 fields, selected at call site by shifting arguments through a_VAR_SER_GEToverload resolver.VarSerialization.hpp. Standard types useVAR_DEFINE_TYPEwhich generates bothserializeanddeserializeinline specializations from a field list. Non-standard types (custom__typestrings, event helpers,ContainerPolicy, enum deserializers) are moved as-is as inline specializations.VarSerializer.hpp/VarDeserializer.hppand removes the out-of-line implementations from the.cppfiles. Both headers now includeVarSerialization.hppat the end so all existing callers pick up the specializations without include changes.