Many protubuf dsl fixes
Motivation
I will probably abandon this and pull bits of it into smaller PRs after #966 merges
Generated RBIs differ in many ways from the ruby protobuf documentation and the code actually generated by protoc.
Attempting to fix as many of them as possible.
Ignore spurious gemfile & version bumps - will revert those
Rebase badly needed
- [x] All parameters to
#initializeshould actually be nilable - [x] Per docs: Readers for fields of
:messagetype can returnnil. Setters for fields of:messagetype can acceptnil. Primitive field types (stringet al) can't be assigned nor returnnil. (But see the previous point - you can still pass nil to#initialize) - [x] There's a generated
clear_foomethod for all fields, was missing. - [x]
:enumfields can accept or return Integer or Symbol per the docs. - [ ] TODO: there's a missing type declaration for Enum values. I've seen these shimmed like
FOO = type_alias(T.untyped)but maybe should beFOO = type_alias(T.any(Integer, Symbol))? - [ ] TODO: The docs say there should be a
has_foo?generated method for all non-repeated fields, but it doesn't seem to actually exist 🤔 ... maybe a more recent version ofprotocthan I have? - [ ] TODO: per the docs there are module methods on Enums:
#lookup,#resolve,#descriptorand we are missing declarations for those
Implementation
Building on top of Ray's make_protobuf_signature_nilable PR
The code with my changes is getting a bit hard to follow and could use some OO refactoring. In particular, the handling of repeated and map fields is not consistent with the others. In current state, i mainly wanted to see if I could get something working and confirm the RBI output.
Tests
Yes, following the existing approach. However, we are lacking tests that the generated sigs actually work as intended