google-protobuf 3.17.3 → 3.22.1-arm64-darwin
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 +128 -116
- data/ext/google/protobuf_c/convert.h +12 -9
- data/ext/google/protobuf_c/defs.c +217 -1521
- data/ext/google/protobuf_c/defs.h +19 -19
- data/ext/google/protobuf_c/extconf.rb +12 -6
- data/ext/google/protobuf_c/map.c +105 -109
- data/ext/google/protobuf_c/map.h +7 -8
- data/ext/google/protobuf_c/message.c +438 -341
- data/ext/google/protobuf_c/message.h +22 -19
- data/ext/google/protobuf_c/protobuf.c +68 -58
- data/ext/google/protobuf_c/protobuf.h +13 -10
- data/ext/google/protobuf_c/repeated_field.c +83 -85
- data/ext/google/protobuf_c/repeated_field.h +6 -6
- data/ext/google/protobuf_c/ruby-upb.c +11782 -6714
- data/ext/google/protobuf_c/ruby-upb.h +9668 -3406
- data/ext/google/protobuf_c/third_party/utf8_range/LICENSE +22 -0
- data/ext/google/protobuf_c/third_party/utf8_range/naive.c +92 -0
- data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +157 -0
- data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +170 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +21 -0
- data/ext/google/protobuf_c/wrap_memcpy.c +4 -3
- data/lib/google/2.6/protobuf_c.bundle +0 -0
- data/lib/google/2.7/protobuf_c.bundle +0 -0
- data/lib/google/3.0/protobuf_c.bundle +0 -0
- data/lib/google/3.1/protobuf_c.bundle +0 -0
- data/lib/google/3.2/protobuf_c.bundle +0 -0
- data/lib/google/protobuf/any_pb.rb +0 -0
- data/lib/google/protobuf/api_pb.rb +1 -0
- data/lib/google/protobuf/descriptor_dsl.rb +465 -0
- data/lib/google/protobuf/descriptor_pb.rb +298 -0
- data/lib/google/protobuf/duration_pb.rb +0 -0
- data/lib/google/protobuf/empty_pb.rb +0 -0
- data/lib/google/protobuf/field_mask_pb.rb +0 -0
- data/lib/google/protobuf/message_exts.rb +7 -2
- data/lib/google/protobuf/plugin_pb.rb +50 -0
- data/lib/google/protobuf/repeated_field.rb +15 -2
- data/lib/google/protobuf/source_context_pb.rb +0 -0
- data/lib/google/protobuf/struct_pb.rb +0 -0
- data/lib/google/protobuf/timestamp_pb.rb +0 -0
- data/lib/google/protobuf/type_pb.rb +1 -0
- data/lib/google/protobuf/well_known_types.rb +12 -2
- data/lib/google/protobuf/wrappers_pb.rb +0 -0
- data/lib/google/protobuf.rb +5 -73
- metadata +28 -40
- data/ext/google/protobuf_c/third_party/wyhash/wyhash.h +0 -145
- data/tests/basic.rb +0 -611
- data/tests/generated_code_test.rb +0 -23
- data/tests/stress.rb +0 -38
@@ -34,17 +34,16 @@
|
|
34
34
|
#include "defs.h"
|
35
35
|
#include "message.h"
|
36
36
|
#include "protobuf.h"
|
37
|
-
#include "third_party/wyhash/wyhash.h"
|
38
37
|
|
39
38
|
// -----------------------------------------------------------------------------
|
40
39
|
// Repeated field container type.
|
41
40
|
// -----------------------------------------------------------------------------
|
42
41
|
|
43
42
|
typedef struct {
|
44
|
-
const
|
43
|
+
const upb_Array* array; // Can get as mutable when non-frozen.
|
45
44
|
TypeInfo type_info;
|
46
45
|
VALUE type_class; // To GC-root the msgdef/enumdef in type_info.
|
47
|
-
VALUE arena; // To GC-root the
|
46
|
+
VALUE arena; // To GC-root the upb_Array.
|
48
47
|
} RepeatedField;
|
49
48
|
|
50
49
|
VALUE cRepeatedField;
|
@@ -56,9 +55,9 @@ static void RepeatedField_mark(void* _self) {
|
|
56
55
|
}
|
57
56
|
|
58
57
|
const rb_data_type_t RepeatedField_type = {
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
"Google::Protobuf::RepeatedField",
|
59
|
+
{RepeatedField_mark, RUBY_DEFAULT_FREE, NULL},
|
60
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
62
61
|
};
|
63
62
|
|
64
63
|
static RepeatedField* ruby_to_RepeatedField(VALUE _self) {
|
@@ -67,9 +66,9 @@ static RepeatedField* ruby_to_RepeatedField(VALUE _self) {
|
|
67
66
|
return self;
|
68
67
|
}
|
69
68
|
|
70
|
-
static
|
69
|
+
static upb_Array* RepeatedField_GetMutable(VALUE _self) {
|
71
70
|
rb_check_frozen(_self);
|
72
|
-
return (
|
71
|
+
return (upb_Array*)ruby_to_RepeatedField(_self)->array;
|
73
72
|
}
|
74
73
|
|
75
74
|
VALUE RepeatedField_alloc(VALUE klass) {
|
@@ -80,7 +79,7 @@ VALUE RepeatedField_alloc(VALUE klass) {
|
|
80
79
|
return TypedData_Wrap_Struct(klass, &RepeatedField_type, self);
|
81
80
|
}
|
82
81
|
|
83
|
-
VALUE RepeatedField_GetRubyWrapper(
|
82
|
+
VALUE RepeatedField_GetRubyWrapper(upb_Array* array, TypeInfo type_info,
|
84
83
|
VALUE arena) {
|
85
84
|
PBRUBY_ASSERT(array);
|
86
85
|
VALUE val = ObjectCache_Get(array);
|
@@ -93,7 +92,7 @@ VALUE RepeatedField_GetRubyWrapper(upb_array* array, TypeInfo type_info,
|
|
93
92
|
self->array = array;
|
94
93
|
self->arena = arena;
|
95
94
|
self->type_info = type_info;
|
96
|
-
if (self->type_info.type ==
|
95
|
+
if (self->type_info.type == kUpb_CType_Message) {
|
97
96
|
self->type_class = Descriptor_DefToClass(type_info.def.msgdef);
|
98
97
|
}
|
99
98
|
}
|
@@ -106,24 +105,24 @@ VALUE RepeatedField_GetRubyWrapper(upb_array* array, TypeInfo type_info,
|
|
106
105
|
|
107
106
|
static VALUE RepeatedField_new_this_type(RepeatedField* from) {
|
108
107
|
VALUE arena_rb = Arena_new();
|
109
|
-
|
108
|
+
upb_Array* array = upb_Array_New(Arena_get(arena_rb), from->type_info.type);
|
110
109
|
VALUE ret = RepeatedField_GetRubyWrapper(array, from->type_info, arena_rb);
|
111
110
|
PBRUBY_ASSERT(ruby_to_RepeatedField(ret)->type_class == from->type_class);
|
112
111
|
return ret;
|
113
112
|
}
|
114
113
|
|
115
|
-
void RepeatedField_Inspect(StringBuilder* b, const
|
114
|
+
void RepeatedField_Inspect(StringBuilder* b, const upb_Array* array,
|
116
115
|
TypeInfo info) {
|
117
116
|
bool first = true;
|
118
117
|
StringBuilder_Printf(b, "[");
|
119
|
-
size_t n = array ?
|
118
|
+
size_t n = array ? upb_Array_Size(array) : 0;
|
120
119
|
for (size_t i = 0; i < n; i++) {
|
121
120
|
if (first) {
|
122
121
|
first = false;
|
123
122
|
} else {
|
124
123
|
StringBuilder_Printf(b, ", ");
|
125
124
|
}
|
126
|
-
StringBuilder_PrintMsgval(b,
|
125
|
+
StringBuilder_PrintMsgval(b, upb_Array_Get(array, i), info);
|
127
126
|
}
|
128
127
|
StringBuilder_Printf(b, "]");
|
129
128
|
}
|
@@ -133,24 +132,24 @@ VALUE RepeatedField_deep_copy(VALUE _self) {
|
|
133
132
|
VALUE new_rptfield = RepeatedField_new_this_type(self);
|
134
133
|
RepeatedField* new_self = ruby_to_RepeatedField(new_rptfield);
|
135
134
|
VALUE arena_rb = new_self->arena;
|
136
|
-
|
137
|
-
|
138
|
-
size_t elements =
|
135
|
+
upb_Array* new_array = RepeatedField_GetMutable(new_rptfield);
|
136
|
+
upb_Arena* arena = Arena_get(arena_rb);
|
137
|
+
size_t elements = upb_Array_Size(self->array);
|
139
138
|
|
140
|
-
|
139
|
+
upb_Array_Resize(new_array, elements, arena);
|
141
140
|
|
142
|
-
size_t size =
|
141
|
+
size_t size = upb_Array_Size(self->array);
|
143
142
|
for (size_t i = 0; i < size; i++) {
|
144
|
-
|
145
|
-
|
146
|
-
|
143
|
+
upb_MessageValue msgval = upb_Array_Get(self->array, i);
|
144
|
+
upb_MessageValue copy = Msgval_DeepCopy(msgval, self->type_info, arena);
|
145
|
+
upb_Array_Set(new_array, i, copy);
|
147
146
|
}
|
148
147
|
|
149
148
|
return new_rptfield;
|
150
149
|
}
|
151
150
|
|
152
|
-
const
|
153
|
-
|
151
|
+
const upb_Array* RepeatedField_GetUpbArray(VALUE val, const upb_FieldDef* field,
|
152
|
+
upb_Arena* arena) {
|
154
153
|
RepeatedField* self;
|
155
154
|
TypeInfo type_info = TypeInfo_get(field);
|
156
155
|
|
@@ -174,17 +173,17 @@ const upb_array* RepeatedField_GetUpbArray(VALUE val, const upb_fielddef* field,
|
|
174
173
|
|
175
174
|
static int index_position(VALUE _index, RepeatedField* repeated_field) {
|
176
175
|
int index = NUM2INT(_index);
|
177
|
-
if (index < 0) index +=
|
176
|
+
if (index < 0) index += upb_Array_Size(repeated_field->array);
|
178
177
|
return index;
|
179
178
|
}
|
180
179
|
|
181
180
|
static VALUE RepeatedField_subarray(RepeatedField* self, long beg, long len) {
|
182
|
-
size_t size =
|
181
|
+
size_t size = upb_Array_Size(self->array);
|
183
182
|
VALUE ary = rb_ary_new2(size);
|
184
183
|
long i;
|
185
184
|
|
186
185
|
for (i = beg; i < beg + len; i++) {
|
187
|
-
|
186
|
+
upb_MessageValue msgval = upb_Array_Get(self->array, i);
|
188
187
|
VALUE elem = Convert_UpbToRuby(msgval, self->type_info, self->arena);
|
189
188
|
rb_ary_push(ary, elem);
|
190
189
|
}
|
@@ -201,18 +200,17 @@ static VALUE RepeatedField_subarray(RepeatedField* self, long beg, long len) {
|
|
201
200
|
*/
|
202
201
|
static VALUE RepeatedField_each(VALUE _self) {
|
203
202
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
204
|
-
int size =
|
203
|
+
int size = upb_Array_Size(self->array);
|
205
204
|
int i;
|
206
205
|
|
207
206
|
for (i = 0; i < size; i++) {
|
208
|
-
|
207
|
+
upb_MessageValue msgval = upb_Array_Get(self->array, i);
|
209
208
|
VALUE val = Convert_UpbToRuby(msgval, self->type_info, self->arena);
|
210
209
|
rb_yield(val);
|
211
210
|
}
|
212
211
|
return _self;
|
213
212
|
}
|
214
213
|
|
215
|
-
|
216
214
|
/*
|
217
215
|
* call-seq:
|
218
216
|
* RepeatedField.[](index) => value
|
@@ -221,20 +219,20 @@ static VALUE RepeatedField_each(VALUE _self) {
|
|
221
219
|
*/
|
222
220
|
static VALUE RepeatedField_index(int argc, VALUE* argv, VALUE _self) {
|
223
221
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
224
|
-
long size =
|
222
|
+
long size = upb_Array_Size(self->array);
|
225
223
|
|
226
224
|
VALUE arg = argv[0];
|
227
225
|
long beg, len;
|
228
226
|
|
229
|
-
if (argc == 1){
|
227
|
+
if (argc == 1) {
|
230
228
|
if (FIXNUM_P(arg)) {
|
231
229
|
/* standard case */
|
232
|
-
|
230
|
+
upb_MessageValue msgval;
|
233
231
|
int index = index_position(argv[0], self);
|
234
|
-
if (index < 0 || (size_t)index >=
|
232
|
+
if (index < 0 || (size_t)index >= upb_Array_Size(self->array)) {
|
235
233
|
return Qnil;
|
236
234
|
}
|
237
|
-
msgval =
|
235
|
+
msgval = upb_Array_Get(self->array, index);
|
238
236
|
return Convert_UpbToRuby(msgval, self->type_info, self->arena);
|
239
237
|
} else {
|
240
238
|
/* check if idx is Range */
|
@@ -270,10 +268,10 @@ static VALUE RepeatedField_index(int argc, VALUE* argv, VALUE _self) {
|
|
270
268
|
*/
|
271
269
|
static VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val) {
|
272
270
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
273
|
-
int size =
|
274
|
-
|
275
|
-
|
276
|
-
|
271
|
+
int size = upb_Array_Size(self->array);
|
272
|
+
upb_Array* array = RepeatedField_GetMutable(_self);
|
273
|
+
upb_Arena* arena = Arena_get(self->arena);
|
274
|
+
upb_MessageValue msgval = Convert_RubyToUpb(val, "", self->type_info, arena);
|
277
275
|
|
278
276
|
int index = index_position(_index, self);
|
279
277
|
if (index < 0 || index >= (INT_MAX - 1)) {
|
@@ -281,17 +279,17 @@ static VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val) {
|
|
281
279
|
}
|
282
280
|
|
283
281
|
if (index >= size) {
|
284
|
-
|
285
|
-
|
282
|
+
upb_Array_Resize(array, index + 1, arena);
|
283
|
+
upb_MessageValue fill;
|
286
284
|
memset(&fill, 0, sizeof(fill));
|
287
285
|
for (int i = size; i < index; i++) {
|
288
286
|
// Fill default values.
|
289
287
|
// TODO(haberman): should this happen at the upb level?
|
290
|
-
|
288
|
+
upb_Array_Set(array, i, fill);
|
291
289
|
}
|
292
290
|
}
|
293
291
|
|
294
|
-
|
292
|
+
upb_Array_Set(array, index, msgval);
|
295
293
|
return Qnil;
|
296
294
|
}
|
297
295
|
|
@@ -303,13 +301,14 @@ static VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val) {
|
|
303
301
|
*/
|
304
302
|
static VALUE RepeatedField_push_vararg(int argc, VALUE* argv, VALUE _self) {
|
305
303
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
306
|
-
|
307
|
-
|
304
|
+
upb_Arena* arena = Arena_get(self->arena);
|
305
|
+
upb_Array* array = RepeatedField_GetMutable(_self);
|
308
306
|
int i;
|
309
307
|
|
310
308
|
for (i = 0; i < argc; i++) {
|
311
|
-
|
312
|
-
|
309
|
+
upb_MessageValue msgval =
|
310
|
+
Convert_RubyToUpb(argv[i], "", self->type_info, arena);
|
311
|
+
upb_Array_Append(array, msgval, arena);
|
313
312
|
}
|
314
313
|
|
315
314
|
return _self;
|
@@ -323,11 +322,11 @@ static VALUE RepeatedField_push_vararg(int argc, VALUE* argv, VALUE _self) {
|
|
323
322
|
*/
|
324
323
|
static VALUE RepeatedField_push(VALUE _self, VALUE val) {
|
325
324
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
326
|
-
|
327
|
-
|
325
|
+
upb_Arena* arena = Arena_get(self->arena);
|
326
|
+
upb_Array* array = RepeatedField_GetMutable(_self);
|
328
327
|
|
329
|
-
|
330
|
-
|
328
|
+
upb_MessageValue msgval = Convert_RubyToUpb(val, "", self->type_info, arena);
|
329
|
+
upb_Array_Append(array, msgval, arena);
|
331
330
|
|
332
331
|
return _self;
|
333
332
|
}
|
@@ -337,19 +336,19 @@ static VALUE RepeatedField_push(VALUE _self, VALUE val) {
|
|
337
336
|
*/
|
338
337
|
static VALUE RepeatedField_pop_one(VALUE _self) {
|
339
338
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
340
|
-
size_t size =
|
341
|
-
|
342
|
-
|
339
|
+
size_t size = upb_Array_Size(self->array);
|
340
|
+
upb_Array* array = RepeatedField_GetMutable(_self);
|
341
|
+
upb_MessageValue last;
|
343
342
|
VALUE ret;
|
344
343
|
|
345
344
|
if (size == 0) {
|
346
345
|
return Qnil;
|
347
346
|
}
|
348
347
|
|
349
|
-
last =
|
348
|
+
last = upb_Array_Get(self->array, size - 1);
|
350
349
|
ret = Convert_UpbToRuby(last, self->type_info, self->arena);
|
351
350
|
|
352
|
-
|
351
|
+
upb_Array_Resize(array, size - 1, Arena_get(self->arena));
|
353
352
|
return ret;
|
354
353
|
}
|
355
354
|
|
@@ -361,11 +360,11 @@ static VALUE RepeatedField_pop_one(VALUE _self) {
|
|
361
360
|
*/
|
362
361
|
static VALUE RepeatedField_replace(VALUE _self, VALUE list) {
|
363
362
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
364
|
-
|
363
|
+
upb_Array* array = RepeatedField_GetMutable(_self);
|
365
364
|
int i;
|
366
365
|
|
367
366
|
Check_Type(list, T_ARRAY);
|
368
|
-
|
367
|
+
upb_Array_Resize(array, 0, Arena_get(self->arena));
|
369
368
|
|
370
369
|
for (i = 0; i < RARRAY_LEN(list); i++) {
|
371
370
|
RepeatedField_push(_self, rb_ary_entry(list, i));
|
@@ -382,8 +381,8 @@ static VALUE RepeatedField_replace(VALUE _self, VALUE list) {
|
|
382
381
|
*/
|
383
382
|
static VALUE RepeatedField_clear(VALUE _self) {
|
384
383
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
385
|
-
|
386
|
-
|
384
|
+
upb_Array* array = RepeatedField_GetMutable(_self);
|
385
|
+
upb_Array_Resize(array, 0, Arena_get(self->arena));
|
387
386
|
return _self;
|
388
387
|
}
|
389
388
|
|
@@ -395,7 +394,7 @@ static VALUE RepeatedField_clear(VALUE _self) {
|
|
395
394
|
*/
|
396
395
|
static VALUE RepeatedField_length(VALUE _self) {
|
397
396
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
398
|
-
return INT2NUM(
|
397
|
+
return INT2NUM(upb_Array_Size(self->array));
|
399
398
|
}
|
400
399
|
|
401
400
|
/*
|
@@ -409,16 +408,16 @@ static VALUE RepeatedField_dup(VALUE _self) {
|
|
409
408
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
410
409
|
VALUE new_rptfield = RepeatedField_new_this_type(self);
|
411
410
|
RepeatedField* new_rptfield_self = ruby_to_RepeatedField(new_rptfield);
|
412
|
-
|
413
|
-
|
414
|
-
int size =
|
411
|
+
upb_Array* new_array = RepeatedField_GetMutable(new_rptfield);
|
412
|
+
upb_Arena* arena = Arena_get(new_rptfield_self->arena);
|
413
|
+
int size = upb_Array_Size(self->array);
|
415
414
|
int i;
|
416
415
|
|
417
416
|
Arena_fuse(self->arena, arena);
|
418
417
|
|
419
418
|
for (i = 0; i < size; i++) {
|
420
|
-
|
421
|
-
|
419
|
+
upb_MessageValue msgval = upb_Array_Get(self->array, i);
|
420
|
+
upb_Array_Append(new_array, msgval, arena);
|
422
421
|
}
|
423
422
|
|
424
423
|
return new_rptfield;
|
@@ -433,12 +432,12 @@ static VALUE RepeatedField_dup(VALUE _self) {
|
|
433
432
|
*/
|
434
433
|
VALUE RepeatedField_to_ary(VALUE _self) {
|
435
434
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
436
|
-
int size =
|
435
|
+
int size = upb_Array_Size(self->array);
|
437
436
|
VALUE ary = rb_ary_new2(size);
|
438
437
|
int i;
|
439
438
|
|
440
439
|
for (i = 0; i < size; i++) {
|
441
|
-
|
440
|
+
upb_MessageValue msgval = upb_Array_Get(self->array, i);
|
442
441
|
VALUE val = Convert_UpbToRuby(msgval, self->type_info, self->arena);
|
443
442
|
rb_ary_push(ary, val);
|
444
443
|
}
|
@@ -474,17 +473,17 @@ VALUE RepeatedField_eq(VALUE _self, VALUE _other) {
|
|
474
473
|
|
475
474
|
self = ruby_to_RepeatedField(_self);
|
476
475
|
other = ruby_to_RepeatedField(_other);
|
477
|
-
size_t n =
|
476
|
+
size_t n = upb_Array_Size(self->array);
|
478
477
|
|
479
478
|
if (self->type_info.type != other->type_info.type ||
|
480
479
|
self->type_class != other->type_class ||
|
481
|
-
|
480
|
+
upb_Array_Size(other->array) != n) {
|
482
481
|
return Qfalse;
|
483
482
|
}
|
484
483
|
|
485
484
|
for (size_t i = 0; i < n; i++) {
|
486
|
-
|
487
|
-
|
485
|
+
upb_MessageValue val1 = upb_Array_Get(self->array, i);
|
486
|
+
upb_MessageValue val2 = upb_Array_Get(other->array, i);
|
488
487
|
if (!Msgval_IsEqual(val1, val2, self->type_info)) {
|
489
488
|
return Qfalse;
|
490
489
|
}
|
@@ -518,10 +517,10 @@ static VALUE RepeatedField_freeze(VALUE _self) {
|
|
518
517
|
VALUE RepeatedField_hash(VALUE _self) {
|
519
518
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
520
519
|
uint64_t hash = 0;
|
521
|
-
size_t n =
|
520
|
+
size_t n = upb_Array_Size(self->array);
|
522
521
|
|
523
522
|
for (size_t i = 0; i < n; i++) {
|
524
|
-
|
523
|
+
upb_MessageValue val = upb_Array_Get(self->array, i);
|
525
524
|
hash = Msgval_GetHash(val, self->type_info, hash);
|
526
525
|
}
|
527
526
|
|
@@ -550,9 +549,10 @@ VALUE RepeatedField_plus(VALUE _self, VALUE list) {
|
|
550
549
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
551
550
|
RepeatedField* list_rptfield = ruby_to_RepeatedField(list);
|
552
551
|
RepeatedField* dupped = ruby_to_RepeatedField(dupped_);
|
553
|
-
|
554
|
-
|
555
|
-
|
552
|
+
upb_Array* dupped_array = RepeatedField_GetMutable(dupped_);
|
553
|
+
upb_Arena* arena = Arena_get(dupped->arena);
|
554
|
+
Arena_fuse(list_rptfield->arena, arena);
|
555
|
+
int size = upb_Array_Size(list_rptfield->array);
|
556
556
|
int i;
|
557
557
|
|
558
558
|
if (self->type_info.type != list_rptfield->type_info.type ||
|
@@ -562,8 +562,8 @@ VALUE RepeatedField_plus(VALUE _self, VALUE list) {
|
|
562
562
|
}
|
563
563
|
|
564
564
|
for (i = 0; i < size; i++) {
|
565
|
-
|
566
|
-
|
565
|
+
upb_MessageValue msgval = upb_Array_Get(list_rptfield->array, i);
|
566
|
+
upb_Array_Append(dupped_array, msgval, arena);
|
567
567
|
}
|
568
568
|
} else {
|
569
569
|
rb_raise(rb_eArgError, "Unknown type appending to RepeatedField");
|
@@ -601,7 +601,7 @@ VALUE RepeatedField_concat(VALUE _self, VALUE list) {
|
|
601
601
|
*/
|
602
602
|
VALUE RepeatedField_init(int argc, VALUE* argv, VALUE _self) {
|
603
603
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
604
|
-
|
604
|
+
upb_Arena* arena;
|
605
605
|
VALUE ary = Qnil;
|
606
606
|
|
607
607
|
self->arena = Arena_new();
|
@@ -612,7 +612,7 @@ VALUE RepeatedField_init(int argc, VALUE* argv, VALUE _self) {
|
|
612
612
|
}
|
613
613
|
|
614
614
|
self->type_info = TypeInfo_FromClass(argc, argv, 0, &self->type_class, &ary);
|
615
|
-
self->array =
|
615
|
+
self->array = upb_Array_New(arena, self->type_info.type);
|
616
616
|
ObjectCache_Add(self->array, _self);
|
617
617
|
|
618
618
|
if (ary != Qnil) {
|
@@ -627,14 +627,12 @@ VALUE RepeatedField_init(int argc, VALUE* argv, VALUE _self) {
|
|
627
627
|
}
|
628
628
|
|
629
629
|
void RepeatedField_register(VALUE module) {
|
630
|
-
VALUE klass = rb_define_class_under(
|
631
|
-
module, "RepeatedField", rb_cObject);
|
630
|
+
VALUE klass = rb_define_class_under(module, "RepeatedField", rb_cObject);
|
632
631
|
rb_define_alloc_func(klass, RepeatedField_alloc);
|
633
632
|
rb_gc_register_address(&cRepeatedField);
|
634
633
|
cRepeatedField = klass;
|
635
634
|
|
636
|
-
rb_define_method(klass, "initialize",
|
637
|
-
RepeatedField_init, -1);
|
635
|
+
rb_define_method(klass, "initialize", RepeatedField_init, -1);
|
638
636
|
rb_define_method(klass, "each", RepeatedField_each, 0);
|
639
637
|
rb_define_method(klass, "[]", RepeatedField_index, -1);
|
640
638
|
rb_define_method(klass, "at", RepeatedField_index, -1);
|
@@ -36,19 +36,19 @@
|
|
36
36
|
#include "protobuf.h"
|
37
37
|
#include "ruby-upb.h"
|
38
38
|
|
39
|
-
// Returns a Ruby wrapper object for the given
|
39
|
+
// Returns a Ruby wrapper object for the given upb_Array, which will be created
|
40
40
|
// if one does not exist already.
|
41
|
-
VALUE RepeatedField_GetRubyWrapper(
|
41
|
+
VALUE RepeatedField_GetRubyWrapper(upb_Array* msg, TypeInfo type_info,
|
42
42
|
VALUE arena);
|
43
43
|
|
44
|
-
// Gets the underlying
|
44
|
+
// Gets the underlying upb_Array for this Ruby RepeatedField object, which must
|
45
45
|
// have a type that matches |f|. If this is not a repeated field or the type
|
46
46
|
// doesn't match, raises an exception.
|
47
|
-
const
|
48
|
-
|
47
|
+
const upb_Array* RepeatedField_GetUpbArray(VALUE value, const upb_FieldDef* f,
|
48
|
+
upb_Arena* arena);
|
49
49
|
|
50
50
|
// Implements #inspect for this repeated field by appending its contents to |b|.
|
51
|
-
void RepeatedField_Inspect(StringBuilder* b, const
|
51
|
+
void RepeatedField_Inspect(StringBuilder* b, const upb_Array* array,
|
52
52
|
TypeInfo info);
|
53
53
|
|
54
54
|
// Returns a deep copy of this RepeatedField object.
|