Skip to main content

Module default_java

Module default_java 

Source
Expand description

The value a Java member takes when the stream does not carry it.

Table 9 of DDS-XTypes 1.3, as Java. crate::default_c is the same table as C and crates/wire-probe/src/default.rs is the reflective column’s; that module carries the clause quotations and the reasoning for the three kinds Table 9 does not list. Deliberately a third derivation and not a call into either: the columns are compared against each other, and a shared helper would make them agree about a mistake.

§Why it is a generated method and not a literal

A literal cannot carry an aggregate. “A structure without any of the optional members and with other members set to their default values” is a new S() and one assignment per member, and writing that at every position a member can go missing would put the same answer in the generated file as many times as the type is reached — where two copies can differ. One method per type is one answer per type, which is what the C column does and for the same reason.

§Why it answers with the value instead of filling one

C’s defaulter is void zd_def_T(T *v): it writes through a pointer. Java has no pointer and no out-parameter, and half of Table 9’s rows are values Java cannot mutate at all — a primitive, a String, an array whose length has to change. So the method returns Table 9’s value and the caller assigns it, which is the same decision one step later. It is also what makes the reader’s own shape work: every generated decoder opens with T v = zd_def_T();, so a position the stream does not carry is already what Table 9 says before a single octet is read.

§What Java forces that C does not

octet is an int and unsigned long is a long, so the zero rows of Table 9 are spelled by the holder and not by the IDL width — adapter/java.rs has the table. A sequence<T> is a T[] and its “zero-length sequence” is new T[0] and not a null: null is what an @optional member’s absence means here, and one value cannot mean both. §7.2.2.4.4.4.7 asks for a zero-length sequence, and §7.2.2.4.4.4.8’s “Implementations shall not provide a default value” for an @optional member is the null.

Functions§

default_into
place = zd_def_<T>();
defaulter_from_decoder
The defaulter that goes with a decoder, by name.
defaulter_name
The defaulter method name for a type.
java_defaulters_called_by
The defaulters members call, and exactly those.
java_defaulters_over
Build the defaulter for each of types, once per name.
member_default
One member’s default: its @default, or its type’s.