Skip to main content

Module fill_cpp

Module fill_cpp 

Source
Expand description

The value-filling code the Fast DDS probe needs.

fill.rs writes C, for the two generators whose output is a plain struct. Fast DDS generates a C++ class: every member is a pair of accessors, so nothing can be assigned through a dotted path and the statements have a shape of their own.

sample.x = 1;                      // Cyclone, RTI
sample.x(1);                       // Fast DDS
sample.location.x = 1.0;           // Cyclone, RTI
sample.location().x(1.0);          // Fast DDS

§Why this is not a self-oracle

The same reason fill.rs is not: the statements place values into the vendor’s structures and the bytes still come from the vendor’s own serialiser. A misplaced value shows up as a disagreement between the three probes on that case, never as a false agreement.

§Accessors, not temporaries

fastddsgen emits a non-const reference getter beside every setter, so a collection or a nested aggregate is reachable in place: sample.items()[0].a(1). That keeps the recursion the same shape as the C one — an expression that names the destination — instead of building a temporary per collection and handing it to the setter. Only the terminal assignment differs, and only in two forms:

reached throughassignment
a member of an aggregateobject.name(value);
an element of an array or a sequenceexpression = value;
a subscript of a mapexpression = value;

§Two places a statement has to reach before it can write

The last row above writes like the middle one and does not exist like it: std::map::operator[] inserts the entry, so a value that emits no statement leaves the entry out of the sample the peer serialises. And a union branch is reachable only after its setter has selected it — fastddsgen’s getter throws until then. Both are handled at one place each, emit and the Union arm, because both were once handled in the arm that happened to hit them and both were recorded as Fast DDS divergences.

Functions§

cpp_name
The C++ name a type takes in fastddsgen’s output.
fill_fastdds
Emit the C++ statements that fill sample with values.
fill_fastdds_recording
As fill_fastdds, recording which scalars of the value were read.