protobuf/ruby/ext/google/protobuf_c/repeated_field.c
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2014 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #include "repeated_field.h"
32 
33 #include "convert.h"
34 #include "defs.h"
35 #include "message.h"
36 #include "protobuf.h"
37 
38 // -----------------------------------------------------------------------------
39 // Repeated field container type.
40 // -----------------------------------------------------------------------------
41 
42 typedef struct {
43  const upb_array *array; // Can get as mutable when non-frozen.
45  VALUE type_class; // To GC-root the msgdef/enumdef in type_info.
46  VALUE arena; // To GC-root the upb_array.
48 
50 
51 static void RepeatedField_mark(void* _self) {
52  RepeatedField* self = (RepeatedField*)_self;
53  rb_gc_mark(self->type_class);
54  rb_gc_mark(self->arena);
55 }
56 
57 const rb_data_type_t RepeatedField_type = {
58  "Google::Protobuf::RepeatedField",
59  { RepeatedField_mark, RUBY_DEFAULT_FREE, NULL },
60  .flags = RUBY_TYPED_FREE_IMMEDIATELY,
61 };
62 
63 static RepeatedField* ruby_to_RepeatedField(VALUE _self) {
64  RepeatedField* self;
65  TypedData_Get_Struct(_self, RepeatedField, &RepeatedField_type, self);
66  return self;
67 }
68 
69 static upb_array *RepeatedField_GetMutable(VALUE _self) {
70  rb_check_frozen(_self);
71  return (upb_array*)ruby_to_RepeatedField(_self)->array;
72 }
73 
74 VALUE RepeatedField_alloc(VALUE klass) {
76  self->arena = Qnil;
77  self->type_class = Qnil;
78  self->array = NULL;
79  return TypedData_Wrap_Struct(klass, &RepeatedField_type, self);
80 }
81 
83  VALUE arena) {
85  VALUE val = ObjectCache_Get(array);
86 
87  if (val == Qnil) {
89  RepeatedField* self;
90  ObjectCache_Add(array, val);
91  TypedData_Get_Struct(val, RepeatedField, &RepeatedField_type, self);
92  self->array = array;
93  self->arena = arena;
94  self->type_info = type_info;
95  if (self->type_info.type == UPB_TYPE_MESSAGE) {
96  self->type_class = Descriptor_DefToClass(type_info.def.msgdef);
97  }
98  }
99 
100  PBRUBY_ASSERT(ruby_to_RepeatedField(val)->type_info.type == type_info.type);
101  PBRUBY_ASSERT(ruby_to_RepeatedField(val)->type_info.def.msgdef ==
102  type_info.def.msgdef);
103  return val;
104 }
105 
107  VALUE arena_rb = Arena_new();
108  upb_array *array = upb_array_new(Arena_get(arena_rb), from->type_info.type);
109  VALUE ret = RepeatedField_GetRubyWrapper(array, from->type_info, arena_rb);
110  PBRUBY_ASSERT(ruby_to_RepeatedField(ret)->type_class == from->type_class);
111  return ret;
112 }
113 
115  TypeInfo info) {
116  bool first = true;
117  StringBuilder_Printf(b, "[");
118  size_t n = array ? upb_array_size(array) : 0;
119  for (size_t i = 0; i < n; i++) {
120  if (first) {
121  first = false;
122  } else {
123  StringBuilder_Printf(b, ", ");
124  }
126  }
127  StringBuilder_Printf(b, "]");
128 }
129 
130 VALUE RepeatedField_deep_copy(VALUE _self) {
131  RepeatedField* self = ruby_to_RepeatedField(_self);
132  VALUE new_rptfield = RepeatedField_new_this_type(self);
133  RepeatedField* new_self = ruby_to_RepeatedField(new_rptfield);
134  VALUE arena_rb = new_self->arena;
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 
139  upb_array_resize(new_array, elements, arena);
140 
141  size_t size = upb_array_size(self->array);
142  for (size_t i = 0; i < size; i++) {
143  upb_msgval msgval = upb_array_get(self->array, i);
144  upb_msgval copy = Msgval_DeepCopy(msgval, self->type_info, arena);
145  upb_array_set(new_array, i, copy);
146  }
147 
148  return new_rptfield;
149 }
150 
152  upb_arena* arena) {
153  RepeatedField* self;
154  TypeInfo type_info = TypeInfo_get(field);
155 
156  if (!RB_TYPE_P(val, T_DATA) || !RTYPEDDATA_P(val) ||
157  RTYPEDDATA_TYPE(val) != &RepeatedField_type) {
158  rb_raise(cTypeError, "Expected repeated field array");
159  }
160 
161  self = ruby_to_RepeatedField(val);
162  if (self->type_info.type != type_info.type) {
163  rb_raise(cTypeError, "Repeated field array has wrong element type");
164  }
165 
166  if (self->type_info.def.msgdef != type_info.def.msgdef) {
167  rb_raise(cTypeError, "Repeated field array has wrong message/enum class");
168  }
169 
170  Arena_fuse(self->arena, arena);
171  return self->array;
172 }
173 
174 static int index_position(VALUE _index, RepeatedField* repeated_field) {
175  int index = NUM2INT(_index);
176  if (index < 0) index += upb_array_size(repeated_field->array);
177  return index;
178 }
179 
180 static VALUE RepeatedField_subarray(RepeatedField* self, long beg, long len) {
181  size_t size = upb_array_size(self->array);
182  VALUE ary = rb_ary_new2(size);
183  long i;
184 
185  for (i = beg; i < beg + len; i++) {
186  upb_msgval msgval = upb_array_get(self->array, i);
187  VALUE elem = Convert_UpbToRuby(msgval, self->type_info, self->arena);
188  rb_ary_push(ary, elem);
189  }
190  return ary;
191 }
192 
193 /*
194  * call-seq:
195  * RepeatedField.each(&block)
196  *
197  * Invokes the block once for each element of the repeated field. RepeatedField
198  * also includes Enumerable; combined with this method, the repeated field thus
199  * acts like an ordinary Ruby sequence.
200  */
201 static VALUE RepeatedField_each(VALUE _self) {
202  RepeatedField* self = ruby_to_RepeatedField(_self);
203  int size = upb_array_size(self->array);
204  int i;
205 
206  for (i = 0; i < size; i++) {
207  upb_msgval msgval = upb_array_get(self->array, i);
208  VALUE val = Convert_UpbToRuby(msgval, self->type_info, self->arena);
209  rb_yield(val);
210  }
211  return _self;
212 }
213 
214 
215 /*
216  * call-seq:
217  * RepeatedField.[](index) => value
218  *
219  * Accesses the element at the given index. Returns nil on out-of-bounds
220  */
221 static VALUE RepeatedField_index(int argc, VALUE* argv, VALUE _self) {
222  RepeatedField* self = ruby_to_RepeatedField(_self);
223  long size = upb_array_size(self->array);
224 
225  VALUE arg = argv[0];
226  long beg, len;
227 
228  if (argc == 1){
229  if (FIXNUM_P(arg)) {
230  /* standard case */
231  upb_msgval msgval;
232  int index = index_position(argv[0], self);
233  if (index < 0 || (size_t)index >= upb_array_size(self->array)) {
234  return Qnil;
235  }
236  msgval = upb_array_get(self->array, index);
237  return Convert_UpbToRuby(msgval, self->type_info, self->arena);
238  } else {
239  /* check if idx is Range */
240  switch (rb_range_beg_len(arg, &beg, &len, size, 0)) {
241  case Qfalse:
242  break;
243  case Qnil:
244  return Qnil;
245  default:
246  return RepeatedField_subarray(self, beg, len);
247  }
248  }
249  }
250 
251  /* assume 2 arguments */
252  beg = NUM2LONG(argv[0]);
253  len = NUM2LONG(argv[1]);
254  if (beg < 0) {
255  beg += size;
256  }
257  if (beg >= size) {
258  return Qnil;
259  }
260  return RepeatedField_subarray(self, beg, len);
261 }
262 
263 /*
264  * call-seq:
265  * RepeatedField.[]=(index, value)
266  *
267  * Sets the element at the given index. On out-of-bounds assignments, extends
268  * the array and fills the hole (if any) with default values.
269  */
270 static VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val) {
271  RepeatedField* self = ruby_to_RepeatedField(_self);
272  int size = upb_array_size(self->array);
274  upb_arena *arena = Arena_get(self->arena);
275  upb_msgval msgval = Convert_RubyToUpb(val, "", self->type_info, arena);
276 
277  int index = index_position(_index, self);
278  if (index < 0 || index >= (INT_MAX - 1)) {
279  return Qnil;
280  }
281 
282  if (index >= size) {
285  memset(&fill, 0, sizeof(fill));
286  for (int i = size; i < index; i++) {
287  // Fill default values.
288  // TODO(haberman): should this happen at the upb level?
290  }
291  }
292 
293  upb_array_set(array, index, msgval);
294  return Qnil;
295 }
296 
297 /*
298  * call-seq:
299  * RepeatedField.push(value, ...)
300  *
301  * Adds a new element to the repeated field.
302  */
303 static VALUE RepeatedField_push_vararg(int argc, VALUE* argv, VALUE _self) {
304  RepeatedField* self = ruby_to_RepeatedField(_self);
305  upb_arena *arena = Arena_get(self->arena);
307  int i;
308 
309  for (i = 0; i < argc; i++) {
310  upb_msgval msgval = Convert_RubyToUpb(argv[i], "", self->type_info, arena);
311  upb_array_append(array, msgval, arena);
312  }
313 
314  return _self;
315 }
316 
317 /*
318  * call-seq:
319  * RepeatedField.<<(value)
320  *
321  * Adds a new element to the repeated field.
322  */
323 static VALUE RepeatedField_push(VALUE _self, VALUE val) {
324  RepeatedField* self = ruby_to_RepeatedField(_self);
325  upb_arena *arena = Arena_get(self->arena);
327 
328  upb_msgval msgval = Convert_RubyToUpb(val, "", self->type_info, arena);
329  upb_array_append(array, msgval, arena);
330 
331  return _self;
332 }
333 
334 /*
335  * Private ruby method, used by RepeatedField.pop
336  */
337 static VALUE RepeatedField_pop_one(VALUE _self) {
338  RepeatedField* self = ruby_to_RepeatedField(_self);
339  size_t size = upb_array_size(self->array);
341  upb_msgval last;
342  VALUE ret;
343 
344  if (size == 0) {
345  return Qnil;
346  }
347 
348  last = upb_array_get(self->array, size - 1);
349  ret = Convert_UpbToRuby(last, self->type_info, self->arena);
350 
351  upb_array_resize(array, size - 1, Arena_get(self->arena));
352  return ret;
353 }
354 
355 /*
356  * call-seq:
357  * RepeatedField.replace(list)
358  *
359  * Replaces the contents of the repeated field with the given list of elements.
360  */
361 static VALUE RepeatedField_replace(VALUE _self, VALUE list) {
362  RepeatedField* self = ruby_to_RepeatedField(_self);
364  int i;
365 
366  Check_Type(list, T_ARRAY);
367  upb_array_resize(array, 0, Arena_get(self->arena));
368 
369  for (i = 0; i < RARRAY_LEN(list); i++) {
370  RepeatedField_push(_self, rb_ary_entry(list, i));
371  }
372 
373  return list;
374 }
375 
376 /*
377  * call-seq:
378  * RepeatedField.clear
379  *
380  * Clears (removes all elements from) this repeated field.
381  */
382 static VALUE RepeatedField_clear(VALUE _self) {
383  RepeatedField* self = ruby_to_RepeatedField(_self);
385  upb_array_resize(array, 0, Arena_get(self->arena));
386  return _self;
387 }
388 
389 /*
390  * call-seq:
391  * RepeatedField.length
392  *
393  * Returns the length of this repeated field.
394  */
395 static VALUE RepeatedField_length(VALUE _self) {
396  RepeatedField* self = ruby_to_RepeatedField(_self);
397  return INT2NUM(upb_array_size(self->array));
398 }
399 
400 /*
401  * call-seq:
402  * RepeatedField.dup => repeated_field
403  *
404  * Duplicates this repeated field with a shallow copy. References to all
405  * non-primitive element objects (e.g., submessages) are shared.
406  */
407 static VALUE RepeatedField_dup(VALUE _self) {
408  RepeatedField* self = ruby_to_RepeatedField(_self);
409  VALUE new_rptfield = RepeatedField_new_this_type(self);
410  RepeatedField* new_rptfield_self = ruby_to_RepeatedField(new_rptfield);
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  int i;
415 
416  Arena_fuse(self->arena, arena);
417 
418  for (i = 0; i < size; i++) {
419  upb_msgval msgval = upb_array_get(self->array, i);
420  upb_array_append(new_array, msgval, arena);
421  }
422 
423  return new_rptfield;
424 }
425 
426 /*
427  * call-seq:
428  * RepeatedField.to_ary => array
429  *
430  * Used when converted implicitly into array, e.g. compared to an Array.
431  * Also called as a fallback of Object#to_a
432  */
433 VALUE RepeatedField_to_ary(VALUE _self) {
434  RepeatedField* self = ruby_to_RepeatedField(_self);
435  int size = upb_array_size(self->array);
436  VALUE ary = rb_ary_new2(size);
437  int i;
438 
439  for (i = 0; i < size; i++) {
440  upb_msgval msgval = upb_array_get(self->array, i);
441  VALUE val = Convert_UpbToRuby(msgval, self->type_info, self->arena);
442  rb_ary_push(ary, val);
443  }
444 
445  return ary;
446 }
447 
448 /*
449  * call-seq:
450  * RepeatedField.==(other) => boolean
451  *
452  * Compares this repeated field to another. Repeated fields are equal if their
453  * element types are equal, their lengths are equal, and each element is equal.
454  * Elements are compared as per normal Ruby semantics, by calling their :==
455  * methods (or performing a more efficient comparison for primitive types).
456  *
457  * Repeated fields with dissimilar element types are never equal, even if value
458  * comparison (for example, between integers and floats) would have otherwise
459  * indicated that every element has equal value.
460  */
461 VALUE RepeatedField_eq(VALUE _self, VALUE _other) {
462  RepeatedField* self;
463  RepeatedField* other;
464 
465  if (_self == _other) {
466  return Qtrue;
467  }
468 
469  if (TYPE(_other) == T_ARRAY) {
470  VALUE self_ary = RepeatedField_to_ary(_self);
471  return rb_equal(self_ary, _other);
472  }
473 
474  self = ruby_to_RepeatedField(_self);
475  other = ruby_to_RepeatedField(_other);
476  size_t n = upb_array_size(self->array);
477 
478  if (self->type_info.type != other->type_info.type ||
479  self->type_class != other->type_class ||
480  upb_array_size(other->array) != n) {
481  return Qfalse;
482  }
483 
484  for (size_t i = 0; i < n; i++) {
485  upb_msgval val1 = upb_array_get(self->array, i);
486  upb_msgval val2 = upb_array_get(other->array, i);
487  if (!Msgval_IsEqual(val1, val2, self->type_info)) {
488  return Qfalse;
489  }
490  }
491 
492  return Qtrue;
493 }
494 
495 /*
496  * call-seq:
497  * RepeatedField.freeze => self
498  *
499  * Freezes the repeated field. We have to intercept this so we can pin the Ruby
500  * object into memory so we don't forget it's frozen.
501  */
502 static VALUE RepeatedField_freeze(VALUE _self) {
503  RepeatedField* self = ruby_to_RepeatedField(_self);
504  if (!RB_OBJ_FROZEN(_self)) {
505  Arena_Pin(self->arena, _self);
506  RB_OBJ_FREEZE(_self);
507  }
508  return _self;
509 }
510 
511 /*
512  * call-seq:
513  * RepeatedField.hash => hash_value
514  *
515  * Returns a hash value computed from this repeated field's elements.
516  */
517 VALUE RepeatedField_hash(VALUE _self) {
518  RepeatedField* self = ruby_to_RepeatedField(_self);
519  uint64_t hash = 0;
520  size_t n = upb_array_size(self->array);
521 
522  for (size_t i = 0; i < n; i++) {
523  upb_msgval val = upb_array_get(self->array, i);
524  hash = Msgval_GetHash(val, self->type_info, hash);
525  }
526 
527  return LL2NUM(hash);
528 }
529 
530 /*
531  * call-seq:
532  * RepeatedField.+(other) => repeated field
533  *
534  * Returns a new repeated field that contains the concatenated list of this
535  * repeated field's elements and other's elements. The other (second) list may
536  * be either another repeated field or a Ruby array.
537  */
538 VALUE RepeatedField_plus(VALUE _self, VALUE list) {
539  VALUE dupped_ = RepeatedField_dup(_self);
540 
541  if (TYPE(list) == T_ARRAY) {
542  int i;
543  for (i = 0; i < RARRAY_LEN(list); i++) {
544  VALUE elem = rb_ary_entry(list, i);
545  RepeatedField_push(dupped_, elem);
546  }
547  } else if (RB_TYPE_P(list, T_DATA) && RTYPEDDATA_P(list) &&
548  RTYPEDDATA_TYPE(list) == &RepeatedField_type) {
549  RepeatedField* self = ruby_to_RepeatedField(_self);
550  RepeatedField* list_rptfield = ruby_to_RepeatedField(list);
551  RepeatedField* dupped = ruby_to_RepeatedField(dupped_);
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  int i;
557 
558  if (self->type_info.type != list_rptfield->type_info.type ||
559  self->type_class != list_rptfield->type_class) {
560  rb_raise(rb_eArgError,
561  "Attempt to append RepeatedField with different element type.");
562  }
563 
564  for (i = 0; i < size; i++) {
565  upb_msgval msgval = upb_array_get(list_rptfield->array, i);
566  upb_array_append(dupped_array, msgval, arena);
567  }
568  } else {
569  rb_raise(rb_eArgError, "Unknown type appending to RepeatedField");
570  }
571 
572  return dupped_;
573 }
574 
575 /*
576  * call-seq:
577  * RepeatedField.concat(other) => self
578  *
579  * concats the passed in array to self. Returns a Ruby array.
580  */
581 VALUE RepeatedField_concat(VALUE _self, VALUE list) {
582  int i;
583 
584  Check_Type(list, T_ARRAY);
585  for (i = 0; i < RARRAY_LEN(list); i++) {
586  RepeatedField_push(_self, rb_ary_entry(list, i));
587  }
588  return _self;
589 }
590 
591 /*
592  * call-seq:
593  * RepeatedField.new(type, type_class = nil, initial_elems = [])
594  *
595  * Creates a new repeated field. The provided type must be a Ruby symbol, and
596  * can take on the same values as those accepted by FieldDescriptor#type=. If
597  * the type is :message or :enum, type_class must be non-nil, and must be the
598  * Ruby class or module returned by Descriptor#msgclass or
599  * EnumDescriptor#enummodule, respectively. An initial list of elements may also
600  * be provided.
601  */
602 VALUE RepeatedField_init(int argc, VALUE* argv, VALUE _self) {
603  RepeatedField* self = ruby_to_RepeatedField(_self);
604  upb_arena *arena;
605  VALUE ary = Qnil;
606 
607  self->arena = Arena_new();
608  arena = Arena_get(self->arena);
609 
610  if (argc < 1) {
611  rb_raise(rb_eArgError, "Expected at least 1 argument.");
612  }
613 
614  self->type_info = TypeInfo_FromClass(argc, argv, 0, &self->type_class, &ary);
615  self->array = upb_array_new(arena, self->type_info.type);
616  ObjectCache_Add(self->array, _self);
617 
618  if (ary != Qnil) {
619  if (!RB_TYPE_P(ary, T_ARRAY)) {
620  rb_raise(rb_eArgError, "Expected array as initialize argument");
621  }
622  for (int i = 0; i < RARRAY_LEN(ary); i++) {
623  RepeatedField_push(_self, rb_ary_entry(ary, i));
624  }
625  }
626  return Qnil;
627 }
628 
630  VALUE klass = rb_define_class_under(
631  module, "RepeatedField", rb_cObject);
632  rb_define_alloc_func(klass, RepeatedField_alloc);
633  rb_gc_register_address(&cRepeatedField);
635 
636  rb_define_method(klass, "initialize",
637  RepeatedField_init, -1);
638  rb_define_method(klass, "each", RepeatedField_each, 0);
639  rb_define_method(klass, "[]", RepeatedField_index, -1);
640  rb_define_method(klass, "at", RepeatedField_index, -1);
641  rb_define_method(klass, "[]=", RepeatedField_index_set, 2);
642  rb_define_method(klass, "push", RepeatedField_push_vararg, -1);
643  rb_define_method(klass, "<<", RepeatedField_push, 1);
644  rb_define_private_method(klass, "pop_one", RepeatedField_pop_one, 0);
645  rb_define_method(klass, "replace", RepeatedField_replace, 1);
646  rb_define_method(klass, "clear", RepeatedField_clear, 0);
647  rb_define_method(klass, "length", RepeatedField_length, 0);
648  rb_define_method(klass, "size", RepeatedField_length, 0);
649  rb_define_method(klass, "dup", RepeatedField_dup, 0);
650  // Also define #clone so that we don't inherit Object#clone.
651  rb_define_method(klass, "clone", RepeatedField_dup, 0);
652  rb_define_method(klass, "==", RepeatedField_eq, 1);
653  rb_define_method(klass, "to_ary", RepeatedField_to_ary, 0);
654  rb_define_method(klass, "freeze", RepeatedField_freeze, 0);
655  rb_define_method(klass, "hash", RepeatedField_hash, 0);
656  rb_define_method(klass, "+", RepeatedField_plus, 1);
657  rb_define_method(klass, "concat", RepeatedField_concat, 1);
658  rb_include_module(klass, rb_mEnumerable);
659 }
RepeatedField_subarray
static VALUE RepeatedField_subarray(RepeatedField *self, long beg, long len)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:180
RepeatedField_alloc
VALUE RepeatedField_alloc(VALUE klass)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:74
grpc::testing::val1
const char val1[]
Definition: client_context_test_peer_test.cc:34
upb_arena
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2252
Convert_RubyToUpb
upb_msgval Convert_RubyToUpb(VALUE value, const char *name, TypeInfo type_info, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/convert.c:127
cRepeatedField
VALUE cRepeatedField
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:49
Convert_UpbToRuby
VALUE Convert_UpbToRuby(upb_msgval upb_val, TypeInfo type_info, VALUE arena)
Definition: protobuf/ruby/ext/google/protobuf_c/convert.c:230
memset
return memset(p, 0, total)
StringBuilder
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:57
RepeatedField::array
upb_array * array
Definition: protobuf/php/ext/google/protobuf/array.c:57
copy
static int copy(grpc_slice_buffer *input, grpc_slice_buffer *output)
Definition: message_compress.cc:145
array
PHP_PROTO_OBJECT_FREE_END PHP_PROTO_OBJECT_DTOR_END intern array
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/array.c:111
Descriptor_DefToClass
VALUE Descriptor_DefToClass(const upb_msgdef *m)
Definition: protobuf/ruby/ext/google/protobuf_c/defs.c:1213
elem
Timer elem
Definition: event_engine/iomgr_event_engine/timer_heap_test.cc:109
Arena_Pin
void Arena_Pin(VALUE _arena, VALUE obj)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:221
upb_array_append
bool upb_array_append(upb_array *arr, upb_msgval val, upb_arena *arena)
Definition: php-upb.c:7280
TypeInfo
Definition: protobuf/php/ext/google/protobuf/def.h:69
PBRUBY_ASSERT
#define PBRUBY_ASSERT(expr)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.h:110
TypeInfo_FromClass
TypeInfo TypeInfo_FromClass(int argc, VALUE *argv, int skip_arg, VALUE *type_class, VALUE *init_arg)
Definition: protobuf/ruby/ext/google/protobuf_c/defs.c:1238
index_position
static int index_position(VALUE _index, RepeatedField *repeated_field)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:174
RepeatedField_hash
VALUE RepeatedField_hash(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:517
RepeatedField_register
void RepeatedField_register(VALUE module)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:629
Arena_get
upb_arena * Arena_get(VALUE _arena)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:201
RepeatedField_push_vararg
static VALUE RepeatedField_push_vararg(int argc, VALUE *argv, VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:303
repeated_field
PHP_PROTO_OBJECT_FREE_END PHP_PROTO_OBJECT_DTOR_END intern repeated_field
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/array.c:486
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
Msgval_IsEqual
bool Msgval_IsEqual(upb_msgval val1, upb_msgval val2, TypeInfo type_info)
Definition: protobuf/ruby/ext/google/protobuf_c/convert.c:302
RepeatedField_Inspect
void RepeatedField_Inspect(StringBuilder *b, const upb_array *array, TypeInfo info)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:114
hash
uint64_t hash
Definition: ring_hash.cc:284
RepeatedField_eq
VALUE RepeatedField_eq(VALUE _self, VALUE _other)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:461
from
size_t from
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1384
upb_array_set
void upb_array_set(upb_array *arr, size_t i, upb_msgval val)
Definition: php-upb.c:7273
RepeatedField_mark
static void RepeatedField_mark(void *_self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:51
RepeatedField
struct RepeatedField RepeatedField
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:667
RepeatedField_concat
VALUE RepeatedField_concat(VALUE _self, VALUE list)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:581
array
Definition: undname.c:101
RepeatedField_init
VALUE RepeatedField_init(int argc, VALUE *argv, VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:602
RepeatedField_index
static VALUE RepeatedField_index(int argc, VALUE *argv, VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:221
upb_array_get
upb_msgval upb_array_get(const upb_array *arr, size_t i)
Definition: php-upb.c:7264
RepeatedField_deep_copy
VALUE RepeatedField_deep_copy(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:130
RepeatedField_GetUpbArray
const upb_array * RepeatedField_GetUpbArray(VALUE val, const upb_fielddef *field, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:151
protobuf.h
grpc::testing::val2
const char val2[]
Definition: client_context_test_peer_test.cc:35
TypeInfo::msgdef
const upb_msgdef * msgdef
Definition: defs.h:56
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
Msgval_GetHash
uint64_t Msgval_GetHash(upb_msgval val, TypeInfo type_info, uint64_t seed)
Definition: protobuf/ruby/ext/google/protobuf_c/convert.c:327
arg
Definition: cmdline.cc:40
upb_array_new
upb_array * upb_array_new(upb_arena *a)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1203
StringBuilder_PrintMsgval
void StringBuilder_PrintMsgval(StringBuilder *b, upb_msgval val, TypeInfo info)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:123
RepeatedField_plus
VALUE RepeatedField_plus(VALUE _self, VALUE list)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:538
RepeatedField_length
static VALUE RepeatedField_length(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:395
upb_array
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:578
upb_fielddef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2934
ObjectCache_Add
void ObjectCache_Add(const void *key, VALUE val)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:383
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
RepeatedField_clear
static VALUE RepeatedField_clear(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:382
cTypeError
VALUE cTypeError
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.c:35
RepeatedField_index_set
static VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:270
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
StringBuilder_Printf
void StringBuilder_Printf(StringBuilder *b, const char *fmt,...)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:83
upb_array_resize
bool upb_array_resize(upb_array *arr, size_t size, upb_arena *arena)
Definition: php-upb.c:7288
RepeatedField_to_ary
VALUE RepeatedField_to_ary(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:433
TypeInfo_get
static TypeInfo TypeInfo_get(const upb_fielddef *f)
Definition: defs.h:61
upb_msgval
Definition: php-upb.h:4612
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
RepeatedField_GetMutable
static upb_array * RepeatedField_GetMutable(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:69
RepeatedField::array
const upb_array * array
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:43
ALLOC
#define ALLOC(class_name)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1486
upb_array_size
size_t upb_array_size(const upb_array *arr)
Definition: php-upb.c:7260
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
RepeatedField_push
static VALUE RepeatedField_push(VALUE _self, VALUE val)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:323
Msgval_DeepCopy
upb_msgval Msgval_DeepCopy(upb_msgval msgval, TypeInfo type_info, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/convert.c:276
descriptor_database_test_wrapper.module
module
Definition: descriptor_database_test_wrapper.py:30
first
StrT first
Definition: cxa_demangle.cpp:4884
RepeatedField_dup
static VALUE RepeatedField_dup(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:407
RepeatedField::arena
VALUE arena
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:46
UPB_TYPE_MESSAGE
@ UPB_TYPE_MESSAGE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:483
defs.h
fill
int fill
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:47
RepeatedField_GetRubyWrapper
VALUE RepeatedField_GetRubyWrapper(upb_array *array, TypeInfo type_info, VALUE arena)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:82
TYPE
#define TYPE(u, l)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:8202
ruby_to_RepeatedField
static RepeatedField * ruby_to_RepeatedField(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:63
RepeatedField_new_this_type
static VALUE RepeatedField_new_this_type(RepeatedField *from)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:106
RepeatedField_each
static VALUE RepeatedField_each(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:201
TypeInfo::type
upb_fieldtype_t type
Definition: protobuf/php/ext/google/protobuf/def.h:70
RepeatedField_type
const rb_data_type_t RepeatedField_type
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:57
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
Arena_new
VALUE Arena_new()
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:217
RepeatedField::arena
zval arena
Definition: protobuf/php/ext/google/protobuf/array.c:56
repeated_field.h
RepeatedField_freeze
static VALUE RepeatedField_freeze(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:502
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
RepeatedField_pop_one
static VALUE RepeatedField_pop_one(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:337
self
PHP_PROTO_OBJECT_FREE_END PHP_PROTO_OBJECT_DTOR_END intern self
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/map.c:543
Arena_fuse
void Arena_fuse(VALUE _arena, upb_arena *other)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:207
convert.h
klass
zend_class_entry * klass
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:810
ObjectCache_Get
VALUE ObjectCache_Get(const void *key)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:397
TypeInfo::def
union TypeInfo::@436 def
RepeatedField::type_info
TypeInfo type_info
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:44
RepeatedField::type_class
VALUE type_class
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:45
RepeatedField_replace
static VALUE RepeatedField_replace(VALUE _self, VALUE list)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:361
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
message.h
RepeatedField
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:403


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:02