google-protobuf 3.25.8 → 4.28.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/convert.c +40 -15
- data/ext/google/protobuf_c/defs.c +365 -26
- data/ext/google/protobuf_c/extconf.rb +1 -1
- data/ext/google/protobuf_c/glue.c +16 -0
- data/ext/google/protobuf_c/map.c +72 -27
- data/ext/google/protobuf_c/map.h +7 -3
- data/ext/google/protobuf_c/message.c +100 -111
- data/ext/google/protobuf_c/message.h +2 -6
- data/ext/google/protobuf_c/protobuf.c +30 -15
- data/ext/google/protobuf_c/protobuf.h +3 -7
- data/ext/google/protobuf_c/repeated_field.c +58 -23
- data/ext/google/protobuf_c/repeated_field.h +6 -2
- data/ext/google/protobuf_c/ruby-upb.c +13047 -10862
- data/ext/google/protobuf_c/ruby-upb.h +11114 -9028
- data/ext/google/protobuf_c/shared_convert.c +7 -2
- data/ext/google/protobuf_c/shared_message.c +3 -32
- data/ext/google/protobuf_c/shared_message.h +0 -4
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c +467 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +9 -8
- data/lib/google/protobuf/any_pb.rb +1 -22
- data/lib/google/protobuf/api_pb.rb +1 -24
- data/lib/google/protobuf/descriptor_pb.rb +3 -23
- data/lib/google/protobuf/duration_pb.rb +1 -22
- data/lib/google/protobuf/empty_pb.rb +1 -22
- data/lib/google/protobuf/ffi/descriptor.rb +4 -4
- data/lib/google/protobuf/ffi/descriptor_pool.rb +3 -1
- data/lib/google/protobuf/ffi/enum_descriptor.rb +3 -1
- data/lib/google/protobuf/ffi/ffi.rb +3 -6
- data/lib/google/protobuf/ffi/field_descriptor.rb +13 -2
- data/lib/google/protobuf/ffi/file_descriptor.rb +3 -13
- data/lib/google/protobuf/ffi/internal/arena.rb +0 -6
- data/lib/google/protobuf/ffi/internal/convert.rb +21 -30
- data/lib/google/protobuf/ffi/map.rb +50 -24
- data/lib/google/protobuf/ffi/message.rb +183 -64
- data/lib/google/protobuf/ffi/method_descriptor.rb +114 -0
- data/lib/google/protobuf/ffi/object_cache.rb +3 -3
- data/lib/google/protobuf/ffi/oneof_descriptor.rb +3 -1
- data/lib/google/protobuf/ffi/repeated_field.rb +47 -19
- data/lib/google/protobuf/ffi/service_descriptor.rb +107 -0
- data/lib/google/protobuf/field_mask_pb.rb +1 -22
- data/lib/google/protobuf/internal/object_cache.rb +99 -0
- data/lib/google/protobuf/plugin_pb.rb +2 -24
- data/lib/google/protobuf/repeated_field.rb +4 -5
- data/lib/google/protobuf/source_context_pb.rb +1 -22
- data/lib/google/protobuf/struct_pb.rb +1 -22
- data/lib/google/protobuf/timestamp_pb.rb +1 -22
- data/lib/google/protobuf/type_pb.rb +1 -24
- data/lib/google/protobuf/wrappers_pb.rb +1 -22
- data/lib/google/protobuf.rb +1 -1
- data/lib/google/protobuf_ffi.rb +3 -2
- data/lib/google/protobuf_native.rb +0 -1
- data/lib/google/tasks/ffi.rake +1 -3
- metadata +25 -12
- data/ext/google/protobuf_c/third_party/utf8_range/naive.c +0 -92
- data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +0 -157
- data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +0 -170
- data/lib/google/protobuf/descriptor_dsl.rb +0 -465
- data/lib/google/protobuf/object_cache.rb +0 -97
@@ -50,13 +50,6 @@ upb_Arena* Arena_get(VALUE arena);
|
|
50
50
|
// possible.
|
51
51
|
void Arena_fuse(VALUE arena, upb_Arena* other);
|
52
52
|
|
53
|
-
// Pins this Ruby object to the lifetime of this arena, so that as long as the
|
54
|
-
// arena is alive this object will not be collected.
|
55
|
-
//
|
56
|
-
// We use this to guarantee that the "frozen" bit on the object will be
|
57
|
-
// remembered, even if the user drops their reference to this precise object.
|
58
|
-
void Arena_Pin(VALUE arena, VALUE obj);
|
59
|
-
|
60
53
|
// -----------------------------------------------------------------------------
|
61
54
|
// ObjectCache
|
62
55
|
// -----------------------------------------------------------------------------
|
@@ -105,6 +98,9 @@ extern VALUE cTypeError;
|
|
105
98
|
rb_bug("Assertion failed at %s:%d, expr: %s", __FILE__, __LINE__, #expr)
|
106
99
|
#endif
|
107
100
|
|
101
|
+
// Raises a Ruby error if val is frozen in Ruby or upb_frozen is true.
|
102
|
+
void Protobuf_CheckNotFrozen(VALUE val, bool upb_frozen);
|
103
|
+
|
108
104
|
#define PBRUBY_MAX(x, y) (((x) > (y)) ? (x) : (y))
|
109
105
|
|
110
106
|
#define UPB_UNUSED(var) (void)var
|
@@ -44,8 +44,9 @@ static RepeatedField* ruby_to_RepeatedField(VALUE _self) {
|
|
44
44
|
}
|
45
45
|
|
46
46
|
static upb_Array* RepeatedField_GetMutable(VALUE _self) {
|
47
|
-
|
48
|
-
|
47
|
+
const upb_Array* array = ruby_to_RepeatedField(_self)->array;
|
48
|
+
Protobuf_CheckNotFrozen(_self, upb_Array_IsFrozen(array));
|
49
|
+
return (upb_Array*)array;
|
49
50
|
}
|
50
51
|
|
51
52
|
VALUE RepeatedField_alloc(VALUE klass) {
|
@@ -56,9 +57,32 @@ VALUE RepeatedField_alloc(VALUE klass) {
|
|
56
57
|
return TypedData_Wrap_Struct(klass, &RepeatedField_type, self);
|
57
58
|
}
|
58
59
|
|
59
|
-
VALUE
|
60
|
+
VALUE RepeatedField_EmptyFrozen(const upb_FieldDef* f) {
|
61
|
+
PBRUBY_ASSERT(upb_FieldDef_IsRepeated(f));
|
62
|
+
VALUE val = ObjectCache_Get(f);
|
63
|
+
|
64
|
+
if (val == Qnil) {
|
65
|
+
val = RepeatedField_alloc(cRepeatedField);
|
66
|
+
RepeatedField* self;
|
67
|
+
TypedData_Get_Struct(val, RepeatedField, &RepeatedField_type, self);
|
68
|
+
self->arena = Arena_new();
|
69
|
+
TypeInfo type_info = TypeInfo_get(f);
|
70
|
+
self->array = upb_Array_New(Arena_get(self->arena), type_info.type);
|
71
|
+
self->type_info = type_info;
|
72
|
+
if (self->type_info.type == kUpb_CType_Message) {
|
73
|
+
self->type_class = Descriptor_DefToClass(type_info.def.msgdef);
|
74
|
+
}
|
75
|
+
val = ObjectCache_TryAdd(f, RepeatedField_freeze(val));
|
76
|
+
}
|
77
|
+
PBRUBY_ASSERT(RB_OBJ_FROZEN(val));
|
78
|
+
PBRUBY_ASSERT(upb_Array_IsFrozen(ruby_to_RepeatedField(val)->array));
|
79
|
+
return val;
|
80
|
+
}
|
81
|
+
|
82
|
+
VALUE RepeatedField_GetRubyWrapper(const upb_Array* array, TypeInfo type_info,
|
60
83
|
VALUE arena) {
|
61
84
|
PBRUBY_ASSERT(array);
|
85
|
+
PBRUBY_ASSERT(arena != Qnil);
|
62
86
|
VALUE val = ObjectCache_Get(array);
|
63
87
|
|
64
88
|
if (val == Qnil) {
|
@@ -78,7 +102,6 @@ VALUE RepeatedField_GetRubyWrapper(upb_Array* array, TypeInfo type_info,
|
|
78
102
|
PBRUBY_ASSERT(ruby_to_RepeatedField(val)->type_info.def.msgdef ==
|
79
103
|
type_info.def.msgdef);
|
80
104
|
PBRUBY_ASSERT(ruby_to_RepeatedField(val)->array == array);
|
81
|
-
|
82
105
|
return val;
|
83
106
|
}
|
84
107
|
|
@@ -473,36 +496,47 @@ VALUE RepeatedField_eq(VALUE _self, VALUE _other) {
|
|
473
496
|
|
474
497
|
/*
|
475
498
|
* call-seq:
|
476
|
-
* RepeatedField.
|
499
|
+
* RepeatedField.frozen? => bool
|
477
500
|
*
|
478
|
-
*
|
479
|
-
*
|
501
|
+
* Returns true if the repeated field is frozen in either Ruby or the underlying
|
502
|
+
* representation. Freezes the Ruby repeated field object if it is not already
|
503
|
+
* frozen in Ruby but it is frozen in the underlying representation.
|
480
504
|
*/
|
481
|
-
|
505
|
+
VALUE RepeatedField_frozen(VALUE _self) {
|
482
506
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
483
|
-
if (!
|
484
|
-
|
485
|
-
|
507
|
+
if (!upb_Array_IsFrozen(self->array)) {
|
508
|
+
PBRUBY_ASSERT(!RB_OBJ_FROZEN(_self));
|
509
|
+
return Qfalse;
|
486
510
|
}
|
487
|
-
|
511
|
+
|
512
|
+
// Lazily freeze the Ruby wrapper.
|
513
|
+
if (!RB_OBJ_FROZEN(_self)) RB_OBJ_FREEZE(_self);
|
514
|
+
return Qtrue;
|
488
515
|
}
|
489
516
|
|
490
517
|
/*
|
491
|
-
*
|
492
|
-
*
|
518
|
+
* call-seq:
|
519
|
+
* RepeatedField.freeze => self
|
520
|
+
*
|
521
|
+
* Freezes the repeated field object. We have to intercept this so we can freeze
|
522
|
+
* the underlying representation, not just the Ruby wrapper.
|
493
523
|
*/
|
494
|
-
VALUE
|
524
|
+
VALUE RepeatedField_freeze(VALUE _self) {
|
495
525
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
526
|
+
if (RB_OBJ_FROZEN(_self)) {
|
527
|
+
PBRUBY_ASSERT(upb_Array_IsFrozen(self->array));
|
528
|
+
return _self;
|
529
|
+
}
|
530
|
+
|
531
|
+
if (!upb_Array_IsFrozen(self->array)) {
|
532
|
+
if (self->type_info.type == kUpb_CType_Message) {
|
533
|
+
upb_Array_Freeze(RepeatedField_GetMutable(_self),
|
534
|
+
upb_MessageDef_MiniTable(self->type_info.def.msgdef));
|
535
|
+
} else {
|
536
|
+
upb_Array_Freeze(RepeatedField_GetMutable(_self), NULL);
|
504
537
|
}
|
505
538
|
}
|
539
|
+
RB_OBJ_FREEZE(_self);
|
506
540
|
return _self;
|
507
541
|
}
|
508
542
|
|
@@ -649,6 +683,7 @@ void RepeatedField_register(VALUE module) {
|
|
649
683
|
rb_define_method(klass, "==", RepeatedField_eq, 1);
|
650
684
|
rb_define_method(klass, "to_ary", RepeatedField_to_ary, 0);
|
651
685
|
rb_define_method(klass, "freeze", RepeatedField_freeze, 0);
|
686
|
+
rb_define_method(klass, "frozen?", RepeatedField_frozen, 0);
|
652
687
|
rb_define_method(klass, "hash", RepeatedField_hash, 0);
|
653
688
|
rb_define_method(klass, "+", RepeatedField_plus, 1);
|
654
689
|
rb_define_method(klass, "concat", RepeatedField_concat, 1);
|
@@ -11,9 +11,13 @@
|
|
11
11
|
#include "protobuf.h"
|
12
12
|
#include "ruby-upb.h"
|
13
13
|
|
14
|
+
// Returns a frozen sentinel Ruby wrapper object for an empty upb_Array of the
|
15
|
+
// type specified by the field. Creates one if it doesn't exist.
|
16
|
+
VALUE RepeatedField_EmptyFrozen(const upb_FieldDef* f);
|
17
|
+
|
14
18
|
// Returns a Ruby wrapper object for the given upb_Array, which will be created
|
15
19
|
// if one does not exist already.
|
16
|
-
VALUE RepeatedField_GetRubyWrapper(upb_Array* msg, TypeInfo type_info,
|
20
|
+
VALUE RepeatedField_GetRubyWrapper(const upb_Array* msg, TypeInfo type_info,
|
17
21
|
VALUE arena);
|
18
22
|
|
19
23
|
// Gets the underlying upb_Array for this Ruby RepeatedField object, which must
|
@@ -36,6 +40,6 @@ extern VALUE cRepeatedField;
|
|
36
40
|
void RepeatedField_register(VALUE module);
|
37
41
|
|
38
42
|
// Recursively freeze RepeatedField.
|
39
|
-
VALUE
|
43
|
+
VALUE RepeatedField_freeze(VALUE _self);
|
40
44
|
|
41
45
|
#endif // RUBY_PROTOBUF_REPEATED_FIELD_H_
|