google-protobuf 3.25.0 → 4.29.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/convert.c +46 -18
- data/ext/google/protobuf_c/defs.c +499 -26
- data/ext/google/protobuf_c/extconf.rb +1 -1
- data/ext/google/protobuf_c/glue.c +53 -2
- data/ext/google/protobuf_c/map.c +82 -17
- data/ext/google/protobuf_c/map.h +9 -2
- data/ext/google/protobuf_c/message.c +144 -104
- data/ext/google/protobuf_c/message.h +8 -5
- data/ext/google/protobuf_c/protobuf.c +30 -17
- data/ext/google/protobuf_c/protobuf.h +3 -7
- data/ext/google/protobuf_c/repeated_field.c +64 -10
- data/ext/google/protobuf_c/repeated_field.h +8 -1
- data/ext/google/protobuf_c/ruby-upb.c +13774 -11526
- data/ext/google/protobuf_c/ruby-upb.h +11198 -9048
- data/ext/google/protobuf_c/shared_convert.c +10 -5
- data/ext/google/protobuf_c/shared_convert.h +2 -2
- data/ext/google/protobuf_c/shared_message.c +3 -31
- data/ext/google/protobuf_c/shared_message.h +0 -4
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c +467 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +9 -8
- data/lib/google/protobuf/any_pb.rb +1 -22
- data/lib/google/protobuf/api_pb.rb +1 -24
- data/lib/google/protobuf/descriptor_pb.rb +3 -23
- data/lib/google/protobuf/duration_pb.rb +1 -22
- data/lib/google/protobuf/empty_pb.rb +1 -22
- data/lib/google/protobuf/ffi/descriptor.rb +13 -2
- data/lib/google/protobuf/ffi/descriptor_pool.rb +16 -9
- data/lib/google/protobuf/ffi/enum_descriptor.rb +13 -1
- data/lib/google/protobuf/ffi/ffi.rb +8 -6
- data/lib/google/protobuf/ffi/field_descriptor.rb +37 -16
- data/lib/google/protobuf/ffi/file_descriptor.rb +13 -12
- data/lib/google/protobuf/ffi/internal/arena.rb +0 -6
- data/lib/google/protobuf/ffi/internal/convert.rb +21 -30
- data/lib/google/protobuf/ffi/map.rb +50 -13
- data/lib/google/protobuf/ffi/message.rb +202 -58
- data/lib/google/protobuf/ffi/method_descriptor.rb +114 -0
- data/lib/google/protobuf/ffi/object_cache.rb +3 -3
- data/lib/google/protobuf/ffi/oneof_descriptor.rb +20 -11
- data/lib/google/protobuf/ffi/repeated_field.rb +50 -142
- data/lib/google/protobuf/ffi/service_descriptor.rb +107 -0
- data/lib/google/protobuf/field_mask_pb.rb +1 -22
- data/lib/google/protobuf/internal/object_cache.rb +99 -0
- data/lib/google/protobuf/plugin_pb.rb +2 -24
- data/lib/google/protobuf/repeated_field.rb +4 -5
- data/lib/google/protobuf/source_context_pb.rb +1 -22
- data/lib/google/protobuf/struct_pb.rb +1 -22
- data/lib/google/protobuf/timestamp_pb.rb +1 -22
- data/lib/google/protobuf/type_pb.rb +1 -24
- data/lib/google/protobuf/wrappers_pb.rb +1 -22
- data/lib/google/protobuf.rb +1 -1
- data/lib/google/protobuf_ffi.rb +3 -2
- data/lib/google/protobuf_native.rb +0 -1
- data/lib/google/tasks/ffi.rake +1 -3
- metadata +25 -12
- data/ext/google/protobuf_c/third_party/utf8_range/naive.c +0 -92
- data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +0 -157
- data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +0 -170
- data/lib/google/protobuf/descriptor_dsl.rb +0 -465
- data/lib/google/protobuf/object_cache.rb +0 -97
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c85266e702141e736a1031dbf1b18b8d430fd48d7cc74e89d003b184165dc92e
|
4
|
+
data.tar.gz: d24556778881104315a347b997525a3baad6df159ebfb1db7bcb0e0ef0a085a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f45523e01c1ccd6572b4917d2f532b676db6b515613c3252bdd50309d552ee9f7eff005248b8f7f076b818616bb2b9601d5a0c398dcf9ee198236c5399d5d85e
|
7
|
+
data.tar.gz: a2dfb8d26a0a0155e28b8cb4d6e086a12a3f942cdf70b805ee6543a7eed0f3f52288705578517e393e4be2774eef7d158ad3138ecdb36c333133e1c4f72b051e
|
@@ -104,6 +104,41 @@ unknownval:
|
|
104
104
|
rb_raise(rb_eRangeError, "Unknown symbol value for enum field '%s'.", name);
|
105
105
|
}
|
106
106
|
|
107
|
+
VALUE Convert_CheckStringUtf8(VALUE str) {
|
108
|
+
VALUE utf8 = rb_enc_from_encoding(rb_utf8_encoding());
|
109
|
+
|
110
|
+
if (rb_obj_encoding(str) == utf8) {
|
111
|
+
// Note: Just because a string is marked as having UTF-8 encoding does
|
112
|
+
// not mean that it is *valid* UTF-8. We have to check separately
|
113
|
+
// whether it is valid.
|
114
|
+
if (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN) {
|
115
|
+
// TODO: For now
|
116
|
+
// we only warn for this case. We will remove the warning and throw an
|
117
|
+
// exception below in the 30.x release
|
118
|
+
|
119
|
+
rb_warn(
|
120
|
+
"String is invalid UTF-8. This will be an error in a future "
|
121
|
+
"version.");
|
122
|
+
// VALUE exc = rb_const_get_at(
|
123
|
+
// rb_cEncoding, rb_intern("InvalidByteSequenceError"));
|
124
|
+
// rb_raise(exc, "String is invalid UTF-8");
|
125
|
+
}
|
126
|
+
} else {
|
127
|
+
// Note: this will not duplicate underlying string data unless
|
128
|
+
// necessary.
|
129
|
+
//
|
130
|
+
// This will throw an exception if the conversion cannot be performed:
|
131
|
+
// - Encoding::UndefinedConversionError if certain characters cannot be
|
132
|
+
// converted to UTF-8.
|
133
|
+
// - Encoding::InvalidByteSequenceError if certain characters were invalid
|
134
|
+
// in the source encoding.
|
135
|
+
str = rb_str_encode(str, utf8, 0, Qnil);
|
136
|
+
PBRUBY_ASSERT(rb_enc_str_coderange(str) != ENC_CODERANGE_BROKEN);
|
137
|
+
}
|
138
|
+
|
139
|
+
return str;
|
140
|
+
}
|
141
|
+
|
107
142
|
upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
|
108
143
|
TypeInfo type_info, upb_Arena* arena) {
|
109
144
|
upb_MessageValue ret;
|
@@ -137,29 +172,18 @@ upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
|
|
137
172
|
}
|
138
173
|
break;
|
139
174
|
}
|
140
|
-
case kUpb_CType_String:
|
141
|
-
VALUE utf8 = rb_enc_from_encoding(rb_utf8_encoding());
|
175
|
+
case kUpb_CType_String:
|
142
176
|
if (rb_obj_class(value) == rb_cSymbol) {
|
143
177
|
value = rb_funcall(value, rb_intern("to_s"), 0);
|
144
|
-
} else if (
|
178
|
+
} else if (!rb_obj_is_kind_of(value, rb_cString)) {
|
145
179
|
rb_raise(cTypeError,
|
146
180
|
"Invalid argument for string field '%s' (given %s).", name,
|
147
181
|
rb_class2name(CLASS_OF(value)));
|
148
182
|
}
|
149
183
|
|
150
|
-
|
151
|
-
// Note: this will not duplicate underlying string data unless
|
152
|
-
// necessary.
|
153
|
-
value = rb_str_encode(value, utf8, 0, Qnil);
|
154
|
-
|
155
|
-
if (rb_enc_str_coderange(value) == ENC_CODERANGE_BROKEN) {
|
156
|
-
rb_raise(rb_eEncodingError, "String is invalid UTF-8");
|
157
|
-
}
|
158
|
-
}
|
159
|
-
|
184
|
+
value = Convert_CheckStringUtf8(value);
|
160
185
|
ret.str_val = Convert_StringData(value, arena);
|
161
186
|
break;
|
162
|
-
}
|
163
187
|
case kUpb_CType_Bytes: {
|
164
188
|
VALUE bytes = rb_enc_from_encoding(rb_ascii8bit_encoding());
|
165
189
|
if (rb_obj_class(value) != rb_cString) {
|
@@ -204,11 +228,13 @@ upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
|
|
204
228
|
ret.uint64_val = NUM2ULL(value);
|
205
229
|
break;
|
206
230
|
default:
|
207
|
-
|
231
|
+
rb_raise(cTypeError, "Convert_RubyToUpb(): Unexpected type %d",
|
232
|
+
(int)type_info.type);
|
208
233
|
}
|
209
234
|
break;
|
210
235
|
default:
|
211
|
-
|
236
|
+
rb_raise(cTypeError,
|
237
|
+
"Convert_RubyToUpb(): Unexpected type %d", (int)type_info.type);
|
212
238
|
}
|
213
239
|
|
214
240
|
return ret;
|
@@ -296,7 +322,8 @@ bool Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2,
|
|
296
322
|
if (upb_Status_IsOk(&status)) {
|
297
323
|
return return_value;
|
298
324
|
} else {
|
299
|
-
rb_raise(rb_eRuntimeError,
|
325
|
+
rb_raise(rb_eRuntimeError, "Msgval_IsEqual(): %s",
|
326
|
+
upb_Status_ErrorMessage(&status));
|
300
327
|
}
|
301
328
|
}
|
302
329
|
|
@@ -309,6 +336,7 @@ uint64_t Msgval_GetHash(upb_MessageValue val, TypeInfo type_info,
|
|
309
336
|
if (upb_Status_IsOk(&status)) {
|
310
337
|
return return_value;
|
311
338
|
} else {
|
312
|
-
rb_raise(rb_eRuntimeError,
|
339
|
+
rb_raise(rb_eRuntimeError, "Msgval_GetHash(): %s",
|
340
|
+
upb_Status_ErrorMessage(&status));
|
313
341
|
}
|
314
342
|
}
|