5fa0fd00
codec: proto2 groups (SGROUP/EGROUP wire format)
Plugin: detect protoreflect.GroupKind, emit kind='group' in the
field descriptor and a SGROUP opening tag in inline codegen. The
group body bypasses the LEN-prefix path entirely — encoder emits
start-tag, body bytes, end-tag in three slots; decoder calls
pb.codec.decode_group(desc, buf, pos, field_id) which reads inner
tags until the matching EGROUP id.
Wire layer already understood SGROUP/EGROUP for skip_field; the new
decode_group reuses the per-tag dispatch from decode_message but
stops on EGROUP instead of end-of-buffer. Repeated groups bracket
each element with its own SGROUP/EGROUP pair.
Runtime parser now desugars `optional|required|repeated group Name
= id { body }` into (a) a nested message named Name and (b) a
synthetic field of kind=group whose lowercased name is `name` — so
source-parsed proto2 schemas behave the same as build-time codegen.
Text format renders groups under the submessage's capitalized name
(`SingleGroup { ... }`) rather than the lowercase field name,
matching mainline protoc's convention.
Adds a vendored, MessageSet-stripped test_messages_proto2.proto in
test/conformance/proto/ (header comment documents the patch).
10 new luatest cases (group_*) cover singular + repeated + text +
descriptor kind, across both codegen modes. 739 tests pass.
Eugene Blikh <bigbes@gmail.com> — 2026-05-17 05:50:00 UTC
Commit 5fa0fd00c4e2919fc979a18f16de259444445c07 —
view raw patch
Parent(s):
cef42bf3
| File | Status | + | − |
|---|---|---|---|
cmd/protoc-gen-tarantool/internal/gen/gen.go
|
M | +9 | -1 |
cmd/protoc-gen-tarantool/internal/gen/inline.go
|
M | +88 | -38 |
examples/expected/full/proto2_basic/proto2_basic_pb.lua
|
M | +275 | |
examples/expected/full/protobuf_test_messages/proto2/test_messages_proto2_pb.lua
|
A | +6111 | |
examples/expected/runtime/proto2_basic/proto2_basic_pb.lua
|
M | +118 | |
examples/expected/runtime/protobuf_test_messages/proto2/test_messages_proto2_pb.lua
|
A | +1633 | |
runtime/pb/codec.lua
|
M | +135 | |
runtime/pb/dynamic.lua
|
M | +15 | -6 |
runtime/pb/parser.lua
|
M | +80 | -33 |
runtime/pb/text.lua
|
M | +12 | |
test/conformance/proto/test_messages_proto2.proto
|
A | +387 | |
test/proto/proto2_basic.proto
|
M | +12 | |
test/proto2_test.lua
|
M | +42 |