Expand description
Encoder bodies, built from the layout plan. Spec §5, §6.2.
One walk, emitted through a CodecTarget. Which member is written,
in what order, under which header and with which length code is
decided here and once; how that is spelled is the backend’s.
The counterpart of crate::encode, which does the same for Rust
against the Rust CST directly and has not been brought over.
Every framing decision is read from zerodds-ast-layout and none is
re-derived: the plan is where the length-code policy and the XCDR2
alignment rule live, and a second derivation would be a second place
to get them wrong.
What the emitted code does not delegate is the wire rule itself.
Alignment, the string length convention, the UTF-16 count, the BCD
packing, the enumerator’s signed holder and the DHEADER, EMHEADER and
PID framing are the target runtime’s — runtime/c, runtime/java
and the rest each implement them from the clause rather than calling
the Rust one. That is what makes a column a second reading of the
specification: where two disagree, one of them has misread it.
§What this walk assumes of every target
- A routine per type. Rust’s emitter names a writer method on the
element type; C has no methods, so every type gets its own routine
and collections call it by name. A target that would rather emit a
method says so in
CodecTarget::routine. - Forward declarations are the target’s business. C needs them
ahead of the bodies so a recursive type does not depend on visit
order; a target with no such thing answers
Noneand the loop emits only bodies. - A
switchis an if-chain. The union’s branch is selected by comparing the discriminator against each case’s labels, which every target can hold and which sidesteps the languages whoseswitchwill not take a 64-bit label.
Structs§
- Codec
Options - The one framing question the layout plan does not answer.
Functions§
- codec
- Build the encoder for every type in the model, under one plan.
- codec_
excluding codecwithout the types inexcluded, and with what the types inalso_reachingreach.- codec_
from - The encoder for the types one root reaches, and no others.
- codec_
from_ many - The encoder for the types several roots reach, each function once.
- codec_
from_ many_ excluding codec_from_manywithout the types inexcluded, whose codecs are written by hand elsewhere (DDS-RPC 1.0 §7.5.1.1.1’s common types come with the runtime in a shape of their own).- codec_
name - The encoder function name for a type.
- key_
holder - The key holder for a keyed type, and nothing for one with no
@key.