google-protobuf 3.25.0 → 4.28.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/convert.c +46 -18
- data/ext/google/protobuf_c/defs.c +499 -25
- 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 +130 -100
- data/ext/google/protobuf_c/message.h +8 -5
- data/ext/google/protobuf_c/protobuf.c +30 -15
- 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 +13047 -10836
- data/ext/google/protobuf_c/ruby-upb.h +11112 -9026
- 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 +3 -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 +196 -56
- 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: 89810f0fea0c365b6862bc16275aa7da8ef73c5923d82fed89ef9af70cc18850
|
4
|
+
data.tar.gz: fd9e7a43e25c88e31978b90384f7e5e693d90ffa13a026da771c20ec7faaabfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc5619f68ea52e4fa1deba15b2b87a016bbdb6ad49089d3e9e3c30b3cd1eb9e67ac1f0cc84a55503d2feb2eec92401fcdd4159b6aa99a4f4acb81c106ba91448
|
7
|
+
data.tar.gz: ce47defb15aec14aeb2f6117982530e5b0ec53138c0f9805cfe9c83f677e8aba37d7f1e6f787b411f396928f2b8053d8567ee48281611c481a7d128ea711dd16
|
@@ -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
|
}
|