google-protobuf 3.15.5-universal-darwin → 3.16.0.rc.2-universal-darwin
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.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/convert.c +1 -1
- data/ext/google/protobuf_c/defs.c +35 -8
- data/ext/google/protobuf_c/message.c +3 -6
- data/ext/google/protobuf_c/protobuf.c +84 -8
- data/ext/google/protobuf_c/protobuf.h +2 -0
- data/lib/google/2.3/protobuf_c.bundle +0 -0
- data/lib/google/2.4/protobuf_c.bundle +0 -0
- data/lib/google/2.5/protobuf_c.bundle +0 -0
- data/lib/google/2.6/protobuf_c.bundle +0 -0
- data/lib/google/2.7/protobuf_c.bundle +0 -0
- data/lib/google/3.0/protobuf_c.bundle +0 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85be90abe037181b7032630e25a902f2ba987276557cba282da815c72672e5da
|
4
|
+
data.tar.gz: ab8bb80943ef0912266ce59e01aff39fce92edec9de770603dc9513a05653120
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c2bd25d2cc9d4105589afbc40048dbeb162c06ee7c78fa803a0df1f5df815e88d778a5095cfb47de86e3953fc9944df729a2b0db8d9850deed3af8f48c0850f
|
7
|
+
data.tar.gz: 110e355781bb49bc260c98d10033c4e477c660fbc325dde768cee18555f20f24ada98cf42c215e854d173f38507efedf25b85a7863c34687966cf1734e23e07e
|
@@ -315,7 +315,7 @@ bool Msgval_IsEqual(upb_msgval val1, upb_msgval val2, TypeInfo type_info) {
|
|
315
315
|
return memcmp(&val1, &val2, 8) == 0;
|
316
316
|
case UPB_TYPE_STRING:
|
317
317
|
case UPB_TYPE_BYTES:
|
318
|
-
return val1.str_val.size
|
318
|
+
return val1.str_val.size == val2.str_val.size &&
|
319
319
|
memcmp(val1.str_val.data, val2.str_val.data,
|
320
320
|
val1.str_val.size) == 0;
|
321
321
|
case UPB_TYPE_MESSAGE:
|
@@ -868,6 +868,20 @@ static VALUE FieldDescriptor_default(VALUE _self) {
|
|
868
868
|
return Convert_UpbToRuby(default_val, TypeInfo_get(self->fielddef), Qnil);
|
869
869
|
}
|
870
870
|
|
871
|
+
|
872
|
+
/*
|
873
|
+
* call-seq:
|
874
|
+
* FieldDescriptor.json_name => json_name
|
875
|
+
*
|
876
|
+
* Returns this field's json_name, as a Ruby string, or nil if not yet set.
|
877
|
+
*/
|
878
|
+
static VALUE FieldDescriptor_json_name(VALUE _self) {
|
879
|
+
FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
|
880
|
+
const upb_fielddef *f = self->fielddef;
|
881
|
+
const char *json_name = upb_fielddef_jsonname(f);
|
882
|
+
return rb_str_new2(json_name);
|
883
|
+
}
|
884
|
+
|
871
885
|
/*
|
872
886
|
* call-seq:
|
873
887
|
* FieldDescriptor.label => label
|
@@ -1043,6 +1057,7 @@ static void FieldDescriptor_register(VALUE module) {
|
|
1043
1057
|
rb_define_method(klass, "name", FieldDescriptor_name, 0);
|
1044
1058
|
rb_define_method(klass, "type", FieldDescriptor__type, 0);
|
1045
1059
|
rb_define_method(klass, "default", FieldDescriptor_default, 0);
|
1060
|
+
rb_define_method(klass, "json_name", FieldDescriptor_json_name, 0);
|
1046
1061
|
rb_define_method(klass, "label", FieldDescriptor_label, 0);
|
1047
1062
|
rb_define_method(klass, "number", FieldDescriptor_number, 0);
|
1048
1063
|
rb_define_method(klass, "submsg_name", FieldDescriptor_submsg_name, 0);
|
@@ -1750,6 +1765,16 @@ static void msgdef_add_field(VALUE msgbuilder_rb, upb_label_t label, VALUE name,
|
|
1750
1765
|
field_proto,
|
1751
1766
|
FileBuilderContext_strdup(self->file_builder, default_value));
|
1752
1767
|
}
|
1768
|
+
|
1769
|
+
if (rb_funcall(options, rb_intern("key?"), 1,
|
1770
|
+
ID2SYM(rb_intern("json_name"))) == Qtrue) {
|
1771
|
+
VALUE json_name =
|
1772
|
+
rb_hash_lookup(options, ID2SYM(rb_intern("json_name")));
|
1773
|
+
|
1774
|
+
google_protobuf_FieldDescriptorProto_set_json_name(
|
1775
|
+
field_proto,
|
1776
|
+
FileBuilderContext_strdup(self->file_builder, json_name));
|
1777
|
+
}
|
1753
1778
|
}
|
1754
1779
|
|
1755
1780
|
if (oneof_index >= 0) {
|
@@ -1899,18 +1924,20 @@ static VALUE MessageBuilderContext_required(int argc, VALUE* argv,
|
|
1899
1924
|
*/
|
1900
1925
|
static VALUE MessageBuilderContext_repeated(int argc, VALUE* argv,
|
1901
1926
|
VALUE _self) {
|
1902
|
-
VALUE name, type, number
|
1927
|
+
VALUE name, type, number;
|
1928
|
+
VALUE type_class, options = Qnil;
|
1903
1929
|
|
1904
|
-
|
1905
|
-
|
1930
|
+
rb_scan_args(argc, argv, "32", &name, &type, &number, &type_class, &options);
|
1931
|
+
|
1932
|
+
// Allow passing (name, type, number, options) or
|
1933
|
+
// (name, type, number, type_class, options)
|
1934
|
+
if (argc == 4 && RB_TYPE_P(type_class, T_HASH)) {
|
1935
|
+
options = type_class;
|
1936
|
+
type_class = Qnil;
|
1906
1937
|
}
|
1907
|
-
name = argv[0];
|
1908
|
-
type = argv[1];
|
1909
|
-
number = argv[2];
|
1910
|
-
type_class = (argc > 3) ? argv[3] : Qnil;
|
1911
1938
|
|
1912
1939
|
msgdef_add_field(_self, UPB_LABEL_REPEATED, name, type, number, type_class,
|
1913
|
-
|
1940
|
+
options, -1, false);
|
1914
1941
|
|
1915
1942
|
return Qnil;
|
1916
1943
|
}
|
@@ -697,16 +697,13 @@ bool Message_Equal(const upb_msg *m1, const upb_msg *m2, const upb_msgdef *m) {
|
|
697
697
|
* field is of a primitive type).
|
698
698
|
*/
|
699
699
|
static VALUE Message_eq(VALUE _self, VALUE _other) {
|
700
|
-
if (
|
701
|
-
return Qfalse;
|
702
|
-
}
|
700
|
+
if (CLASS_OF(_self) != CLASS_OF(_other)) return Qfalse;
|
703
701
|
|
704
702
|
Message* self = ruby_to_Message(_self);
|
705
703
|
Message* other = ruby_to_Message(_other);
|
704
|
+
assert(self->msgdef == other->msgdef);
|
706
705
|
|
707
|
-
return Message_Equal(self->msg, other->msg, self->msgdef)
|
708
|
-
? Qtrue
|
709
|
-
: Qfalse;
|
706
|
+
return Message_Equal(self->msg, other->msg, self->msgdef) ? Qtrue : Qfalse;
|
710
707
|
}
|
711
708
|
|
712
709
|
uint64_t Message_Hash(const upb_msg* msg, const upb_msgdef* m, uint64_t seed) {
|
@@ -37,7 +37,7 @@
|
|
37
37
|
#include "message.h"
|
38
38
|
#include "repeated_field.h"
|
39
39
|
|
40
|
-
VALUE
|
40
|
+
VALUE cParseError;
|
41
41
|
VALUE cTypeError;
|
42
42
|
|
43
43
|
const upb_fielddef* map_field_key(const upb_fielddef* field) {
|
@@ -180,6 +180,7 @@ static void Arena_mark(void *data) {
|
|
180
180
|
static void Arena_free(void *data) {
|
181
181
|
Arena *arena = data;
|
182
182
|
upb_arena_free(arena->arena);
|
183
|
+
xfree(arena);
|
183
184
|
}
|
184
185
|
|
185
186
|
static VALUE cArena;
|
@@ -251,14 +252,80 @@ void Arena_register(VALUE module) {
|
|
251
252
|
// The object is used only for its identity; it does not contain any data.
|
252
253
|
VALUE secondary_map = Qnil;
|
253
254
|
|
255
|
+
// Mutations to the map are under a mutex, because SeconaryMap_MaybeGC()
|
256
|
+
// iterates over the map which cannot happen in parallel with insertions, or
|
257
|
+
// Ruby will throw:
|
258
|
+
// can't add a new key into hash during iteration (RuntimeError)
|
259
|
+
VALUE secondary_map_mutex = Qnil;
|
260
|
+
|
261
|
+
// Lambda that will GC entries from the secondary map that are no longer present
|
262
|
+
// in the primary map.
|
263
|
+
VALUE gc_secondary_map_lambda = Qnil;
|
264
|
+
ID length;
|
265
|
+
|
266
|
+
extern VALUE weak_obj_cache;
|
267
|
+
|
254
268
|
static void SecondaryMap_Init() {
|
255
269
|
rb_gc_register_address(&secondary_map);
|
270
|
+
rb_gc_register_address(&gc_secondary_map_lambda);
|
271
|
+
rb_gc_register_address(&secondary_map_mutex);
|
256
272
|
secondary_map = rb_hash_new();
|
273
|
+
gc_secondary_map_lambda = rb_eval_string(
|
274
|
+
"->(secondary, weak) {\n"
|
275
|
+
" secondary.delete_if { |k, v| !weak.key?(v) }\n"
|
276
|
+
"}\n");
|
277
|
+
secondary_map_mutex = rb_mutex_new();
|
278
|
+
length = rb_intern("length");
|
257
279
|
}
|
258
280
|
|
259
|
-
|
281
|
+
// The secondary map is a regular Hash, and will never shrink on its own.
|
282
|
+
// The main object cache is a WeakMap that will automatically remove entries
|
283
|
+
// when the target object is no longer reachable, but unless we manually
|
284
|
+
// remove the corresponding entries from the secondary map, it will grow
|
285
|
+
// without bound.
|
286
|
+
//
|
287
|
+
// To avoid this unbounded growth we periodically remove entries from the
|
288
|
+
// secondary map that are no longer present in the WeakMap. The logic of
|
289
|
+
// how often to perform this GC is an artbirary tuning parameter that
|
290
|
+
// represents a straightforward CPU/memory tradeoff.
|
291
|
+
//
|
292
|
+
// Requires: secondary_map_mutex is held.
|
293
|
+
static void SecondaryMap_MaybeGC() {
|
294
|
+
PBRUBY_ASSERT(rb_mutex_locked_p(secondary_map_mutex) == Qtrue);
|
295
|
+
size_t weak_len = NUM2ULL(rb_funcall(weak_obj_cache, length, 0));
|
296
|
+
size_t secondary_len = RHASH_SIZE(secondary_map);
|
297
|
+
if (secondary_len < weak_len) {
|
298
|
+
// Logically this case should not be possible: a valid entry cannot exist in
|
299
|
+
// the weak table unless there is a corresponding entry in the secondary
|
300
|
+
// table. It should *always* be the case that secondary_len >= weak_len.
|
301
|
+
//
|
302
|
+
// However ObjectSpace::WeakMap#length (and therefore weak_len) is
|
303
|
+
// unreliable: it overreports its true length by including non-live objects.
|
304
|
+
// However these non-live objects are not yielded in iteration, so we may
|
305
|
+
// have previously deleted them from the secondary map in a previous
|
306
|
+
// invocation of SecondaryMap_MaybeGC().
|
307
|
+
//
|
308
|
+
// In this case, we can't measure any waste, so we just return.
|
309
|
+
return;
|
310
|
+
}
|
311
|
+
size_t waste = secondary_len - weak_len;
|
312
|
+
// GC if we could remove at least 2000 entries or 20% of the table size
|
313
|
+
// (whichever is greater). Since the cost of the GC pass is O(N), we
|
314
|
+
// want to make sure that we condition this on overall table size, to
|
315
|
+
// avoid O(N^2) CPU costs.
|
316
|
+
size_t threshold = PBRUBY_MAX(secondary_len * 0.2, 2000);
|
317
|
+
if (waste > threshold) {
|
318
|
+
rb_funcall(gc_secondary_map_lambda, rb_intern("call"), 2,
|
319
|
+
secondary_map, weak_obj_cache);
|
320
|
+
}
|
321
|
+
}
|
322
|
+
|
323
|
+
// Requires: secondary_map_mutex is held by this thread iff create == true.
|
324
|
+
static VALUE SecondaryMap_Get(VALUE key, bool create) {
|
325
|
+
PBRUBY_ASSERT(!create || rb_mutex_locked_p(secondary_map_mutex) == Qtrue);
|
260
326
|
VALUE ret = rb_hash_lookup(secondary_map, key);
|
261
|
-
if (ret == Qnil) {
|
327
|
+
if (ret == Qnil && create) {
|
328
|
+
SecondaryMap_MaybeGC();
|
262
329
|
ret = rb_eval_string("Object.new");
|
263
330
|
rb_hash_aset(secondary_map, key, ret);
|
264
331
|
}
|
@@ -267,14 +334,15 @@ static VALUE SecondaryMap_Get(VALUE key) {
|
|
267
334
|
|
268
335
|
#endif
|
269
336
|
|
270
|
-
|
337
|
+
// Requires: secondary_map_mutex is held by this thread iff create == true.
|
338
|
+
static VALUE ObjectCache_GetKey(const void* key, bool create) {
|
271
339
|
char buf[sizeof(key)];
|
272
340
|
memcpy(&buf, &key, sizeof(key));
|
273
341
|
intptr_t key_int = (intptr_t)key;
|
274
342
|
PBRUBY_ASSERT((key_int & 3) == 0);
|
275
343
|
VALUE ret = LL2NUM(key_int >> 2);
|
276
344
|
#if USE_SECONDARY_MAP
|
277
|
-
ret = SecondaryMap_Get(ret);
|
345
|
+
ret = SecondaryMap_Get(ret, create);
|
278
346
|
#endif
|
279
347
|
return ret;
|
280
348
|
}
|
@@ -298,14 +366,20 @@ static void ObjectCache_Init() {
|
|
298
366
|
|
299
367
|
void ObjectCache_Add(const void* key, VALUE val) {
|
300
368
|
PBRUBY_ASSERT(ObjectCache_Get(key) == Qnil);
|
301
|
-
|
369
|
+
#if USE_SECONDARY_MAP
|
370
|
+
rb_mutex_lock(secondary_map_mutex);
|
371
|
+
#endif
|
372
|
+
VALUE key_rb = ObjectCache_GetKey(key, true);
|
302
373
|
rb_funcall(weak_obj_cache, item_set, 2, key_rb, val);
|
374
|
+
#if USE_SECONDARY_MAP
|
375
|
+
rb_mutex_unlock(secondary_map_mutex);
|
376
|
+
#endif
|
303
377
|
PBRUBY_ASSERT(ObjectCache_Get(key) == val);
|
304
378
|
}
|
305
379
|
|
306
380
|
// Returns the cached object for this key, if any. Otherwise returns Qnil.
|
307
381
|
VALUE ObjectCache_Get(const void* key) {
|
308
|
-
VALUE key_rb = ObjectCache_GetKey(key);
|
382
|
+
VALUE key_rb = ObjectCache_GetKey(key, false);
|
309
383
|
return rb_funcall(weak_obj_cache, item_get, 1, key_rb);
|
310
384
|
}
|
311
385
|
|
@@ -368,8 +442,10 @@ void Init_protobuf_c() {
|
|
368
442
|
Map_register(protobuf);
|
369
443
|
Message_register(protobuf);
|
370
444
|
|
371
|
-
|
445
|
+
cParseError = rb_const_get(protobuf, rb_intern("ParseError"));
|
446
|
+
rb_gc_register_mark_object(cParseError);
|
372
447
|
cTypeError = rb_const_get(protobuf, rb_intern("TypeError"));
|
448
|
+
rb_gc_register_mark_object(cTypeError);
|
373
449
|
|
374
450
|
rb_define_singleton_method(protobuf, "discard_unknown",
|
375
451
|
Google_Protobuf_discard_unknown, 1);
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-protobuf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.16.0.rc.2
|
5
5
|
platform: universal-darwin
|
6
6
|
authors:
|
7
7
|
- Protobuf Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler-dock
|
@@ -128,7 +128,7 @@ homepage: https://developers.google.com/protocol-buffers
|
|
128
128
|
licenses:
|
129
129
|
- BSD-3-Clause
|
130
130
|
metadata:
|
131
|
-
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.
|
131
|
+
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.16.0-rc2/ruby
|
132
132
|
post_install_message:
|
133
133
|
rdoc_options: []
|
134
134
|
require_paths:
|
@@ -143,11 +143,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
143
|
version: 3.1.dev
|
144
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
145
|
requirements:
|
146
|
-
- - "
|
146
|
+
- - ">"
|
147
147
|
- !ruby/object:Gem::Version
|
148
|
-
version:
|
148
|
+
version: 1.3.1
|
149
149
|
requirements: []
|
150
|
-
rubygems_version: 3.2.
|
150
|
+
rubygems_version: 3.2.17
|
151
151
|
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: Protocol Buffers
|