~bigbes/tarantool-protobuf: 5a1dc35b

codec,text,json: proto2 extensions end-to-end

Plugin iterates file.Extensions and per-message Extensions, emitting
\`pb.register_extension(extendee_desc, {…})\` calls. Each extension
becomes a field descriptor attached to the extendee under two
indices: extensions_by_id (wire-decode lookup) and
extensions_by_full_name (encode + textual emission ordering).

Codec encode_message walks data._extensions after the regular field
loop and calls encode_field through the extension's descriptor.
decode_message routes an unknown tag through decode_extension when
extensions_by_id matches; the helper mirrors the in-line dispatch
on field kind (scalar/enum/message/group, singular/repeated) and
stores into result._extensions[full_name].

Text decoder recognizes bracket syntax \`[pkg.ext_name]\` outside an
Any-target and looks the name up in extensions_by_full_name. Names
that don't resolve (e.g. \`[pkg.GroupField]\` for the CapitalCase
group type instead of the lowercase field name) raise a parse error
per spec. Text encoder emits each set extension as
\`[full.name]: value\` or \`[full.name] { … }\`.

JSON encoder emits set extensions under the bracketed full-name key
(\`"[pkg.ext_name]": value\`). JSON decoder recognizes the same
shape and stores into _extensions; unknown bracket-names stay
silently dropped to match the spec's tolerant behavior for unknown
JSON keys.

Extensions on google.protobuf.* descriptors (file/message/field
option extends) are skipped — those are meta-only and our WKT
module doesn't surface their descriptors.

Conformance baseline (strict --enforce_recommended, protobuf v34.1):
  Binary + JSON suite: 2806 ✓ / 0 failures   (was 1493 ✓ / 1313 skipped)
  Text-format suite:    434 ✓ / 0 failures   (was  416 ✓ /   18 skipped)

100% pass.

Eugene Blikh <bigbes@gmail.com> — 2026-05-17 06:06:14 UTC

Commit 5a1dc35b1458d857afaa4fb8b5d8aee84126ab30view raw patch

Parent(s): e9b650e9

7 changed file(s)

FileStatus+
cmd/protoc-gen-tarantool/internal/gen/gen.go M +129
examples/expected/full/protobuf_test_messages/proto2/test_messages_proto2_pb.lua M +9
examples/expected/runtime/protobuf_test_messages/proto2/test_messages_proto2_pb.lua M +9
runtime/pb/codec.lua M +108 -4
runtime/pb/init.lua M +14
runtime/pb/json.lua M +50 -1
runtime/pb/text.lua M +70 -3