google-protobuf 3.19.6-x64-mingw32 → 3.20.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 +124 -111
- data/ext/google/protobuf_c/convert.h +12 -9
- data/ext/google/protobuf_c/defs.c +196 -201
- data/ext/google/protobuf_c/defs.h +19 -19
- data/ext/google/protobuf_c/extconf.rb +11 -3
- data/ext/google/protobuf_c/map.c +109 -101
- data/ext/google/protobuf_c/map.h +7 -8
- data/ext/google/protobuf_c/message.c +382 -303
- data/ext/google/protobuf_c/message.h +22 -19
- data/ext/google/protobuf_c/protobuf.c +57 -58
- data/ext/google/protobuf_c/protobuf.h +13 -10
- data/ext/google/protobuf_c/repeated_field.c +82 -84
- data/ext/google/protobuf_c/repeated_field.h +6 -6
- data/ext/google/protobuf_c/ruby-upb.c +4945 -3084
- data/ext/google/protobuf_c/ruby-upb.h +2285 -1701
- data/ext/google/protobuf_c/third_party/utf8_range/LICENSE +21 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c +395 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +9 -0
- data/ext/google/protobuf_c/wrap_memcpy.c +4 -3
- data/lib/google/2.5/protobuf_c.so +0 -0
- data/lib/google/2.6/protobuf_c.so +0 -0
- data/lib/google/2.7/protobuf_c.so +0 -0
- data/lib/google/3.0/protobuf_c.so +0 -0
- data/lib/google/protobuf/descriptor_dsl.rb +8 -1
- data/lib/google/protobuf/descriptor_pb.rb +3 -2
- data/lib/google/protobuf/message_exts.rb +2 -2
- data/lib/google/protobuf/well_known_types.rb +11 -6
- data/lib/google/protobuf.rb +4 -4
- data/tests/basic.rb +14 -0
- metadata +8 -5
@@ -40,10 +40,10 @@
|
|
40
40
|
// -----------------------------------------------------------------------------
|
41
41
|
|
42
42
|
typedef struct {
|
43
|
-
const
|
43
|
+
const upb_Array* array; // Can get as mutable when non-frozen.
|
44
44
|
TypeInfo type_info;
|
45
45
|
VALUE type_class; // To GC-root the msgdef/enumdef in type_info.
|
46
|
-
VALUE arena; // To GC-root the
|
46
|
+
VALUE arena; // To GC-root the upb_Array.
|
47
47
|
} RepeatedField;
|
48
48
|
|
49
49
|
VALUE cRepeatedField;
|
@@ -55,9 +55,9 @@ static void RepeatedField_mark(void* _self) {
|
|
55
55
|
}
|
56
56
|
|
57
57
|
const rb_data_type_t RepeatedField_type = {
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
"Google::Protobuf::RepeatedField",
|
59
|
+
{RepeatedField_mark, RUBY_DEFAULT_FREE, NULL},
|
60
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
61
61
|
};
|
62
62
|
|
63
63
|
static RepeatedField* ruby_to_RepeatedField(VALUE _self) {
|
@@ -66,9 +66,9 @@ static RepeatedField* ruby_to_RepeatedField(VALUE _self) {
|
|
66
66
|
return self;
|
67
67
|
}
|
68
68
|
|
69
|
-
static
|
69
|
+
static upb_Array* RepeatedField_GetMutable(VALUE _self) {
|
70
70
|
rb_check_frozen(_self);
|
71
|
-
return (
|
71
|
+
return (upb_Array*)ruby_to_RepeatedField(_self)->array;
|
72
72
|
}
|
73
73
|
|
74
74
|
VALUE RepeatedField_alloc(VALUE klass) {
|
@@ -79,7 +79,7 @@ VALUE RepeatedField_alloc(VALUE klass) {
|
|
79
79
|
return TypedData_Wrap_Struct(klass, &RepeatedField_type, self);
|
80
80
|
}
|
81
81
|
|
82
|
-
VALUE RepeatedField_GetRubyWrapper(
|
82
|
+
VALUE RepeatedField_GetRubyWrapper(upb_Array* array, TypeInfo type_info,
|
83
83
|
VALUE arena) {
|
84
84
|
PBRUBY_ASSERT(array);
|
85
85
|
VALUE val = ObjectCache_Get(array);
|
@@ -92,7 +92,7 @@ VALUE RepeatedField_GetRubyWrapper(upb_array* array, TypeInfo type_info,
|
|
92
92
|
self->array = array;
|
93
93
|
self->arena = arena;
|
94
94
|
self->type_info = type_info;
|
95
|
-
if (self->type_info.type ==
|
95
|
+
if (self->type_info.type == kUpb_CType_Message) {
|
96
96
|
self->type_class = Descriptor_DefToClass(type_info.def.msgdef);
|
97
97
|
}
|
98
98
|
}
|
@@ -105,24 +105,24 @@ VALUE RepeatedField_GetRubyWrapper(upb_array* array, TypeInfo type_info,
|
|
105
105
|
|
106
106
|
static VALUE RepeatedField_new_this_type(RepeatedField* from) {
|
107
107
|
VALUE arena_rb = Arena_new();
|
108
|
-
|
108
|
+
upb_Array* array = upb_Array_New(Arena_get(arena_rb), from->type_info.type);
|
109
109
|
VALUE ret = RepeatedField_GetRubyWrapper(array, from->type_info, arena_rb);
|
110
110
|
PBRUBY_ASSERT(ruby_to_RepeatedField(ret)->type_class == from->type_class);
|
111
111
|
return ret;
|
112
112
|
}
|
113
113
|
|
114
|
-
void RepeatedField_Inspect(StringBuilder* b, const
|
114
|
+
void RepeatedField_Inspect(StringBuilder* b, const upb_Array* array,
|
115
115
|
TypeInfo info) {
|
116
116
|
bool first = true;
|
117
117
|
StringBuilder_Printf(b, "[");
|
118
|
-
size_t n = array ?
|
118
|
+
size_t n = array ? upb_Array_Size(array) : 0;
|
119
119
|
for (size_t i = 0; i < n; i++) {
|
120
120
|
if (first) {
|
121
121
|
first = false;
|
122
122
|
} else {
|
123
123
|
StringBuilder_Printf(b, ", ");
|
124
124
|
}
|
125
|
-
StringBuilder_PrintMsgval(b,
|
125
|
+
StringBuilder_PrintMsgval(b, upb_Array_Get(array, i), info);
|
126
126
|
}
|
127
127
|
StringBuilder_Printf(b, "]");
|
128
128
|
}
|
@@ -132,24 +132,24 @@ VALUE RepeatedField_deep_copy(VALUE _self) {
|
|
132
132
|
VALUE new_rptfield = RepeatedField_new_this_type(self);
|
133
133
|
RepeatedField* new_self = ruby_to_RepeatedField(new_rptfield);
|
134
134
|
VALUE arena_rb = new_self->arena;
|
135
|
-
|
136
|
-
|
137
|
-
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);
|
138
138
|
|
139
|
-
|
139
|
+
upb_Array_Resize(new_array, elements, arena);
|
140
140
|
|
141
|
-
size_t size =
|
141
|
+
size_t size = upb_Array_Size(self->array);
|
142
142
|
for (size_t i = 0; i < size; i++) {
|
143
|
-
|
144
|
-
|
145
|
-
|
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);
|
146
146
|
}
|
147
147
|
|
148
148
|
return new_rptfield;
|
149
149
|
}
|
150
150
|
|
151
|
-
const
|
152
|
-
|
151
|
+
const upb_Array* RepeatedField_GetUpbArray(VALUE val, const upb_FieldDef* field,
|
152
|
+
upb_Arena* arena) {
|
153
153
|
RepeatedField* self;
|
154
154
|
TypeInfo type_info = TypeInfo_get(field);
|
155
155
|
|
@@ -173,17 +173,17 @@ const upb_array* RepeatedField_GetUpbArray(VALUE val, const upb_fielddef* field,
|
|
173
173
|
|
174
174
|
static int index_position(VALUE _index, RepeatedField* repeated_field) {
|
175
175
|
int index = NUM2INT(_index);
|
176
|
-
if (index < 0) index +=
|
176
|
+
if (index < 0) index += upb_Array_Size(repeated_field->array);
|
177
177
|
return index;
|
178
178
|
}
|
179
179
|
|
180
180
|
static VALUE RepeatedField_subarray(RepeatedField* self, long beg, long len) {
|
181
|
-
size_t size =
|
181
|
+
size_t size = upb_Array_Size(self->array);
|
182
182
|
VALUE ary = rb_ary_new2(size);
|
183
183
|
long i;
|
184
184
|
|
185
185
|
for (i = beg; i < beg + len; i++) {
|
186
|
-
|
186
|
+
upb_MessageValue msgval = upb_Array_Get(self->array, i);
|
187
187
|
VALUE elem = Convert_UpbToRuby(msgval, self->type_info, self->arena);
|
188
188
|
rb_ary_push(ary, elem);
|
189
189
|
}
|
@@ -200,18 +200,17 @@ static VALUE RepeatedField_subarray(RepeatedField* self, long beg, long len) {
|
|
200
200
|
*/
|
201
201
|
static VALUE RepeatedField_each(VALUE _self) {
|
202
202
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
203
|
-
int size =
|
203
|
+
int size = upb_Array_Size(self->array);
|
204
204
|
int i;
|
205
205
|
|
206
206
|
for (i = 0; i < size; i++) {
|
207
|
-
|
207
|
+
upb_MessageValue msgval = upb_Array_Get(self->array, i);
|
208
208
|
VALUE val = Convert_UpbToRuby(msgval, self->type_info, self->arena);
|
209
209
|
rb_yield(val);
|
210
210
|
}
|
211
211
|
return _self;
|
212
212
|
}
|
213
213
|
|
214
|
-
|
215
214
|
/*
|
216
215
|
* call-seq:
|
217
216
|
* RepeatedField.[](index) => value
|
@@ -220,20 +219,20 @@ static VALUE RepeatedField_each(VALUE _self) {
|
|
220
219
|
*/
|
221
220
|
static VALUE RepeatedField_index(int argc, VALUE* argv, VALUE _self) {
|
222
221
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
223
|
-
long size =
|
222
|
+
long size = upb_Array_Size(self->array);
|
224
223
|
|
225
224
|
VALUE arg = argv[0];
|
226
225
|
long beg, len;
|
227
226
|
|
228
|
-
if (argc == 1){
|
227
|
+
if (argc == 1) {
|
229
228
|
if (FIXNUM_P(arg)) {
|
230
229
|
/* standard case */
|
231
|
-
|
230
|
+
upb_MessageValue msgval;
|
232
231
|
int index = index_position(argv[0], self);
|
233
|
-
if (index < 0 || (size_t)index >=
|
232
|
+
if (index < 0 || (size_t)index >= upb_Array_Size(self->array)) {
|
234
233
|
return Qnil;
|
235
234
|
}
|
236
|
-
msgval =
|
235
|
+
msgval = upb_Array_Get(self->array, index);
|
237
236
|
return Convert_UpbToRuby(msgval, self->type_info, self->arena);
|
238
237
|
} else {
|
239
238
|
/* check if idx is Range */
|
@@ -269,10 +268,10 @@ static VALUE RepeatedField_index(int argc, VALUE* argv, VALUE _self) {
|
|
269
268
|
*/
|
270
269
|
static VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val) {
|
271
270
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
272
|
-
int size =
|
273
|
-
|
274
|
-
|
275
|
-
|
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);
|
276
275
|
|
277
276
|
int index = index_position(_index, self);
|
278
277
|
if (index < 0 || index >= (INT_MAX - 1)) {
|
@@ -280,17 +279,17 @@ static VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val) {
|
|
280
279
|
}
|
281
280
|
|
282
281
|
if (index >= size) {
|
283
|
-
|
284
|
-
|
282
|
+
upb_Array_Resize(array, index + 1, arena);
|
283
|
+
upb_MessageValue fill;
|
285
284
|
memset(&fill, 0, sizeof(fill));
|
286
285
|
for (int i = size; i < index; i++) {
|
287
286
|
// Fill default values.
|
288
287
|
// TODO(haberman): should this happen at the upb level?
|
289
|
-
|
288
|
+
upb_Array_Set(array, i, fill);
|
290
289
|
}
|
291
290
|
}
|
292
291
|
|
293
|
-
|
292
|
+
upb_Array_Set(array, index, msgval);
|
294
293
|
return Qnil;
|
295
294
|
}
|
296
295
|
|
@@ -302,13 +301,14 @@ static VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val) {
|
|
302
301
|
*/
|
303
302
|
static VALUE RepeatedField_push_vararg(int argc, VALUE* argv, VALUE _self) {
|
304
303
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
305
|
-
|
306
|
-
|
304
|
+
upb_Arena* arena = Arena_get(self->arena);
|
305
|
+
upb_Array* array = RepeatedField_GetMutable(_self);
|
307
306
|
int i;
|
308
307
|
|
309
308
|
for (i = 0; i < argc; i++) {
|
310
|
-
|
311
|
-
|
309
|
+
upb_MessageValue msgval =
|
310
|
+
Convert_RubyToUpb(argv[i], "", self->type_info, arena);
|
311
|
+
upb_Array_Append(array, msgval, arena);
|
312
312
|
}
|
313
313
|
|
314
314
|
return _self;
|
@@ -322,11 +322,11 @@ static VALUE RepeatedField_push_vararg(int argc, VALUE* argv, VALUE _self) {
|
|
322
322
|
*/
|
323
323
|
static VALUE RepeatedField_push(VALUE _self, VALUE val) {
|
324
324
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
325
|
-
|
326
|
-
|
325
|
+
upb_Arena* arena = Arena_get(self->arena);
|
326
|
+
upb_Array* array = RepeatedField_GetMutable(_self);
|
327
327
|
|
328
|
-
|
329
|
-
|
328
|
+
upb_MessageValue msgval = Convert_RubyToUpb(val, "", self->type_info, arena);
|
329
|
+
upb_Array_Append(array, msgval, arena);
|
330
330
|
|
331
331
|
return _self;
|
332
332
|
}
|
@@ -336,19 +336,19 @@ static VALUE RepeatedField_push(VALUE _self, VALUE val) {
|
|
336
336
|
*/
|
337
337
|
static VALUE RepeatedField_pop_one(VALUE _self) {
|
338
338
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
339
|
-
size_t size =
|
340
|
-
|
341
|
-
|
339
|
+
size_t size = upb_Array_Size(self->array);
|
340
|
+
upb_Array* array = RepeatedField_GetMutable(_self);
|
341
|
+
upb_MessageValue last;
|
342
342
|
VALUE ret;
|
343
343
|
|
344
344
|
if (size == 0) {
|
345
345
|
return Qnil;
|
346
346
|
}
|
347
347
|
|
348
|
-
last =
|
348
|
+
last = upb_Array_Get(self->array, size - 1);
|
349
349
|
ret = Convert_UpbToRuby(last, self->type_info, self->arena);
|
350
350
|
|
351
|
-
|
351
|
+
upb_Array_Resize(array, size - 1, Arena_get(self->arena));
|
352
352
|
return ret;
|
353
353
|
}
|
354
354
|
|
@@ -360,11 +360,11 @@ static VALUE RepeatedField_pop_one(VALUE _self) {
|
|
360
360
|
*/
|
361
361
|
static VALUE RepeatedField_replace(VALUE _self, VALUE list) {
|
362
362
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
363
|
-
|
363
|
+
upb_Array* array = RepeatedField_GetMutable(_self);
|
364
364
|
int i;
|
365
365
|
|
366
366
|
Check_Type(list, T_ARRAY);
|
367
|
-
|
367
|
+
upb_Array_Resize(array, 0, Arena_get(self->arena));
|
368
368
|
|
369
369
|
for (i = 0; i < RARRAY_LEN(list); i++) {
|
370
370
|
RepeatedField_push(_self, rb_ary_entry(list, i));
|
@@ -381,8 +381,8 @@ static VALUE RepeatedField_replace(VALUE _self, VALUE list) {
|
|
381
381
|
*/
|
382
382
|
static VALUE RepeatedField_clear(VALUE _self) {
|
383
383
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
384
|
-
|
385
|
-
|
384
|
+
upb_Array* array = RepeatedField_GetMutable(_self);
|
385
|
+
upb_Array_Resize(array, 0, Arena_get(self->arena));
|
386
386
|
return _self;
|
387
387
|
}
|
388
388
|
|
@@ -394,7 +394,7 @@ static VALUE RepeatedField_clear(VALUE _self) {
|
|
394
394
|
*/
|
395
395
|
static VALUE RepeatedField_length(VALUE _self) {
|
396
396
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
397
|
-
return INT2NUM(
|
397
|
+
return INT2NUM(upb_Array_Size(self->array));
|
398
398
|
}
|
399
399
|
|
400
400
|
/*
|
@@ -408,16 +408,16 @@ static VALUE RepeatedField_dup(VALUE _self) {
|
|
408
408
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
409
409
|
VALUE new_rptfield = RepeatedField_new_this_type(self);
|
410
410
|
RepeatedField* new_rptfield_self = ruby_to_RepeatedField(new_rptfield);
|
411
|
-
|
412
|
-
|
413
|
-
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);
|
414
414
|
int i;
|
415
415
|
|
416
416
|
Arena_fuse(self->arena, arena);
|
417
417
|
|
418
418
|
for (i = 0; i < size; i++) {
|
419
|
-
|
420
|
-
|
419
|
+
upb_MessageValue msgval = upb_Array_Get(self->array, i);
|
420
|
+
upb_Array_Append(new_array, msgval, arena);
|
421
421
|
}
|
422
422
|
|
423
423
|
return new_rptfield;
|
@@ -432,12 +432,12 @@ static VALUE RepeatedField_dup(VALUE _self) {
|
|
432
432
|
*/
|
433
433
|
VALUE RepeatedField_to_ary(VALUE _self) {
|
434
434
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
435
|
-
int size =
|
435
|
+
int size = upb_Array_Size(self->array);
|
436
436
|
VALUE ary = rb_ary_new2(size);
|
437
437
|
int i;
|
438
438
|
|
439
439
|
for (i = 0; i < size; i++) {
|
440
|
-
|
440
|
+
upb_MessageValue msgval = upb_Array_Get(self->array, i);
|
441
441
|
VALUE val = Convert_UpbToRuby(msgval, self->type_info, self->arena);
|
442
442
|
rb_ary_push(ary, val);
|
443
443
|
}
|
@@ -473,17 +473,17 @@ VALUE RepeatedField_eq(VALUE _self, VALUE _other) {
|
|
473
473
|
|
474
474
|
self = ruby_to_RepeatedField(_self);
|
475
475
|
other = ruby_to_RepeatedField(_other);
|
476
|
-
size_t n =
|
476
|
+
size_t n = upb_Array_Size(self->array);
|
477
477
|
|
478
478
|
if (self->type_info.type != other->type_info.type ||
|
479
479
|
self->type_class != other->type_class ||
|
480
|
-
|
480
|
+
upb_Array_Size(other->array) != n) {
|
481
481
|
return Qfalse;
|
482
482
|
}
|
483
483
|
|
484
484
|
for (size_t i = 0; i < n; i++) {
|
485
|
-
|
486
|
-
|
485
|
+
upb_MessageValue val1 = upb_Array_Get(self->array, i);
|
486
|
+
upb_MessageValue val2 = upb_Array_Get(other->array, i);
|
487
487
|
if (!Msgval_IsEqual(val1, val2, self->type_info)) {
|
488
488
|
return Qfalse;
|
489
489
|
}
|
@@ -517,10 +517,10 @@ static VALUE RepeatedField_freeze(VALUE _self) {
|
|
517
517
|
VALUE RepeatedField_hash(VALUE _self) {
|
518
518
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
519
519
|
uint64_t hash = 0;
|
520
|
-
size_t n =
|
520
|
+
size_t n = upb_Array_Size(self->array);
|
521
521
|
|
522
522
|
for (size_t i = 0; i < n; i++) {
|
523
|
-
|
523
|
+
upb_MessageValue val = upb_Array_Get(self->array, i);
|
524
524
|
hash = Msgval_GetHash(val, self->type_info, hash);
|
525
525
|
}
|
526
526
|
|
@@ -549,10 +549,10 @@ VALUE RepeatedField_plus(VALUE _self, VALUE list) {
|
|
549
549
|
RepeatedField* self = ruby_to_RepeatedField(_self);
|
550
550
|
RepeatedField* list_rptfield = ruby_to_RepeatedField(list);
|
551
551
|
RepeatedField* dupped = ruby_to_RepeatedField(dupped_);
|
552
|
-
|
553
|
-
|
552
|
+
upb_Array* dupped_array = RepeatedField_GetMutable(dupped_);
|
553
|
+
upb_Arena* arena = Arena_get(dupped->arena);
|
554
554
|
Arena_fuse(list_rptfield->arena, arena);
|
555
|
-
int size =
|
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.
|