google-protobuf 3.25.2-java → 4.26.0.rc.2-java
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/message.c +38 -76
- data/ext/google/protobuf_c/message.h +1 -1
- data/ext/google/protobuf_c/ruby-upb.c +11791 -10801
- data/ext/google/protobuf_c/ruby-upb.h +5163 -4241
- data/ext/google/protobuf_c/shared_convert.c +5 -3
- data/ext/google/protobuf_c/shared_convert.h +2 -2
- data/ext/google/protobuf_c/shared_message.c +8 -6
- 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 +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 +3 -1
- 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_java.jar +0 -0
- data/lib/google/protobuf_native.rb +0 -1
- data/lib/google/tasks/ffi.rake +1 -3
- metadata +9 -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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 643cc294f605823202975825fd740709203bf665d796b70bcb0df800e7af3b36
|
4
|
+
data.tar.gz: e6b8c91d862b508a01ad77151ff5ae3baccde869a1bcf571010b7328b25ea764
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56f0dff037836b4aee54f182042f2b3d7506d2c9418c7b696612b2b62fe7d59c499d40f8770cb1f9a0cf0a078fcc437511f6aa9ce5c25eef486179b0542c2615
|
7
|
+
data.tar.gz: 45f4029093236e85d2d97e2896fec27fb9092803d876f1f72eb90cf1e12bae297f5985b51873d85b4226557754e079d1368149d48186905a270159e815ae02ad
|
@@ -488,7 +488,8 @@ static int Map_initialize_kwarg(VALUE key, VALUE val, VALUE _self) {
|
|
488
488
|
k = Convert_RubyToUpb(key, "", map_init->key_type, NULL);
|
489
489
|
|
490
490
|
if (map_init->val_type.type == kUpb_CType_Message && TYPE(val) == T_HASH) {
|
491
|
-
upb_MiniTable* t =
|
491
|
+
const upb_MiniTable* t =
|
492
|
+
upb_MessageDef_MiniTable(map_init->val_type.def.msgdef);
|
492
493
|
upb_Message* msg = upb_Message_New(t, map_init->arena);
|
493
494
|
Message_InitFromValue(msg, map_init->val_type.def.msgdef, val,
|
494
495
|
map_init->arena);
|
@@ -519,7 +520,7 @@ static upb_MessageValue MessageValue_FromValue(VALUE val, TypeInfo info,
|
|
519
520
|
upb_Arena* arena) {
|
520
521
|
if (info.type == kUpb_CType_Message) {
|
521
522
|
upb_MessageValue msgval;
|
522
|
-
upb_MiniTable* t = upb_MessageDef_MiniTable(info.def.msgdef);
|
523
|
+
const upb_MiniTable* t = upb_MessageDef_MiniTable(info.def.msgdef);
|
523
524
|
upb_Message* msg = upb_Message_New(t, arena);
|
524
525
|
Message_InitFromValue(msg, info.def.msgdef, val, arena);
|
525
526
|
msgval.msg_val = msg;
|
@@ -635,7 +636,7 @@ static VALUE Message_initialize(int argc, VALUE* argv, VALUE _self) {
|
|
635
636
|
Message* self = ruby_to_Message(_self);
|
636
637
|
VALUE arena_rb = Arena_new();
|
637
638
|
upb_Arena* arena = Arena_get(arena_rb);
|
638
|
-
upb_MiniTable* t = upb_MessageDef_MiniTable(self->msgdef);
|
639
|
+
const upb_MiniTable* t = upb_MessageDef_MiniTable(self->msgdef);
|
639
640
|
upb_Message* msg = upb_Message_New(t, arena);
|
640
641
|
|
641
642
|
Message_InitPtr(_self, msg, arena_rb);
|
@@ -660,11 +661,8 @@ static VALUE Message_dup(VALUE _self) {
|
|
660
661
|
Message* self = ruby_to_Message(_self);
|
661
662
|
VALUE new_msg = rb_class_new_instance(0, NULL, CLASS_OF(_self));
|
662
663
|
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);
|
664
|
+
const upb_MiniTable* m = upb_MessageDef_MiniTable(self->msgdef);
|
665
|
+
upb_Message_ShallowCopy((upb_Message*)new_msg_self->msg, self->msg, m);
|
668
666
|
Arena_fuse(self->arena, Arena_get(new_msg_self->arena));
|
669
667
|
return new_msg;
|
670
668
|
}
|
@@ -678,7 +676,8 @@ bool Message_Equal(const upb_Message* m1, const upb_Message* m2,
|
|
678
676
|
if (upb_Status_IsOk(&status)) {
|
679
677
|
return return_value;
|
680
678
|
} else {
|
681
|
-
rb_raise(cParseError,
|
679
|
+
rb_raise(cParseError, "Message_Equal(): %s",
|
680
|
+
upb_Status_ErrorMessage(&status));
|
682
681
|
}
|
683
682
|
}
|
684
683
|
|
@@ -709,7 +708,8 @@ uint64_t Message_Hash(const upb_Message* msg, const upb_MessageDef* m,
|
|
709
708
|
if (upb_Status_IsOk(&status)) {
|
710
709
|
return return_value;
|
711
710
|
} else {
|
712
|
-
rb_raise(cParseError,
|
711
|
+
rb_raise(cParseError, "Message_Hash(): %s",
|
712
|
+
upb_Status_ErrorMessage(&status));
|
713
713
|
}
|
714
714
|
}
|
715
715
|
|
@@ -766,58 +766,34 @@ static VALUE Message_CreateHash(const upb_Message* msg,
|
|
766
766
|
if (!msg) return Qnil;
|
767
767
|
|
768
768
|
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
|
-
}
|
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;
|
793
773
|
|
794
|
-
|
795
|
-
if (
|
796
|
-
|
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]"
|
797
778
|
continue;
|
798
779
|
}
|
799
780
|
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
// Proto2 omits empty map/repeated filds also.
|
781
|
+
TypeInfo type_info = TypeInfo_get(field);
|
782
|
+
VALUE msg_value;
|
804
783
|
|
805
784
|
if (upb_FieldDef_IsMap(field)) {
|
806
785
|
const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(field);
|
807
786
|
const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry_m, 1);
|
808
787
|
const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry_m, 2);
|
809
788
|
upb_CType key_type = upb_FieldDef_CType(key_f);
|
810
|
-
msg_value = Map_CreateHash(
|
789
|
+
msg_value = Map_CreateHash(val.map_val, key_type, TypeInfo_get(val_f));
|
811
790
|
} 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);
|
791
|
+
msg_value = RepeatedField_CreateArray(val.array_val, type_info);
|
817
792
|
} else {
|
818
|
-
msg_value = Scalar_CreateHash(
|
793
|
+
msg_value = Scalar_CreateHash(val, type_info);
|
819
794
|
}
|
820
795
|
|
796
|
+
VALUE msg_key = ID2SYM(rb_intern(upb_FieldDef_Name(field)));
|
821
797
|
rb_hash_aset(hash, msg_key, msg_value);
|
822
798
|
}
|
823
799
|
|
@@ -850,22 +826,12 @@ static VALUE Message_to_h(VALUE _self) {
|
|
850
826
|
* Freezes the message object. We have to intercept this so we can pin the
|
851
827
|
* Ruby object into memory so we don't forget it's frozen.
|
852
828
|
*/
|
853
|
-
|
829
|
+
VALUE Message_freeze(VALUE _self) {
|
854
830
|
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
831
|
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
*/
|
866
|
-
VALUE Message_internal_deep_freeze(VALUE _self) {
|
867
|
-
Message* self = ruby_to_Message(_self);
|
868
|
-
Message_freeze(_self);
|
832
|
+
if (RB_OBJ_FROZEN(_self)) return _self;
|
833
|
+
Arena_Pin(self->arena, _self);
|
834
|
+
RB_OBJ_FREEZE(_self);
|
869
835
|
|
870
836
|
int n = upb_MessageDef_FieldCount(self->msgdef);
|
871
837
|
for (int i = 0; i < n; i++) {
|
@@ -874,11 +840,11 @@ VALUE Message_internal_deep_freeze(VALUE _self) {
|
|
874
840
|
|
875
841
|
if (field != Qnil) {
|
876
842
|
if (upb_FieldDef_IsMap(f)) {
|
877
|
-
|
843
|
+
Map_freeze(field);
|
878
844
|
} else if (upb_FieldDef_IsRepeated(f)) {
|
879
|
-
|
845
|
+
RepeatedField_freeze(field);
|
880
846
|
} else if (upb_FieldDef_IsSubMessage(f)) {
|
881
|
-
|
847
|
+
Message_freeze(field);
|
882
848
|
}
|
883
849
|
}
|
884
850
|
}
|
@@ -987,7 +953,7 @@ VALUE Message_decode_bytes(int size, const char* bytes, int options,
|
|
987
953
|
rb_raise(cParseError, "Error occurred during parsing");
|
988
954
|
}
|
989
955
|
if (freeze) {
|
990
|
-
|
956
|
+
Message_freeze(msg_rb);
|
991
957
|
}
|
992
958
|
return msg_rb;
|
993
959
|
}
|
@@ -1009,9 +975,6 @@ static VALUE Message_decode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1009
975
|
int options = 0;
|
1010
976
|
upb_Status status;
|
1011
977
|
|
1012
|
-
// TODO: use this message's pool instead.
|
1013
|
-
const upb_DefPool* symtab = DescriptorPool_GetSymtab(generated_pool);
|
1014
|
-
|
1015
978
|
if (argc < 1 || argc > 2) {
|
1016
979
|
rb_raise(rb_eArgError, "Expected 1 or 2 arguments.");
|
1017
980
|
}
|
@@ -1045,8 +1008,9 @@ static VALUE Message_decode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1045
1008
|
}
|
1046
1009
|
|
1047
1010
|
upb_Status_Clear(&status);
|
1011
|
+
const upb_DefPool* pool = upb_FileDef_Pool(upb_MessageDef_File(msg->msgdef));
|
1048
1012
|
if (!upb_JsonDecode(RSTRING_PTR(data), RSTRING_LEN(data),
|
1049
|
-
(upb_Message*)msg->msg, msg->msgdef,
|
1013
|
+
(upb_Message*)msg->msg, msg->msgdef, pool, options,
|
1050
1014
|
Arena_get(msg->arena), &status)) {
|
1051
1015
|
rb_raise(cParseError, "Error occurred during parsing: %s",
|
1052
1016
|
upb_Status_ErrorMessage(&status));
|
@@ -1125,9 +1089,6 @@ static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1125
1089
|
size_t size;
|
1126
1090
|
upb_Status status;
|
1127
1091
|
|
1128
|
-
// TODO: use this message's pool instead.
|
1129
|
-
const upb_DefPool* symtab = DescriptorPool_GetSymtab(generated_pool);
|
1130
|
-
|
1131
1092
|
if (argc < 1 || argc > 2) {
|
1132
1093
|
rb_raise(rb_eArgError, "Expected 1 or 2 arguments.");
|
1133
1094
|
}
|
@@ -1162,8 +1123,9 @@ static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1162
1123
|
}
|
1163
1124
|
|
1164
1125
|
upb_Status_Clear(&status);
|
1165
|
-
|
1166
|
-
|
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);
|
1167
1129
|
|
1168
1130
|
if (!upb_Status_IsOk(&status)) {
|
1169
1131
|
rb_raise(cParseError, "Error occurred during encoding: %s",
|
@@ -1173,7 +1135,7 @@ static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
|
|
1173
1135
|
VALUE ret;
|
1174
1136
|
if (size >= sizeof(buf)) {
|
1175
1137
|
char* buf2 = malloc(size + 1);
|
1176
|
-
upb_JsonEncode(msg->msg, msg->msgdef,
|
1138
|
+
upb_JsonEncode(msg->msg, msg->msgdef, pool, options, buf2, size + 1,
|
1177
1139
|
&status);
|
1178
1140
|
ret = rb_str_new(buf2, size);
|
1179
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);
|