This PR implements lookup of service descriptor and method descriptor objects in Ruby as described in issue https://github.com/protocolbuffers/protobuf/issues/14891.
It contains three implementations - one for the CRuby extension API, one for JRuby, and one for FFI.
With this patch,
* `DescriptorPool#lookup('fully.qualified.service.name')` works and returns a `Google::Protobuf::ServiceDescriptor` object
* You can call `#options` on that to get the service options
* You can call `#methods` on that to get the services' methods as `Google::Protobuf::MethodDescriptor` objects,
* You can call `MethodDescriptor#options` to get method options
* You can also get the streaming flags & input/output types of the method with `#input_type`, `#output_type`, `#client_streaming`, and `#server_streaming`.
In order to make the FFI implementation work, I had to mark some more methods in the UPB header as exported - I guess that's something which will have to be done on the UPB side, like this 01fed1cc1b
CC @dazuma & @haberman from the original issue, and @JasonLunn (since you work on protobuf it seems - small world!)
I apologies for the large volume of copy-pasta'd code from the existing descriptor class implementations into the new ones - I felt this was probably better than designing new abstractions to reduce it off the bat though; this feels like it "fits in" with the existing implementation.
Closes#15817
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/15817 from KJTsanaktsidis:ktsanaktsidis/add_service_method_descriptors 54d7218431
PiperOrigin-RevId: 618221016
Three of these runtimes are based on upb, and the fourth is based on the Java runtime. Both of these already have editions support, so this was mostly just a matter of:
- Advertising support to allow editions codegen
- Stripping features from the runtime options
- Hooking up conformance tests
- Adding some lightweight editions tests
There are also a few minor orthogonal fixes included here:
- Ruby's upb hack for treating all enums as open enums needed tweaking
- The `enable_editions` flag is no longer needed in our internal proto rules
PiperOrigin-RevId: 616256211
These tests were put into the wrong scope, and never actually ran. Fixing them turned up a bug in JRuby FFI where this fix wasn't applied.
PiperOrigin-RevId: 616172197
This was unintentionally disabling a test in repeated_field_test that is broken in JRuby FFI. It appears to be a bug in Enumeration, rather than our code.
PiperOrigin-RevId: 616164907
Coming from [[protobuf/issues/15180] [Ruby] Support for currently ignored Array methods in `RepeatedField`](https://github.com/protocolbuffers/protobuf/issues/15180)
This adds a couple of `Array` methods to what gets delegated from `RepeatedField`.
- `intersection`, because `|` was already delegated
- `union`, because `&` was already delegated
- `difference`, because `-` was already delegated
Closes#15652
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/15652 from marianosimone:delegate_rb_array_methods 2971981338
PiperOrigin-RevId: 604534655
The previous limit of 127 was causing error messages to get truncated when long identifiers are in use.
This will increase the stack usage of any code that is allocating a `upb_Status` on the stack. If we want to support smaller stacks in the future, we could change `upb_Status` to store its capacity inline, so different users can allocate error buffers with different capacity.
Fixes: https://github.com/protocolbuffers/protobuf/issues/14376
PiperOrigin-RevId: 603136385
Currently we're aliasing `each_index` to `each_with_index`, incorrectly passing both the index and the value of a repeated field to the block.
What we want is to just pass the index. Luckily this is a method on Ruby arrays, so we just wrap the native Ruby array method.
Fixes https://github.com/protocolbuffers/protobuf/issues/7806Closes#11767
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/11767 from shaldengeki:shaldengeki-repeated-field-each-index-returns-actual-index 874916c21d
PiperOrigin-RevId: 593835025
There is no canonical rules_ruby repo today, and we don't want our fork to become one. In order to unblock inclusion of Protobuf in the bzlmod registry, we're making this a dev dependency and dropping support for Bazel/Ruby.
Fixes#14569
PiperOrigin-RevId: 584393841
Rewrrte and extension of #12828, with additional work for JRuby. Partially fixes#1198 by adding support for custom options. Handling of extensions will be handled in a follow up.
Also includes these unrelated fixes:
* Removes code echo between `google/protobuf/repeated_field.rb` and `google/protobuf/ffi/repeated_field.rb` by `require`'ing the former in the latter.
* Adds missing calles to `testFrozen()` from methods of `RepeatedField` under JRuby that mutate.
* Various typos in comments.
Closes#14594
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/14594 from protocolbuffers:add-support-for-options-in-ruby 16cc9e35b8
PiperOrigin-RevId: 580848874
Fixes a class of flaky test failures observed only in the FFI implementation due to garbage collection in between calls to an accessors for a frozen field.
Closes#13420
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13420 from protocolbuffers:rub 0ea91165fb
PiperOrigin-RevId: 552602026
Add bazel targets to create ruby release artifacts.
Should be run with:
```
bazel run ruby:release
bazel run ruby:jruby_release
```
Closes#11468
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/11468 from deannagarcia:rubyTargets b7b7eb6865
PiperOrigin-RevId: 503277136
This uses https://github.com/protocolbuffers/rules_ruby to fully Bazelify our ruby runtime code. The Rakefile is left in place for now and is still used by our aarch64 tests. With the current implementation ruby behaves similarly to our python wrapper, which selects whatever version is installed in the system. Future enhancements will allow for more hermetic builds via Bazel flags to pin a specific version
Closes#10525
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/10525 from mkruskal-google:rules_ruby 97fa1f70ab
PiperOrigin-RevId: 499283908
The only difference between all the `Message` classes is just
their `descriptor` instance variable.
So rather than create an entirely new class from scratch every time
we can simply inherit from an abstract class.
This shink each `Message` class from `1456` bytes to `944` bytes, and
the singleton class of each from `960` to `792`, for a total of
`680` bytes saved per message class, so a ~28% reduction.
* Message.decode/encode: Add max_recursion_depth option
This allows increasing the recursing depth from the default of 64, by
setting the "max_recursion_depth" to the desired integer value. This is
useful to encode or decode complex nested protobuf messages that otherwise
error out with a RuntimeError or "Error occurred during parsing".
Fixes#1493
* Address review comments
Co-authored-by: Adam Cozzette <acozzette@google.com>