Skip to content

refactor: introduce macro-based serialization for core structs#415

Draft
kisielewski wants to merge 2 commits intodevelfrom
refactor/macro-driven-serialization-for-core-structs
Draft

refactor: introduce macro-based serialization for core structs#415
kisielewski wants to merge 2 commits intodevelfrom
refactor/macro-driven-serialization-for-core-structs

Conversation

@kisielewski
Copy link
Copy Markdown
Member

Summary

  • Rewrites VarSerializationMacros.hpp — the original _VAR_SER_FIELDS was a self-recursive macro that the C preprocessor cannot expand (blue-painting rule). Replaced with the GET_MACRO count-based dispatch pattern: explicit _VAR_SER_N / _VAR_DESER_N variants for 1–20 fields, selected at call site by shifting arguments through a _VAR_SER_GET overload resolver.
  • Consolidates all core struct serializations into VarSerialization.hpp. Standard types use VAR_DEFINE_TYPE which generates both serialize and deserialize inline specializations from a field list. Non-standard types (custom __type strings, event helpers, ContainerPolicy, enum deserializers) are moved as-is as inline specializations.
  • Strips the corresponding forward declarations from VarSerializer.hpp / VarDeserializer.hpp and removes the out-of-line implementations from the .cpp files. Both headers now include VarSerialization.hpp at the end so all existing callers pick up the specializations without include changes.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant