google-protobuf 3.23.3 → 4.27.1

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 +512 -60
  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 +88 -143
  12. data/ext/google/protobuf_c/message.h +10 -32
  13. data/ext/google/protobuf_c/protobuf.c +49 -175
  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 +13046 -10690
  18. data/ext/google/protobuf_c/ruby-upb.h +8405 -5836
  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 +1 -22
  27. data/lib/google/protobuf/api_pb.rb +1 -24
  28. data/lib/google/protobuf/descriptor_pb.rb +14 -23
  29. data/lib/google/protobuf/duration_pb.rb +1 -22
  30. data/lib/google/protobuf/empty_pb.rb +1 -22
  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 +1 -22
  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 +2 -24
  52. data/lib/google/protobuf/repeated_field.rb +7 -31
  53. data/lib/google/protobuf/source_context_pb.rb +1 -22
  54. data/lib/google/protobuf/struct_pb.rb +1 -22
  55. data/lib/google/protobuf/timestamp_pb.rb +1 -22
  56. data/lib/google/protobuf/type_pb.rb +1 -24
  57. data/lib/google/protobuf/well_known_types.rb +5 -34
  58. data/lib/google/protobuf/wrappers_pb.rb +1 -22
  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: 50c81aca55482dbeb28e0b9def873a386d8ffa21c27486c524261a30df8afde1
4
- data.tar.gz: 3dec5edc021d4b55d6728d84a34dd30bd85b4942fe3d23646f4538e963c0d1ac
3
+ metadata.gz: 1689f8aaf80c92c7de32a7c9855268c6e7d3cca4ec2f8a5f2003a2437f171cc8
4
+ data.tar.gz: 70c5c8a1bfe5eb4416b5a478e10c684d6336c656a4bb87c20c239f6d19548e20
5
5
  SHA512:
6
- metadata.gz: c0a787ca87a5cbdf434a4162aa3d25b83c1c741fe6388bc81c8ca525f15f20eb435c09b6c5d794922af9f00258872ec78093ae6702c14d53c0d8f2e22f24c07a
7
- data.tar.gz: 1cfc4f0b25605d3c9314c63a98fb3720a00c0f9845b7f7010b4a4d4ec277ded8b0ea035d111e1e96b70ec01368bbb1d45828237dd18bac508d64b68f97ec063b
6
+ metadata.gz: 1b0c148a0b05451581069cab709e02bfeb64b4f2ef25bd410bf200e140b0e6aa5c12d81e00321e48667d861f7af5707d43d3ec858357fccd0508cbb8a0405ff1
7
+ data.tar.gz: 3be5e7abd0fd576b9ebc1564c37a553fa24bee8404b3d4f727879e734c07125e161826e7c53aefd963fb6b07306d112e5056f6c4850cd24770822f6d195cd05d
@@ -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