google-protobuf 3.22.3 → 4.27.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/ext/google/protobuf_c/Rakefile +3 -0
  3. data/ext/google/protobuf_c/convert.c +28 -72
  4. data/ext/google/protobuf_c/convert.h +3 -28
  5. data/ext/google/protobuf_c/defs.c +534 -72
  6. data/ext/google/protobuf_c/defs.h +3 -28
  7. data/ext/google/protobuf_c/extconf.rb +2 -1
  8. data/ext/google/protobuf_c/glue.c +72 -0
  9. data/ext/google/protobuf_c/map.c +28 -36
  10. data/ext/google/protobuf_c/map.h +6 -28
  11. data/ext/google/protobuf_c/message.c +101 -148
  12. data/ext/google/protobuf_c/message.h +10 -32
  13. data/ext/google/protobuf_c/protobuf.c +53 -177
  14. data/ext/google/protobuf_c/protobuf.h +24 -32
  15. data/ext/google/protobuf_c/repeated_field.c +23 -33
  16. data/ext/google/protobuf_c/repeated_field.h +6 -28
  17. data/ext/google/protobuf_c/ruby-upb.c +12741 -10337
  18. data/ext/google/protobuf_c/ruby-upb.h +8911 -5235
  19. data/ext/google/protobuf_c/shared_convert.c +69 -0
  20. data/ext/google/protobuf_c/shared_convert.h +26 -0
  21. data/ext/google/protobuf_c/shared_message.c +37 -0
  22. data/ext/google/protobuf_c/shared_message.h +21 -0
  23. data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c +467 -0
  24. data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +9 -8
  25. data/ext/google/protobuf_c/wrap_memcpy.c +3 -26
  26. data/lib/google/protobuf/any_pb.rb +6 -8
  27. data/lib/google/protobuf/api_pb.rb +6 -26
  28. data/lib/google/protobuf/descriptor_pb.rb +20 -252
  29. data/lib/google/protobuf/duration_pb.rb +6 -8
  30. data/lib/google/protobuf/empty_pb.rb +6 -6
  31. data/lib/google/protobuf/ffi/descriptor.rb +166 -0
  32. data/lib/google/protobuf/ffi/descriptor_pool.rb +77 -0
  33. data/lib/google/protobuf/ffi/enum_descriptor.rb +173 -0
  34. data/lib/google/protobuf/ffi/ffi.rb +210 -0
  35. data/lib/google/protobuf/ffi/field_descriptor.rb +330 -0
  36. data/lib/google/protobuf/ffi/file_descriptor.rb +49 -0
  37. data/lib/google/protobuf/ffi/internal/arena.rb +66 -0
  38. data/lib/google/protobuf/ffi/internal/convert.rb +289 -0
  39. data/lib/google/protobuf/ffi/internal/pointer_helper.rb +35 -0
  40. data/lib/google/protobuf/ffi/internal/type_safety.rb +25 -0
  41. data/lib/google/protobuf/ffi/map.rb +409 -0
  42. data/lib/google/protobuf/ffi/message.rb +659 -0
  43. data/lib/google/protobuf/ffi/method_descriptor.rb +114 -0
  44. data/lib/google/protobuf/ffi/object_cache.rb +30 -0
  45. data/lib/google/protobuf/ffi/oneof_descriptor.rb +97 -0
  46. data/lib/google/protobuf/ffi/repeated_field.rb +385 -0
  47. data/lib/google/protobuf/ffi/service_descriptor.rb +107 -0
  48. data/lib/google/protobuf/field_mask_pb.rb +6 -7
  49. data/lib/google/protobuf/internal/object_cache.rb +99 -0
  50. data/lib/google/protobuf/message_exts.rb +3 -26
  51. data/lib/google/protobuf/plugin_pb.rb +6 -31
  52. data/lib/google/protobuf/repeated_field.rb +7 -31
  53. data/lib/google/protobuf/source_context_pb.rb +6 -7
  54. data/lib/google/protobuf/struct_pb.rb +6 -23
  55. data/lib/google/protobuf/timestamp_pb.rb +6 -8
  56. data/lib/google/protobuf/type_pb.rb +6 -71
  57. data/lib/google/protobuf/well_known_types.rb +5 -34
  58. data/lib/google/protobuf/wrappers_pb.rb +6 -31
  59. data/lib/google/protobuf.rb +27 -45
  60. data/lib/google/protobuf_ffi.rb +51 -0
  61. data/lib/google/protobuf_native.rb +19 -0
  62. data/lib/google/tasks/ffi.rake +100 -0
  63. metadata +89 -8
  64. data/ext/google/protobuf_c/third_party/utf8_range/naive.c +0 -92
  65. data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +0 -157
  66. data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +0 -170
  67. data/lib/google/protobuf/descriptor_dsl.rb +0 -465
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36a0cf54a74c46392a4b56ba35af0b7d1c97af893b39da281a5c18261f358039
4
- data.tar.gz: d1980f60cb8e4bcfb97480b646cde1ade2435ed76b5554e924b5027da883acc3
3
+ metadata.gz: 634150e62701d649c61a06216e0134020a54022be183cbe07f82def99f1e8e58
4
+ data.tar.gz: 7405081dedf538d964fd91af689d1eddf7ba78e7d6a5ded51f45f32f8472712d
5
5
  SHA512:
