google-protobuf 3.25.2 → 4.26.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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/ext/google/protobuf_c/convert.c +7 -4
  3. data/ext/google/protobuf_c/defs.c +40 -27
  4. data/ext/google/protobuf_c/extconf.rb +1 -1
  5. data/ext/google/protobuf_c/map.c +12 -19
  6. data/ext/google/protobuf_c/map.h +1 -1
  7. data/ext/google/protobuf_c/message.c +41 -77
  8. data/ext/google/protobuf_c/message.h +1 -1
  9. data/ext/google/protobuf_c/protobuf.c +19 -6
  10. data/ext/google/protobuf_c/repeated_field.c +6 -15
  11. data/ext/google/protobuf_c/repeated_field.h +1 -1
  12. data/ext/google/protobuf_c/ruby-upb.c +11788 -10795
  13. data/ext/google/protobuf_c/ruby-upb.h +5164 -4242
  14. data/ext/google/protobuf_c/shared_convert.c +5 -3
  15. data/ext/google/protobuf_c/shared_convert.h +2 -2
  16. data/ext/google/protobuf_c/shared_message.c +8 -6
  17. data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c +467 -0
  18. data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +9 -8
  19. data/lib/google/protobuf/any_pb.rb +1 -22
  20. data/lib/google/protobuf/api_pb.rb +1 -24
  21. data/lib/google/protobuf/descriptor_pb.rb +2 -23
  22. data/lib/google/protobuf/duration_pb.rb +1 -22
  23. data/lib/google/protobuf/empty_pb.rb +1 -22
  24. data/lib/google/protobuf/ffi/descriptor.rb +2 -3
  25. data/lib/google/protobuf/ffi/enum_descriptor.rb +1 -1
  26. data/lib/google/protobuf/ffi/ffi.rb +3 -1
  27. data/lib/google/protobuf/ffi/field_descriptor.rb +10 -1
  28. data/lib/google/protobuf/ffi/file_descriptor.rb +1 -13
  29. data/lib/google/protobuf/ffi/internal/convert.rb +7 -23
  30. data/lib/google/protobuf/ffi/map.rb +13 -11
  31. data/lib/google/protobuf/ffi/message.rb +10 -13
  32. data/lib/google/protobuf/ffi/object_cache.rb +3 -3
  33. data/lib/google/protobuf/ffi/oneof_descriptor.rb +1 -1
  34. data/lib/google/protobuf/ffi/repeated_field.rb +12 -10
  35. data/lib/google/protobuf/field_mask_pb.rb +1 -22
  36. data/lib/google/protobuf/internal/object_cache.rb +99 -0
  37. data/lib/google/protobuf/plugin_pb.rb +2 -24
  38. data/lib/google/protobuf/repeated_field.rb +1 -2
  39. data/lib/google/protobuf/source_context_pb.rb +1 -22
  40. data/lib/google/protobuf/struct_pb.rb +1 -22
  41. data/lib/google/protobuf/timestamp_pb.rb +1 -22
  42. data/lib/google/protobuf/type_pb.rb +1 -24
  43. data/lib/google/protobuf/wrappers_pb.rb +1 -22
  44. data/lib/google/protobuf.rb +1 -1
  45. data/lib/google/protobuf_ffi.rb +1 -2
  46. data/lib/google/protobuf_native.rb +0 -1
  47. data/lib/google/tasks/ffi.rake +1 -3
  48. metadata +8 -11
  49. data/ext/google/protobuf_c/third_party/utf8_range/naive.c +0 -92
  50. data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +0 -157
  51. data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +0 -170
  52. data/lib/google/protobuf/descriptor_dsl.rb +0 -465
  53. data/lib/google/protobuf/object_cache.rb +0 -97
@@ -1,97 +0,0 @@
1
- # Protocol Buffers - Google's data interchange format
2
- # Copyright 2023 Google Inc. All rights reserved.
3
- #
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
7
-
8
- module Google
9
- module Protobuf
10
- # A pointer -> Ruby Object cache that keeps references to Ruby wrapper
11
- # objects. This allows us to look up any Ruby wrapper object by the address
12
- # of the object it is wrapping. That way we can avoid ever creating two
13
- # different wrapper objects for the same C object, which saves memory and
14
- # preserves object identity.
15
- #
16
- # We use WeakMap for the cache. If sizeof(long) > sizeof(VALUE), we also
17
- # need a secondary Hash to store WeakMap keys, because our pointer keys may
18
- # need to be stored as Bignum instead of Fixnum. Since WeakMap is weak for
19
- # both keys and values, a Bignum key will cause the WeakMap entry to be
20
- # collected immediately unless there is another reference to the Bignum.
21
- # This happens on 64-bit Windows, on which pointers are 64 bits but longs
22
- # are 32 bits. In this case, we enable the secondary Hash to hold the keys
23
- # and prevent them from being collected.
24
- class ObjectCache
25
- def initialize
26
- @map = ObjectSpace::WeakMap.new
27
- @mutex = Mutex.new
28
- end
29
-
30
- def get(key)
31
- @map[key]
32
- end
33
-
34
- def try_add(key, value)
35
- @map[key] || @mutex.synchronize do
36
- @map[key] ||= value
37
- end
38
- end
39
- end
40
-
41
- class LegacyObjectCache
42
- def initialize
43
- @secondary_map = {}
44
- @map = ObjectSpace::WeakMap.new
45
- @mutex = Mutex.new
46
- end
47
-
48
- def get(key)
49
- value = if secondary_key = @secondary_map[key]
50
- @map[secondary_key]
51
- else
52
- @mutex.synchronize do
53
- @map[(@secondary_map[key] ||= Object.new)]
54
- end
55
- end
56
-
57
- # GC if we could remove at least 2000 entries or 20% of the table size
58
- # (whichever is greater). Since the cost of the GC pass is O(N), we
59
- # want to make sure that we condition this on overall table size, to
60
- # avoid O(N^2) CPU costs.
61
- cutoff = (@secondary_map.size * 0.2).ceil
62
- cutoff = 2_000 if cutoff < 2_000
63
- if (@secondary_map.size - @map.size) > cutoff
64
- purge
65
- end
66
-
67
- value
68
- end
69
-
70
- def try_add(key, value)
71
- if secondary_key = @secondary_map[key]
72
- if old_value = @map[secondary_key]
73
- return old_value
74
- end
75
- end
76
-
77
- @mutex.synchronize do
78
- secondary_key ||= (@secondary_map[key] ||= Object.new)
79
- @map[secondary_key] ||= value
80
- end
81
- end
82
-
83
- private
84
-
85
- def purge
86
- @mutex.synchronize do
87
- @secondary_map.each do |key, secondary_key|
88
- unless @map.key?(secondary_key)
89
- @secondary_map.delete(key)
90
- end
91
- end
92
- end
93
- nil
94
- end
95
- end
96
- end
97
- end