From fd1a3ff11d5854c34ba66c63598cdc5fd234e399 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Tue, 6 Jan 2015 15:44:09 -0800 Subject: Support for maps in the MRI C Ruby extension. This adds the Map container and support for parsing and serializing maps in the protobuf wire format (as defined by the C++ implementation, with MapEntry submessages in a repeated field). JSON map serialization/parsing are not yet supported as these will require some changes to upb as well. --- ruby/ext/google/protobuf_c/repeated_field.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ruby/ext/google/protobuf_c/repeated_field.c') diff --git a/ruby/ext/google/protobuf_c/repeated_field.c b/ruby/ext/google/protobuf_c/repeated_field.c index 6bd13b07..6e3f0bc7 100644 --- a/ruby/ext/google/protobuf_c/repeated_field.c +++ b/ruby/ext/google/protobuf_c/repeated_field.c @@ -324,6 +324,10 @@ VALUE RepeatedField_deep_copy(VALUE _self) { * element types are equal, their lengths are equal, and each element is equal. * Elements are compared as per normal Ruby semantics, by calling their :== * methods (or performing a more efficient comparison for primitive types). + * + * Repeated fields with dissimilar element types are never equal, even if value + * comparison (for example, between integers and floats) would have otherwise + * indicated that every element has equal value. */ VALUE RepeatedField_eq(VALUE _self, VALUE _other) { if (_self == _other) { @@ -458,7 +462,7 @@ VALUE RepeatedField_plus(VALUE _self, VALUE list) { return dupped; } -static void validate_type_class(upb_fieldtype_t type, VALUE klass) { +void validate_type_class(upb_fieldtype_t type, VALUE klass) { if (rb_iv_get(klass, kDescriptorInstanceVar) == Qnil) { rb_raise(rb_eArgError, "Type class has no descriptor. Please pass a " -- cgit v1.2.3