6
- metadata.gz: e7c05d8fc134b72971ac14d911ea0d45a183fbcf308346bcf510dbbefd190c4f84caa1232be8a367fc5ee0d7c119239c21d6365b54d85cb0a775676a11e231d6
7
- data.tar.gz: 4f7bd0f43ebd8fdab52094a54974ff366239dc7886127d5e119159538e83512bafd2da5a3d5df70af559abd9155cddd94e21f17cbf7060c249423d03a0791401
6
+ metadata.gz: bf5c2b83695785285dc3139b48442f3306cda0ee0d61ca150a5cb82844d4171d03bfbfa7366bc28ba1ab3f6b947fc42c537e94b173fba5434d5cbc506d6b4e78
7
+ data.tar.gz: e277db5f9bbf4449f79ab59ae077b09da7e63ca8798c3e8ec844bd5286c6c98e0156d94c40323d83b46d15b516eda65a67b66a69205c6fb253d2f1379b3ec530
@@ -0,0 +1,3 @@
1
+ import '../../../lib/google/tasks/ffi.rake'
2
+
3
+ task default: ['ffi-protobuf:default']
@@ -1,32 +1,9 @@
1
1
  // Protocol Buffers - Google's data interchange format
2
2
  // Copyright 2008 Google Inc. All rights reserved.
3
- // https://developers.google.com/protocol-buffers/
4
3
  //
5
- // Redistribution and use in source and binary forms, with or without
6
- // modification, are permitted provided that the following conditions are
7
- // met:
8
- //
9
- // * Redistributions of source code must retain the above copyright
10
- // notice, this list of conditions and the following disclaimer.
11
- // * Redistributions in binary form must reproduce the above
12
- // copyright notice, this list of conditions and the following disclaimer
13
- // in the documentation and/or other materials provided with the
14
- // distribution.
15
- // * Neither the name of Google Inc. nor the names of its
16
- // contributors may be used to endorse or promote products derived from
17
- // this software without specific prior written permission.
18
- //
19
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file or at
6
+ // https://developers.google.com/open-source/licenses/bsd
30
7
 
31
8
  // -----------------------------------------------------------------------------
32
9
  // Ruby <-> upb data conversion functions.
@@ -41,6 +18,7 @@
41
18
 
42
19
  #include "message.h"
43
20
  #include "protobuf.h"
21
+ #include "shared_convert.h"
44
22
 
