6e7835a2
c_runtime: encode/decode singular sub-messages (ra6 3d)
Refactor encode_lua/decode_lua into encode_body/decode_body so the field-walk loop is callable recursively, then dispatch the MESSAGE kind into a per-side sub-handler. Repeated and map fields still skip at the field-walk level — 3e (jc9) and 3h (asz) land them next. encode_submessage_field force-establishes the parent enc_buf's heap_idx via a no-op ebuf_grow before recursing. Without that the final ebuf_reserve on the parent could land its new userdata above sub-encode's leaked stack slots, making the closing lua_settop drop the parent's heap. decode_submessage_field bounds the inner read by temporarily shrinking c->len to the sub-message end offset; the wire-prim helpers already bounds-check against c->len, so a malformed inner payload can't over-read into the outer message's bytes. New fixture test/proto/c_nested.proto carries a 5-level singular chain (L1->L2->L3->L4->L5) for the depth test. The two existing "skip message" tests are renamed to "skip repeated and map" — sub- messages now encode and decode end-to-end. bd-hwe
Eugene Blikh <bigbes@gmail.com> — 2026-05-23 10:25:00 UTC
Commit 6e7835a29a3678aa86a49dfff76c55b18d091755 —
view raw patch
Parent(s):
82717b15
| File | Status | + | − |
|---|---|---|---|
.beads/interactions.jsonl
|
M | +1 | |
.beads/issues.jsonl
|
M | +1 | -1 |
examples/expected/full/c_nested/c_nested_pb.lua
|
A | +625 | |
examples/expected/runtime/c_nested/c_nested_pb.lua
|
A | +187 | |
runtime/pb/c/c_runtime.c
|
M | +209 | -65 |
test/c_runtime_decode_test.lua
|
M | +64 | -11 |
test/c_runtime_encode_test.lua
|
M | +77 | -8 |
test/proto/c_nested.proto
|
A | +13 |