google-protobuf 4.29.1 → 4.33.1
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 +3 -10
- data/ext/google/protobuf_c/defs.c +469 -130
- data/ext/google/protobuf_c/extconf.rb +20 -10
- data/ext/google/protobuf_c/glue.c +63 -0
- data/ext/google/protobuf_c/map.c +76 -39
- data/ext/google/protobuf_c/message.c +96 -62
- data/ext/google/protobuf_c/protobuf.c +3 -2
- data/ext/google/protobuf_c/protobuf.h +0 -8
- data/ext/google/protobuf_c/repeated_field.c +75 -38
- data/ext/google/protobuf_c/ruby-upb.c +14055 -13540
- data/ext/google/protobuf_c/ruby-upb.h +4343 -2827
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c +21 -281
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range_neon.inc +117 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range_sse.inc +272 -0
- data/lib/google/protobuf/any_pb.rb +1 -1
- data/lib/google/protobuf/api_pb.rb +2 -2
- data/lib/google/protobuf/descriptor_pb.rb +6 -2
- data/lib/google/protobuf/duration_pb.rb +1 -1
- data/lib/google/protobuf/empty_pb.rb +1 -1
- data/lib/google/protobuf/ffi/descriptor.rb +10 -0
- data/lib/google/protobuf/ffi/descriptor_pool.rb +3 -1
- data/lib/google/protobuf/ffi/enum_descriptor.rb +10 -0
- data/lib/google/protobuf/ffi/ffi.rb +0 -1
- data/lib/google/protobuf/ffi/field_descriptor.rb +16 -0
- data/lib/google/protobuf/ffi/file_descriptor.rb +36 -0
- data/lib/google/protobuf/ffi/internal/convert.rb +1 -5
- data/lib/google/protobuf/ffi/internal/pointer_helper.rb +2 -1
- data/lib/google/protobuf/ffi/map.rb +2 -2
- data/lib/google/protobuf/ffi/message.rb +2 -4
- data/lib/google/protobuf/ffi/method_descriptor.rb +11 -1
- data/lib/google/protobuf/ffi/oneof_descriptor.rb +10 -0
- data/lib/google/protobuf/ffi/service_descriptor.rb +11 -1
- data/lib/google/protobuf/field_mask_pb.rb +1 -1
- data/lib/google/protobuf/message_exts.rb +4 -0
- data/lib/google/protobuf/plugin_pb.rb +1 -1
- data/lib/google/protobuf/source_context_pb.rb +1 -1
- data/lib/google/protobuf/struct_pb.rb +1 -1
- data/lib/google/protobuf/timestamp_pb.rb +1 -1
- data/lib/google/protobuf/type_pb.rb +1 -1
- data/lib/google/protobuf/wrappers_pb.rb +1 -1
- data/lib/google/protobuf_ffi.rb +3 -2
- data/lib/google/tasks/ffi.rake +1 -1
- metadata +23 -22
- data/ext/google/protobuf_c/wrap_memcpy.c +0 -29
|
@@ -6,23 +6,33 @@ ext_name = "google/protobuf_c"
|
|
|
6
6
|
|
|
7
7
|
dir_config(ext_name)
|
|
8
8
|
|
|
9
|
-
if
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
if ENV["CC"]
|
|
10
|
+
RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
if ENV["CXX"]
|
|
14
|
+
RbConfig::CONFIG["CXX"] = RbConfig::MAKEFILE_CONFIG["CXX"] = ENV["CXX"]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
if ENV["LD"]
|
|
18
|
+
RbConfig::CONFIG["LD"] = RbConfig::MAKEFILE_CONFIG["LD"] = ENV["LD"]
|
|
13
19
|
end
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
debug_enabled = ENV["PROTOBUF_CONFIG"] == "dbg"
|
|
22
|
+
|
|
23
|
+
additional_c_flags = debug_enabled ? "-O0 -fno-omit-frame-pointer -fvisibility=default -g" : "-O3 -DNDEBUG -fvisibility=hidden"
|
|
24
|
+
|
|
25
|
+
if RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/ || RUBY_PLATFORM =~ /freebsd/
|
|
26
|
+
$CFLAGS += " -std=gnu99 -Wall -Wsign-compare -Wno-declaration-after-statement #{additional_c_flags}"
|
|
27
|
+
else
|
|
28
|
+
$CFLAGS += " -std=gnu99 #{additional_c_flags}"
|
|
18
29
|
end
|
|
19
30
|
|
|
20
31
|
$VPATH << "$(srcdir)/third_party/utf8_range"
|
|
21
32
|
$INCFLAGS += " -I$(srcdir)/third_party/utf8_range"
|
|
22
33
|
|
|
23
|
-
$srcs = ["protobuf.c", "convert.c", "defs.c", "message.c",
|
|
24
|
-
"
|
|
25
|
-
"utf8_range.c", "shared_convert.c",
|
|
34
|
+
$srcs = ["protobuf.c", "convert.c", "defs.c", "message.c", "repeated_field.c",
|
|
35
|
+
"map.c", "ruby-upb.c", "utf8_range.c", "shared_convert.c",
|
|
26
36
|
"shared_message.c"]
|
|
27
37
|
|
|
28
38
|
create_makefile(ext_name)
|
|
@@ -26,6 +26,15 @@ char* EnumDescriptor_serialized_options(const upb_EnumDef* enumdef,
|
|
|
26
26
|
return serialized;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
char* EnumDescriptor_serialized_to_proto(const upb_EnumDef* enumdef,
|
|
30
|
+
size_t* size, upb_Arena* arena) {
|
|
31
|
+
const google_protobuf_EnumDescriptorProto* file_proto =
|
|
32
|
+
upb_EnumDef_ToProto(enumdef, arena);
|
|
33
|
+
char* serialized =
|
|
34
|
+
google_protobuf_EnumDescriptorProto_serialize(file_proto, arena, size);
|
|
35
|
+
return serialized;
|
|
36
|
+
}
|
|
37
|
+
|
|
29
38
|
char* FileDescriptor_serialized_options(const upb_FileDef* filedef,
|
|
30
39
|
size_t* size, upb_Arena* arena) {
|
|
31
40
|
const google_protobuf_FileOptions* opts = upb_FileDef_Options(filedef);
|
|
@@ -33,6 +42,15 @@ char* FileDescriptor_serialized_options(const upb_FileDef* filedef,
|
|
|
33
42
|
return serialized;
|
|
34
43
|
}
|
|
35
44
|
|
|
45
|
+
char* FileDescriptor_serialized_to_proto(const upb_FileDef* filedef,
|
|
46
|
+
size_t* size, upb_Arena* arena) {
|
|
47
|
+
const google_protobuf_FileDescriptorProto* file_proto =
|
|
48
|
+
upb_FileDef_ToProto(filedef, arena);
|
|
49
|
+
char* serialized =
|
|
50
|
+
google_protobuf_FileDescriptorProto_serialize(file_proto, arena, size);
|
|
51
|
+
return serialized;
|
|
52
|
+
}
|
|
53
|
+
|
|
36
54
|
char* Descriptor_serialized_options(const upb_MessageDef* msgdef, size_t* size,
|
|
37
55
|
upb_Arena* arena) {
|
|
38
56
|
const google_protobuf_MessageOptions* opts = upb_MessageDef_Options(msgdef);
|
|
@@ -41,6 +59,15 @@ char* Descriptor_serialized_options(const upb_MessageDef* msgdef, size_t* size,
|
|
|
41
59
|
return serialized;
|
|
42
60
|
}
|
|
43
61
|
|
|
62
|
+
char* Descriptor_serialized_to_proto(const upb_MessageDef* msgdef, size_t* size,
|
|
63
|
+
upb_Arena* arena) {
|
|
64
|
+
const google_protobuf_DescriptorProto* proto =
|
|
65
|
+
upb_MessageDef_ToProto(msgdef, arena);
|
|
66
|
+
char* serialized =
|
|
67
|
+
google_protobuf_DescriptorProto_serialize(proto, arena, size);
|
|
68
|
+
return serialized;
|
|
69
|
+
}
|
|
70
|
+
|
|
44
71
|
char* OneOfDescriptor_serialized_options(const upb_OneofDef* oneofdef,
|
|
45
72
|
size_t* size, upb_Arena* arena) {
|
|
46
73
|
const google_protobuf_OneofOptions* opts = upb_OneofDef_Options(oneofdef);
|
|
@@ -48,6 +75,15 @@ char* OneOfDescriptor_serialized_options(const upb_OneofDef* oneofdef,
|
|
|
48
75
|
return serialized;
|
|
49
76
|
}
|
|
50
77
|
|
|
78
|
+
char* OneOfDescriptor_serialized_to_proto(const upb_OneofDef* oneofdef,
|
|
79
|
+
size_t* size, upb_Arena* arena) {
|
|
80
|
+
const google_protobuf_OneofDescriptorProto* proto =
|
|
81
|
+
upb_OneofDef_ToProto(oneofdef, arena);
|
|
82
|
+
char* serialized =
|
|
83
|
+
google_protobuf_OneofDescriptorProto_serialize(proto, arena, size);
|
|
84
|
+
return serialized;
|
|
85
|
+
}
|
|
86
|
+
|
|
51
87
|
char* FieldDescriptor_serialized_options(const upb_FieldDef* fielddef,
|
|
52
88
|
size_t* size, upb_Arena* arena) {
|
|
53
89
|
const google_protobuf_FieldOptions* opts = upb_FieldDef_Options(fielddef);
|
|
@@ -55,6 +91,15 @@ char* FieldDescriptor_serialized_options(const upb_FieldDef* fielddef,
|
|
|
55
91
|
return serialized;
|
|
56
92
|
}
|
|
57
93
|
|
|
94
|
+
char* FieldDescriptor_serialized_to_proto(const upb_FieldDef* fieldef,
|
|
95
|
+
size_t* size, upb_Arena* arena) {
|
|
96
|
+
const google_protobuf_FieldDescriptorProto* proto =
|
|
97
|
+
upb_FieldDef_ToProto(fieldef, arena);
|
|
98
|
+
char* serialized =
|
|
99
|
+
google_protobuf_FieldDescriptorProto_serialize(proto, arena, size);
|
|
100
|
+
return serialized;
|
|
101
|
+
}
|
|
102
|
+
|
|
58
103
|
char* ServiceDescriptor_serialized_options(const upb_ServiceDef* servicedef,
|
|
59
104
|
size_t* size, upb_Arena* arena) {
|
|
60
105
|
const google_protobuf_ServiceOptions* opts =
|
|
@@ -64,9 +109,27 @@ char* ServiceDescriptor_serialized_options(const upb_ServiceDef* servicedef,
|
|
|
64
109
|
return serialized;
|
|
65
110
|
}
|
|
66
111
|
|
|
112
|
+
char* ServiceDescriptor_serialized_to_proto(const upb_ServiceDef* servicedef,
|
|
113
|
+
size_t* size, upb_Arena* arena) {
|
|
114
|
+
const google_protobuf_ServiceDescriptorProto* proto =
|
|
115
|
+
upb_ServiceDef_ToProto(servicedef, arena);
|
|
116
|
+
char* serialized =
|
|
117
|
+
google_protobuf_ServiceDescriptorProto_serialize(proto, arena, size);
|
|
118
|
+
return serialized;
|
|
119
|
+
}
|
|
120
|
+
|
|
67
121
|
char* MethodDescriptor_serialized_options(const upb_MethodDef* methoddef,
|
|
68
122
|
size_t* size, upb_Arena* arena) {
|
|
69
123
|
const google_protobuf_MethodOptions* opts = upb_MethodDef_Options(methoddef);
|
|
70
124
|
char* serialized = google_protobuf_MethodOptions_serialize(opts, arena, size);
|
|
71
125
|
return serialized;
|
|
72
126
|
}
|
|
127
|
+
|
|
128
|
+
char* MethodDescriptor_serialized_to_proto(const upb_MethodDef* methodef,
|
|
129
|
+
size_t* size, upb_Arena* arena) {
|
|
130
|
+
const google_protobuf_MethodDescriptorProto* proto =
|
|
131
|
+
upb_MethodDef_ToProto(methodef, arena);
|
|
132
|
+
char* serialized =
|
|
133
|
+
google_protobuf_MethodDescriptorProto_serialize(proto, arena, size);
|
|
134
|
+
return serialized;
|
|
135
|
+
}
|
data/ext/google/protobuf_c/map.c
CHANGED
|
@@ -236,10 +236,15 @@ static VALUE Map_merge_into_self(VALUE _self, VALUE hashmap) {
|
|
|
236
236
|
return _self;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
+
/**
|
|
240
|
+
* ruby-doc: Map
|
|
241
|
+
*
|
|
242
|
+
* This class represents a Protobuf Map. It is largely automatically transformed
|
|
243
|
+
* to and from a Ruby hash.
|
|
244
|
+
*/
|
|
245
|
+
|
|
239
246
|
/*
|
|
240
|
-
*
|
|
241
|
-
* Map.new(key_type, value_type, value_typeclass = nil, init_hashmap = {})
|
|
242
|
-
* => new map
|
|
247
|
+
* ruby-doc: Map#initialize
|
|
243
248
|
*
|
|
244
249
|
* Allocates a new Map container. This constructor may be called with 2, 3, or 4
|
|
245
250
|
* arguments. The first two arguments are always present and are symbols (taking
|
|
@@ -265,6 +270,13 @@ static VALUE Map_merge_into_self(VALUE _self, VALUE hashmap) {
|
|
|
265
270
|
* shallow-copied into the new Map: the original map is unmodified, but
|
|
266
271
|
* references to underlying objects will be shared if the value type is a
|
|
267
272
|
* message type.
|
|
273
|
+
*
|
|
274
|
+
* @param key_type [Symbol]
|
|
275
|
+
* @param value_type [Symbol]
|
|
276
|
+
* @param value_typeclass [Class<AbstractMessage>,Module]
|
|
277
|
+
* @paramdefault value_typeclass nil
|
|
278
|
+
* @param init_hashmap [Hash,Map]
|
|
279
|
+
* @paramdefault init_hashmap {}
|
|
268
280
|
*/
|
|
269
281
|
static VALUE Map_init(int argc, VALUE* argv, VALUE _self) {
|
|
270
282
|
Map* self = ruby_to_Map(_self);
|
|
@@ -311,12 +323,14 @@ static VALUE Map_init(int argc, VALUE* argv, VALUE _self) {
|
|
|
311
323
|
}
|
|
312
324
|
|
|
313
325
|
/*
|
|
314
|
-
*
|
|
315
|
-
* Map.each(&block)
|
|
326
|
+
* ruby-doc: Map#each
|
|
316
327
|
*
|
|
317
328
|
* Invokes &block on each |key, value| pair in the map, in unspecified order.
|
|
318
329
|
* Note that Map also includes Enumerable; map thus acts like a normal Ruby
|
|
319
330
|
* sequence.
|
|
331
|
+
*
|
|
332
|
+
* @yield [Object, Object]
|
|
333
|
+
* @return [nil]
|
|
320
334
|
*/
|
|
321
335
|
static VALUE Map_each(VALUE _self) {
|
|
322
336
|
Map* self = ruby_to_Map(_self);
|
|
@@ -333,10 +347,11 @@ static VALUE Map_each(VALUE _self) {
|
|
|
333
347
|
}
|
|
334
348
|
|
|
335
349
|
/*
|
|
336
|
-
*
|
|
337
|
-
* Map.keys => [list_of_keys]
|
|
350
|
+
* ruby-doc: Map#keys
|
|
338
351
|
*
|
|
339
352
|
* Returns the list of keys contained in the map, in unspecified order.
|
|
353
|
+
*
|
|
354
|
+
* @return [Array<Object>]
|
|
340
355
|
*/
|
|
341
356
|
static VALUE Map_keys(VALUE _self) {
|
|
342
357
|
Map* self = ruby_to_Map(_self);
|
|
@@ -353,10 +368,11 @@ static VALUE Map_keys(VALUE _self) {
|
|
|
353
368
|
}
|
|
354
369
|
|
|
355
370
|
/*
|
|
356
|
-
*
|
|
357
|
-
* Map.values => [list_of_values]
|
|
371
|
+
* ruby-doc: Map#values
|
|
358
372
|
*
|
|
359
373
|
* Returns the list of values contained in the map, in unspecified order.
|
|
374
|
+
*
|
|
375
|
+
* @return [Array<Object>]
|
|
360
376
|
*/
|
|
361
377
|
static VALUE Map_values(VALUE _self) {
|
|
362
378
|
Map* self = ruby_to_Map(_self);
|
|
@@ -373,11 +389,13 @@ static VALUE Map_values(VALUE _self) {
|
|
|
373
389
|
}
|
|
374
390
|
|
|
375
391
|
/*
|
|
376
|
-
*
|
|
377
|
-
* Map.[](key) => value
|
|
392
|
+
* ruby-doc: Map#[]
|
|
378
393
|
*
|
|
379
394
|
* Accesses the element at the given key. Throws an exception if the key type is
|
|
380
395
|
* incorrect. Returns nil when the key is not present in the map.
|
|
396
|
+
*
|
|
397
|
+
* @param key [Object]
|
|
398
|
+
* @return [Object]
|
|
381
399
|
*/
|
|
382
400
|
static VALUE Map_index(VALUE _self, VALUE key) {
|
|
383
401
|
Map* self = ruby_to_Map(_self);
|
|
@@ -393,12 +411,15 @@ static VALUE Map_index(VALUE _self, VALUE key) {
|
|
|
393
411
|
}
|
|
394
412
|
|
|
395
413
|
/*
|
|
396
|
-
*
|
|
397
|
-
* Map.[]=(key, value) => value
|
|
414
|
+
* ruby-doc: Map#[]=
|
|
398
415
|
*
|
|
399
416
|
* Inserts or overwrites the value at the given key with the given new value.
|
|
400
417
|
* Throws an exception if the key type is incorrect. Returns the new value that
|
|
401
418
|
* was just inserted.
|
|
419
|
+
*
|
|
420
|
+
* @param key [Object]
|
|
421
|
+
* @param value [Object]
|
|
422
|
+
* @return [Object]
|
|
402
423
|
*/
|
|
403
424
|
static VALUE Map_index_set(VALUE _self, VALUE key, VALUE val) {
|
|
404
425
|
Map* self = ruby_to_Map(_self);
|
|
@@ -414,11 +435,13 @@ static VALUE Map_index_set(VALUE _self, VALUE key, VALUE val) {
|
|
|
414
435
|
}
|
|
415
436
|
|
|
416
437
|
/*
|
|
417
|
-
*
|
|
418
|
-
* Map.has_key?(key) => bool
|
|
438
|
+
* ruby-doc: Map#has_key?
|
|
419
439
|
*
|
|
420
440
|
* Returns true if the given key is present in the map. Throws an exception if
|
|
421
441
|
* the key has the wrong type.
|
|
442
|
+
*
|
|
443
|
+
* @param key [Object]
|
|
444
|
+
* @return [Boolean]
|
|
422
445
|
*/
|
|
423
446
|
static VALUE Map_has_key(VALUE _self, VALUE key) {
|
|
424
447
|
Map* self = ruby_to_Map(_self);
|
|
@@ -433,11 +456,13 @@ static VALUE Map_has_key(VALUE _self, VALUE key) {
|
|
|
433
456
|
}
|
|
434
457
|
|
|
435
458
|
/*
|
|
436
|
-
*
|
|
437
|
-
* Map.delete(key) => old_value
|
|
459
|
+
* ruby-doc: Map#delete
|
|
438
460
|
*
|
|
439
461
|
* Deletes the value at the given key, if any, returning either the old value or
|
|
440
462
|
* nil if none was present. Throws an exception if the key is of the wrong type.
|
|
463
|
+
*
|
|
464
|
+
* @param key [Object]
|
|
465
|
+
* @return [Object]
|
|
441
466
|
*/
|
|
442
467
|
static VALUE Map_delete(VALUE _self, VALUE key) {
|
|
443
468
|
upb_Map* map = Map_GetMutable(_self);
|
|
@@ -455,10 +480,11 @@ static VALUE Map_delete(VALUE _self, VALUE key) {
|
|
|
455
480
|
}
|
|
456
481
|
|
|
457
482
|
/*
|
|
458
|
-
*
|
|
459
|
-
* Map.clear
|
|
483
|
+
* ruby-doc: Map#clear
|
|
460
484
|
*
|
|
461
485
|
* Removes all entries from the map.
|
|
486
|
+
*
|
|
487
|
+
* @return [nil]
|
|
462
488
|
*/
|
|
463
489
|
static VALUE Map_clear(VALUE _self) {
|
|
464
490
|
upb_Map_Clear(Map_GetMutable(_self));
|
|
@@ -466,10 +492,11 @@ static VALUE Map_clear(VALUE _self) {
|
|
|
466
492
|
}
|
|
467
493
|
|
|
468
494
|
/*
|
|
469
|
-
*
|
|
470
|
-
* Map.length
|
|
495
|
+
* ruby-doc: Map#length
|
|
471
496
|
*
|
|
472
497
|
* Returns the number of entries (key-value pairs) in the map.
|
|
498
|
+
*
|
|
499
|
+
* @return [Integer]
|
|
473
500
|
*/
|
|
474
501
|
static VALUE Map_length(VALUE _self) {
|
|
475
502
|
Map* self = ruby_to_Map(_self);
|
|
@@ -477,11 +504,12 @@ static VALUE Map_length(VALUE _self) {
|
|
|
477
504
|
}
|
|
478
505
|
|
|
479
506
|
/*
|
|
480
|
-
*
|
|
481
|
-
* Map.dup => new_map
|
|
507
|
+
* ruby-doc: Map#dup
|
|
482
508
|
*
|
|
483
509
|
* Duplicates this map with a shallow copy. References to all non-primitive
|
|
484
510
|
* element objects (e.g., submessages) are shared.
|
|
511
|
+
*
|
|
512
|
+
* @return [Map]
|
|
485
513
|
*/
|
|
486
514
|
static VALUE Map_dup(VALUE _self) {
|
|
487
515
|
Map* self = ruby_to_Map(_self);
|
|
@@ -502,8 +530,7 @@ static VALUE Map_dup(VALUE _self) {
|
|
|
502
530
|
}
|
|
503
531
|
|
|
504
532
|
/*
|
|
505
|
-
*
|
|
506
|
-
* Map.==(other) => boolean
|
|
533
|
+
* ruby-doc: Map#==
|
|
507
534
|
*
|
|
508
535
|
* Compares this map to another. Maps are equal if they have identical key sets,
|
|
509
536
|
* and for each key, the values in both maps compare equal. Elements are
|
|
@@ -513,6 +540,9 @@ static VALUE Map_dup(VALUE _self) {
|
|
|
513
540
|
* Maps with dissimilar key types or value types/typeclasses are never equal,
|
|
514
541
|
* even if value comparison (for example, between integers and floats) would
|
|
515
542
|
* have otherwise indicated that every element has equal value.
|
|
543
|
+
*
|
|
544
|
+
* @param other [Map]
|
|
545
|
+
* @return [Boolean]
|
|
516
546
|
*/
|
|
517
547
|
VALUE Map_eq(VALUE _self, VALUE _other) {
|
|
518
548
|
Map* self = ruby_to_Map(_self);
|
|
@@ -560,12 +590,13 @@ VALUE Map_eq(VALUE _self, VALUE _other) {
|
|
|
560
590
|
}
|
|
561
591
|
|
|
562
592
|
/*
|
|
563
|
-
*
|
|
564
|
-
* Map.frozen? => bool
|
|
593
|
+
* ruby-doc: Map#frozen?
|
|
565
594
|
*
|
|
566
595
|
* Returns true if the map is frozen in either Ruby or the underlying
|
|
567
596
|
* representation. Freezes the Ruby map object if it is not already frozen in
|
|
568
597
|
* Ruby but it is frozen in the underlying representation.
|
|
598
|
+
*
|
|
599
|
+
* @return [Boolean]
|
|
569
600
|
*/
|
|
570
601
|
VALUE Map_frozen(VALUE _self) {
|
|
571
602
|
Map* self = ruby_to_Map(_self);
|
|
@@ -580,11 +611,12 @@ VALUE Map_frozen(VALUE _self) {
|
|
|
580
611
|
}
|
|
581
612
|
|
|
582
613
|
/*
|
|
583
|
-
*
|
|
584
|
-
* Map.freeze => self
|
|
614
|
+
* ruby-doc: Map#freeze
|
|
585
615
|
*
|
|
586
616
|
* Freezes the map object. We have to intercept this so we can freeze the
|
|
587
617
|
* underlying representation, not just the Ruby wrapper.
|
|
618
|
+
*
|
|
619
|
+
* @return [self]
|
|
588
620
|
*/
|
|
589
621
|
VALUE Map_freeze(VALUE _self) {
|
|
590
622
|
Map* self = ruby_to_Map(_self);
|
|
@@ -637,10 +669,11 @@ VALUE Map_EmptyFrozen(const upb_FieldDef* f) {
|
|
|
637
669
|
}
|
|
638
670
|
|
|
639
671
|
/*
|
|
640
|
-
*
|
|
641
|
-
* Map.hash => hash_value
|
|
672
|
+
* ruby-doc: Map#hash
|
|
642
673
|
*
|
|
643
674
|
* Returns a hash value based on this map's contents.
|
|
675
|
+
*
|
|
676
|
+
* @return [Integer]
|
|
644
677
|
*/
|
|
645
678
|
VALUE Map_hash(VALUE _self) {
|
|
646
679
|
Map* self = ruby_to_Map(_self);
|
|
@@ -650,18 +683,19 @@ VALUE Map_hash(VALUE _self) {
|
|
|
650
683
|
TypeInfo key_info = {self->key_type};
|
|
651
684
|
upb_MessageValue key, val;
|
|
652
685
|
while (upb_Map_Next(self->map, &key, &val, &iter)) {
|
|
653
|
-
hash
|
|
654
|
-
hash
|
|
686
|
+
hash += Msgval_GetHash(key, key_info, 0);
|
|
687
|
+
hash += Msgval_GetHash(val, self->value_type_info, 0);
|
|
655
688
|
}
|
|
656
689
|
|
|
657
690
|
return LL2NUM(hash);
|
|
658
691
|
}
|
|
659
692
|
|
|
660
693
|
/*
|
|
661
|
-
*
|
|
662
|
-
* Map.to_h => {}
|
|
694
|
+
* ruby-doc: Map#to_h
|
|
663
695
|
*
|
|
664
696
|
* Returns a Ruby Hash object containing all the values within the map
|
|
697
|
+
*
|
|
698
|
+
* @return [Hash]
|
|
665
699
|
*/
|
|
666
700
|
VALUE Map_to_h(VALUE _self) {
|
|
667
701
|
Map* self = ruby_to_Map(_self);
|
|
@@ -669,12 +703,13 @@ VALUE Map_to_h(VALUE _self) {
|
|
|
669
703
|
}
|
|
670
704
|
|
|
671
705
|
/*
|
|
672
|
-
*
|
|
673
|
-
* Map.inspect => string
|
|
706
|
+
* ruby-doc: Map#inspect
|
|
674
707
|
*
|
|
675
708
|
* Returns a string representing this map's elements. It will be formatted as
|
|
676
709
|
* "{key => value, key => value, ...}", with each key and value string
|
|
677
710
|
* representation computed by its own #inspect method.
|
|
711
|
+
*
|
|
712
|
+
* @return [String]
|
|
678
713
|
*/
|
|
679
714
|
VALUE Map_inspect(VALUE _self) {
|
|
680
715
|
Map* self = ruby_to_Map(_self);
|
|
@@ -687,13 +722,15 @@ VALUE Map_inspect(VALUE _self) {
|
|
|
687
722
|
}
|
|
688
723
|
|
|
689
724
|
/*
|
|
690
|
-
*
|
|
691
|
-
* Map.merge(other_map) => map
|
|
725
|
+
* ruby-doc: Map#merge
|
|
692
726
|
*
|
|
693
727
|
* Copies key/value pairs from other_map into a copy of this map. If a key is
|
|
694
728
|
* set in other_map and this map, the value from other_map overwrites the value
|
|
695
729
|
* in the new copy of this map. Returns the new copy of this map with merged
|
|
696
730
|
* contents.
|
|
731
|
+
*
|
|
732
|
+
* @param other_map [Map]
|
|
733
|
+
* @return [Map]
|
|
697
734
|
*/
|
|
698
735
|
static VALUE Map_merge(VALUE _self, VALUE hashmap) {
|
|
699
736
|
VALUE dupped = Map_dup(_self);
|