45
23
  static upb_StringView Convert_StringData(VALUE str, upb_Arena* arena) {
46
24
  upb_StringView ret;
@@ -111,8 +89,7 @@ static int32_t Convert_ToEnum(VALUE value, const char* name,
111
89
  case T_SYMBOL: {
112
90
  const upb_EnumValueDef* ev =
113
91
  upb_EnumDef_FindValueByName(e, rb_id2name(SYM2ID(value)));
114
- if (!ev)
115
- goto unknownval;
92
+ if (!ev) goto unknownval;
116
93
  val = upb_EnumValueDef_Number(ev);
117
94
  break;
118
95
  }
@@ -164,7 +141,7 @@ upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
164
141
  VALUE utf8 = rb_enc_from_encoding(rb_utf8_encoding());
165
142
  if (rb_obj_class(value) == rb_cSymbol) {
166
143
  value = rb_funcall(value, rb_intern("to_s"), 0);
167
- } else if (rb_obj_class(value) != rb_cString) {
144
+ } else if (!rb_obj_is_kind_of(value, rb_cString)) {
168
145
  rb_raise(cTypeError,
169
146
  "Invalid argument for string field '%s' (given %s).", name,
170
147
  rb_class2name(CLASS_OF(value)));
@@ -194,7 +171,7 @@ upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
194
171
  if (rb_obj_encoding(value) != bytes) {
195
172
  // Note: this will not duplicate underlying string data unless
196
173
  // necessary.
197
- // TODO(haberman): is this really necessary to get raw bytes?
174
+ // TODO: is this really necessary to get raw bytes?
198
175
  value = rb_str_encode(value, bytes, 0, Qnil);
199
176
  }
200
177
 
@@ -231,7 +208,8 @@ upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
231
208
  }
232
209
  break;
233
210
  default:
234
- break;
211
+ rb_raise(cTypeError,
212
+ "Convert_RubyToUpb(): Unexpected type %d", (int)type_info.type);
235
213
  }
236
214
 
237
215
  return ret;
@@ -255,7 +233,7 @@ VALUE Convert_UpbToRuby(upb_MessageValue upb_val, TypeInfo type_info,
255
233
  case kUpb_CType_UInt64:
256
234
  return ULL2NUM(upb_val.int64_val);
257
235
  case kUpb_CType_Enum: {
258
- const upb_EnumValueDef *ev = upb_EnumDef_FindValueByNumber(
236
+ const upb_EnumValueDef* ev = upb_EnumDef_FindValueByNumber(
259
237
  type_info.def.enumdef, upb_val.int32_val);
260
238
  if (ev) {
261
239
  return ID2SYM(rb_intern(upb_EnumValueDef_Name(ev)));
@@ -312,50 +290,28 @@ upb_MessageValue Msgval_DeepCopy(upb_MessageValue msgval, TypeInfo type_info,
312
290
 
313
291
  bool Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2,
314
292
  TypeInfo type_info) {
315
- switch (type_info.type) {
316
- case kUpb_CType_Bool:
317
- return memcmp(&val1, &val2, 1) == 0;
318
- case kUpb_CType_Float:
319
- case kUpb_CType_Int32:
320
- case kUpb_CType_UInt32:
321
- case kUpb_CType_Enum:
322
- return memcmp(&val1, &val2, 4) == 0;
323
- case kUpb_CType_Double:
324
- case kUpb_CType_Int64:
325
- case kUpb_CType_UInt64:
326
- return memcmp(&val1, &val2, 8) == 0;
327
- case kUpb_CType_String:
328
- case kUpb_CType_Bytes:
329
- return val1.str_val.size == val2.str_val.size &&
330
- memcmp(val1.str_val.data, val2.str_val.data, val1.str_val.size) ==
331
- 0;
332
- case kUpb_CType_Message:
333
- return Message_Equal(val1.msg_val, val2.msg_val, type_info.def.msgdef);
334
- default:
335
- rb_raise(rb_eRuntimeError, "Internal error, unexpected type");
293
+ upb_Status status;
294
+ upb_Status_Clear(&status);
295
+ bool return_value = shared_Msgval_IsEqual(val1, val2, type_info.type,
296
+ type_info.def.msgdef, &status);
297
+ if (upb_Status_IsOk(&status)) {
298
+ return return_value;
299
+ } else {
300
+ rb_raise(rb_eRuntimeError, "Msgval_IsEqual(): %s",
301
+ upb_Status_ErrorMessage(&status));
336
302
  }
337
303
  }
338
304
 
339
305
  uint64_t Msgval_GetHash(upb_MessageValue val, TypeInfo type_info,
340
306
  uint64_t seed) {
341
- switch (type_info.type) {
342
- case kUpb_CType_Bool:
343
- return _upb_Hash(&val, 1, seed);
344
- case kUpb_CType_Float:
345
- case kUpb_CType_Int32:
346
- case kUpb_CType_UInt32:
347
- case kUpb_CType_Enum:
348
- return _upb_Hash(&val, 4, seed);
349
- case kUpb_CType_Double:
350
- case kUpb_CType_Int64:
351
- case kUpb_CType_UInt64:
352
- return _upb_Hash(&val, 8, seed);
353
- case kUpb_CType_String:
354
- case kUpb_CType_Bytes:
355
- return _upb_Hash(val.str_val.data, val.str_val.size, seed);
356
- case kUpb_CType_Message:
357
- return Message_Hash(val.msg_val, type_info.def.msgdef, seed);
358
- default:
359
- rb_raise(rb_eRuntimeError, "Internal error, unexpected type");
307
+ upb_Status status;
308
+ upb_Status_Clear(&status);
309
+ uint64_t return_value = shared_Msgval_GetHash(
310
+ val, type_info.type, type_info.def.msgdef, seed, &status);
311
+ if (upb_Status_IsOk(&status)) {
312
+ return return_value;
313
+ } else {
314
+ rb_raise(rb_eRuntimeError, "Msgval_GetHash(): %s",
315
+ upb_Status_ErrorMessage(&status));
360
316
  }
361
317
  }
@@ -1,38 +1,13 @@
1
1
  // Protocol Buffers - Google's data interchange format
2
2
  // Copyright 2008 Google Inc. All rights reserved.
3
- // https://developers.google.com/protocol-buffers/
4
3
  //
5
- // Redistribution and use in source and binary forms, with or without
6
- // modification, are permitted provided that the following conditions are
7
- // met:
8
- //
9
- // * Redistributions of source code must retain the above copyright
10
- // notice, this list of conditions and the following disclaimer.
11
- // * Redistributions in binary form must reproduce the above
12
- // copyright notice, this list of conditions and the following disclaimer
13
- // in the documentation and/or other materials provided with the
14
- // distribution.
15
- // * Neither the name of Google Inc. nor the names of its
16
- // contributors may be used to endorse or promote products derived from
17
- // this software without specific prior written permission.
18
- //
19
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file or at
6
+ // https://developers.google.com/open-source/licenses/bsd
30
7
 
31
8
  #ifndef RUBY_PROTOBUF_CONVERT_H_
32
9
  #define RUBY_PROTOBUF_CONVERT_H_
33
10
 
34
- #include <ruby/ruby.h>
35
-
36
11
  #include "protobuf.h"
37
12
  #include "ruby-upb.h"
38
13