google-protobuf 3.25.6-x64-mingw32 → 4.26.0.rc.1-x64-mingw32
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 +37 -24
- data/ext/google/protobuf_c/extconf.rb +1 -1
- data/ext/google/protobuf_c/map.c +7 -16
- data/ext/google/protobuf_c/map.h +1 -1
- data/ext/google/protobuf_c/message.c +30 -71
- data/ext/google/protobuf_c/message.h +1 -1
- 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 +11786 -10822
- data/ext/google/protobuf_c/ruby-upb.h +5161 -4239
- data/ext/google/protobuf_c/shared_convert.c +2 -0
- data/ext/google/protobuf_c/shared_message.c +8 -7
- 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/2.7/protobuf_c.so +0 -0
- data/lib/google/3.0/protobuf_c.so +0 -0
- 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 +2 -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 +2 -3
- data/lib/google/protobuf/ffi/enum_descriptor.rb +1 -1
- data/lib/google/protobuf/ffi/ffi.rb +2 -0
- data/lib/google/protobuf/ffi/field_descriptor.rb +10 -1
- data/lib/google/protobuf/ffi/file_descriptor.rb +1 -13
- data/lib/google/protobuf/ffi/internal/convert.rb +7 -23
- data/lib/google/protobuf/ffi/map.rb +13 -11
- data/lib/google/protobuf/ffi/message.rb +10 -13
- data/lib/google/protobuf/ffi/oneof_descriptor.rb +1 -1
- data/lib/google/protobuf/ffi/repeated_field.rb +12 -10
- data/lib/google/protobuf/field_mask_pb.rb +1 -22
- data/lib/google/protobuf/plugin_pb.rb +2 -24
- data/lib/google/protobuf/repeated_field.rb +1 -2
- 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_ffi.rb +1 -2
- data/lib/google/protobuf_native.rb +0 -1
- data/lib/google/tasks/ffi.rake +1 -3
- metadata +10 -13
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2299a21bd6ac2790f7c8c1bb91c7aced2f82afc09481118cb30dfa19cac5a4ea
|
4
|
+
data.tar.gz: 63cbfc393ee507fa8c7a09ec66506e6a913fe125bd15aec96f7005c998ac15e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a9de264a8a1290b9f23ba6d18922be4a8311c5f6a4071389f328557b796ada2bd64ac7735f0941edbdc749b35529a6f8591e9177668d0bf27a2bc6e56d5c7ae
|
7
|
+
data.tar.gz: 67bab4b7556fd2a1eea78559f36f0784298a02d50a4cc13fd4457af3a562f7437fe0e6e54db34f7ee6600da4c0bc16ae77248f9c9b167fd1f82dea8845bd3eb3
|
@@ -141,7 +141,7 @@ upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
|
|
141
141
|
VALUE utf8 = rb_enc_from_encoding(rb_utf8_encoding());
|
142
142
|
if (rb_obj_class(value) == rb_cSymbol) {
|
143
143
|
value = rb_funcall(value, rb_intern("to_s"), 0);
|
144
|
-
} else if (
|
144
|
+
} else if (!rb_obj_is_kind_of(value, rb_cString)) {
|
145
145
|
rb_raise(cTypeError,
|
146
146
|
"Invalid argument for string field '%s' (given %s).", name,
|
147
147
|
rb_class2name(CLASS_OF(value)));
|
@@ -489,7 +489,7 @@ static VALUE FileDescriptor_alloc(VALUE klass) {
|
|
489
489
|
* call-seq:
|
490
490
|
* FileDescriptor.new => file
|
491
491
|
*
|
492
|
-
* Returns a new file descriptor.
|
492
|
+
* Returns a new file descriptor. May
|
493
493
|
* to a builder.
|
494
494
|
*/
|
495
495
|
static VALUE FileDescriptor_initialize(VALUE _self, VALUE cookie,
|
@@ -519,28 +519,6 @@ static VALUE FileDescriptor_name(VALUE _self) {
|
|
519
519
|
return name == NULL ? Qnil : rb_str_new2(name);
|
520
520
|
}
|
521
521
|
|
522
|
-
/*
|
523
|
-
* call-seq:
|
524
|
-
* FileDescriptor.syntax => syntax
|
525
|
-
*
|
526
|
-
* Returns this file descriptors syntax.
|
527
|
-
*
|
528
|
-
* Valid syntax versions are:
|
529
|
-
* :proto2 or :proto3.
|
530
|
-
*/
|
531
|
-
static VALUE FileDescriptor_syntax(VALUE _self) {
|
532
|
-
FileDescriptor* self = ruby_to_FileDescriptor(_self);
|
533
|
-
|
534
|
-
switch (upb_FileDef_Syntax(self->filedef)) {
|
535
|
-
case kUpb_Syntax_Proto3:
|
536
|
-
return ID2SYM(rb_intern("proto3"));
|
537
|
-
case kUpb_Syntax_Proto2:
|
538
|
-
return ID2SYM(rb_intern("proto2"));
|
539
|
-
default:
|
540
|
-
return Qnil;
|
541
|
-
}
|
542
|
-
}
|
543
|
-
|
544
522
|
/*
|
545
523
|
* call-seq:
|
546
524
|
* FileDescriptor.options => options
|
@@ -564,7 +542,6 @@ static void FileDescriptor_register(VALUE module) {
|
|
564
542
|
rb_define_alloc_func(klass, FileDescriptor_alloc);
|
565
543
|
rb_define_method(klass, "initialize", FileDescriptor_initialize, 3);
|
566
544
|
rb_define_method(klass, "name", FileDescriptor_name, 0);
|
567
|
-
rb_define_method(klass, "syntax", FileDescriptor_syntax, 0);
|
568
545
|
rb_define_method(klass, "options", FileDescriptor_options, 0);
|
569
546
|
rb_gc_register_address(&cFileDescriptor);
|
570
547
|
cFileDescriptor = klass;
|
@@ -736,6 +713,28 @@ static VALUE FieldDescriptor_default(VALUE _self) {
|
|
736
713
|
return Convert_UpbToRuby(default_val, TypeInfo_get(self->fielddef), Qnil);
|
737
714
|
}
|
738
715
|
|
716
|
+
/*
|
717
|
+
* call-seq:
|
718
|
+
* FieldDescriptor.has_presence? => bool
|
719
|
+
*
|
720
|
+
* Returns whether this field tracks presence.
|
721
|
+
*/
|
722
|
+
static VALUE FieldDescriptor_has_presence(VALUE _self) {
|
723
|
+
FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
|
724
|
+
return upb_FieldDef_HasPresence(self->fielddef) ? Qtrue : Qfalse;
|
725
|
+
}
|
726
|
+
|
727
|
+
/*
|
728
|
+
* call-seq:
|
729
|
+
* FieldDescriptor.is_packed? => bool
|
730
|
+
*
|
731
|
+
* Returns whether this is a repeated field that uses packed encoding.
|
732
|
+
*/
|
733
|
+
static VALUE FieldDescriptor_is_packed(VALUE _self) {
|
734
|
+
FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
|
735
|
+
return upb_FieldDef_IsPacked(self->fielddef) ? Qtrue : Qfalse;
|
736
|
+
}
|
737
|
+
|
739
738
|
/*
|
740
739
|
* call-seq:
|
741
740
|
* FieldDescriptor.json_name => json_name
|
@@ -943,6 +942,8 @@ static void FieldDescriptor_register(VALUE module) {
|
|
943
942
|
rb_define_method(klass, "name", FieldDescriptor_name, 0);
|
944
943
|
rb_define_method(klass, "type", FieldDescriptor__type, 0);
|
945
944
|
rb_define_method(klass, "default", FieldDescriptor_default, 0);
|
945
|
+
rb_define_method(klass, "has_presence?", FieldDescriptor_has_presence, 0);
|
946
|
+
rb_define_method(klass, "is_packed?", FieldDescriptor_is_packed, 0);
|
946
947
|
rb_define_method(klass, "json_name", FieldDescriptor_json_name, 0);
|
947
948
|
rb_define_method(klass, "label", FieldDescriptor_label, 0);
|
948
949
|
rb_define_method(klass, "number", FieldDescriptor_number, 0);
|
@@ -1163,6 +1164,17 @@ static VALUE EnumDescriptor_file_descriptor(VALUE _self) {
|
|
1163
1164
|
upb_EnumDef_File(self->enumdef));
|
1164
1165
|
}
|
1165
1166
|
|
1167
|
+
/*
|
1168
|
+
* call-seq:
|
1169
|
+
* EnumDescriptor.is_closed? => bool
|
1170
|
+
*
|
1171
|
+
* Returns whether this enum is open or closed.
|
1172
|
+
*/
|
1173
|
+
static VALUE EnumDescriptor_is_closed(VALUE _self) {
|
1174
|
+
EnumDescriptor* self = ruby_to_EnumDescriptor(_self);
|
1175
|
+
return upb_EnumDef_IsClosed(self->enumdef) ? Qtrue : Qfalse;
|
1176
|
+
}
|
1177
|
+
|
1166
1178
|
/*
|
1167
1179
|
* call-seq:
|
1168
1180
|
* EnumDescriptor.name => name
|
@@ -1275,6 +1287,7 @@ static void EnumDescriptor_register(VALUE module) {
|
|
1275
1287
|
rb_define_method(klass, "each", EnumDescriptor_each, 0);
|
1276
1288
|
rb_define_method(klass, "enummodule", EnumDescriptor_enummodule, 0);
|
1277
1289
|
rb_define_method(klass, "file_descriptor", EnumDescriptor_file_descriptor, 0);
|
1290
|
+
rb_define_method(klass, "is_closed?", EnumDescriptor_is_closed, 0);
|
1278
1291
|
rb_define_method(klass, "options", EnumDescriptor_options, 0);
|
1279
1292
|
rb_include_module(klass, rb_mEnumerable);
|
1280
1293
|
rb_gc_register_address(&cEnumDescriptor);
|
@@ -22,7 +22,7 @@ $INCFLAGS += " -I$(srcdir)/third_party/utf8_range"
|
|
22
22
|
|
23
23
|
$srcs = ["protobuf.c", "convert.c", "defs.c", "message.c",
|
24
24
|
"repeated_field.c", "map.c", "ruby-upb.c", "wrap_memcpy.c",
|
25
|
-
"
|
25
|
+
"utf8_range.c", "shared_convert.c",
|
26
26
|
"shared_message.c"]
|
27
27
|
|
28
28
|
create_makefile(ext_name)
|
data/ext/google/protobuf_c/map.c
CHANGED
@@ -444,7 +444,7 @@ static VALUE Map_delete(VALUE _self, VALUE key) {
|
|
444
444
|
Convert_RubyToUpb(key, "", Map_keyinfo(self), NULL);
|
445
445
|
upb_MessageValue val_upb;
|
446
446
|
|
447
|
-
if (upb_Map_Delete(
|
447
|
+
if (upb_Map_Delete(Map_GetMutable(_self), key_upb, &val_upb)) {
|
448
448
|
return Convert_UpbToRuby(val_upb, self->value_type_info, self->arena);
|
449
449
|
} else {
|
450
450
|
return Qnil;
|
@@ -563,22 +563,13 @@ VALUE Map_eq(VALUE _self, VALUE _other) {
|
|
563
563
|
* Freezes the message object. We have to intercept this so we can pin the
|
564
564
|
* Ruby object into memory so we don't forget it's frozen.
|
565
565
|
*/
|
566
|
-
|
566
|
+
VALUE Map_freeze(VALUE _self) {
|
567
567
|
Map* self = ruby_to_Map(_self);
|
568
|
-
if (!RB_OBJ_FROZEN(_self)) {
|
569
|
-
Arena_Pin(self->arena, _self);
|
570
|
-
RB_OBJ_FREEZE(_self);
|
571
|
-
}
|
572
|
-
return _self;
|
573
|
-
}
|
574
568
|
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
VALUE Map_internal_deep_freeze(VALUE _self) {
|
580
|
-
Map* self = ruby_to_Map(_self);
|
581
|
-
Map_freeze(_self);
|
569
|
+
if (RB_OBJ_FROZEN(_self)) return _self;
|
570
|
+
Arena_Pin(self->arena, _self);
|
571
|
+
RB_OBJ_FREEZE(_self);
|
572
|
+
|
582
573
|
if (self->value_type_info.type == kUpb_CType_Message) {
|
583
574
|
size_t iter = kUpb_Map_Begin;
|
584
575
|
upb_MessageValue key, val;
|
@@ -586,7 +577,7 @@ VALUE Map_internal_deep_freeze(VALUE _self) {
|
|
586
577
|
while (upb_Map_Next(self->map, &key, &val, &iter)) {
|
587
578
|
VALUE val_val =
|
588
579
|
Convert_UpbToRuby(val, self->value_type_info, self->arena);
|
589
|
-
|
580
|
+
Message_freeze(val_val);
|
590
581
|
}
|
591
582
|
}
|
592
583
|
return _self;
|
data/ext/google/protobuf_c/map.h
CHANGED
@@ -661,11 +661,8 @@ static VALUE Message_dup(VALUE _self) {
|
|
661
661
|
Message* self = ruby_to_Message(_self);
|
662
662
|
VALUE new_msg = rb_class_new_instance(0, NULL, CLASS_OF(_self));
|
663
663
|
Message* new_msg_self = ruby_to_Message(new_msg);
|
664
|
-
|
665
|
-
|
666
|
-
// TODO
|
667
|
-
// TODO
|
668
|
-
memcpy((upb_Message*)new_msg_self->msg, self->msg, size);
|
664
|
+
const upb_MiniTable* m = upb_MessageDef_MiniTable(self->msgdef);
|
665
|
+
upb_Message_ShallowCopy((upb_Message*)new_msg_self->msg, self->msg, m);
|
669
666
|
Arena_fuse(self->arena, Arena_get(new_msg_self->arena));
|
670
667
|
return new_msg;
|
671
668
|
}
|
@@ -769,58 +766,34 @@ static VALUE Message_CreateHash(const upb_Message* msg,
|
|
769
766
|
if (!msg) return Qnil;
|
770
767
|
|
771
768
|
VALUE hash = rb_hash_new();
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
// This is unfortunate, we should key behaviors off field attributes (like
|
777
|
-
// whether a field has presence), not proto2 vs. proto3. We should see if we
|
778
|
-
// can change this without breaking users.
|
779
|
-
is_proto2 = upb_MessageDef_Syntax(m) == kUpb_Syntax_Proto2;
|
780
|
-
|
781
|
-
for (int i = 0; i < n; i++) {
|
782
|
-
const upb_FieldDef* field = upb_MessageDef_Field(m, i);
|
783
|
-
TypeInfo type_info = TypeInfo_get(field);
|
784
|
-
upb_MessageValue msgval;
|
785
|
-
VALUE msg_value;
|
786
|
-
VALUE msg_key;
|
787
|
-
|
788
|
-
if (!is_proto2 && upb_FieldDef_IsSubMessage(field) &&
|
789
|
-
!upb_FieldDef_IsRepeated(field) &&
|
790
|
-
!upb_Message_HasFieldByDef(msg, field)) {
|
791
|
-
// TODO: Legacy behavior, remove when we fix the is_proto2 differences.
|
792
|
-
msg_key = ID2SYM(rb_intern(upb_FieldDef_Name(field)));
|
793
|
-
rb_hash_aset(hash, msg_key, Qnil);
|
794
|
-
continue;
|
795
|
-
}
|
769
|
+
size_t iter = kUpb_Message_Begin;
|
770
|
+
const upb_DefPool* pool = upb_FileDef_Pool(upb_MessageDef_File(m));
|
771
|
+
const upb_FieldDef* field;
|
772
|
+
upb_MessageValue val;
|
796
773
|
|
797
|
-
|
798
|
-
if (
|
799
|
-
|
774
|
+
while (upb_Message_Next(msg, m, pool, &field, &val, &iter)) {
|
775
|
+
if (upb_FieldDef_IsExtension(field)) {
|
776
|
+
// TODO: allow extensions once we have decided what naming scheme the
|
777
|
+
// symbol should use. eg. :"[pkg.ext]"
|
800
778
|
continue;
|
801
779
|
}
|
802
780
|
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
// Proto2 omits empty map/repeated filds also.
|
781
|
+
TypeInfo type_info = TypeInfo_get(field);
|
782
|
+
VALUE msg_value;
|
807
783
|
|
808
784
|
if (upb_FieldDef_IsMap(field)) {
|
809
785
|
const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(field);
|
810
786
|
const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry_m, 1);
|
811
787
|
const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry_m, 2);
|
812
788
|
upb_CType key_type = upb_FieldDef_CType(key_f);
|
813
|
-
msg_value = Map_CreateHash(
|
789
|
+
msg_value = Map_CreateHash(val.map_val, key_type, TypeInfo_get(val_f));
|
814
790
|
} else if (upb_FieldDef_IsRepeated(field)) {
|
815
|
-
|
816
|
-
(!msgval.array_val || upb_Array_Size(msgval.array_val) == 0)) {
|
817
|
-
continue;
|
818
|
-
}
|
819
|
-
msg_value = RepeatedField_CreateArray(msgval.array_val, type_info);
|
791
|
+
msg_value = RepeatedField_CreateArray(val.array_val, type_info);
|
820
792
|
} else {
|
821
|
-
msg_value = Scalar_CreateHash(
|
793
|
+
msg_value = Scalar_CreateHash(val, type_info);
|
822
794
|
}
|
823
795
|
|
796
|
+
VALUE msg_key = ID2SYM(rb_intern(upb_FieldDef_Name(field)));
|
824
797
|
rb_hash_aset(hash, msg_key, msg_value);
|
825
798
|
}
|
826
799
|
|
@@ -853,22 +826,12 @@ static VALUE Message_to_h(VALUE _self) {
|
|
853
826
|
* Freezes the message object. We have to intercept this so we can pin the
|
854
827
|
* Ruby object into memory so we don't forget it's frozen.
|
855
828
|
*/
|
856
|
-
|
829
|
+
VALUE Message_freeze(VALUE _self) {
|
857
830
|
Message* self = ruby_to_Message(_self);
|
858
|
-
if (!RB_OBJ_FROZEN(_self)) {
|
859
|
-
Arena_Pin(self->arena, _self);
|
860
|
-
RB_OBJ_FREEZE(_self);
|
861
|
-
}
|
862
|
-
return _self;
|
863
|
-
}
|
864
831
|
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
*/
|
869
|
-
VALUE Message_internal_deep_freeze(VALUE _self) {
|
870
|
-
Message* self = ruby_to_Message(_self);
|
871
|
-
Message_freeze(_self);
|
832
|
+
if (RB_OBJ_FROZEN(_self)) return _self;
|
833
|
+
Arena_Pin(self->arena, _self);
|
834
|
+
RB_OBJ_FREEZE(_self);
|
872
835
|
|
873
836
|
int n = upb_MessageDef_FieldCount(self->msgdef);
|
874
837
|
for (int i = 0; i < n; i++) {
|
@@ -877,11 +840,11 @@ VALUE Message_internal_deep_freeze(VALUE _self) {
|
|
877
840
|
|
878
841
|
if (field != Qnil) {
|
879
842
|
if (upb_FieldDef_IsMap(f)) {
|
880
|
-
|
843
|
+
Map_freeze(field);
|
881
844
|
} else if (upb_FieldDef_IsRepeated(f)) {
|
882
|
-
|
845
|
+
RepeatedField_freeze(field);
|
883
846
|
} else if (upb_FieldDef_IsSubMessage(f)) {
|
884
|
-
|
847
|
+
Message_freeze(field);
|
885
848
|
}
|
886
849
|
}
|
887
850
|
}
|
@@ -990,7 +953,7 @@ VALUE Message_decode_bytes(int size, const char* bytes, int options,
|
|
990
953
|
rb_raise(cParseError, "Error occurred during parsing");
|
991
954
|
}
|
992
955
|
if (freeze) {
|
993
|
-
|
956
|
+
Message_freeze(msg_rb);
|
994
957
|
}
|
995
958
|
return msg_rb;
|
996
959
|
}
|
@@ -1012,9 +975,6 @@ static VALUE Message_decode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1012
975
|
int options = 0;
|
1013
976
|
upb_Status status;
|
1014
977
|
|
1015
|
-
// TODO: use this message's pool instead.
|
1016
|
-
const upb_DefPool* symtab = DescriptorPool_GetSymtab(generated_pool);
|
1017
|
-
|
1018
978
|
if (argc < 1 || argc > 2) {
|
1019
979
|
rb_raise(rb_eArgError, "Expected 1 or 2 arguments.");
|
1020
980
|
}
|
@@ -1048,8 +1008,9 @@ static VALUE Message_decode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1048
1008
|
}
|
1049
1009
|
|
1050
1010
|
upb_Status_Clear(&status);
|
1011
|
+
const upb_DefPool* pool = upb_FileDef_Pool(upb_MessageDef_File(msg->msgdef));
|
1051
1012
|
if (!upb_JsonDecode(RSTRING_PTR(data), RSTRING_LEN(data),
|
1052
|
-
(upb_Message*)msg->msg, msg->msgdef,
|
1013
|
+
(upb_Message*)msg->msg, msg->msgdef, pool, options,
|
1053
1014
|
Arena_get(msg->arena), &status)) {
|
1054
1015
|
rb_raise(cParseError, "Error occurred during parsing: %s",
|
1055
1016
|
upb_Status_ErrorMessage(&status));
|
@@ -1128,9 +1089,6 @@ static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1128
1089
|
size_t size;
|
1129
1090
|
upb_Status status;
|
1130
1091
|
|
1131
|
-
// TODO: use this message's pool instead.
|
1132
|
-
const upb_DefPool* symtab = DescriptorPool_GetSymtab(generated_pool);
|
1133
|
-
|
1134
1092
|
if (argc < 1 || argc > 2) {
|
1135
1093
|
rb_raise(rb_eArgError, "Expected 1 or 2 arguments.");
|
1136
1094
|
}
|
@@ -1165,8 +1123,9 @@ static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1165
1123
|
}
|
1166
1124
|
|
1167
1125
|
upb_Status_Clear(&status);
|
1168
|
-
|
1169
|
-
|
1126
|
+
const upb_DefPool* pool = upb_FileDef_Pool(upb_MessageDef_File(msg->msgdef));
|
1127
|
+
size = upb_JsonEncode(msg->msg, msg->msgdef, pool, options, buf, sizeof(buf),
|
1128
|
+
&status);
|
1170
1129
|
|
1171
1130
|
if (!upb_Status_IsOk(&status)) {
|
1172
1131
|
rb_raise(cParseError, "Error occurred during encoding: %s",
|
@@ -1176,7 +1135,7 @@ static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1176
1135
|
VALUE ret;
|
1177
1136
|
if (size >= sizeof(buf)) {
|
1178
1137
|
char* buf2 = malloc(size + 1);
|
1179
|
-
upb_JsonEncode(msg->msg, msg->msgdef,
|
1138
|
+
upb_JsonEncode(msg->msg, msg->msgdef, pool, options, buf2, size + 1,
|
1180
1139
|
&status);
|
1181
1140
|
ret = rb_str_new(buf2, size);
|
1182
1141
|
free(buf2);
|
@@ -78,7 +78,7 @@ VALUE Message_decode_bytes(int size, const char* bytes, int options,
|
|
78
78
|
VALUE klass, bool freeze);
|
79
79
|
|
80
80
|
// Recursively freeze message
|
81
|
-
VALUE
|
81
|
+
VALUE Message_freeze(VALUE _self);
|
82
82
|
|
83
83
|
// Call at startup to register all types in this module.
|
84
84
|
void Message_register(VALUE protobuf);
|
@@ -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_
|