google-protobuf 3.21.8 → 3.25.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/ext/google/protobuf_c/Rakefile +3 -0
  3. data/ext/google/protobuf_c/convert.c +23 -70
  4. data/ext/google/protobuf_c/convert.h +3 -28
  5. data/ext/google/protobuf_c/defs.c +178 -55
  6. data/ext/google/protobuf_c/defs.h +3 -28
  7. data/ext/google/protobuf_c/extconf.rb +4 -4
  8. data/ext/google/protobuf_c/glue.c +56 -0
  9. data/ext/google/protobuf_c/map.c +54 -70
  10. data/ext/google/protobuf_c/map.h +6 -28
  11. data/ext/google/protobuf_c/message.c +182 -163
  12. data/ext/google/protobuf_c/message.h +10 -28
  13. data/ext/google/protobuf_c/protobuf.c +39 -176
  14. data/ext/google/protobuf_c/protobuf.h +24 -32
  15. data/ext/google/protobuf_c/repeated_field.c +28 -29
  16. data/ext/google/protobuf_c/repeated_field.h +6 -28
  17. data/ext/google/protobuf_c/ruby-upb.c +12326 -9027
  18. data/ext/google/protobuf_c/ruby-upb.h +11950 -4518
  19. data/ext/google/protobuf_c/shared_convert.c +64 -0
  20. data/ext/google/protobuf_c/shared_convert.h +26 -0
  21. data/ext/google/protobuf_c/shared_message.c +65 -0
  22. data/ext/google/protobuf_c/shared_message.h +25 -0
  23. data/ext/google/protobuf_c/third_party/utf8_range/LICENSE +1 -0
  24. data/ext/google/protobuf_c/third_party/utf8_range/naive.c +0 -0
  25. data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +1 -1
  26. data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +0 -0
  27. data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +13 -1
  28. data/ext/google/protobuf_c/wrap_memcpy.c +3 -26
  29. data/lib/google/protobuf/any_pb.rb +24 -5
  30. data/lib/google/protobuf/api_pb.rb +26 -23
  31. data/lib/google/protobuf/descriptor_dsl.rb +0 -0
  32. data/lib/google/protobuf/descriptor_pb.rb +43 -226
  33. data/lib/google/protobuf/duration_pb.rb +24 -5
  34. data/lib/google/protobuf/empty_pb.rb +24 -3
  35. data/lib/google/protobuf/ffi/descriptor.rb +165 -0
  36. data/lib/google/protobuf/ffi/descriptor_pool.rb +75 -0
  37. data/lib/google/protobuf/ffi/enum_descriptor.rb +171 -0
  38. data/lib/google/protobuf/ffi/ffi.rb +213 -0
  39. data/lib/google/protobuf/ffi/field_descriptor.rb +319 -0
  40. data/lib/google/protobuf/ffi/file_descriptor.rb +59 -0
  41. data/lib/google/protobuf/ffi/internal/arena.rb +66 -0
  42. data/lib/google/protobuf/ffi/internal/convert.rb +305 -0
  43. data/lib/google/protobuf/ffi/internal/pointer_helper.rb +35 -0
  44. data/lib/google/protobuf/ffi/internal/type_safety.rb +25 -0
  45. data/lib/google/protobuf/ffi/map.rb +407 -0
  46. data/lib/google/protobuf/ffi/message.rb +662 -0
  47. data/lib/google/protobuf/ffi/object_cache.rb +30 -0
  48. data/lib/google/protobuf/ffi/oneof_descriptor.rb +95 -0
  49. data/lib/google/protobuf/ffi/repeated_field.rb +383 -0
  50. data/lib/google/protobuf/field_mask_pb.rb +24 -4
  51. data/lib/google/protobuf/message_exts.rb +8 -26
  52. data/lib/google/protobuf/object_cache.rb +97 -0
  53. data/lib/google/protobuf/plugin_pb.rb +47 -0
  54. data/lib/google/protobuf/repeated_field.rb +3 -26
  55. data/lib/google/protobuf/source_context_pb.rb +24 -4
  56. data/lib/google/protobuf/struct_pb.rb +24 -20
  57. data/lib/google/protobuf/timestamp_pb.rb +24 -5
  58. data/lib/google/protobuf/type_pb.rb +26 -68
  59. data/lib/google/protobuf/well_known_types.rb +5 -34
  60. data/lib/google/protobuf/wrappers_pb.rb +24 -28
  61. data/lib/google/protobuf.rb +27 -45
  62. data/lib/google/protobuf_ffi.rb +50 -0
  63. data/lib/google/protobuf_native.rb +20 -0
  64. data/lib/google/tasks/ffi.rake +102 -0
  65. metadata +75 -12
  66. data/tests/basic.rb +0 -739
  67. data/tests/generated_code_test.rb +0 -23
  68. data/tests/stress.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42878b39e56b69fd23d1c616d81bef82ca279c7872fa11a9d75005b4d0affb3f
