~bigbes/tarantool-protobuf: 7676fdc2

codegen: preserve descriptor options as `options = { ... }`

Every populated *Options message — FileOptions, MessageOptions,
FieldOptions, OneofOptions, EnumOptions, EnumValueOptions,
ServiceOptions, MethodOptions — surfaces on the generated descriptor as
a plain Lua sub-table named `options` (or `oneof_options` /
`value_options` for the per-member shapes). Standard fields use their
proto name as a bare Lua key; extensions use their fully-qualified
extension name as a bracket-quoted string key.

The walker is generic — no extension-specific code paths. Consumers
pull whatever they care about: `(google.api.http)` for REST routing,
`(versionpb.etcd_version_*)` for compatibility gates, `[deprecated =
true]` for migration tooling, and any in-house extension without pb
knowing about them. Standard fields sort alphabetically before
extensions (also alphabetical by full name) so codegen output stays
byte-identical across runs.

The `options` key is only emitted when at least one field is populated,
so option-free protos produce zero-diff output to before. Resolver
re-links *Options* messages so in-file extensions surface via the
protoreflect walker — protogen builds f.Desc before in-file extensions
are registered, and only f.Proto gets the post-pass fix-up, so we
rebuild the resolver manually.

UninterpretedOption is treated as a codegen-time error: a populated
entry means protoc couldn't resolve the extension, and emitting
opaque parser state would hide the problem.

Eugene Blikh <bigbes@gmail.com> — 2026-05-17 04:46:02 UTC

Commit 7676fdc2fdd14066e363732e504a8f640a01cab3view raw patch

Parent(s): 7ae72311

14 changed file(s)

FileStatus+
PLAN.md M +13
README.md M +38
cmd/protoc-gen-tarantool/internal/gen/descopts.go A +344
cmd/protoc-gen-tarantool/internal/gen/gen.go M +90 -3
cmd/protoc-gen-tarantool/internal/gen/service.go M +6
examples/expected/full/conformance/conformance_pb.lua M +2
examples/expected/full/hello/hello_pb.lua M +2
examples/expected/full/protobuf_test_messages/proto3/test_messages_proto3_pb.lua M +35 -32
examples/expected/full/quickstart/quickstart_pb.lua M +2
examples/expected/runtime/conformance/conformance_pb.lua M +2
examples/expected/runtime/hello/hello_pb.lua M +2
examples/expected/runtime/protobuf_test_messages/proto3/test_messages_proto3_pb.lua M +35 -32
examples/expected/runtime/quickstart/quickstart_pb.lua M +2
test/codegen_options_test.lua A +235