google-protobuf 3.25.4 → 4.27.2
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 +7 -4
- data/ext/google/protobuf_c/defs.c +367 -28
- 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 +12 -19
- data/ext/google/protobuf_c/map.h +1 -1
- data/ext/google/protobuf_c/message.c +43 -90
- data/ext/google/protobuf_c/message.h +1 -5
- data/ext/google/protobuf_c/protobuf.c +19 -6
- data/ext/google/protobuf_c/repeated_field.c +6 -15
- data/ext/google/protobuf_c/repeated_field.h +1 -1
- data/ext/google/protobuf_c/ruby-upb.c +12684 -10768
- data/ext/google/protobuf_c/ruby-upb.h +6889 -5584
- data/ext/google/protobuf_c/shared_convert.c +10 -5
- data/ext/google/protobuf_c/shared_convert.h +2 -2
- data/ext/google/protobuf_c/shared_message.c +3 -31
- 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 -3
- 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/convert.rb +8 -24
- data/lib/google/protobuf/ffi/map.rb +13 -11
- data/lib/google/protobuf/ffi/message.rb +10 -13
- 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 +12 -10
- 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
@@ -44,9 +44,11 @@ static void Message_mark(void* _self) {
|
|
44
44
|
rb_gc_mark(self->arena);
|
45
45
|
}
|
46
46
|
|
47
|
+
static size_t Message_memsize(const void* _self) { return sizeof(Message); }
|
48
|
+
|
47
49
|
static rb_data_type_t Message_type = {
|
48
50
|
"Google::Protobuf::Message",
|
49
|
-
{Message_mark, RUBY_DEFAULT_FREE,
|
51
|
+
{Message_mark, RUBY_DEFAULT_FREE, Message_memsize},
|
50
52
|
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
51
53
|
};
|
52
54
|
|
@@ -488,7 +490,8 @@ static int Map_initialize_kwarg(VALUE key, VALUE val, VALUE _self) {
|
|
488
490
|
k = Convert_RubyToUpb(key, "", map_init->key_type, NULL);
|
489
491
|
|
490
492
|
if (map_init->val_type.type == kUpb_CType_Message && TYPE(val) == T_HASH) {
|
491
|
-
upb_MiniTable* t =
|
493
|
+
const upb_MiniTable* t =
|
494
|
+
upb_MessageDef_MiniTable(map_init->val_type.def.msgdef);
|
492
495
|
upb_Message* msg = upb_Message_New(t, map_init->arena);
|
493
496
|
Message_InitFromValue(msg, map_init->val_type.def.msgdef, val,
|
494
497
|
map_init->arena);
|
@@ -519,7 +522,7 @@ static upb_MessageValue MessageValue_FromValue(VALUE val, TypeInfo info,
|
|
519
522
|
upb_Arena* arena) {
|
520
523
|
if (info.type == kUpb_CType_Message) {
|
521
524
|
upb_MessageValue msgval;
|
522
|
-
upb_MiniTable* t = upb_MessageDef_MiniTable(info.def.msgdef);
|
525
|
+
const upb_MiniTable* t = upb_MessageDef_MiniTable(info.def.msgdef);
|
523
526
|
upb_Message* msg = upb_Message_New(t, arena);
|
524
527
|
Message_InitFromValue(msg, info.def.msgdef, val, arena);
|
525
528
|
msgval.msg_val = msg;
|
@@ -635,7 +638,7 @@ static VALUE Message_initialize(int argc, VALUE* argv, VALUE _self) {
|
|
635
638
|
Message* self = ruby_to_Message(_self);
|
636
639
|
VALUE arena_rb = Arena_new();
|
637
640
|
upb_Arena* arena = Arena_get(arena_rb);
|
638
|
-
upb_MiniTable* t = upb_MessageDef_MiniTable(self->msgdef);
|
641
|
+
const upb_MiniTable* t = upb_MessageDef_MiniTable(self->msgdef);
|
639
642
|
upb_Message* msg = upb_Message_New(t, arena);
|
640
643
|
|
641
644
|
Message_InitPtr(_self, msg, arena_rb);
|
@@ -660,28 +663,12 @@ static VALUE Message_dup(VALUE _self) {
|
|
660
663
|
Message* self = ruby_to_Message(_self);
|
661
664
|
VALUE new_msg = rb_class_new_instance(0, NULL, CLASS_OF(_self));
|
662
665
|
Message* new_msg_self = ruby_to_Message(new_msg);
|
663
|
-
|
664
|
-
|
665
|
-
// TODO
|
666
|
-
// TODO
|
667
|
-
memcpy((upb_Message*)new_msg_self->msg, self->msg, size);
|
666
|
+
const upb_MiniTable* m = upb_MessageDef_MiniTable(self->msgdef);
|
667
|
+
upb_Message_ShallowCopy((upb_Message*)new_msg_self->msg, self->msg, m);
|
668
668
|
Arena_fuse(self->arena, Arena_get(new_msg_self->arena));
|
669
669
|
return new_msg;
|
670
670
|
}
|
671
671
|
|
672
|
-
// Support function for Message_eq, and also used by other #eq functions.
|
673
|
-
bool Message_Equal(const upb_Message* m1, const upb_Message* m2,
|
674
|
-
const upb_MessageDef* m) {
|
675
|
-
upb_Status status;
|
676
|
-
upb_Status_Clear(&status);
|
677
|
-
bool return_value = shared_Message_Equal(m1, m2, m, &status);
|
678
|
-
if (upb_Status_IsOk(&status)) {
|
679
|
-
return return_value;
|
680
|
-
} else {
|
681
|
-
rb_raise(cParseError, upb_Status_ErrorMessage(&status));
|
682
|
-
}
|
683
|
-
}
|
684
|
-
|
685
672
|
/*
|
686
673
|
* call-seq:
|
687
674
|
* Message.==(other) => boolean
|
@@ -698,7 +685,10 @@ static VALUE Message_eq(VALUE _self, VALUE _other) {
|
|
698
685
|
Message* other = ruby_to_Message(_other);
|
699
686
|
assert(self->msgdef == other->msgdef);
|
700
687
|
|
701
|
-
|
688
|
+
const upb_MiniTable* m = upb_MessageDef_MiniTable(self->msgdef);
|
689
|
+
const int options = 0;
|
690
|
+
return upb_Message_IsEqual(self->msg, other->msg, m, options) ? Qtrue
|
691
|
+
: Qfalse;
|
702
692
|
}
|
703
693
|
|
704
694
|
uint64_t Message_Hash(const upb_Message* msg, const upb_MessageDef* m,
|
@@ -709,7 +699,8 @@ uint64_t Message_Hash(const upb_Message* msg, const upb_MessageDef* m,
|
|
709
699
|
if (upb_Status_IsOk(&status)) {
|
710
700
|
return return_value;
|
711
701
|
} else {
|
712
|
-
rb_raise(cParseError,
|
702
|
+
rb_raise(cParseError, "Message_Hash(): %s",
|
703
|
+
upb_Status_ErrorMessage(&status));
|
713
704
|
}
|
714
705
|
}
|
715
706
|
|
@@ -766,58 +757,34 @@ static VALUE Message_CreateHash(const upb_Message* msg,
|
|
766
757
|
if (!msg) return Qnil;
|
767
758
|
|
768
759
|
VALUE hash = rb_hash_new();
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
// This is unfortunate, we should key behaviors off field attributes (like
|
774
|
-
// whether a field has presence), not proto2 vs. proto3. We should see if we
|
775
|
-
// can change this without breaking users.
|
776
|
-
is_proto2 = upb_MessageDef_Syntax(m) == kUpb_Syntax_Proto2;
|
777
|
-
|
778
|
-
for (int i = 0; i < n; i++) {
|
779
|
-
const upb_FieldDef* field = upb_MessageDef_Field(m, i);
|
780
|
-
TypeInfo type_info = TypeInfo_get(field);
|
781
|
-
upb_MessageValue msgval;
|
782
|
-
VALUE msg_value;
|
783
|
-
VALUE msg_key;
|
784
|
-
|
785
|
-
if (!is_proto2 && upb_FieldDef_IsSubMessage(field) &&
|
786
|
-
!upb_FieldDef_IsRepeated(field) &&
|
787
|
-
!upb_Message_HasFieldByDef(msg, field)) {
|
788
|
-
// TODO: Legacy behavior, remove when we fix the is_proto2 differences.
|
789
|
-
msg_key = ID2SYM(rb_intern(upb_FieldDef_Name(field)));
|
790
|
-
rb_hash_aset(hash, msg_key, Qnil);
|
791
|
-
continue;
|
792
|
-
}
|
760
|
+
size_t iter = kUpb_Message_Begin;
|
761
|
+
const upb_DefPool* pool = upb_FileDef_Pool(upb_MessageDef_File(m));
|
762
|
+
const upb_FieldDef* field;
|
763
|
+
upb_MessageValue val;
|
793
764
|
|
794
|
-
|
795
|
-
if (
|
796
|
-
|
765
|
+
while (upb_Message_Next(msg, m, pool, &field, &val, &iter)) {
|
766
|
+
if (upb_FieldDef_IsExtension(field)) {
|
767
|
+
// TODO: allow extensions once we have decided what naming scheme the
|
768
|
+
// symbol should use. eg. :"[pkg.ext]"
|
797
769
|
continue;
|
798
770
|
}
|
799
771
|
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
// Proto2 omits empty map/repeated filds also.
|
772
|
+
TypeInfo type_info = TypeInfo_get(field);
|
773
|
+
VALUE msg_value;
|
804
774
|
|
805
775
|
if (upb_FieldDef_IsMap(field)) {
|
806
776
|
const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(field);
|
807
777
|
const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry_m, 1);
|
808
778
|
const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry_m, 2);
|
809
779
|
upb_CType key_type = upb_FieldDef_CType(key_f);
|
810
|
-
msg_value = Map_CreateHash(
|
780
|
+
msg_value = Map_CreateHash(val.map_val, key_type, TypeInfo_get(val_f));
|
811
781
|
} else if (upb_FieldDef_IsRepeated(field)) {
|
812
|
-
|
813
|
-
(!msgval.array_val || upb_Array_Size(msgval.array_val) == 0)) {
|
814
|
-
continue;
|
815
|
-
}
|
816
|
-
msg_value = RepeatedField_CreateArray(msgval.array_val, type_info);
|
782
|
+
msg_value = RepeatedField_CreateArray(val.array_val, type_info);
|
817
783
|
} else {
|
818
|
-
msg_value = Scalar_CreateHash(
|
784
|
+
msg_value = Scalar_CreateHash(val, type_info);
|
819
785
|
}
|
820
786
|
|
787
|
+
VALUE msg_key = ID2SYM(rb_intern(upb_FieldDef_Name(field)));
|
821
788
|
rb_hash_aset(hash, msg_key, msg_value);
|
822
789
|
}
|
823
790
|
|
@@ -850,22 +817,12 @@ static VALUE Message_to_h(VALUE _self) {
|
|
850
817
|
* Freezes the message object. We have to intercept this so we can pin the
|
851
818
|
* Ruby object into memory so we don't forget it's frozen.
|
852
819
|
*/
|
853
|
-
|
820
|
+
VALUE Message_freeze(VALUE _self) {
|
854
821
|
Message* self = ruby_to_Message(_self);
|
855
|
-
if (!RB_OBJ_FROZEN(_self)) {
|
856
|
-
Arena_Pin(self->arena, _self);
|
857
|
-
RB_OBJ_FREEZE(_self);
|
858
|
-
}
|
859
|
-
return _self;
|
860
|
-
}
|
861
822
|
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
*/
|
866
|
-
VALUE Message_internal_deep_freeze(VALUE _self) {
|
867
|
-
Message* self = ruby_to_Message(_self);
|
868
|
-
Message_freeze(_self);
|
823
|
+
if (RB_OBJ_FROZEN(_self)) return _self;
|
824
|
+
Arena_Pin(self->arena, _self);
|
825
|
+
RB_OBJ_FREEZE(_self);
|
869
826
|
|
870
827
|
int n = upb_MessageDef_FieldCount(self->msgdef);
|
871
828
|
for (int i = 0; i < n; i++) {
|
@@ -874,11 +831,11 @@ VALUE Message_internal_deep_freeze(VALUE _self) {
|
|
874
831
|
|
875
832
|
if (field != Qnil) {
|
876
833
|
if (upb_FieldDef_IsMap(f)) {
|
877
|
-
|
834
|
+
Map_freeze(field);
|
878
835
|
} else if (upb_FieldDef_IsRepeated(f)) {
|
879
|
-
|
836
|
+
RepeatedField_freeze(field);
|
880
837
|
} else if (upb_FieldDef_IsSubMessage(f)) {
|
881
|
-
|
838
|
+
Message_freeze(field);
|
882
839
|
}
|
883
840
|
}
|
884
841
|
}
|
@@ -987,7 +944,7 @@ VALUE Message_decode_bytes(int size, const char* bytes, int options,
|
|
987
944
|
rb_raise(cParseError, "Error occurred during parsing");
|
988
945
|
}
|
989
946
|
if (freeze) {
|
990
|
-
|
947
|
+
Message_freeze(msg_rb);
|
991
948
|
}
|
992
949
|
return msg_rb;
|
993
950
|
}
|
@@ -1009,9 +966,6 @@ static VALUE Message_decode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1009
966
|
int options = 0;
|
1010
967
|
upb_Status status;
|
1011
968
|
|
1012
|
-
// TODO: use this message's pool instead.
|
1013
|
-
const upb_DefPool* symtab = DescriptorPool_GetSymtab(generated_pool);
|
1014
|
-
|
1015
969
|
if (argc < 1 || argc > 2) {
|
1016
970
|
rb_raise(rb_eArgError, "Expected 1 or 2 arguments.");
|
1017
971
|
}
|
@@ -1045,8 +999,9 @@ static VALUE Message_decode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1045
999
|
}
|
1046
1000
|
|
1047
1001
|
upb_Status_Clear(&status);
|
1002
|
+
const upb_DefPool* pool = upb_FileDef_Pool(upb_MessageDef_File(msg->msgdef));
|
1048
1003
|
if (!upb_JsonDecode(RSTRING_PTR(data), RSTRING_LEN(data),
|
1049
|
-
(upb_Message*)msg->msg, msg->msgdef,
|
1004
|
+
(upb_Message*)msg->msg, msg->msgdef, pool, options,
|
1050
1005
|
Arena_get(msg->arena), &status)) {
|
1051
1006
|
rb_raise(cParseError, "Error occurred during parsing: %s",
|
1052
1007
|
upb_Status_ErrorMessage(&status));
|
@@ -1125,9 +1080,6 @@ static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1125
1080
|
size_t size;
|
1126
1081
|
upb_Status status;
|
1127
1082
|
|
1128
|
-
// TODO: use this message's pool instead.
|
1129
|
-
const upb_DefPool* symtab = DescriptorPool_GetSymtab(generated_pool);
|
1130
|
-
|
1131
1083
|
if (argc < 1 || argc > 2) {
|
1132
1084
|
rb_raise(rb_eArgError, "Expected 1 or 2 arguments.");
|
1133
1085
|
}
|
@@ -1162,8 +1114,9 @@ static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1162
1114
|
}
|
1163
1115
|
|
1164
1116
|
upb_Status_Clear(&status);
|
1165
|
-
|
1166
|
-
|
1117
|
+
const upb_DefPool* pool = upb_FileDef_Pool(upb_MessageDef_File(msg->msgdef));
|
1118
|
+
size = upb_JsonEncode(msg->msg, msg->msgdef, pool, options, buf, sizeof(buf),
|
1119
|
+
&status);
|
1167
1120
|
|
1168
1121
|
if (!upb_Status_IsOk(&status)) {
|
1169
1122
|
rb_raise(cParseError, "Error occurred during encoding: %s",
|
@@ -1173,7 +1126,7 @@ static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1173
1126
|
VALUE ret;
|
1174
1127
|
if (size >= sizeof(buf)) {
|
1175
1128
|
char* buf2 = malloc(size + 1);
|
1176
|
-
upb_JsonEncode(msg->msg, msg->msgdef,
|
1129
|
+
upb_JsonEncode(msg->msg, msg->msgdef, pool, options, buf2, size + 1,
|
1177
1130
|
&status);
|
1178
1131
|
ret = rb_str_new(buf2, size);
|
1179
1132
|
free(buf2);
|
@@ -54,10 +54,6 @@ uint64_t Message_Hash(const upb_Message* msg, const upb_MessageDef* m,
|
|
54
54
|
upb_Message* Message_deep_copy(const upb_Message* msg, const upb_MessageDef* m,
|
55
55
|
upb_Arena* arena);
|
56
56
|
|
57
|
-
// Returns true if these two messages are equal.
|
58
|
-
bool Message_Equal(const upb_Message* m1, const upb_Message* m2,
|
59
|
-
const upb_MessageDef* m);
|
60
|
-
|
61
57
|
// Checks that this Ruby object is a message, and raises an exception if not.
|
62
58
|
void Message_CheckClass(VALUE klass);
|
63
59
|
|
@@ -78,7 +74,7 @@ VALUE Message_decode_bytes(int size, const char* bytes, int options,
|
|
78
74
|
VALUE klass, bool freeze);
|
79
75
|
|
80
76
|
// Recursively freeze message
|
81
|
-
VALUE
|
77
|
+
VALUE Message_freeze(VALUE _self);
|
82
78
|
|
83
79
|
// Call at startup to register all types in this module.
|
84
80
|
void Message_register(VALUE protobuf);
|
@@ -164,11 +164,23 @@ static void Arena_free(void *data) {
|
|
164
164
|
xfree(arena);
|
165
165
|
}
|
166
166
|
|
167
|
+
static size_t Arena_memsize(const void *data) {
|
168
|
+
const Arena *arena = data;
|
169
|
+
size_t fused_count;
|
170
|
+
size_t memsize = upb_Arena_SpaceAllocated(arena->arena, &fused_count);
|
171
|
+
if (fused_count > 1) {
|
172
|
+
// If other arena were fused we attribute an equal
|
173
|
+
// share of memory usage to each one.
|
174
|
+
memsize /= fused_count;
|
175
|
+
}
|
176
|
+
return memsize + sizeof(Arena);
|
177
|
+
}
|
178
|
+
|
167
179
|
static VALUE cArena;
|
168
180
|
|
169
181
|
const rb_data_type_t Arena_type = {
|
170
182
|
"Google::Protobuf::Internal::Arena",
|
171
|
-
{Arena_mark, Arena_free,
|
183
|
+
{Arena_mark, Arena_free, Arena_memsize},
|
172
184
|
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
173
185
|
};
|
174
186
|
|
@@ -241,16 +253,17 @@ static void ObjectCache_Init(VALUE protobuf) {
|
|
241
253
|
item_try_add = rb_intern("try_add");
|
242
254
|
|
243
255
|
rb_gc_register_address(&weak_obj_cache);
|
256
|
+
VALUE internal = rb_const_get(protobuf, rb_intern("Internal"));
|
244
257
|
#if SIZEOF_LONG >= SIZEOF_VALUE
|
245
|
-
VALUE cache_class = rb_const_get(
|
258
|
+
VALUE cache_class = rb_const_get(internal, rb_intern("ObjectCache"));
|
246
259
|
#else
|
247
|
-
VALUE cache_class = rb_const_get(
|
260
|
+
VALUE cache_class = rb_const_get(internal, rb_intern("LegacyObjectCache"));
|
248
261
|
#endif
|
249
262
|
|
250
263
|
weak_obj_cache = rb_class_new_instance(0, NULL, cache_class);
|
251
|
-
rb_const_set(
|
252
|
-
rb_const_set(
|
253
|
-
rb_const_set(
|
264
|
+
rb_const_set(internal, rb_intern("OBJECT_CACHE"), weak_obj_cache);
|
265
|
+
rb_const_set(internal, rb_intern("SIZEOF_LONG"), INT2NUM(SIZEOF_LONG));
|
266
|
+
rb_const_set(internal, rb_intern("SIZEOF_VALUE"), INT2NUM(SIZEOF_VALUE));
|
254
267
|
}
|
255
268
|
|
256
269
|
static VALUE ObjectCache_GetKey(const void *key) {
|
@@ -478,29 +478,20 @@ VALUE RepeatedField_eq(VALUE _self, VALUE _other) {
|
|
478
478
|
* Freezes the repeated field. We have to intercept this so we can pin the Ruby
|
479
479
|
* object into memory so we don't forget it's frozen.
|
480
480
|
*/
|
481
|
-
|
481
|
+
VALUE RepeatedField_freeze(VALUE _self) {
|
482
482
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
483
|
-
if (!RB_OBJ_FROZEN(_self)) {
|
484
|
-
Arena_Pin(self->arena, _self);
|
485
|
-
RB_OBJ_FREEZE(_self);
|
486
|
-
}
|
487
|
-
return _self;
|
488
|
-
}
|
489
483
|
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
VALUE RepeatedField_internal_deep_freeze(VALUE _self) {
|
495
|
-
RepeatedField* self = ruby_to_RepeatedField(_self);
|
496
|
-
RepeatedField_freeze(_self);
|
484
|
+
if (RB_OBJ_FROZEN(_self)) return _self;
|
485
|
+
Arena_Pin(self->arena, _self);
|
486
|
+
RB_OBJ_FREEZE(_self);
|
487
|
+
|
497
488
|
if (self->type_info.type == kUpb_CType_Message) {
|
498
489
|
int size = upb_Array_Size(self->array);
|
499
490
|
int i;
|
500
491
|
for (i = 0; i < size; i++) {
|
501
492
|
upb_MessageValue msgval = upb_Array_Get(self->array, i);
|
502
493
|
VALUE val = Convert_UpbToRuby(msgval, self->type_info, self->arena);
|
503
|
-
|
494
|
+
Message_freeze(val);
|
504
495
|
}
|
505
496
|
}
|
506
497
|
return _self;
|
@@ -36,6 +36,6 @@ extern VALUE cRepeatedField;
|
|
36
36
|
void RepeatedField_register(VALUE module);
|
37
37
|
|
38
38
|
// Recursively freeze RepeatedField.
|
39
|
-
VALUE
|
39
|
+
VALUE RepeatedField_freeze(VALUE _self);
|
40
40
|
|
41
41
|
#endif // RUBY_PROTOBUF_REPEATED_FIELD_H_
|