Skip to main content

Module default_elixir

Module default_elixir 

Source
Expand description

The value an Elixir member takes when the stream does not carry it.

Table 9 of DDS-XTypes 1.3, as Elixir. crate::default_python is the same table as Python and carries the clause quotations; deliberately a further derivation and not a call into any sibling, because the columns are compared against each other and a shared helper would make them agree about a mistake.

§The shape

One zero-arity function per type — zd_def_T() -> value — because a literal cannot be trusted to appear identically at every position a member can go missing, and because the decoder’s own shape wants it: emit/elixir.rs’s reader opens with v = zd_def_T(), so every position the stream does not carry is already what Table 9 says before an octet is read.

§What the Elixir mapping decides

  • An aggregate is a struct literal: %Common.Pose{x: 0, y: 0.0}, every non-optional field written. An @optional member is left out — the defstruct default is already nil, and §7.2.2.4.4.4.8’s “Implementations shall not provide a default value” is that absence.
  • An enumeration’s default is its constant function: Common.Mode.idle(), which answers the declared integer — the binding holds enumerations as integers, and the function is the materialiser’s own spelling, so a moved @value moves both sides.
  • A char is "\0" — a one-character binary, because the member holds one and an integer there would be a different type.
  • A long double is ZeroddsWire.Float128.zero() — sixteen octets, never a float(), which holds 53 of its 113 significand bits.
  • A fixed<P,S> is the one decimal spelling of zero for its scale — "0.00" for fixed<5,2>; "" is not a decimal.
  • A collection is [] and an array is its elements spelled out as a tuple, one defaulter call per element — the {T, …} the materialiser declares, which a list is not == to. List.duplicate(zd_def_T(), n) would evaluate the element once, which for an immutable value is harmless — and is still not written, because the sibling columns spell the elements out and a reader comparing generated files should not have to know which columns may share.

Functions§

default_into
place = zd_def_T().
defaulter_from_decoder
The defaulter that goes with a decoder, by name — the two schemes differ in one word because both are built from the same key.
defaulter_name
The defaulter function name for a type, keyed the same way crate::emit::decode::decoder_name is.
elixir_defaulters_called_by
The defaulters decls call, and exactly those — read off the emitted calls rather than derived a second time from the model, for the reason crate::default_python::python_defaulters_called_by gives at length.
elixir_defaulters_over
Build the defaulter for each of types, once per name.
member_default
One member’s default: its @default, or its type’s. §7.2.2.4.4.4.9 puts the explicit one first.