Serdde derives are ordinary Dudu macros. The compiler contains no Serdde registry, built-in serializer, or package-name check.
Inspect an expansion with:
duc expand examples/basic.dd --show-originsFilter to one derive name when a source file uses several macros:
duc expand examples/basic.dd --macro Serde --show-originsThe output includes the macro invocation, macro definition, source declaration, and generated methods.
For a class, the derive emits:
- a field-count method that accounts for skips and flattened objects;
- normal-order field serialization;
- deterministic-order field serialization;
- an object method that selects the backend's required ordering.
Each active field is written directly through serialize_to. A field adapter
calls its generic serialize[Writer] method. Errors gain the serialized field
name while returning.
No generated method names Value, ValueKind, to_value, from_value, or
serdde.convert. scripts/test_generated_direct.sh enforces this boundary.
The generated method:
- checks the encoded kind;
- resolves primary names and aliases;
- rejects duplicate aliases for one field;
- applies defaults or reports a missing field;
- decodes each present field directly into its declared type;
- checks unknown fields when requested;
- constructs the destination once.
Flattened fields receive the parent reader and route their own keys. Untagged enums retry immutable bounded child readers; they do not construct a dynamic tree.
Macro diagnostics point at source declarations and attributes. Compiler diagnostics from generated declarations retain macro-origin notes. Generated names are hygienic and tested against user fields resembling Serdde's internal names.
Generated declarations participate in ordinary semantic analysis, LSP navigation, and C++ emission. Derives emit AST nodes, not source strings.