google-protobuf 3.25.3-java → 4.26.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/ext/google/protobuf_c/message.c +41 -77
  3. data/ext/google/protobuf_c/message.h +1 -1
  4. data/ext/google/protobuf_c/protobuf.c +19 -6
  5. data/ext/google/protobuf_c/ruby-upb.c +11788 -10795
  6. data/ext/google/protobuf_c/ruby-upb.h +5164 -4242
  7. data/ext/google/protobuf_c/shared_convert.c +5 -3
  8. data/ext/google/protobuf_c/shared_convert.h +2 -2
  9. data/ext/google/protobuf_c/shared_message.c +8 -6
  10. data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c +467 -0
  11. data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +9 -8
  12. data/lib/google/protobuf/any_pb.rb +1 -22
  13. data/lib/google/protobuf/api_pb.rb +1 -24
  14. data/lib/google/protobuf/descriptor_pb.rb +2 -23
  15. data/lib/google/protobuf/duration_pb.rb +1 -22
  16. data/lib/google/protobuf/empty_pb.rb +1 -22
  17. data/lib/google/protobuf/ffi/descriptor.rb +2 -3
  18. data/lib/google/protobuf/ffi/enum_descriptor.rb +1 -1
  19. data/lib/google/protobuf/ffi/ffi.rb +3 -1
  20. data/lib/google/protobuf/ffi/field_descriptor.rb +10 -1
  21. data/lib/google/protobuf/ffi/file_descriptor.rb +1 -13
  22. data/lib/google/protobuf/ffi/internal/convert.rb +7 -23
  23. data/lib/google/protobuf/ffi/map.rb +13 -11
  24. data/lib/google/protobuf/ffi/message.rb +10 -13
  25. data/lib/google/protobuf/ffi/object_cache.rb +3 -3
  26. data/lib/google/protobuf/ffi/oneof_descriptor.rb +1 -1
  27. data/lib/google/protobuf/ffi/repeated_field.rb +12 -10
  28. data/lib/google/protobuf/field_mask_pb.rb +1 -22
  29. data/lib/google/protobuf/internal/object_cache.rb +99 -0
  30. data/lib/google/protobuf/plugin_pb.rb +2 -24
  31. data/lib/google/protobuf/repeated_field.rb +1 -2
  32. data/lib/google/protobuf/source_context_pb.rb +1 -22
  33. data/lib/google/protobuf/struct_pb.rb +1 -22
  34. data/lib/google/protobuf/timestamp_pb.rb +1 -22
  35. data/lib/google/protobuf/type_pb.rb +1 -24
  36. data/lib/google/protobuf/wrappers_pb.rb +1 -22
  37. data/lib/google/protobuf.rb +1 -1
  38. data/lib/google/protobuf_ffi.rb +1 -2
  39. data/lib/google/protobuf_java.jar +0 -0
  40. data/lib/google/protobuf_native.rb +0 -1
  41. data/lib/google/tasks/ffi.rake +1 -3
  42. metadata +8 -11
  43. data/ext/google/protobuf_c/third_party/utf8_range/naive.c +0 -92
  44. data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +0 -157
  45. data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +0 -170
  46. data/lib/google/protobuf/descriptor_dsl.rb +0 -465
  47. 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