protobuf/ruby/ext/google/protobuf_c/message.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 "message.h"
32 
33 #include "convert.h"
34 #include "defs.h"
35 #include "map.h"
36 #include "protobuf.h"
37 #include "repeated_field.h"
38 
39 static VALUE cParseError = Qnil;
41 
43  return rb_funcall(klass, rb_intern("new"), 0);
44 }
45 
47  return rb_ivar_get(klass, descriptor_instancevar_interned);
48 }
49 
50 // -----------------------------------------------------------------------------
51 // Class/module creation from msgdefs and enumdefs, respectively.
52 // -----------------------------------------------------------------------------
53 
54 typedef struct {
55  VALUE arena;
56  const upb_msg* msg; // Can get as mutable when non-frozen.
57  const upb_msgdef* msgdef; // kept alive by self.class.descriptor reference.
58 } Message;
59 
60 static void Message_mark(void* _self) {
61  Message* self = (Message *)_self;
62  rb_gc_mark(self->arena);
63 }
64 
65 static rb_data_type_t Message_type = {
66  "Message",
67  { Message_mark, RUBY_DEFAULT_FREE, NULL },
68  .flags = RUBY_TYPED_FREE_IMMEDIATELY,
69 };
70 
71 static Message* ruby_to_Message(VALUE msg_rb) {
72  Message* msg;
73  TypedData_Get_Struct(msg_rb, Message, &Message_type, msg);
74  return msg;
75 }
76 
77 static VALUE Message_alloc(VALUE klass) {
78  VALUE descriptor = rb_ivar_get(klass, descriptor_instancevar_interned);
80  VALUE ret;
81 
83  msg->arena = Qnil;
84  msg->msg = NULL;
85 
86  ret = TypedData_Wrap_Struct(klass, &Message_type, msg);
88 
89  return ret;
90 }
91 
92 const upb_msg *Message_Get(VALUE msg_rb, const upb_msgdef **m) {
93  Message* msg = ruby_to_Message(msg_rb);
94  if (m) *m = msg->msgdef;
95  return msg->msg;
96 }
97 
98 upb_msg *Message_GetMutable(VALUE msg_rb, const upb_msgdef **m) {
99  rb_check_frozen(msg_rb);
100  return (upb_msg*)Message_Get(msg_rb, m);
101 }
102 
103 void Message_InitPtr(VALUE self_, upb_msg *msg, VALUE arena) {
104  Message* self = ruby_to_Message(self_);
105  self->msg = msg;
106  self->arena = arena;
107  ObjectCache_Add(msg, self_);
108 }
109 
110 VALUE Message_GetArena(VALUE msg_rb) {
111  Message* msg = ruby_to_Message(msg_rb);
112  return msg->arena;
113 }
114 
116  if (rb_get_alloc_func(klass) != &Message_alloc) {
117  rb_raise(rb_eArgError,
118  "Message class was not returned by the DescriptorPool.");
119  }
120 }
121 
123  if (msg == NULL) return Qnil;
124 
125  VALUE val = ObjectCache_Get(msg);
126 
127  if (val == Qnil) {
128  VALUE klass = Descriptor_DefToClass(m);
129  val = Message_alloc(klass);
130  Message_InitPtr(val, msg, arena);
131  }
132 
133  return val;
134 }
135 
137  const upb_msgdef* m) {
138  bool first = true;
139  int n = upb_msgdef_fieldcount(m);
140  VALUE klass = Descriptor_DefToClass(m);
141  StringBuilder_Printf(b, "<%s: ", rb_class2name(klass));
142 
143  for (int i = 0; i < n; i++) {
145 
147  continue;
148  }
149 
150  if (!first) {
151  StringBuilder_Printf(b, ", ");
152  } else {
153  first = false;
154  }
155 
156  upb_msgval msgval = upb_msg_get(msg, field);
157 
159 
160  if (upb_fielddef_ismap(field)) {
161  const upb_msgdef* entry_m = upb_fielddef_msgsubdef(field);
162  const upb_fielddef* key_f = upb_msgdef_itof(entry_m, 1);
163  const upb_fielddef* val_f = upb_msgdef_itof(entry_m, 2);
164  TypeInfo val_info = TypeInfo_get(val_f);
165  Map_Inspect(b, msgval.map_val, upb_fielddef_type(key_f), val_info);
166  } else if (upb_fielddef_isseq(field)) {
168  } else {
170  }
171  }
172 
173  StringBuilder_Printf(b, ">");
174 }
175 
176 // Helper functions for #method_missing ////////////////////////////////////////
177 
178 enum {
187 };
188 
189 // Check if the field is a well known wrapper type
190 static bool IsWrapper(const upb_fielddef* f) {
191  return upb_fielddef_issubmsg(f) &&
193 }
194 
195 static bool Match(const upb_msgdef* m, const char* name, const upb_fielddef** f,
196  const upb_oneofdef** o, const char* prefix,
197  const char* suffix) {
198  size_t sp = strlen(prefix);
199  size_t ss = strlen(suffix);
200  size_t sn = strlen(name);
201 
202  if (sn <= sp + ss) return false;
203 
204  if (memcmp(name, prefix, sp) != 0 ||
205  memcmp(name + sn - ss, suffix, ss) != 0) {
206  return false;
207  }
208 
209  return upb_msgdef_lookupname(m, name + sp, sn - sp - ss, f, o);
210 }
211 
212 static int extract_method_call(VALUE method_name, Message* self,
213  const upb_fielddef** f, const upb_oneofdef** o) {
214  const upb_msgdef* m = self->msgdef;
215  const char* name;
216 
217  Check_Type(method_name, T_SYMBOL);
218  name = rb_id2name(SYM2ID(method_name));
219 
220  if (Match(m, name, f, o, "", "")) return METHOD_GETTER;
221  if (Match(m, name, f, o, "", "=")) return METHOD_SETTER;
222  if (Match(m, name, f, o, "clear_", "")) return METHOD_CLEAR;
223  if (Match(m, name, f, o, "has_", "?") &&
224  (*o || (*f && upb_fielddef_haspresence(*f)))) {
225  // Disallow oneof hazzers for proto3.
226  // TODO(haberman): remove this test when we are enabling oneof hazzers for
227  // proto3.
228  if (*f && !upb_fielddef_issubmsg(*f) &&
232  return METHOD_UNKNOWN;
233  }
234  return METHOD_PRESENCE;
235  }
236  if (Match(m, name, f, o, "", "_as_value") && *f && !upb_fielddef_isseq(*f) &&
237  IsWrapper(*f)) {
238  return METHOD_WRAPPER_GETTER;
239  }
240  if (Match(m, name, f, o, "", "_as_value=") && *f && !upb_fielddef_isseq(*f) &&
241  IsWrapper(*f)) {
242  return METHOD_WRAPPER_SETTER;
243  }
244  if (Match(m, name, f, o, "", "_const") && *f &&
246  return METHOD_ENUM_GETTER;
247  }
248 
249  return METHOD_UNKNOWN;
250 }
251 
252 static VALUE Message_oneof_accessor(VALUE _self, const upb_oneofdef* o,
253  int accessor_type) {
254  Message* self = ruby_to_Message(_self);
255  const upb_fielddef* oneof_field = upb_msg_whichoneof(self->msg, o);
256 
257  switch (accessor_type) {
258  case METHOD_PRESENCE:
259  return oneof_field == NULL ? Qfalse : Qtrue;
260  case METHOD_CLEAR:
261  if (oneof_field != NULL) {
262  upb_msg_clearfield(Message_GetMutable(_self, NULL), oneof_field);
263  }
264  return Qnil;
265  case METHOD_GETTER:
266  return oneof_field == NULL
267  ? Qnil
268  : ID2SYM(rb_intern(upb_fielddef_name(oneof_field)));
269  case METHOD_SETTER:
270  rb_raise(rb_eRuntimeError, "Oneof accessors are read-only.");
271  }
272  rb_raise(rb_eRuntimeError, "Invalid access of oneof field.");
273 }
274 
275 static void Message_setfield(upb_msg* msg, const upb_fielddef* f, VALUE val,
276  upb_arena* arena) {
277  upb_msgval msgval;
278  if (upb_fielddef_ismap(f)) {
279  msgval.map_val = Map_GetUpbMap(val, f, arena);
280  } else if (upb_fielddef_isseq(f)) {
281  msgval.array_val = RepeatedField_GetUpbArray(val, f, arena);
282  } else {
283  if (val == Qnil &&
286  return;
287  }
288  msgval =
290  }
291  upb_msg_set(msg, f, msgval, arena);
292 }
293 
294 VALUE Message_getfield(VALUE _self, const upb_fielddef* f) {
295  Message* self = ruby_to_Message(_self);
296  // This is a special-case: upb_msg_mutable() for map & array are logically
297  // const (they will not change what is serialized) but physically
298  // non-const, as they do allocate a repeated field or map. The logical
299  // constness means it's ok to do even if the message is frozen.
300  upb_msg *msg = (upb_msg*)self->msg;
301  upb_arena *arena = Arena_get(self->arena);
302  if (upb_fielddef_ismap(f)) {
304  const upb_fielddef *key_f = map_field_key(f);
305  const upb_fielddef *val_f = map_field_value(f);
307  TypeInfo value_type_info = TypeInfo_get(val_f);
308  return Map_GetRubyWrapper(map, key_type, value_type_info, self->arena);
309  } else if (upb_fielddef_isseq(f)) {
311  return RepeatedField_GetRubyWrapper(arr, TypeInfo_get(f), self->arena);
312  } else if (upb_fielddef_issubmsg(f)) {
313  if (!upb_msg_has(self->msg, f)) return Qnil;
314  upb_msg *submsg = upb_msg_mutable(msg, f, arena).msg;
316  return Message_GetRubyWrapper(submsg, m, self->arena);
317  } else {
318  upb_msgval msgval = upb_msg_get(self->msg, f);
319  return Convert_UpbToRuby(msgval, TypeInfo_get(f), self->arena);
320  }
321 }
322 
323 static VALUE Message_field_accessor(VALUE _self, const upb_fielddef* f,
324  int accessor_type, int argc, VALUE* argv) {
326 
327  switch (accessor_type) {
328  case METHOD_SETTER:
329  Message_setfield(Message_GetMutable(_self, NULL), f, argv[1], arena);
330  return Qnil;
331  case METHOD_CLEAR:
332  upb_msg_clearfield(Message_GetMutable(_self, NULL), f);
333  return Qnil;
334  case METHOD_PRESENCE:
335  if (!upb_fielddef_haspresence(f)) {
336  rb_raise(rb_eRuntimeError, "Field does not have presence.");
337  }
338  return upb_msg_has(Message_Get(_self, NULL), f);
339  case METHOD_WRAPPER_GETTER: {
340  Message* self = ruby_to_Message(_self);
341  if (upb_msg_has(self->msg, f)) {
344  const upb_msgdef *wrapper_m = upb_fielddef_msgsubdef(f);
345  const upb_fielddef *value_f = upb_msgdef_itof(wrapper_m, 1);
346  upb_msgval value = upb_msg_get(wrapper.msg_val, value_f);
347  return Convert_UpbToRuby(value, TypeInfo_get(value_f), self->arena);
348  } else {
349  return Qnil;
350  }
351  }
352  case METHOD_WRAPPER_SETTER: {
353  upb_msg *msg = Message_GetMutable(_self, NULL);
354  if (argv[1] == Qnil) {
356  } else {
358  upb_msgval msgval = Convert_RubyToUpb(argv[1], upb_fielddef_name(f),
359  TypeInfo_get(val_f), arena);
361  upb_msg_set(wrapper, val_f, msgval, arena);
362  }
363  return Qnil;
364  }
365  case METHOD_ENUM_GETTER: {
366  upb_msgval msgval = upb_msg_get(Message_Get(_self, NULL), f);
367 
369  // Map repeated fields to a new type with ints
370  VALUE arr = rb_ary_new();
371  size_t i, n = upb_array_size(msgval.array_val);
372  for (i = 0; i < n; i++) {
374  rb_ary_push(arr, INT2NUM(elem.int32_val));
375  }
376  return arr;
377  } else {
378  return INT2NUM(msgval.int32_val);
379  }
380  }
381  case METHOD_GETTER:
382  return Message_getfield(_self, f);
383  default:
384  rb_raise(rb_eRuntimeError, "Internal error, no such accessor: %d",
385  accessor_type);
386  }
387 }
388 
389 /*
390  * call-seq:
391  * Message.method_missing(*args)
392  *
393  * Provides accessors and setters and methods to clear and check for presence of
394  * message fields according to their field names.
395  *
396  * For any field whose name does not conflict with a built-in method, an
397  * accessor is provided with the same name as the field, and a setter is
398  * provided with the name of the field plus the '=' suffix. Thus, given a
399  * message instance 'msg' with field 'foo', the following code is valid:
400  *
401  * msg.foo = 42
402  * puts msg.foo
403  *
404  * This method also provides read-only accessors for oneofs. If a oneof exists
405  * with name 'my_oneof', then msg.my_oneof will return a Ruby symbol equal to
406  * the name of the field in that oneof that is currently set, or nil if none.
407  *
408  * It also provides methods of the form 'clear_fieldname' to clear the value
409  * of the field 'fieldname'. For basic data types, this will set the default
410  * value of the field.
411  *
412  * Additionally, it provides methods of the form 'has_fieldname?', which returns
413  * true if the field 'fieldname' is set in the message object, else false. For
414  * 'proto3' syntax, calling this for a basic type field will result in an error.
415  */
416 static VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) {
417  Message* self = ruby_to_Message(_self);
418  const upb_oneofdef* o;
419  const upb_fielddef* f;
420  int accessor_type;
421 
422  if (argc < 1) {
423  rb_raise(rb_eArgError, "Expected method name as first argument.");
424  }
425 
426  accessor_type = extract_method_call(argv[0], self, &f, &o);
427 
428  if (accessor_type == METHOD_UNKNOWN) return rb_call_super(argc, argv);
429 
430  // Validate argument count.
431  switch (accessor_type) {
432  case METHOD_SETTER:
434  if (argc != 2) {
435  rb_raise(rb_eArgError, "Expected 2 arguments, received %d", argc);
436  }
437  rb_check_frozen(_self);
438  break;
439  default:
440  if (argc != 1) {
441  rb_raise(rb_eArgError, "Expected 1 argument, received %d", argc);
442  }
443  break;
444  }
445 
446  // Dispatch accessor.
447  if (o != NULL) {
448  return Message_oneof_accessor(_self, o, accessor_type);
449  } else {
450  return Message_field_accessor(_self, f, accessor_type, argc, argv);
451  }
452 }
453 
454 static VALUE Message_respond_to_missing(int argc, VALUE* argv, VALUE _self) {
455  Message* self = ruby_to_Message(_self);
456  const upb_oneofdef* o;
457  const upb_fielddef* f;
458  int accessor_type;
459 
460  if (argc < 1) {
461  rb_raise(rb_eArgError, "Expected method name as first argument.");
462  }
463 
464  accessor_type = extract_method_call(argv[0], self, &f, &o);
465 
466  if (accessor_type == METHOD_UNKNOWN) {
467  return rb_call_super(argc, argv);
468  } else if (o != NULL) {
469  return accessor_type == METHOD_SETTER ? Qfalse : Qtrue;
470  } else {
471  return Qtrue;
472  }
473 }
474 
475 void Message_InitFromValue(upb_msg* msg, const upb_msgdef* m, VALUE val,
476  upb_arena* arena);
477 
478 typedef struct {
483 } MapInit;
484 
485 static int Map_initialize_kwarg(VALUE key, VALUE val, VALUE _self) {
486  MapInit *map_init = (MapInit*)_self;
487  upb_msgval k, v;
488  k = Convert_RubyToUpb(key, "", map_init->key_type, NULL);
489 
490  if (map_init->val_type.type == UPB_TYPE_MESSAGE && TYPE(val) == T_HASH) {
491  upb_msg *msg = upb_msg_new(map_init->val_type.def.msgdef, map_init->arena);
492  Message_InitFromValue(msg, map_init->val_type.def.msgdef, val,
493  map_init->arena);
494  v.msg_val = msg;
495  } else {
496  v = Convert_RubyToUpb(val, "", map_init->val_type, map_init->arena);
497  }
498  upb_map_set(map_init->map, k, v, map_init->arena);
499  return ST_CONTINUE;
500 }
501 
502 static void Map_InitFromValue(upb_map* map, const upb_fielddef* f, VALUE val,
503  upb_arena* arena) {
504  const upb_msgdef* entry_m = upb_fielddef_msgsubdef(f);
505  const upb_fielddef* key_f = upb_msgdef_itof(entry_m, 1);
506  const upb_fielddef* val_f = upb_msgdef_itof(entry_m, 2);
507  if (TYPE(val) != T_HASH) {
508  rb_raise(rb_eArgError,
509  "Expected Hash object as initializer value for map field '%s' "
510  "(given %s).",
511  upb_fielddef_name(f), rb_class2name(CLASS_OF(val)));
512  }
513  MapInit map_init = {map, TypeInfo_get(key_f), TypeInfo_get(val_f), arena};
514  rb_hash_foreach(val, Map_initialize_kwarg, (VALUE)&map_init);
515 }
516 
518  upb_arena* arena) {
519  if (info.type == UPB_TYPE_MESSAGE) {
520  upb_msgval msgval;
523  msgval.msg_val = msg;
524  return msgval;
525  } else {
526  return Convert_RubyToUpb(val, "", info, arena);
527  }
528 }
529 
531  VALUE val, upb_arena* arena) {
532  TypeInfo type_info = TypeInfo_get(f);
533 
534  if (TYPE(val) != T_ARRAY) {
535  rb_raise(rb_eArgError,
536  "Expected array as initializer value for repeated field '%s' (given %s).",
537  upb_fielddef_name(f), rb_class2name(CLASS_OF(val)));
538  }
539 
540  for (int i = 0; i < RARRAY_LEN(val); i++) {
541  VALUE entry = rb_ary_entry(val, i);
542  upb_msgval msgval;
543  if (upb_fielddef_issubmsg(f) && TYPE(entry) == T_HASH) {
544  msgval = MessageValue_FromValue(entry, type_info, arena);
545  } else {
546  msgval = Convert_RubyToUpb(entry, upb_fielddef_name(f), type_info, arena);
547  }
548  upb_array_append(arr, msgval, arena);
549  }
550 }
551 
553  VALUE val, upb_arena* arena) {
554  if (TYPE(val) == T_NIL) return;
555 
556  if (upb_fielddef_ismap(f)) {
558  Map_InitFromValue(map, f, val, arena);
559  } else if (upb_fielddef_label(f) == UPB_LABEL_REPEATED) {
561  RepeatedField_InitFromValue(arr, f, val, arena);
562  } else if (upb_fielddef_issubmsg(f)) {
563  if (TYPE(val) == T_HASH) {
564  upb_msg *submsg = upb_msg_mutable(msg, f, arena).msg;
566  } else {
567  Message_setfield(msg, f, val, arena);
568  }
569  } else {
570  upb_msgval msgval =
572  upb_msg_set(msg, f, msgval, arena);
573  }
574 }
575 
576 typedef struct {
580 } MsgInit;
581 
582 static int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) {
583  MsgInit *msg_init = (MsgInit*)_self;
584  const char *name;
585 
586  if (TYPE(key) == T_STRING) {
587  name = RSTRING_PTR(key);
588  } else if (TYPE(key) == T_SYMBOL) {
589  name = RSTRING_PTR(rb_id2str(SYM2ID(key)));
590  } else {
591  rb_raise(rb_eArgError,
592  "Expected string or symbols as hash keys when initializing proto from hash.");
593  }
594 
595  const upb_fielddef* f = upb_msgdef_ntofz(msg_init->msgdef, name);
596 
597  if (f == NULL) {
598  rb_raise(rb_eArgError,
599  "Unknown field name '%s' in initialization map entry.", name);
600  }
601 
602  Message_InitFieldFromValue(msg_init->msg, f, val, msg_init->arena);
603  return ST_CONTINUE;
604 }
605 
606 void Message_InitFromValue(upb_msg* msg, const upb_msgdef* m, VALUE val,
607  upb_arena* arena) {
608  MsgInit msg_init = {msg, m, arena};
609  if (TYPE(val) == T_HASH) {
610  rb_hash_foreach(val, Message_initialize_kwarg, (VALUE)&msg_init);
611  } else {
612  rb_raise(rb_eArgError, "Expected hash arguments or message, not %s",
613  rb_class2name(CLASS_OF(val)));
614  }
615 }
616 
617 /*
618  * call-seq:
619  * Message.new(kwargs) => new_message
620  *
621  * Creates a new instance of the given message class. Keyword arguments may be
622  * provided with keywords corresponding to field names.
623  *
624  * Note that no literal Message class exists. Only concrete classes per message
625  * type exist, as provided by the #msgclass method on Descriptors after they
626  * have been added to a pool. The method definitions described here on the
627  * Message class are provided on each concrete message class.
628  */
629 static VALUE Message_initialize(int argc, VALUE* argv, VALUE _self) {
630  Message* self = ruby_to_Message(_self);
631  VALUE arena_rb = Arena_new();
632  upb_arena *arena = Arena_get(arena_rb);
633  upb_msg *msg = upb_msg_new(self->msgdef, arena);
634 
635  Message_InitPtr(_self, msg, arena_rb);
636 
637  if (argc == 0) {
638  return Qnil;
639  }
640  if (argc != 1) {
641  rb_raise(rb_eArgError, "Expected 0 or 1 arguments.");
642  }
643  Message_InitFromValue((upb_msg*)self->msg, self->msgdef, argv[0], arena);
644  return Qnil;
645 }
646 
647 /*
648  * call-seq:
649  * Message.dup => new_message
650  *
651  * Performs a shallow copy of this message and returns the new copy.
652  */
653 static VALUE Message_dup(VALUE _self) {
654  Message* self = ruby_to_Message(_self);
655  VALUE new_msg = rb_class_new_instance(0, NULL, CLASS_OF(_self));
656  Message* new_msg_self = ruby_to_Message(new_msg);
657  size_t size = upb_msgdef_layout(self->msgdef)->size;
658 
659  // TODO(copy unknown fields?)
660  // TODO(use official upb msg copy function)
661  memcpy((upb_msg*)new_msg_self->msg, self->msg, size);
662  Arena_fuse(self->arena, Arena_get(new_msg_self->arena));
663  return new_msg;
664 }
665 
666 // Support function for Message_eq, and also used by other #eq functions.
667 bool Message_Equal(const upb_msg *m1, const upb_msg *m2, const upb_msgdef *m) {
668  if (m1 == m2) return true;
669 
670  size_t size1, size2;
672  upb_arena *arena_tmp = upb_arena_new();
674 
675  // Compare deterministically serialized payloads with no unknown fields.
676  char *data1 = upb_encode_ex(m1, layout, encode_opts, arena_tmp, &size1);
677  char *data2 = upb_encode_ex(m2, layout, encode_opts, arena_tmp, &size2);
678 
679  if (data1 && data2) {
680  bool ret = (size1 == size2) && (memcmp(data1, data2, size1) == 0);
681  upb_arena_free(arena_tmp);
682  return ret;
683  } else {
684  upb_arena_free(arena_tmp);
685  rb_raise(cParseError, "Error comparing messages");
686  }
687 }
688 
689 /*
690  * call-seq:
691  * Message.==(other) => boolean
692  *
693  * Performs a deep comparison of this message with another. Messages are equal
694  * if they have the same type and if each field is equal according to the :==
695  * method's semantics (a more efficient comparison may actually be done if the
696  * field is of a primitive type).
697  */
698 static VALUE Message_eq(VALUE _self, VALUE _other) {
699  if (CLASS_OF(_self) != CLASS_OF(_other)) return Qfalse;
700 
701  Message* self = ruby_to_Message(_self);
702  Message* other = ruby_to_Message(_other);
703  assert(self->msgdef == other->msgdef);
704 
705  return Message_Equal(self->msg, other->msg, self->msgdef) ? Qtrue : Qfalse;
706 }
707 
710  const char *data;
711  size_t size;
712 
713  // Hash a deterministically serialized payloads with no unknown fields.
716  &size);
717 
718  if (data) {
721  return ret;
722  } else {
724  rb_raise(cParseError, "Error calculating hash");
725  }
726 }
727 
728 /*
729  * call-seq:
730  * Message.hash => hash_value
731  *
732  * Returns a hash value that represents this message's field values.
733  */
734 static VALUE Message_hash(VALUE _self) {
735  Message* self = ruby_to_Message(_self);
736  uint64_t hash_value = Message_Hash(self->msg, self->msgdef, 0);
737  // RUBY_FIXNUM_MAX should be one less than a power of 2.
738  assert((RUBY_FIXNUM_MAX & (RUBY_FIXNUM_MAX + 1)) == 0);
739  return INT2FIX(hash_value & RUBY_FIXNUM_MAX);
740 }
741 
742 /*
743  * call-seq:
744  * Message.inspect => string
745  *
746  * Returns a human-readable string representing this message. It will be
747  * formatted as "<MessageType: field1: value1, field2: value2, ...>". Each
748  * field's value is represented according to its own #inspect method.
749  */
750 static VALUE Message_inspect(VALUE _self) {
751  Message* self = ruby_to_Message(_self);
752 
754  Message_PrintMessage(builder, self->msg, self->msgdef);
757  return ret;
758 }
759 
760 // Support functions for Message_to_h //////////////////////////////////////////
761 
762 static VALUE RepeatedField_CreateArray(const upb_array* arr,
763  TypeInfo type_info) {
764  int size = arr ? upb_array_size(arr) : 0;
765  VALUE ary = rb_ary_new2(size);
766 
767  for (int i = 0; i < size; i++) {
768  upb_msgval msgval = upb_array_get(arr, i);
769  VALUE val = Scalar_CreateHash(msgval, type_info);
770  rb_ary_push(ary, val);
771  }
772 
773  return ary;
774 }
775 
776 static VALUE Message_CreateHash(const upb_msg *msg, const upb_msgdef *m) {
777  if (!msg) return Qnil;
778 
779  VALUE hash = rb_hash_new();
780  int n = upb_msgdef_fieldcount(m);
781  bool is_proto2;
782 
783  // We currently have a few behaviors that are specific to proto2.
784  // This is unfortunate, we should key behaviors off field attributes (like
785  // whether a field has presence), not proto2 vs. proto3. We should see if we
786  // can change this without breaking users.
787  is_proto2 = upb_msgdef_syntax(m) == UPB_SYNTAX_PROTO2;
788 
789  for (int i = 0; i < n; i++) {
791  TypeInfo type_info = TypeInfo_get(field);
792  upb_msgval msgval;
793  VALUE msg_value;
794  VALUE msg_key;
795 
796  if (!is_proto2 && upb_fielddef_issubmsg(field) &&
798  // TODO: Legacy behavior, remove when we fix the is_proto2 differences.
799  msg_key = ID2SYM(rb_intern(upb_fielddef_name(field)));
800  rb_hash_aset(hash, msg_key, Qnil);
801  continue;
802  }
803 
804  // Do not include fields that are not present (oneof or optional fields).
805  if (is_proto2 && upb_fielddef_haspresence(field) &&
806  !upb_msg_has(msg, field)) {
807  continue;
808  }
809 
810  msg_key = ID2SYM(rb_intern(upb_fielddef_name(field)));
811  msgval = upb_msg_get(msg, field);
812 
813  // Proto2 omits empty map/repeated filds also.
814 
815  if (upb_fielddef_ismap(field)) {
816  const upb_msgdef *entry_m = upb_fielddef_msgsubdef(field);
817  const upb_fielddef *key_f = upb_msgdef_itof(entry_m, 1);
818  const upb_fielddef *val_f = upb_msgdef_itof(entry_m, 2);
820  msg_value = Map_CreateHash(msgval.map_val, key_type, TypeInfo_get(val_f));
821  } else if (upb_fielddef_isseq(field)) {
822  if (is_proto2 &&
823  (!msgval.array_val || upb_array_size(msgval.array_val) == 0)) {
824  continue;
825  }
826  msg_value = RepeatedField_CreateArray(msgval.array_val, type_info);
827  } else {
828  msg_value = Scalar_CreateHash(msgval, type_info);
829  }
830 
831  rb_hash_aset(hash, msg_key, msg_value);
832  }
833 
834  return hash;
835 }
836 
837 VALUE Scalar_CreateHash(upb_msgval msgval, TypeInfo type_info) {
838  if (type_info.type == UPB_TYPE_MESSAGE) {
839  return Message_CreateHash(msgval.msg_val, type_info.def.msgdef);
840  } else {
841  return Convert_UpbToRuby(msgval, type_info, Qnil);
842  }
843 }
844 
845 /*
846  * call-seq:
847  * Message.to_h => {}
848  *
849  * Returns the message as a Ruby Hash object, with keys as symbols.
850  */
851 static VALUE Message_to_h(VALUE _self) {
852  Message* self = ruby_to_Message(_self);
853  return Message_CreateHash(self->msg, self->msgdef);
854 }
855 
856 /*
857  * call-seq:
858  * Message.freeze => self
859  *
860  * Freezes the message object. We have to intercept this so we can pin the
861  * Ruby object into memory so we don't forget it's frozen.
862  */
863 static VALUE Message_freeze(VALUE _self) {
864  Message* self = ruby_to_Message(_self);
865  if (!RB_OBJ_FROZEN(_self)) {
866  Arena_Pin(self->arena, _self);
867  RB_OBJ_FREEZE(_self);
868  }
869  return _self;
870 }
871 
872 /*
873  * call-seq:
874  * Message.[](index) => value
875  *
876  * Accesses a field's value by field name. The provided field name should be a
877  * string.
878  */
879 static VALUE Message_index(VALUE _self, VALUE field_name) {
880  Message* self = ruby_to_Message(_self);
881  const upb_fielddef* field;
882 
883  Check_Type(field_name, T_STRING);
884  field = upb_msgdef_ntofz(self->msgdef, RSTRING_PTR(field_name));
885 
886  if (field == NULL) {
887  return Qnil;
888  }
889 
890  return Message_getfield(_self, field);
891 }
892 
893 /*
894  * call-seq:
895  * Message.[]=(index, value)
896  *
897  * Sets a field's value by field name. The provided field name should be a
898  * string.
899  */
900 static VALUE Message_index_set(VALUE _self, VALUE field_name, VALUE value) {
901  Message* self = ruby_to_Message(_self);
902  const upb_fielddef* f;
903  upb_msgval val;
904  upb_arena *arena = Arena_get(self->arena);
905 
906  Check_Type(field_name, T_STRING);
907  f = upb_msgdef_ntofz(self->msgdef, RSTRING_PTR(field_name));
908 
909  if (f == NULL) {
910  rb_raise(rb_eArgError, "Unknown field: %s", RSTRING_PTR(field_name));
911  }
912 
914  upb_msg_set(Message_GetMutable(_self, NULL), f, val, arena);
915 
916  return Qnil;
917 }
918 
919 /*
920  * call-seq:
921  * MessageClass.decode(data) => message
922  *
923  * Decodes the given data (as a string containing bytes in protocol buffers wire
924  * format) under the interpretration given by this message class's definition
925  * and returns a message object with the corresponding field values.
926  */
927 static VALUE Message_decode(VALUE klass, VALUE data) {
928  if (TYPE(data) != T_STRING) {
929  rb_raise(rb_eArgError, "Expected string for binary protobuf data.");
930  }
931 
932  VALUE msg_rb = initialize_rb_class_with_no_args(klass);
933  Message* msg = ruby_to_Message(msg_rb);
934 
935  if (!upb_decode(RSTRING_PTR(data), RSTRING_LEN(data), (upb_msg*)msg->msg,
936  upb_msgdef_layout(msg->msgdef),
937  Arena_get(msg->arena))) {
938  rb_raise(cParseError, "Error occurred during parsing");
939  }
940 
941  return msg_rb;
942 }
943 
944 /*
945  * call-seq:
946  * MessageClass.decode_json(data, options = {}) => message
947  *
948  * Decodes the given data (as a string containing bytes in protocol buffers wire
949  * format) under the interpretration given by this message class's definition
950  * and returns a message object with the corresponding field values.
951  *
952  * @param options [Hash] options for the decoder
953  * ignore_unknown_fields: set true to ignore unknown fields (default is to
954  * raise an error)
955  */
956 static VALUE Message_decode_json(int argc, VALUE* argv, VALUE klass) {
957  VALUE data = argv[0];
958  int options = 0;
960 
961  // TODO(haberman): use this message's pool instead.
963 
964  if (argc < 1 || argc > 2) {
965  rb_raise(rb_eArgError, "Expected 1 or 2 arguments.");
966  }
967 
968  if (argc == 2) {
969  VALUE hash_args = argv[1];
970  if (TYPE(hash_args) != T_HASH) {
971  rb_raise(rb_eArgError, "Expected hash arguments.");
972  }
973 
974  if (RTEST(rb_hash_lookup2( hash_args, ID2SYM(rb_intern("ignore_unknown_fields")), Qfalse))) {
976  }
977  }
978 
979  if (TYPE(data) != T_STRING) {
980  rb_raise(rb_eArgError, "Expected string for JSON data.");
981  }
982 
983  // TODO(cfallin): Check and respect string encoding. If not UTF-8, we need to
984  // convert, because string handlers pass data directly to message string
985  // fields.
986 
987  VALUE msg_rb = initialize_rb_class_with_no_args(klass);
988  Message* msg = ruby_to_Message(msg_rb);
989 
990  // We don't allow users to decode a wrapper type directly.
991  if (upb_msgdef_iswrapper(msg->msgdef)) {
992  rb_raise(rb_eRuntimeError, "Cannot parse a wrapper directly.");
993  }
994 
996  if (!upb_json_decode(RSTRING_PTR(data), RSTRING_LEN(data), (upb_msg*)msg->msg,
997  msg->msgdef, symtab, options,
998  Arena_get(msg->arena), &status)) {
999  rb_raise(cParseError, "Error occurred during parsing: %s",
1001  }
1002 
1003  return msg_rb;
1004 }
1005 
1006 /*
1007  * call-seq:
1008  * MessageClass.encode(msg) => bytes
1009  *
1010  * Encodes the given message object to its serialized form in protocol buffers
1011  * wire format.
1012  */
1013 static VALUE Message_encode(VALUE klass, VALUE msg_rb) {
1014  Message* msg = ruby_to_Message(msg_rb);
1015  const char *data;
1016  size_t size;
1017 
1018  if (CLASS_OF(msg_rb) != klass) {
1019  rb_raise(rb_eArgError, "Message of wrong type.");
1020  }
1021 
1023 
1024  data = upb_encode(msg->msg, upb_msgdef_layout(msg->msgdef), arena,
1025  &size);
1026 
1027  if (data) {
1028  VALUE ret = rb_str_new(data, size);
1029  rb_enc_associate(ret, rb_ascii8bit_encoding());
1031  return ret;
1032  } else {
1034  rb_raise(rb_eRuntimeError, "Exceeded maximum depth (possibly cycle)");
1035  }
1036 }
1037 
1038 /*
1039  * call-seq:
1040  * MessageClass.encode_json(msg, options = {}) => json_string
1041  *
1042  * Encodes the given message object into its serialized JSON representation.
1043  * @param options [Hash] options for the decoder
1044  * preserve_proto_fieldnames: set true to use original fieldnames (default is to camelCase)
1045  * emit_defaults: set true to emit 0/false values (default is to omit them)
1046  */
1047 static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
1048  Message* msg = ruby_to_Message(argv[0]);
1049  int options = 0;
1050  char buf[1024];
1051  size_t size;
1053 
1054  // TODO(haberman): use this message's pool instead.
1056 
1057  if (argc < 1 || argc > 2) {
1058  rb_raise(rb_eArgError, "Expected 1 or 2 arguments.");
1059  }
1060 
1061  if (argc == 2) {
1062  VALUE hash_args = argv[1];
1063  if (TYPE(hash_args) != T_HASH) {
1064  rb_raise(rb_eArgError, "Expected hash arguments.");
1065  }
1066 
1067  if (RTEST(rb_hash_lookup2(hash_args,
1068  ID2SYM(rb_intern("preserve_proto_fieldnames")),
1069  Qfalse))) {
1071  }
1072 
1073  if (RTEST(rb_hash_lookup2(hash_args, ID2SYM(rb_intern("emit_defaults")),
1074  Qfalse))) {
1076  }
1077  }
1078 
1080  size = upb_json_encode(msg->msg, msg->msgdef, symtab, options, buf,
1081  sizeof(buf), &status);
1082 
1083  if (!upb_ok(&status)) {
1084  rb_raise(cParseError, "Error occurred during encoding: %s",
1086  }
1087 
1088  VALUE ret;
1089  if (size >= sizeof(buf)) {
1090  char* buf2 = malloc(size + 1);
1091  upb_json_encode(msg->msg, msg->msgdef, symtab, options, buf2, size + 1,
1092  &status);
1093  ret = rb_str_new(buf2, size);
1094  free(buf2);
1095  } else {
1096  ret = rb_str_new(buf, size);
1097  }
1098 
1099  rb_enc_associate(ret, rb_utf8_encoding());
1100  return ret;
1101 }
1102 
1103 /*
1104  * call-seq:
1105  * Message.descriptor => descriptor
1106  *
1107  * Class method that returns the Descriptor instance corresponding to this
1108  * message class's type.
1109  */
1110 static VALUE Message_descriptor(VALUE klass) {
1111  return rb_ivar_get(klass, descriptor_instancevar_interned);
1112 }
1113 
1115  const char *name;
1116  VALUE klass;
1117 
1119  if (name == NULL) {
1120  rb_raise(rb_eRuntimeError, "Descriptor does not have assigned name.");
1121  }
1122 
1123  klass = rb_define_class_id(
1124  // Docs say this parameter is ignored. User will assign return value to
1125  // their own toplevel constant class name.
1126  rb_intern("Message"),
1127  rb_cObject);
1129  rb_define_alloc_func(klass, Message_alloc);
1130  rb_require("google/protobuf/message_exts");
1131  rb_include_module(klass, rb_eval_string("::Google::Protobuf::MessageExts"));
1132  rb_extend_object(
1133  klass, rb_eval_string("::Google::Protobuf::MessageExts::ClassMethods"));
1134 
1135  rb_define_method(klass, "method_missing",
1137  rb_define_method(klass, "respond_to_missing?",
1139  rb_define_method(klass, "initialize", Message_initialize, -1);
1140  rb_define_method(klass, "dup", Message_dup, 0);
1141  // Also define #clone so that we don't inherit Object#clone.
1142  rb_define_method(klass, "clone", Message_dup, 0);
1143  rb_define_method(klass, "==", Message_eq, 1);
1144  rb_define_method(klass, "eql?", Message_eq, 1);
1145  rb_define_method(klass, "freeze", Message_freeze, 0);
1146  rb_define_method(klass, "hash", Message_hash, 0);
1147  rb_define_method(klass, "to_h", Message_to_h, 0);
1148  rb_define_method(klass, "inspect", Message_inspect, 0);
1149  rb_define_method(klass, "to_s", Message_inspect, 0);
1150  rb_define_method(klass, "[]", Message_index, 1);
1151  rb_define_method(klass, "[]=", Message_index_set, 2);
1152  rb_define_singleton_method(klass, "decode", Message_decode, 1);
1153  rb_define_singleton_method(klass, "encode", Message_encode, 1);
1154  rb_define_singleton_method(klass, "decode_json", Message_decode_json, -1);
1155  rb_define_singleton_method(klass, "encode_json", Message_encode_json, -1);
1156  rb_define_singleton_method(klass, "descriptor", Message_descriptor, 0);
1157 
1158  return klass;
1159 }
1160 
1161 /*
1162  * call-seq:
1163  * Enum.lookup(number) => name
1164  *
1165  * This module method, provided on each generated enum module, looks up an enum
1166  * value by number and returns its name as a Ruby symbol, or nil if not found.
1167  */
1168 static VALUE enum_lookup(VALUE self, VALUE number) {
1169  int32_t num = NUM2INT(number);
1170  VALUE desc = rb_ivar_get(self, descriptor_instancevar_interned);
1172 
1173  const char* name = upb_enumdef_iton(e, num);
1174  if (name == NULL) {
1175  return Qnil;
1176  } else {
1177  return ID2SYM(rb_intern(name));
1178  }
1179 }
1180 
1181 /*
1182  * call-seq:
1183  * Enum.resolve(name) => number
1184  *
1185  * This module method, provided on each generated enum module, looks up an enum
1186  * value by name (as a Ruby symbol) and returns its name, or nil if not found.
1187  */
1188 static VALUE enum_resolve(VALUE self, VALUE sym) {
1189  const char* name = rb_id2name(SYM2ID(sym));
1190  VALUE desc = rb_ivar_get(self, descriptor_instancevar_interned);
1192 
1193  int32_t num = 0;
1194  bool found = upb_enumdef_ntoiz(e, name, &num);
1195  if (!found) {
1196  return Qnil;
1197  } else {
1198  return INT2NUM(num);
1199  }
1200 }
1201 
1202 /*
1203  * call-seq:
1204  * Enum.descriptor
1205  *
1206  * This module method, provided on each generated enum module, returns the
1207  * EnumDescriptor corresponding to this enum type.
1208  */
1209 static VALUE enum_descriptor(VALUE self) {
1210  return rb_ivar_get(self, descriptor_instancevar_interned);
1211 }
1212 
1213 VALUE build_module_from_enumdesc(VALUE _enumdesc) {
1214  const upb_enumdef *e = EnumDescriptor_GetEnumDef(_enumdesc);
1215  VALUE mod = rb_define_module_id(rb_intern(upb_enumdef_fullname(e)));
1216 
1217  upb_enum_iter it;
1218  for (upb_enum_begin(&it, e);
1219  !upb_enum_done(&it);
1220  upb_enum_next(&it)) {
1221  const char* name = upb_enum_iter_name(&it);
1223  if (name[0] < 'A' || name[0] > 'Z') {
1224  rb_warn("Enum value '%s' does not start with an uppercase letter "
1225  "as is required for Ruby constants.",
1226  name);
1227  }
1228  rb_define_const(mod, name, INT2NUM(value));
1229  }
1230 
1231  rb_define_singleton_method(mod, "lookup", enum_lookup, 1);
1232  rb_define_singleton_method(mod, "resolve", enum_resolve, 1);
1233  rb_define_singleton_method(mod, "descriptor", enum_descriptor, 0);
1234  rb_ivar_set(mod, descriptor_instancevar_interned, _enumdesc);
1235 
1236  return mod;
1237 }
1238 
1239 // Internal only; used by Google::Protobuf.deep_copy.
1241  upb_arena *arena) {
1242  // Serialize and parse.
1243  upb_arena *tmp_arena = upb_arena_new();
1245  size_t size;
1246 
1247  char* data = upb_encode_ex(msg, layout, 0, tmp_arena, &size);
1248  upb_msg* new_msg = upb_msg_new(m, arena);
1249 
1250  if (!data || !upb_decode(data, size, new_msg, layout, arena)) {
1251  upb_arena_free(tmp_arena);
1252  rb_raise(cParseError, "Error occurred copying proto");
1253  }
1254 
1255  upb_arena_free(tmp_arena);
1256  return new_msg;
1257 }
1258 
1260  const char* name, upb_arena* arena) {
1261  if (value == Qnil) {
1262  rb_raise(cTypeError, "nil message not allowed here.");
1263  }
1264 
1265  VALUE klass = CLASS_OF(value);
1266  VALUE desc_rb = rb_ivar_get(klass, descriptor_instancevar_interned);
1267  const upb_msgdef* val_m =
1268  desc_rb == Qnil ? NULL : Descriptor_GetMsgDef(desc_rb);
1269 
1270  if (val_m != m) {
1271  // Check for possible implicit conversions
1272  // TODO: hash conversion?
1273 
1274  switch (upb_msgdef_wellknowntype(m)) {
1275  case UPB_WELLKNOWN_TIMESTAMP: {
1276  // Time -> Google::Protobuf::Timestamp
1277  upb_msg *msg = upb_msg_new(m, arena);
1278  upb_msgval sec, nsec;
1279  struct timespec time;
1280  const upb_fielddef *sec_f = upb_msgdef_itof(m, 1);
1281  const upb_fielddef *nsec_f = upb_msgdef_itof(m, 2);
1282 
1283  if (!rb_obj_is_kind_of(value, rb_cTime)) goto badtype;
1284 
1285  time = rb_time_timespec(value);
1286  sec.int64_val = time.tv_sec;
1287  nsec.int32_val = time.tv_nsec;
1288  upb_msg_set(msg, sec_f, sec, arena);
1289  upb_msg_set(msg, nsec_f, nsec, arena);
1290  return msg;
1291  }
1292  case UPB_WELLKNOWN_DURATION: {
1293  // Numeric -> Google::Protobuf::Duration
1294  upb_msg *msg = upb_msg_new(m, arena);
1295  upb_msgval sec, nsec;
1296  const upb_fielddef *sec_f = upb_msgdef_itof(m, 1);
1297  const upb_fielddef *nsec_f = upb_msgdef_itof(m, 2);
1298 
1299  if (!rb_obj_is_kind_of(value, rb_cNumeric)) goto badtype;
1300 
1301  sec.int64_val = NUM2LL(value);
1302  nsec.int32_val = round((NUM2DBL(value) - NUM2LL(value)) * 1000000000);
1303  upb_msg_set(msg, sec_f, sec, arena);
1304  upb_msg_set(msg, nsec_f, nsec, arena);
1305  return msg;
1306  }
1307  default:
1308  badtype:
1309  rb_raise(cTypeError,
1310  "Invalid type %s to assign to submessage field '%s'.",
1311  rb_class2name(CLASS_OF(value)), name);
1312  }
1313 
1314  }
1315 
1316  Message* self = ruby_to_Message(value);
1317  Arena_fuse(self->arena, arena);
1318 
1319  return self->msg;
1320 }
1321 
1323  cParseError = rb_const_get(protobuf, rb_intern("ParseError"));
1324 
1325  // Ruby-interned string: "descriptor". We use this identifier to store an
1326  // instance variable on message classes we create in order to link them back
1327  // to their descriptors.
1328  descriptor_instancevar_interned = rb_intern("descriptor");
1329 }
DescriptorPool_GetSymtab
const upb_symtab * DescriptorPool_GetSymtab(VALUE desc_pool_rb)
Definition: protobuf/ruby/ext/google/protobuf_c/defs.c:110
UPB_SYNTAX_PROTO2
@ UPB_SYNTAX_PROTO2
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2972
upb_decode
bool upb_decode(const char *buf, size_t size, void *msg, const upb_msglayout *l, upb_arena *arena)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:742
upb_mutmsgval::msg
upb_msg * msg
Definition: php-upb.h:4628
Message_respond_to_missing
static VALUE Message_respond_to_missing(int argc, VALUE *argv, VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:454
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
StringBuilder_Free
void StringBuilder_Free(StringBuilder *b)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:78
regen-readme.it
it
Definition: regen-readme.py:15
upb_fielddef_label
upb_label_t upb_fielddef_label(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3347
upb_status_clear
void upb_status_clear(upb_status *status)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2196
Convert_UpbToRuby
VALUE Convert_UpbToRuby(upb_msgval upb_val, TypeInfo type_info, VALUE arena)
Definition: protobuf/ruby/ext/google/protobuf_c/convert.c:230
upb_enum_iter_name
const char * upb_enum_iter_name(upb_enum_iter *iter)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3289
Message_decode
static VALUE Message_decode(VALUE klass, VALUE data)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:927
upb_json_decode
bool upb_json_decode(const char *buf, size_t size, upb_msg *msg, const upb_msgdef *m, const upb_symtab *any_pool, int options, upb_arena *arena, upb_status *status)
Definition: php-upb.c:8775
upb_msgval::array_val
const upb_array * array_val
Definition: php-upb.h:4622
IsWrapper
static bool IsWrapper(const upb_fielddef *f)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:190
upb_status
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:197
Message_GetRubyWrapper
VALUE Message_GetRubyWrapper(upb_msg *msg, const upb_msgdef *m, VALUE arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:122
StringBuilder
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:57
upb_enum_done
bool upb_enum_done(upb_enum_iter *iter)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3271
upb_msglayout::size
uint16_t size
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:570
MapInit::arena
upb_arena * arena
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:482
cParseError
static VALUE cParseError
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:39
upb_msgdef_lookupname
bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len, const upb_fielddef **f, const upb_oneofdef **o)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3584
upb_msgval::map_val
const upb_map * map_val
Definition: php-upb.h:4620
upb_fielddef_issubmsg
bool upb_fielddef_issubmsg(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3486
map_field_key
const upb_fielddef * map_field_key(const upb_fielddef *field)
Definition: php/ext/google/protobuf/storage.c:530
MapInit::key_type
TypeInfo key_type
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:480
upb_enumdef_fullname
const char * upb_enumdef_fullname(const upb_enumdef *e)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3244
upb_msg_whichoneof
const upb_fielddef * upb_msg_whichoneof(const upb_msg *msg, const upb_oneofdef *o)
Definition: php-upb.c:7075
MsgInit::msgdef
const upb_msgdef * msgdef
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:578
METHOD_CLEAR
@ METHOD_CLEAR
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:182
upb_fieldtype_t
upb_fieldtype_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:472
options
double_dict options[]
Definition: capstone_test.c:55
upb_arena_free
void upb_arena_free(upb_arena *a)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2391
Message_register
void Message_register(VALUE protobuf)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1322
seed
static const uint8_t seed[20]
Definition: dsa_test.cc:79
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
MapInit::map
upb_map * map
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:479
nsec
static int64_t nsec()
Definition: bloaty/third_party/re2/util/benchmark.cc:37
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
grpc::protobuf::Message
GRPC_CUSTOM_MESSAGE Message
Definition: include/grpcpp/impl/codegen/config_protobuf.h:78
upb_msgdef_iswrapper
bool upb_msgdef_iswrapper(const upb_msgdef *m)
Definition: php-upb.c:5473
upb_msgdef_fieldcount
int upb_msgdef_fieldcount(const upb_msgdef *m)
Definition: php-upb.c:5433
upb_array_append
bool upb_array_append(upb_array *arr, upb_msgval val, upb_arena *arena)
Definition: php-upb.c:7280
upb_msg_new
upb_msg * upb_msg_new(const upb_msglayout *l, upb_arena *a)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1175
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
upb_msg_get
upb_msgval upb_msg_get(const upb_msg *msg, const upb_fielddef *f)
Definition: php-upb.c:7090
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
Message_Hash
uint64_t Message_Hash(const upb_msg *msg, const upb_msgdef *m, uint64_t seed)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:708
status
absl::Status status
Definition: rls.cc:251
MessageOrEnum_GetDescriptor
VALUE MessageOrEnum_GetDescriptor(VALUE klass)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:46
upb_msg_has
bool upb_msg_has(const upb_msg *msg, const upb_fielddef *f)
Definition: php-upb.c:7062
setup.name
name
Definition: setup.py:542
Message_encode_json
static VALUE Message_encode_json(int argc, VALUE *argv, VALUE klass)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1047
METHOD_SETTER
@ METHOD_SETTER
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:181
Message_eq
static VALUE Message_eq(VALUE _self, VALUE _other)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:698
map.h
Message_InitFieldFromValue
static void Message_InitFieldFromValue(upb_msg *msg, const upb_fielddef *f, VALUE val, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:552
setup.k
k
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
Arena_get
upb_arena * Arena_get(VALUE _arena)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:201
map
zval * map
Definition: php/ext/google/protobuf/encode_decode.c:480
Message_mark
static void Message_mark(void *_self)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:60
Message_deep_copy
upb_msg * Message_deep_copy(const upb_msg *msg, const upb_msgdef *m, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1240
upb_msg_set
void upb_msg_set(upb_msg *msg, const upb_fielddef *f, upb_msgval val, upb_arena *a)
Definition: php-upb.c:7132
upb_msg
void upb_msg
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:548
UPB_JSONENC_PROTONAMES
@ UPB_JSONENC_PROTONAMES
Definition: php-upb.h:4806
Message::msg
upb_msg * msg
Definition: protobuf/php/ext/google/protobuf/message.c:57
Message_InitPtr
void Message_InitPtr(VALUE self_, upb_msg *msg, VALUE arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:103
upb_enumdef_ntoiz
UPB_INLINE bool upb_enumdef_ntoiz(const upb_enumdef *e, const char *name, int32_t *num)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:3607
Message_Equal
bool Message_Equal(const upb_msg *m1, const upb_msg *m2, const upb_msgdef *m)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:667
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
upb_fielddef_msgsubdef
const upb_msgdef * upb_fielddef_msgsubdef(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3476
RepeatedField_Inspect
void RepeatedField_Inspect(StringBuilder *b, const upb_array *array, TypeInfo info)
Definition: protobuf/ruby/ext/google/protobuf_c/repeated_field.c:114
o
UnboundConversion o
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:97
hash
uint64_t hash
Definition: ring_hash.cc:284
Message_decode_json
static VALUE Message_decode_json(int argc, VALUE *argv, VALUE klass)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:956
UPB_ENCODE_SKIPUNKNOWN
@ UPB_ENCODE_SKIPUNKNOWN
Definition: php-upb.h:1945
upb_oneofdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2992
UPB_TYPE_ENUM
@ UPB_TYPE_ENUM
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:479
UPB_JSONDEC_IGNOREUNKNOWN
@ UPB_JSONDEC_IGNOREUNKNOWN
Definition: php-upb.h:4778
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
Message_InitFromValue
void Message_InitFromValue(upb_msg *msg, const upb_msgdef *m, VALUE val, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:606
profile_analyzer.builder
builder
Definition: profile_analyzer.py:159
Message_oneof_accessor
static VALUE Message_oneof_accessor(VALUE _self, const upb_oneofdef *o, int accessor_type)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:252
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
upb_msgdef_fullname
const char * upb_msgdef_fullname(const upb_msgdef *m)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3532
Message::arena
zval arena
Definition: protobuf/php/ext/google/protobuf/message.c:55
ruby_to_Message
static Message * ruby_to_Message(VALUE msg_rb)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:71
gen_stats_data.found
bool found
Definition: gen_stats_data.py:61
Map_initialize_kwarg
static int Map_initialize_kwarg(VALUE key, VALUE val, VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:485
UPB_WELLKNOWN_DURATION
@ UPB_WELLKNOWN_DURATION
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2984
upb_status_errmsg
const char * upb_status_errmsg(const upb_status *status)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2204
Message_CreateHash
static VALUE Message_CreateHash(const upb_msg *msg, const upb_msgdef *m)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:776
Message::msg
const upb_msg * msg
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:56
MsgInit
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:576
Map_CreateHash
VALUE Map_CreateHash(const upb_map *map, upb_fieldtype_t key_type, TypeInfo val_info)
Definition: protobuf/ruby/ext/google/protobuf_c/map.c:133
Message_initialize
static VALUE Message_initialize(int argc, VALUE *argv, VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:629
Message_GetUpbMessage
const upb_msg * Message_GetUpbMessage(VALUE value, const upb_msgdef *m, const char *name, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1259
upb_array_get
upb_msgval upb_array_get(const upb_array *arr, size_t i)
Definition: php-upb.c:7264
upb_enum_iter_number
int32_t upb_enum_iter_number(upb_enum_iter *iter)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3293
setup.v
v
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
UPB_WELLKNOWN_TIMESTAMP
@ UPB_WELLKNOWN_TIMESTAMP
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2985
Message_hash
static VALUE Message_hash(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:734
protobuf.h
Message_PrintMessage
void Message_PrintMessage(StringBuilder *b, const upb_msg *msg, const upb_msgdef *m)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:136
round
static int round(int n)
Definition: bloaty/third_party/re2/util/benchmark.cc:91
TypeInfo::msgdef
const upb_msgdef * msgdef
Definition: defs.h:56
Message_freeze
static VALUE Message_freeze(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:863
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
Message_inspect
static VALUE Message_inspect(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:750
Descriptor_GetMsgDef
const upb_msgdef * Descriptor_GetMsgDef(VALUE desc_rb)
Definition: protobuf/ruby/ext/google/protobuf_c/defs.c:1222
upb_mutmsgval::array
upb_array * array
Definition: php-upb.h:4629
upb_enumdef_iton
const char * upb_enumdef_iton(const upb_enumdef *def, int32_t num)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3283
extract_method_call
static int extract_method_call(VALUE method_name, Message *self, const upb_fielddef **f, const upb_oneofdef **o)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:212
upb_symtab
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3018
Map_InitFromValue
static void Map_InitFromValue(upb_map *map, const upb_fielddef *f, VALUE val, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:502
upb_arena_new
UPB_INLINE upb_arena * upb_arena_new(void)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:392
number
int32_t number
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:850
METHOD_ENUM_GETTER
@ METHOD_ENUM_GETTER
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:184
Message_to_h
static VALUE Message_to_h(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:851
Message_initialize_kwarg
static int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:582
StringBuilder_PrintMsgval
void StringBuilder_PrintMsgval(StringBuilder *b, upb_msgval val, TypeInfo info)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:123
Message_GetMutable
upb_msg * Message_GetMutable(VALUE msg_rb, const upb_msgdef **m)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:98
generated_pool
InternalDescriptorPool * generated_pool
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/def.c:582
upb_fielddef_ismap
bool upb_fielddef_ismap(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3503
upb_encode_ex
char * upb_encode_ex(const void *msg, const upb_msglayout *l, int options, upb_arena *arena, size_t *size)
Definition: php-upb.c:1447
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
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
wrapper
grpc_channel_wrapper * wrapper
Definition: src/php/ext/grpc/channel.h:48
Message_index
static VALUE Message_index(VALUE _self, VALUE field_name)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:879
Message_alloc
static VALUE Message_alloc(VALUE klass)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:77
enum_resolve
static VALUE enum_resolve(VALUE self, VALUE sym)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1188
map_field_value
const upb_fielddef * map_field_value(const upb_fielddef *field)
Definition: php/ext/google/protobuf/storage.c:535
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
Message_encode
static VALUE Message_encode(VALUE klass, VALUE msg_rb)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1013
upb_fielddef_containingtype
const upb_msgdef * upb_fielddef_containingtype(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3414
build_class_from_descriptor
VALUE build_class_from_descriptor(VALUE descriptor)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1114
layout
MessageLayout * layout
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:809
upb_enum_begin
void upb_enum_begin(upb_enum_iter *i, const upb_enumdef *e)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3265
cTypeError
VALUE cTypeError
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.c:35
EnumDescriptor_GetEnumDef
const upb_enumdef * EnumDescriptor_GetEnumDef(VALUE enum_desc_rb)
Definition: protobuf/ruby/ext/google/protobuf_c/defs.c:1029
upb_msgdef_itof
const upb_fielddef * upb_msgdef_itof(const upb_msgdef *m, uint32_t i)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3556
MapInit::val_type
TypeInfo val_type
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:481
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
upb_ok
bool upb_ok(const upb_status *status)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2202
upb_mutmsgval::map
upb_map * map
Definition: php-upb.h:4627
absl::hash_internal::kWyhashSalt
constexpr uint64_t kWyhashSalt[5]
Definition: bloaty/third_party/abseil-cpp/absl/hash/internal/hash.cc:58
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
METHOD_WRAPPER_SETTER
@ METHOD_WRAPPER_SETTER
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:186
StringBuilder_Printf
void StringBuilder_Printf(StringBuilder *b, const char *fmt,...)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:83
Match
static bool Match(const upb_msgdef *m, const char *name, const upb_fielddef **f, const upb_oneofdef **o, const char *prefix, const char *suffix)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:195
upb_json_encode
size_t upb_json_encode(const upb_msg *msg, const upb_msgdef *m, const upb_symtab *ext_pool, int options, char *buf, size_t size, upb_status *status)
Definition: php-upb.c:9501
upb_enum_next
void upb_enum_next(upb_enum_iter *iter)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3270
Map_Inspect
void Map_Inspect(StringBuilder *b, const upb_map *map, upb_fieldtype_t key_type, TypeInfo val_type)
Definition: protobuf/ruby/ext/google/protobuf_c/map.c:197
Message_type
static rb_data_type_t Message_type
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:65
value
const char * value
Definition: hpack_parser_table.cc:165
symtab
upb_symtab * symtab
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:774
TypeInfo_get
static TypeInfo TypeInfo_get(const upb_fielddef *f)
Definition: defs.h:61
Scalar_CreateHash
VALUE Scalar_CreateHash(upb_msgval msgval, TypeInfo type_info)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:837
Message_index_set
static VALUE Message_index_set(VALUE _self, VALUE field_name, VALUE value)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:900
upb_msglayout
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:565
upb_msgval
Definition: php-upb.h:4612
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
Message_getfield
VALUE Message_getfield(VALUE _self, const upb_fielddef *f)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:294
key
const char * key
Definition: hpack_parser_table.cc:164
StringBuilder_ToRubyString
VALUE StringBuilder_ToRubyString(StringBuilder *b)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:107
Message_setfield
static void Message_setfield(upb_msg *msg, const upb_fielddef *f, VALUE val, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:275
suffix
unsigned char suffix[65536]
Definition: bloaty/third_party/zlib/examples/gun.c:164
upb_enumdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2984
Message_Get
const upb_msg * Message_Get(VALUE msg_rb, const upb_msgdef **m)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:92
upb_fielddef_haspresence
bool upb_fielddef_haspresence(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3512
Message_CheckClass
void Message_CheckClass(VALUE klass)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:115
UPB_LABEL_REPEATED
@ UPB_LABEL_REPEATED
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:494
ALLOC
#define ALLOC(class_name)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1486
upb_msg_clearfield
void upb_msg_clearfield(upb_msg *msg, const upb_fielddef *f)
Definition: php-upb.c:7145
upb_array_size
size_t upb_array_size(const upb_array *arr)
Definition: php-upb.c:7260
UPB_JSONENC_EMITDEFAULTS
@ UPB_JSONENC_EMITDEFAULTS
Definition: php-upb.h:4802
absl::hash_internal::Wyhash
uint64_t Wyhash(const void *data, size_t len, uint64_t seed, const uint64_t salt[])
Definition: wyhash.cc:30
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
build_module_from_enumdesc
VALUE build_module_from_enumdesc(VALUE _enumdesc)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1213
StringBuilder_New
StringBuilder * StringBuilder_New()
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:69
METHOD_UNKNOWN
@ METHOD_UNKNOWN
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:179
first
StrT first
Definition: cxa_demangle.cpp:4884
upb_msgval::msg_val
const upb_msg * msg_val
Definition: php-upb.h:4621
upb_msgdef_syntax
upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3544
upb_msgdef_layout
const upb_msglayout * upb_msgdef_layout(const upb_msgdef *m)
Definition: php-upb.c:5445
prefix
static const char prefix[]
Definition: head_of_line_blocking.cc:28
xds_manager.num
num
Definition: xds_manager.py:56
descriptor_instancevar_interned
static ID descriptor_instancevar_interned
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:40
Message_GetArena
VALUE Message_GetArena(VALUE msg_rb)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:110
Message_descriptor
static VALUE Message_descriptor(VALUE klass)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1110
desc
#define desc
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:338
METHOD_GETTER
@ METHOD_GETTER
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:180
UPB_TYPE_MESSAGE
@ UPB_TYPE_MESSAGE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:483
MessageValue_FromValue
static upb_msgval MessageValue_FromValue(VALUE val, TypeInfo info, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:517
buf2
static char buf2[32]
Definition: test-fs.c:127
upb_msgdef_wellknowntype
upb_wellknowntype_t upb_msgdef_wellknowntype(const upb_msgdef *m)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3612
Message::arena
VALUE arena
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:55
upb_msg_mutable
upb_mutmsgval upb_msg_mutable(upb_msg *msg, const upb_fielddef *f, upb_arena *a)
Definition: php-upb.c:7098
Message_method_missing
static VALUE Message_method_missing(int argc, VALUE *argv, VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:416
enum_descriptor
static VALUE enum_descriptor(VALUE self)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1209
defs.h
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
Message_dup
static VALUE Message_dup(VALUE _self)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:653
RepeatedField_GetUpbArray
upb_array * RepeatedField_GetUpbArray(zval *val, TypeInfo type, upb_arena *arena)
Definition: protobuf/php/ext/google/protobuf/array.c:172
upb_msgval::int32_val
int32_t int32_val
Definition: php-upb.h:4616
TypeInfo::type
upb_fieldtype_t type
Definition: protobuf/php/ext/google/protobuf/def.h:70
Message_field_accessor
static VALUE Message_field_accessor(VALUE _self, const upb_fielddef *f, int accessor_type, int argc, VALUE *argv)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:323
MsgInit::msg
upb_msg * msg
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:577
RepeatedField_CreateArray
static VALUE RepeatedField_CreateArray(const upb_array *arr, TypeInfo type_info)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:762
MapInit
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:478
Arena_new
VALUE Arena_new()
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:217
repeated_field.h
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
upb_strtable_iter
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:1086
RepeatedField_InitFromValue
static void RepeatedField_InitFromValue(upb_array *arr, const upb_fielddef *f, VALUE val, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:530
key_type
upb_fieldtype_t key_type
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1071
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
regress.m
m
Definition: regress/regress.py:25
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
upb_fielddef_isseq
bool upb_fielddef_isseq(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3495
Arena_fuse
void Arena_fuse(VALUE _arena, upb_arena *other)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:207
upb_encode
char * upb_encode(const void *msg, const upb_msglayout *m, upb_arena *arena, size_t *size)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1105
upb_fielddef_realcontainingoneof
const upb_oneofdef * upb_fielddef_realcontainingoneof(const upb_fielddef *f)
Definition: php-upb.c:5215
upb_map_set
bool upb_map_set(upb_map *map, upb_msgval key, upb_msgval val, upb_arena *arena)
Definition: php-upb.c:7312
convert.h
UPB_ENCODE_DETERMINISTIC
@ UPB_ENCODE_DETERMINISTIC
Definition: php-upb.h:1942
upb_msgdef_field
const upb_fielddef * upb_msgdef_field(const upb_msgdef *m, int i)
Definition: php-upb.c:5449
klass
zend_class_entry * klass
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:810
METHOD_WRAPPER_GETTER
@ METHOD_WRAPPER_GETTER
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:185
MsgInit::arena
upb_arena * arena
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:579
descriptor
static const char descriptor[1336]
Definition: certs.upbdefs.c:16
initialize_rb_class_with_no_args
static VALUE initialize_rb_class_with_no_args(VALUE klass)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:42
Map_GetRubyWrapper
VALUE Map_GetRubyWrapper(upb_map *map, upb_fieldtype_t key_type, TypeInfo value_type, VALUE arena)
Definition: protobuf/ruby/ext/google/protobuf_c/map.c:87
method_name
absl::string_view method_name
Definition: call_creds_util.cc:40
enum_lookup
static VALUE enum_lookup(VALUE self, VALUE number)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1168
ObjectCache_Get
VALUE ObjectCache_Get(const void *key)
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:397
TypeInfo::def
union TypeInfo::@436 def
Message::msgdef
const upb_msgdef * msgdef
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:57
upb_msgdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2962
Message
Definition: protobuf/php/ext/google/protobuf/message.c:53
upb_msgdef_ntofz
const UPB_INLINE upb_fielddef * upb_msgdef_ntofz(const upb_msgdef *m, const char *name)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:3350
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
upb_fielddef_name
const char * upb_fielddef_name(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3367
upb_msgval::int64_val
int64_t int64_val
Definition: php-upb.h:4617
upb_fielddef_type
upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3304
message.h
METHOD_PRESENCE
@ METHOD_PRESENCE
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:183
Map_GetUpbMap
const upb_map * Map_GetUpbMap(VALUE val, const upb_fielddef *field, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/map.c:170
upb_map
Definition: php-upb.h:1487


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:24