~bigbes/tarantool

tarantool-protobuf

ref: 11b9ebde83fd05574699fd26b0fd3c82117ab6bb tarantool-protobuf/test/c_runtime_oneof_test.lua -rw-r--r-- 5.0 KiB
b840992a — Eugene Blikh 2 months ago
c_runtime: oneof encode + decode dispatch (ra6 3g)

Encode resolves the active member per oneof group (last-non-nil wins in
declaration order via plan->oneofs[].member_indices), skips non-active
members, and force-emits the active branch so default values like
text="" still carry presence.

Decode clears sibling result-table entries after writing any field with
oneof_idx >= 0, mirroring codec.lua's oneof_siblings handling — wire
last-wins. Sibling-clear runs for both the scalar/string/enum/bytes arm
and the sub-message arm.

20 new tests in test/c_runtime_oneof_test.lua cover all three Result
branches across both codegen modes: byte-equal vs full.hello reference,
round-trip preservation of the active branch and absence of siblings,
default-value emission for active branches, and last-wins on both
encode (multi-branch input) and decode (multi-occurrence wire bytes).

Acceptance per bd-w3u