google-protobuf 3.21.6 → 3.23.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 +0 -0
- data/ext/google/protobuf_c/convert.h +0 -0
- data/ext/google/protobuf_c/defs.c +25 -15
- data/ext/google/protobuf_c/defs.h +0 -0
- data/ext/google/protobuf_c/extconf.rb +2 -3
- data/ext/google/protobuf_c/map.c +27 -42
- data/ext/google/protobuf_c/map.h +0 -0
- data/ext/google/protobuf_c/message.c +137 -105
- data/ext/google/protobuf_c/message.h +0 -0
- data/ext/google/protobuf_c/protobuf.c +4 -2
- data/ext/google/protobuf_c/protobuf.h +0 -0
- data/ext/google/protobuf_c/repeated_field.c +0 -0
- data/ext/google/protobuf_c/repeated_field.h +0 -0
- data/ext/google/protobuf_c/ruby-upb.c +11669 -8810
- data/ext/google/protobuf_c/ruby-upb.h +9057 -2889
- data/ext/google/protobuf_c/third_party/utf8_range/LICENSE +1 -0
- data/ext/google/protobuf_c/third_party/utf8_range/naive.c +0 -0
- data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +1 -1
- data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +0 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +13 -1
- data/ext/google/protobuf_c/wrap_memcpy.c +0 -0
- data/lib/google/protobuf/any_pb.rb +24 -5
- data/lib/google/protobuf/api_pb.rb +26 -23
- data/lib/google/protobuf/descriptor_dsl.rb +0 -0
- data/lib/google/protobuf/descriptor_pb.rb +32 -226
- data/lib/google/protobuf/duration_pb.rb +24 -5
- data/lib/google/protobuf/empty_pb.rb +24 -3
- data/lib/google/protobuf/field_mask_pb.rb +24 -4
- data/lib/google/protobuf/message_exts.rb +5 -0
- data/lib/google/protobuf/plugin_pb.rb +47 -0
- data/lib/google/protobuf/repeated_field.rb +0 -0
- data/lib/google/protobuf/source_context_pb.rb +24 -4
- data/lib/google/protobuf/struct_pb.rb +24 -20
- data/lib/google/protobuf/timestamp_pb.rb +24 -5
- data/lib/google/protobuf/type_pb.rb +26 -68
- data/lib/google/protobuf/wrappers_pb.rb +24 -28
- data/lib/google/protobuf.rb +0 -0
- metadata +6 -11
- data/tests/basic.rb +0 -739
- data/tests/generated_code_test.rb +0 -23
- data/tests/stress.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0f2dc4694cbfd349bc8459fbf1ad8cfcbfc4cecdeb23f3190062ed1c808f69b
|
4
|
+
data.tar.gz: 6cbb860ef5c0dd26adf0eba272e77dd431761786082cf80842ed8743fe4b9e68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c14897c5b77fba81af662c3384eafff9a73dd360c64c724baa6152a4aa40294f35d84655ce433b301deafed9b9c88b4babec2539f3c56b6b689be6697e19f59
|
7
|
+
data.tar.gz: 7cc9300a84e382b0ed8fd2e458daff9d23adbf35307545162b77d836a3fb710a8e90914f3361266d89b9cdbdfb29a6309846a284fe5774530d4cef23554c36e9
|
File without changes
|
File without changes
|
@@ -223,6 +223,8 @@ static void DescriptorPool_register(VALUE module) {
|
|
223
223
|
|
224
224
|
typedef struct {
|
225
225
|
const upb_MessageDef* msgdef;
|
226
|
+
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
|
227
|
+
// macro to update VALUE references, as to trigger write barriers.
|
226
228
|
VALUE klass;
|
227
229
|
VALUE descriptor_pool;
|
228
230
|
} Descriptor;
|
@@ -238,7 +240,7 @@ static void Descriptor_mark(void* _self) {
|
|
238
240
|
static const rb_data_type_t Descriptor_type = {
|
239
241
|
"Google::Protobuf::Descriptor",
|
240
242
|
{Descriptor_mark, RUBY_DEFAULT_FREE, NULL},
|
241
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
243
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
242
244
|
};
|
243
245
|
|
244
246
|
static Descriptor* ruby_to_Descriptor(VALUE val) {
|
@@ -280,7 +282,7 @@ static VALUE Descriptor_initialize(VALUE _self, VALUE cookie,
|
|
280
282
|
"Descriptor objects may not be created from Ruby.");
|
281
283
|
}
|
282
284
|
|
283
|
-
self->descriptor_pool
|
285
|
+
RB_OBJ_WRITE(_self, &self->descriptor_pool, descriptor_pool);
|
284
286
|
self->msgdef = (const upb_MessageDef*)NUM2ULL(ptr);
|
285
287
|
|
286
288
|
return Qnil;
|
@@ -390,7 +392,7 @@ static VALUE Descriptor_lookup_oneof(VALUE _self, VALUE name) {
|
|
390
392
|
static VALUE Descriptor_msgclass(VALUE _self) {
|
391
393
|
Descriptor* self = ruby_to_Descriptor(_self);
|
392
394
|
if (self->klass == Qnil) {
|
393
|
-
self->klass
|
395
|
+
RB_OBJ_WRITE(_self, &self->klass, build_class_from_descriptor(_self));
|
394
396
|
}
|
395
397
|
return self->klass;
|
396
398
|
}
|
@@ -417,6 +419,8 @@ static void Descriptor_register(VALUE module) {
|
|
417
419
|
|
418
420
|
typedef struct {
|
419
421
|
const upb_FileDef* filedef;
|
422
|
+
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
|
423
|
+
// macro to update VALUE references, as to trigger write barriers.
|
420
424
|
VALUE descriptor_pool; // Owns the upb_FileDef.
|
421
425
|
} FileDescriptor;
|
422
426
|
|
@@ -430,7 +434,7 @@ static void FileDescriptor_mark(void* _self) {
|
|
430
434
|
static const rb_data_type_t FileDescriptor_type = {
|
431
435
|
"Google::Protobuf::FileDescriptor",
|
432
436
|
{FileDescriptor_mark, RUBY_DEFAULT_FREE, NULL},
|
433
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
437
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
434
438
|
};
|
435
439
|
|
436
440
|
static FileDescriptor* ruby_to_FileDescriptor(VALUE val) {
|
@@ -463,7 +467,7 @@ static VALUE FileDescriptor_initialize(VALUE _self, VALUE cookie,
|
|
463
467
|
"Descriptor objects may not be created from Ruby.");
|
464
468
|
}
|
465
469
|
|
466
|
-
self->descriptor_pool
|
470
|
+
RB_OBJ_WRITE(_self, &self->descriptor_pool, descriptor_pool);
|
467
471
|
self->filedef = (const upb_FileDef*)NUM2ULL(ptr);
|
468
472
|
|
469
473
|
return Qnil;
|
@@ -519,6 +523,8 @@ static void FileDescriptor_register(VALUE module) {
|
|
519
523
|
|
520
524
|
typedef struct {
|
521
525
|
const upb_FieldDef* fielddef;
|
526
|
+
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
|
527
|
+
// macro to update VALUE references, as to trigger write barriers.
|
522
528
|
VALUE descriptor_pool; // Owns the upb_FieldDef.
|
523
529
|
} FieldDescriptor;
|
524
530
|
|
@@ -532,7 +538,7 @@ static void FieldDescriptor_mark(void* _self) {
|
|
532
538
|
static const rb_data_type_t FieldDescriptor_type = {
|
533
539
|
"Google::Protobuf::FieldDescriptor",
|
534
540
|
{FieldDescriptor_mark, RUBY_DEFAULT_FREE, NULL},
|
535
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
541
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
536
542
|
};
|
537
543
|
|
538
544
|
static FieldDescriptor* ruby_to_FieldDescriptor(VALUE val) {
|
@@ -570,7 +576,7 @@ static VALUE FieldDescriptor_initialize(VALUE _self, VALUE cookie,
|
|
570
576
|
"Descriptor objects may not be created from Ruby.");
|
571
577
|
}
|
572
578
|
|
573
|
-
self->descriptor_pool
|
579
|
+
RB_OBJ_WRITE(_self, &self->descriptor_pool, descriptor_pool);
|
574
580
|
self->fielddef = (const upb_FieldDef*)NUM2ULL(ptr);
|
575
581
|
|
576
582
|
return Qnil;
|
@@ -811,7 +817,7 @@ static VALUE FieldDescriptor_has(VALUE _self, VALUE msg_rb) {
|
|
811
817
|
rb_raise(rb_eArgError, "does not track presence");
|
812
818
|
}
|
813
819
|
|
814
|
-
return
|
820
|
+
return upb_Message_HasFieldByDef(msg, self->fielddef) ? Qtrue : Qfalse;
|
815
821
|
}
|
816
822
|
|
817
823
|
/*
|
@@ -829,7 +835,7 @@ static VALUE FieldDescriptor_clear(VALUE _self, VALUE msg_rb) {
|
|
829
835
|
rb_raise(cTypeError, "has method called on wrong message type");
|
830
836
|
}
|
831
837
|
|
832
|
-
|
838
|
+
upb_Message_ClearFieldByDef(msg, self->fielddef);
|
833
839
|
return Qnil;
|
834
840
|
}
|
835
841
|
|
@@ -854,7 +860,7 @@ static VALUE FieldDescriptor_set(VALUE _self, VALUE msg_rb, VALUE value) {
|
|
854
860
|
|
855
861
|
msgval = Convert_RubyToUpb(value, upb_FieldDef_Name(self->fielddef),
|
856
862
|
TypeInfo_get(self->fielddef), arena);
|
857
|
-
|
863
|
+
upb_Message_SetFieldByDef(msg, self->fielddef, msgval, arena);
|
858
864
|
return Qnil;
|
859
865
|
}
|
860
866
|
|
@@ -884,6 +890,8 @@ static void FieldDescriptor_register(VALUE module) {
|
|
884
890
|
|
885
891
|
typedef struct {
|
886
892
|
const upb_OneofDef* oneofdef;
|
893
|
+
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
|
894
|
+
// macro to update VALUE references, as to trigger write barriers.
|
887
895
|
VALUE descriptor_pool; // Owns the upb_OneofDef.
|
888
896
|
} OneofDescriptor;
|
889
897
|
|
@@ -897,7 +905,7 @@ static void OneofDescriptor_mark(void* _self) {
|
|
897
905
|
static const rb_data_type_t OneofDescriptor_type = {
|
898
906
|
"Google::Protobuf::OneofDescriptor",
|
899
907
|
{OneofDescriptor_mark, RUBY_DEFAULT_FREE, NULL},
|
900
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
908
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
901
909
|
};
|
902
910
|
|
903
911
|
static OneofDescriptor* ruby_to_OneofDescriptor(VALUE val) {
|
@@ -936,7 +944,7 @@ static VALUE OneofDescriptor_initialize(VALUE _self, VALUE cookie,
|
|
936
944
|
"Descriptor objects may not be created from Ruby.");
|
937
945
|
}
|
938
946
|
|
939
|
-
self->descriptor_pool
|
947
|
+
RB_OBJ_WRITE(_self, &self->descriptor_pool, descriptor_pool);
|
940
948
|
self->oneofdef = (const upb_OneofDef*)NUM2ULL(ptr);
|
941
949
|
|
942
950
|
return Qnil;
|
@@ -988,6 +996,8 @@ static void OneofDescriptor_register(VALUE module) {
|
|
988
996
|
|
989
997
|
typedef struct {
|
990
998
|
const upb_EnumDef* enumdef;
|
999
|
+
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
|
1000
|
+
// macro to update VALUE references, as to trigger write barriers.
|
991
1001
|
VALUE module; // begins as nil
|
992
1002
|
VALUE descriptor_pool; // Owns the upb_EnumDef.
|
993
1003
|
} EnumDescriptor;
|
@@ -1003,7 +1013,7 @@ static void EnumDescriptor_mark(void* _self) {
|
|
1003
1013
|
static const rb_data_type_t EnumDescriptor_type = {
|
1004
1014
|
"Google::Protobuf::EnumDescriptor",
|
1005
1015
|
{EnumDescriptor_mark, RUBY_DEFAULT_FREE, NULL},
|
1006
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
1016
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
1007
1017
|
};
|
1008
1018
|
|
1009
1019
|
static EnumDescriptor* ruby_to_EnumDescriptor(VALUE val) {
|
@@ -1042,7 +1052,7 @@ static VALUE EnumDescriptor_initialize(VALUE _self, VALUE cookie,
|
|
1042
1052
|
"Descriptor objects may not be created from Ruby.");
|
1043
1053
|
}
|
1044
1054
|
|
1045
|
-
self->descriptor_pool
|
1055
|
+
RB_OBJ_WRITE(_self, &self->descriptor_pool, descriptor_pool);
|
1046
1056
|
self->enumdef = (const upb_EnumDef*)NUM2ULL(ptr);
|
1047
1057
|
|
1048
1058
|
return Qnil;
|
@@ -1138,7 +1148,7 @@ static VALUE EnumDescriptor_each(VALUE _self) {
|
|
1138
1148
|
static VALUE EnumDescriptor_enummodule(VALUE _self) {
|
1139
1149
|
EnumDescriptor* self = ruby_to_EnumDescriptor(_self);
|
1140
1150
|
if (self->module == Qnil) {
|
1141
|
-
self->module
|
1151
|
+
RB_OBJ_WRITE(_self, &self->module, build_module_from_enumdesc(_self));
|
1142
1152
|
}
|
1143
1153
|
return self->module;
|
1144
1154
|
}
|
File without changes
|
@@ -6,20 +6,19 @@ ext_name = "google/protobuf_c"
|
|
6
6
|
|
7
7
|
dir_config(ext_name)
|
8
8
|
|
9
|
-
if RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/
|
9
|
+
if RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/ || RUBY_PLATFORM =~ /freebsd/
|
10
10
|
$CFLAGS += " -std=gnu99 -O3 -DNDEBUG -fvisibility=hidden -Wall -Wsign-compare -Wno-declaration-after-statement"
|
11
11
|
else
|
12
12
|
$CFLAGS += " -std=gnu99 -O3 -DNDEBUG"
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
15
|
if RUBY_PLATFORM =~ /linux/
|
17
16
|
# Instruct the linker to point memcpy calls at our __wrap_memcpy wrapper.
|
18
17
|
$LDFLAGS += " -Wl,-wrap,memcpy"
|
19
18
|
end
|
20
19
|
|
21
20
|
$VPATH << "$(srcdir)/third_party/utf8_range"
|
22
|
-
$INCFLAGS
|
21
|
+
$INCFLAGS += " -I$(srcdir)/third_party/utf8_range"
|
23
22
|
|
24
23
|
$srcs = ["protobuf.c", "convert.c", "defs.c", "message.c",
|
25
24
|
"repeated_field.c", "map.c", "ruby-upb.c", "wrap_memcpy.c",
|
data/ext/google/protobuf_c/map.c
CHANGED
@@ -133,14 +133,13 @@ static upb_Map* Map_GetMutable(VALUE _self) {
|
|
133
133
|
VALUE Map_CreateHash(const upb_Map* map, upb_CType key_type,
|
134
134
|
TypeInfo val_info) {
|
135
135
|
VALUE hash = rb_hash_new();
|
136
|
-
size_t iter = kUpb_Map_Begin;
|
137
136
|
TypeInfo key_info = TypeInfo_from_type(key_type);
|
138
137
|
|
139
138
|
if (!map) return hash;
|
140
139
|
|
141
|
-
|
142
|
-
|
143
|
-
|
140
|
+
size_t iter = kUpb_Map_Begin;
|
141
|
+
upb_MessageValue key, val;
|
142
|
+
while (upb_Map_Next(map, &key, &val, &iter)) {
|
144
143
|
VALUE key_val = Convert_UpbToRuby(key, key_info, Qnil);
|
145
144
|
VALUE val_val = Scalar_CreateHash(val, val_info);
|
146
145
|
rb_hash_aset(hash, key_val, val_val);
|
@@ -156,9 +155,8 @@ VALUE Map_deep_copy(VALUE obj) {
|
|
156
155
|
upb_Map* new_map =
|
157
156
|
upb_Map_New(arena, self->key_type, self->value_type_info.type);
|
158
157
|
size_t iter = kUpb_Map_Begin;
|
159
|
-
|
160
|
-
|
161
|
-
upb_MessageValue val = upb_MapIterator_Value(self->map, iter);
|
158
|
+
upb_MessageValue key, val;
|
159
|
+
while (upb_Map_Next(self->map, &key, &val, &iter)) {
|
162
160
|
upb_MessageValue val_copy =
|
163
161
|
Msgval_DeepCopy(val, self->value_type_info, arena);
|
164
162
|
upb_Map_Set(new_map, key, val_copy, arena);
|
@@ -202,9 +200,8 @@ void Map_Inspect(StringBuilder* b, const upb_Map* map, upb_CType key_type,
|
|
202
200
|
StringBuilder_Printf(b, "{");
|
203
201
|
if (map) {
|
204
202
|
size_t iter = kUpb_Map_Begin;
|
205
|
-
|
206
|
-
|
207
|
-
upb_MessageValue val = upb_MapIterator_Value(map, iter);
|
203
|
+
upb_MessageValue key, val;
|
204
|
+
while (upb_Map_Next(map, &key, &val, &iter)) {
|
208
205
|
if (first) {
|
209
206
|
first = false;
|
210
207
|
} else {
|
@@ -239,7 +236,6 @@ static VALUE Map_merge_into_self(VALUE _self, VALUE hashmap) {
|
|
239
236
|
Map* other = ruby_to_Map(hashmap);
|
240
237
|
upb_Arena* arena = Arena_get(self->arena);
|
241
238
|
upb_Message* self_msg = Map_GetMutable(_self);
|
242
|
-
size_t iter = kUpb_Map_Begin;
|
243
239
|
|
244
240
|
Arena_fuse(other->arena, arena);
|
245
241
|
|
@@ -249,9 +245,9 @@ static VALUE Map_merge_into_self(VALUE _self, VALUE hashmap) {
|
|
249
245
|
rb_raise(rb_eArgError, "Attempt to merge Map with mismatching types");
|
250
246
|
}
|
251
247
|
|
252
|
-
|
253
|
-
|
254
|
-
|
248
|
+
size_t iter = kUpb_Map_Begin;
|
249
|
+
upb_MessageValue key, val;
|
250
|
+
while (upb_Map_Next(other->map, &key, &val, &iter)) {
|
255
251
|
upb_Map_Set(self_msg, key, val, arena);
|
256
252
|
}
|
257
253
|
} else {
|
@@ -343,10 +339,9 @@ static VALUE Map_init(int argc, VALUE* argv, VALUE _self) {
|
|
343
339
|
static VALUE Map_each(VALUE _self) {
|
344
340
|
Map* self = ruby_to_Map(_self);
|
345
341
|
size_t iter = kUpb_Map_Begin;
|
342
|
+
upb_MessageValue key, val;
|
346
343
|
|
347
|
-
while (
|
348
|
-
upb_MessageValue key = upb_MapIterator_Key(self->map, iter);
|
349
|
-
upb_MessageValue val = upb_MapIterator_Value(self->map, iter);
|
344
|
+
while (upb_Map_Next(self->map, &key, &val, &iter)) {
|
350
345
|
VALUE key_val = Convert_UpbToRuby(key, Map_keyinfo(self), self->arena);
|
351
346
|
VALUE val_val = Convert_UpbToRuby(val, self->value_type_info, self->arena);
|
352
347
|
rb_yield_values(2, key_val, val_val);
|
@@ -365,9 +360,9 @@ static VALUE Map_keys(VALUE _self) {
|
|
365
360
|
Map* self = ruby_to_Map(_self);
|
366
361
|
size_t iter = kUpb_Map_Begin;
|
367
362
|
VALUE ret = rb_ary_new();
|
363
|
+
upb_MessageValue key, val;
|
368
364
|
|
369
|
-
while (
|
370
|
-
upb_MessageValue key = upb_MapIterator_Key(self->map, iter);
|
365
|
+
while (upb_Map_Next(self->map, &key, &val, &iter)) {
|
371
366
|
VALUE key_val = Convert_UpbToRuby(key, Map_keyinfo(self), self->arena);
|
372
367
|
rb_ary_push(ret, key_val);
|
373
368
|
}
|
@@ -385,9 +380,9 @@ static VALUE Map_values(VALUE _self) {
|
|
385
380
|
Map* self = ruby_to_Map(_self);
|
386
381
|
size_t iter = kUpb_Map_Begin;
|
387
382
|
VALUE ret = rb_ary_new();
|
383
|
+
upb_MessageValue key, val;
|
388
384
|
|
389
|
-
while (
|
390
|
-
upb_MessageValue val = upb_MapIterator_Value(self->map, iter);
|
385
|
+
while (upb_Map_Next(self->map, &key, &val, &iter)) {
|
391
386
|
VALUE val_val = Convert_UpbToRuby(val, self->value_type_info, self->arena);
|
392
387
|
rb_ary_push(ret, val_val);
|
393
388
|
}
|
@@ -464,24 +459,17 @@ static VALUE Map_has_key(VALUE _self, VALUE key) {
|
|
464
459
|
*/
|
465
460
|
static VALUE Map_delete(VALUE _self, VALUE key) {
|
466
461
|
Map* self = ruby_to_Map(_self);
|
462
|
+
rb_check_frozen(_self);
|
463
|
+
|
467
464
|
upb_MessageValue key_upb =
|
468
465
|
Convert_RubyToUpb(key, "", Map_keyinfo(self), NULL);
|
469
466
|
upb_MessageValue val_upb;
|
470
|
-
VALUE ret;
|
471
467
|
|
472
|
-
|
473
|
-
|
474
|
-
// TODO(haberman): make upb_Map_Delete() also capable of returning the deleted
|
475
|
-
// value.
|
476
|
-
if (upb_Map_Get(self->map, key_upb, &val_upb)) {
|
477
|
-
ret = Convert_UpbToRuby(val_upb, self->value_type_info, self->arena);
|
468
|
+
if (upb_Map_Delete(self->map, key_upb, &val_upb)) {
|
469
|
+
return Convert_UpbToRuby(val_upb, self->value_type_info, self->arena);
|
478
470
|
} else {
|
479
|
-
|
471
|
+
return Qnil;
|
480
472
|
}
|
481
|
-
|
482
|
-
upb_Map_Delete(Map_GetMutable(_self), key_upb);
|
483
|
-
|
484
|
-
return ret;
|
485
473
|
}
|
486
474
|
|
487
475
|
/*
|
@@ -523,9 +511,8 @@ static VALUE Map_dup(VALUE _self) {
|
|
523
511
|
|
524
512
|
Arena_fuse(self->arena, arena);
|
525
513
|
|
526
|
-
|
527
|
-
|
528
|
-
upb_MessageValue val = upb_MapIterator_Value(self->map, iter);
|
514
|
+
upb_MessageValue key, val;
|
515
|
+
while (upb_Map_Next(self->map, &key, &val, &iter)) {
|
529
516
|
upb_Map_Set(new_map, key, val, arena);
|
530
517
|
}
|
531
518
|
|
@@ -574,9 +561,8 @@ VALUE Map_eq(VALUE _self, VALUE _other) {
|
|
574
561
|
// For each member of self, check that an equal member exists at the same key
|
575
562
|
// in other.
|
576
563
|
size_t iter = kUpb_Map_Begin;
|
577
|
-
|
578
|
-
|
579
|
-
upb_MessageValue val = upb_MapIterator_Value(self->map, iter);
|
564
|
+
upb_MessageValue key, val;
|
565
|
+
while (upb_Map_Next(self->map, &key, &val, &iter)) {
|
580
566
|
upb_MessageValue other_val;
|
581
567
|
if (!upb_Map_Get(other->map, key, &other_val)) {
|
582
568
|
// Not present in other map.
|
@@ -619,9 +605,8 @@ VALUE Map_hash(VALUE _self) {
|
|
619
605
|
|
620
606
|
size_t iter = kUpb_Map_Begin;
|
621
607
|
TypeInfo key_info = {self->key_type};
|
622
|
-
|
623
|
-
|
624
|
-
upb_MessageValue val = upb_MapIterator_Value(self->map, iter);
|
608
|
+
upb_MessageValue key, val;
|
609
|
+
while (upb_Map_Next(self->map, &key, &val, &iter)) {
|
625
610
|
hash = Msgval_GetHash(key, key_info, hash);
|
626
611
|
hash = Msgval_GetHash(val, self->value_type_info, hash);
|
627
612
|
}
|
data/ext/google/protobuf_c/map.h
CHANGED
File without changes
|