4
- data.tar.gz: a6da6e837daa1b28dad8d2ceaa85a889746fda1eb4e1830266bbbff16a35bec3
3
+ metadata.gz: 7cabebe8487759e6e7876a1a4c69fd7751bb22aad693fbe82e91e14c984bbf8e
4
+ data.tar.gz: 9e57bf2ee2ebef1063605d28ecb713c0851f94d0d66222d0fc24841b9b868089
5
5
  SHA512:
6
- metadata.gz: b08289ac2aaf130780ad52af88d981d931d696690c3f139d054806247bbd472834c19cd6cd625adf17638018239074a7599e3b2878033b932a92e18561b3b815
7
- data.tar.gz: d29b79ecd9e5cd129d821384eb1cc11052523fde3283d8bd3edb7e29b08509d77e6df2c61f388e66efc3a6313351e1809dccb06578263316f71d73dd54fb7691
6
+ metadata.gz: 8a76ee7003807d5b6e37da0bf6129a761f08ac00b26e9df59e33f8f6325a642dd501655accc7d2943ec233518e9d6d10fe6c21efbe6b91b860f101fff8fca9ee
7
+ data.tar.gz: 41dd9a63af13bc7e88c765254fd15bc62f588cc3ab14b0696632fe93d2de00b3e1c9e7bfe01b48b13dc0943176bf86e2cfdba011046c94d11eefabd320e2391b
@@ -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
  }
@@ -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
 
@@ -255,7 +232,7 @@ VALUE Convert_UpbToRuby(upb_MessageValue upb_val, TypeInfo type_info,
255
232
  case kUpb_CType_UInt64:
256
233
  return ULL2NUM(upb_val.int64_val);
257
234
  case kUpb_CType_Enum: {
258
- const upb_EnumValueDef *ev = upb_EnumDef_FindValueByNumber(
235
+ const upb_EnumValueDef* ev = upb_EnumDef_FindValueByNumber(
259
236
  type_info.def.enumdef, upb_val.int32_val);
260
237
  if (ev) {
261
238
  return ID2SYM(rb_intern(upb_EnumValueDef_Name(ev)));
@@ -312,50 +289,26 @@ upb_MessageValue Msgval_DeepCopy(upb_MessageValue msgval, TypeInfo type_info,
312
289
 
313
290
  bool Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2,
314
291
  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");
292
+ upb_Status status;
293
+ upb_Status_Clear(&status);
294
+ bool return_value = shared_Msgval_IsEqual(val1, val2, type_info.type,
295
+ type_info.def.msgdef, &status);
296
+ if (upb_Status_IsOk(&status)) {
297
+ return return_value;
298
+ } else {
299
+ rb_raise(rb_eRuntimeError, upb_Status_ErrorMessage(&status));
336
300
  }
337
301
  }
338
302
 
339
303
  uint64_t Msgval_GetHash(upb_MessageValue val, TypeInfo type_info,
340
304
  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");
305
+ upb_Status status;
306
+ upb_Status_Clear(&status);
307
+ uint64_t return_value = shared_Msgval_GetHash(
308
+ val, type_info.type, type_info.def.msgdef, seed, &status);
309
+ if (upb_Status_IsOk(&status)) {
310
+ return return_value;
311
+ } else {
312
+ rb_raise(rb_eRuntimeError, upb_Status_ErrorMessage(&status));
360
313
  }
361
314
  }
@@ -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