upb/upb/def.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2021, Google LLC
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of Google LLC nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include "upb/def.h"
29 
30 #include <ctype.h>
31 #include <errno.h>
32 #include <setjmp.h>
33 #include <stdlib.h>
34 #include <string.h>
35 
37 #include "upb/reflection.h"
38 
39 /* Must be last. */
40 #include "upb/port_def.inc"
41 
42 typedef struct {
43  size_t len;
44  char str[1]; /* Null-terminated string data follows. */
45 } str_t;
46 
47 /* The upb core does not generally have a concept of default instances. However
48  * for descriptor options we make an exception since the max size is known and
49  * modest (<200 bytes). All types can share a default instance since it is
50  * initialized to zeroes.
51  *
52  * We have to allocate an extra pointer for upb's internal metadata. */
53 static const char opt_default_buf[_UPB_MAXOPT_SIZE + sizeof(void*)] = {0};
54 static const char* opt_default = &opt_default_buf[sizeof(void*)];
55 
56 struct upb_FieldDef {
58  const upb_FileDef* file;
60  const char* full_name;
61  const char* json_name;
62  union {
65  double dbl;
66  float flt;
67  bool boolean;
69  } defaultval;
70  union {
73  } scope;
74  union {
75  const upb_MessageDef* msgdef;
78  } sub;
81  uint16_t layout_index; /* Index into msgdef->layout->fields or file->exts */
84  bool packed_;
89 #if UINTPTR_MAX == 0xffffffff
90  uint32_t padding; // Increase size to a multiple of 8.
91 #endif
92 };
93 
98 };
99 
105  const char* full_name;
106 
107  /* Tables for looking up fields by number and name. */
110 
111  /* All nested defs.
112  * MEM: We could save some space here by putting nested defs in a contiguous
113  * region and calculating counts from offsets or vice-versa. */
129 #if UINTPTR_MAX == 0xffffffff
130  uint32_t padding; // Increase size to a multiple of 8.
131 #endif
132 };
133 
134 struct upb_EnumDef {
136  const upb_MiniTable_Enum* layout; // Only for proto2.
138  const upb_MessageDef* containing_type; // Could be merged with "file".
139  const char* full_name;
145 #if UINTPTR_MAX == 0xffffffff
146  uint32_t padding; // Increase size to a multiple of 8.
147 #endif
148 };
149 
153  const char* full_name;
155 };
156 
157 struct upb_OneofDef {
160  const char* full_name;
162  bool synthetic;
166 #if UINTPTR_MAX == 0xffffffff
167  uint32_t padding; // Increase size to a multiple of 8.
168 #endif
169 };
170 
171 struct upb_FileDef {
173  const char* name;
174  const char* package;
175 
176  const upb_FileDef** deps;
185 
193  int ext_count; /* All exts in the file. */
195 };
196 
200  const char* full_name;
203  int index;
206 };
207 
211  const char* full_name;
214  int index;
215 };
216 
217 struct upb_DefPool {
219  upb_strtable syms; /* full_name -> packed def ptr */
220  upb_strtable files; /* file_name -> upb_FileDef* */
221  upb_inttable exts; /* upb_MiniTable_Extension* -> upb_FieldDef* */
223  size_t bytes_loaded;
224 };
225 
226 /* Inside a symtab we store tagged pointers to specific def types. */
227 typedef enum {
229 
230  /* Only inside symtab table. */
236 
237  /* Only inside message table. */
241 
242  /* Only inside file table. */
245 } upb_deftype_t;
246 
247 #define FIELD_TYPE_UNSPECIFIED 0
248 
250  uintptr_t num = (uintptr_t)upb_value_getconstptr(v);
251  return num & UPB_DEFTYPE_MASK;
252 }
253 
254 static const void* unpack_def(upb_value v, upb_deftype_t type) {
255  uintptr_t num = (uintptr_t)upb_value_getconstptr(v);
256  return (num & UPB_DEFTYPE_MASK) == type
257  ? (const void*)(num & ~UPB_DEFTYPE_MASK)
258  : NULL;
259 }
260 
261 static upb_value pack_def(const void* ptr, upb_deftype_t type) {
262  // Our 3-bit pointer tagging requires all pointers to be multiples of 8.
263  // The arena will always yield 8-byte-aligned addresses, however we put
264  // the defs into arrays. For each element in the array to be 8-byte-aligned,
265  // the sizes of each def type must also be a multiple of 8.
266  //
267  // If any of these asserts fail, we need to add or remove padding on 32-bit
268  // machines (64-bit machines will have 8-byte alignment already due to
269  // pointers, which all of these structs have).
270  UPB_ASSERT((sizeof(upb_FieldDef) & UPB_DEFTYPE_MASK) == 0);
271  UPB_ASSERT((sizeof(upb_MessageDef) & UPB_DEFTYPE_MASK) == 0);
272  UPB_ASSERT((sizeof(upb_EnumDef) & UPB_DEFTYPE_MASK) == 0);
273  UPB_ASSERT((sizeof(upb_EnumValueDef) & UPB_DEFTYPE_MASK) == 0);
274  UPB_ASSERT((sizeof(upb_ServiceDef) & UPB_DEFTYPE_MASK) == 0);
275  UPB_ASSERT((sizeof(upb_OneofDef) & UPB_DEFTYPE_MASK) == 0);
277  UPB_ASSERT((num & UPB_DEFTYPE_MASK) == 0);
278  num |= type;
279  return upb_value_constptr((const void*)num);
280 }
281 
282 /* isalpha() etc. from <ctype.h> are locale-dependent, which we don't want. */
283 static bool upb_isbetween(uint8_t c, uint8_t low, uint8_t high) {
284  return c >= low && c <= high;
285 }
286 
287 static char upb_ascii_lower(char ch) {
288  // Per ASCII this will lower-case a letter. If the result is a letter, the
289  // input was definitely a letter. If the output is not a letter, this may
290  // have transformed the character unpredictably.
291  return ch | 0x20;
292 }
293 
294 static bool upb_isletter(char c) {
295  char lower = upb_ascii_lower(c);
296  return upb_isbetween(lower, 'a', 'z') || c == '_';
297 }
298 
299 static bool upb_isalphanum(char c) {
300  return upb_isletter(c) || upb_isbetween(c, '0', '9');
301 }
302 
303 static const char* shortdefname(const char* fullname) {
304  const char* p;
305 
306  if (fullname == NULL) {
307  return NULL;
308  } else if ((p = strrchr(fullname, '.')) == NULL) {
309  /* No '.' in the name, return the full string. */
310  return fullname;
311  } else {
312  /* Return one past the last '.'. */
313  return p + 1;
314  }
315 }
316 
317 /* All submessage fields are lower than all other fields.
318  * Secondly, fields are increasing in order. */
321  const uint32_t high_bit = 1 << 30;
322  UPB_ASSERT(ret < high_bit);
323  if (!upb_FieldDef_IsSubMessage(f)) ret |= high_bit;
324  return ret;
325 }
326 
327 int cmp_fields(const void* p1, const void* p2) {
328  const upb_FieldDef* f1 = *(upb_FieldDef* const*)p1;
329  const upb_FieldDef* f2 = *(upb_FieldDef* const*)p2;
330  return field_rank(f1) - field_rank(f2);
331 }
332 
334  upb_Status_SetErrorMessage(status, "out of memory");
335 }
336 
338  const char* name = upb_MessageDef_FullName(m);
339  if (name == NULL) {
340  m->well_known_type = kUpb_WellKnown_Unspecified;
341  return;
342  }
343  if (!strcmp(name, "google.protobuf.Any")) {
344  m->well_known_type = kUpb_WellKnown_Any;
345  } else if (!strcmp(name, "google.protobuf.FieldMask")) {
346  m->well_known_type = kUpb_WellKnown_FieldMask;
347  } else if (!strcmp(name, "google.protobuf.Duration")) {
348  m->well_known_type = kUpb_WellKnown_Duration;
349  } else if (!strcmp(name, "google.protobuf.Timestamp")) {
350  m->well_known_type = kUpb_WellKnown_Timestamp;
351  } else if (!strcmp(name, "google.protobuf.DoubleValue")) {
352  m->well_known_type = kUpb_WellKnown_DoubleValue;
353  } else if (!strcmp(name, "google.protobuf.FloatValue")) {
354  m->well_known_type = kUpb_WellKnown_FloatValue;
355  } else if (!strcmp(name, "google.protobuf.Int64Value")) {
356  m->well_known_type = kUpb_WellKnown_Int64Value;
357  } else if (!strcmp(name, "google.protobuf.UInt64Value")) {
358  m->well_known_type = kUpb_WellKnown_UInt64Value;
359  } else if (!strcmp(name, "google.protobuf.Int32Value")) {
360  m->well_known_type = kUpb_WellKnown_Int32Value;
361  } else if (!strcmp(name, "google.protobuf.UInt32Value")) {
362  m->well_known_type = kUpb_WellKnown_UInt32Value;
363  } else if (!strcmp(name, "google.protobuf.BoolValue")) {
364  m->well_known_type = kUpb_WellKnown_BoolValue;
365  } else if (!strcmp(name, "google.protobuf.StringValue")) {
366  m->well_known_type = kUpb_WellKnown_StringValue;
367  } else if (!strcmp(name, "google.protobuf.BytesValue")) {
368  m->well_known_type = kUpb_WellKnown_BytesValue;
369  } else if (!strcmp(name, "google.protobuf.Value")) {
370  m->well_known_type = kUpb_WellKnown_Value;
371  } else if (!strcmp(name, "google.protobuf.ListValue")) {
372  m->well_known_type = kUpb_WellKnown_ListValue;
373  } else if (!strcmp(name, "google.protobuf.Struct")) {
374  m->well_known_type = kUpb_WellKnown_Struct;
375  } else {
376  m->well_known_type = kUpb_WellKnown_Unspecified;
377  }
378 }
379 
380 /* upb_EnumDef ****************************************************************/
381 
383  return e->opts;
384 }
385 
387  return e->opts != (void*)opt_default;
388 }
389 
390 const char* upb_EnumDef_FullName(const upb_EnumDef* e) { return e->full_name; }
391 
392 const char* upb_EnumDef_Name(const upb_EnumDef* e) {
393  return shortdefname(e->full_name);
394 }
395 
396 const upb_FileDef* upb_EnumDef_File(const upb_EnumDef* e) { return e->file; }
397 
399  return e->containing_type;
400 }
401 
403  UPB_ASSERT(upb_EnumDef_FindValueByNumber(e, e->defaultval));
404  return e->defaultval;
405 }
406 
407 int upb_EnumDef_ValueCount(const upb_EnumDef* e) { return e->value_count; }
408 
410  const upb_EnumDef* def, const char* name, size_t len) {
411  upb_value v;
412  return upb_strtable_lookup2(&def->ntoi, name, len, &v)
413  ? upb_value_getconstptr(v)
414  : NULL;
415 }
416 
418  int32_t num) {
419  upb_value v;
420  return upb_inttable_lookup(&def->iton, num, &v) ? upb_value_getconstptr(v)
421  : NULL;
422 }
423 
425  // We could use upb_EnumDef_FindValueByNumber(e, num) != NULL, but we expect
426  // this to be faster (especially for small numbers).
427  return upb_MiniTable_Enum_CheckValue(e->layout, num);
428 }
429 
431  UPB_ASSERT(0 <= i && i < e->value_count);
432  return &e->values[i];
433 }
434 
435 /* upb_EnumValueDef ***********************************************************/
436 
438  const upb_EnumValueDef* e) {
439  return e->opts;
440 }
441 
443  return e->opts != (void*)opt_default;
444 }
445 
447  return ev->parent;
448 }
449 
451  return ev->full_name;
452 }
453 
454 const char* upb_EnumValueDef_Name(const upb_EnumValueDef* ev) {
455  return shortdefname(ev->full_name);
456 }
457 
459  return ev->number;
460 }
461 
463  // Compute index in our parent's array.
464  return ev - ev->parent->values;
465 }
466 
467 /* upb_ExtensionRange
468  * ***************************************************************/
469 
471  const upb_ExtensionRange* r) {
472  return r->opts;
473 }
474 
476  return r->opts != (void*)opt_default;
477 }
478 
480  return e->start;
481 }
482 
484 
485 /* upb_FieldDef ***************************************************************/
486 
488  const upb_FieldDef* f) {
489  return f->opts;
490 }
491 
493  return f->opts != (void*)opt_default;
494 }
495 
496 const char* upb_FieldDef_FullName(const upb_FieldDef* f) {
497  return f->full_name;
498 }
499 
501  switch (f->type_) {
503  return kUpb_CType_Double;
505  return kUpb_CType_Float;
509  return kUpb_CType_Int64;
513  return kUpb_CType_Int32;
516  return kUpb_CType_UInt64;
519  return kUpb_CType_UInt32;
520  case kUpb_FieldType_Enum:
521  return kUpb_CType_Enum;
522  case kUpb_FieldType_Bool:
523  return kUpb_CType_Bool;
525  return kUpb_CType_String;
527  return kUpb_CType_Bytes;
530  return kUpb_CType_Message;
531  }
532  UPB_UNREACHABLE();
533 }
534 
535 upb_FieldType upb_FieldDef_Type(const upb_FieldDef* f) { return f->type_; }
536 
537 uint32_t upb_FieldDef_Index(const upb_FieldDef* f) { return f->index_; }
538 
539 upb_Label upb_FieldDef_Label(const upb_FieldDef* f) { return f->label_; }
540 
541 uint32_t upb_FieldDef_Number(const upb_FieldDef* f) { return f->number_; }
542 
544  return f->is_extension_;
545 }
546 
547 bool upb_FieldDef_IsPacked(const upb_FieldDef* f) { return f->packed_; }
548 
549 const char* upb_FieldDef_Name(const upb_FieldDef* f) {
550  return shortdefname(f->full_name);
551 }
552 
553 const char* upb_FieldDef_JsonName(const upb_FieldDef* f) {
554  return f->json_name;
555 }
556 
558  return f->has_json_name_;
559 }
560 
561 const upb_FileDef* upb_FieldDef_File(const upb_FieldDef* f) { return f->file; }
562 
564  return f->msgdef;
565 }
566 
568  return f->is_extension_ ? f->scope.extension_scope : NULL;
569 }
570 
572  return f->is_extension_ ? NULL : f->scope.oneof;
573 }
574 
577  if (!oneof || upb_OneofDef_IsSynthetic(oneof)) return NULL;
578  return oneof;
579 }
580 
584 
585  switch (upb_FieldDef_CType(f)) {
586  case kUpb_CType_Bool:
587  return (upb_MessageValue){.bool_val = f->defaultval.boolean};
588  case kUpb_CType_Int64:
589  return (upb_MessageValue){.int64_val = f->defaultval.sint};
590  case kUpb_CType_UInt64:
591  return (upb_MessageValue){.uint64_val = f->defaultval.uint};
592  case kUpb_CType_Enum:
593  case kUpb_CType_Int32:
594  return (upb_MessageValue){.int32_val = (int32_t)f->defaultval.sint};
595  case kUpb_CType_UInt32:
596  return (upb_MessageValue){.uint32_val = (uint32_t)f->defaultval.uint};
597  case kUpb_CType_Float:
598  return (upb_MessageValue){.float_val = f->defaultval.flt};
599  case kUpb_CType_Double:
600  return (upb_MessageValue){.double_val = f->defaultval.dbl};
601  case kUpb_CType_String:
602  case kUpb_CType_Bytes: {
603  str_t* str = f->defaultval.str;
604  if (str) {
605  return (upb_MessageValue){
606  .str_val = (upb_StringView){.data = str->str, .size = str->len}};
607  } else {
608  return (upb_MessageValue){
609  .str_val = (upb_StringView){.data = NULL, .size = 0}};
610  }
611  }
612  default:
613  UPB_UNREACHABLE();
614  }
615 
616  return ret;
617 }
618 
620  return upb_FieldDef_CType(f) == kUpb_CType_Message ? f->sub.msgdef : NULL;
621 }
622 
624  return upb_FieldDef_CType(f) == kUpb_CType_Enum ? f->sub.enumdef : NULL;
625 }
626 
629  return &f->msgdef->layout->fields[f->layout_index];
630 }
631 
633  const upb_FieldDef* f) {
635  return f->file->ext_layouts[f->layout_index];
636 }
637 
639  return f->proto3_optional_;
640 }
641 
644 }
645 
649 }
650 
653 }
654 
657 }
658 
662 }
663 
664 bool upb_FieldDef_HasDefault(const upb_FieldDef* f) { return f->has_default; }
665 
667  return upb_FieldDef_IsSubMessage(f) ||
669 }
670 
672  if (upb_FieldDef_IsRepeated(f)) return false;
674  f->file->syntax == kUpb_Syntax_Proto2;
675 }
676 
677 static bool between(int32_t x, int32_t low, int32_t high) {
678  return x >= low && x <= high;
679 }
680 
682 bool upb_FieldDef_checktype(int32_t type) { return between(type, 1, 11); }
684 
686  return between(type, 1, 18);
687 }
688 
689 /* upb_MessageDef
690  * *****************************************************************/
691 
693  const upb_MessageDef* m) {
694  return m->opts;
695 }
696 
698  return m->opts != (void*)opt_default;
699 }
700 
702  return m->full_name;
703 }
704 
706  return m->file;
707 }
708 
710  return m->containing_type;
711 }
712 
713 const char* upb_MessageDef_Name(const upb_MessageDef* m) {
714  return shortdefname(m->full_name);
715 }
716 
718  return m->file->syntax;
719 }
720 
722  uint32_t i) {
723  upb_value val;
724  return upb_inttable_lookup(&m->itof, i, &val) ? upb_value_getconstptr(val)
725  : NULL;
726 }
727 
729  const upb_MessageDef* m, const char* name, size_t len) {
730  upb_value val;
731 
732  if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) {
733  return NULL;
734  }
735 
736  return unpack_def(val, UPB_DEFTYPE_FIELD);
737 }
738 
740  const upb_MessageDef* m, const char* name, size_t len) {
741  upb_value val;
742 
743  if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) {
744  return NULL;
745  }
746 
747  return unpack_def(val, UPB_DEFTYPE_ONEOF);
748 }
749 
751  const char* name, size_t len,
752  const upb_FieldDef** out_f,
753  const upb_OneofDef** out_o) {
754  upb_value val;
755 
756  if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) {
757  return false;
758  }
759 
762  if (out_f) *out_f = f;
763  if (out_o) *out_o = o;
764  return f || o; /* False if this was a JSON name. */
765 }
766 
768  const upb_MessageDef* m, const char* name, size_t len) {
769  upb_value val;
770  const upb_FieldDef* f;
771 
772  if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) {
773  return NULL;
774  }
775 
778 
779  return f;
780 }
781 
782 int upb_MessageDef_numfields(const upb_MessageDef* m) { return m->field_count; }
783 
784 int upb_MessageDef_numoneofs(const upb_MessageDef* m) { return m->oneof_count; }
785 
787  return m->real_oneof_count;
788 }
789 
791  return m->ext_range_count;
792 }
793 
795  return m->field_count;
796 }
797 
799  return m->oneof_count;
800 }
801 
803  return m->nested_msg_count;
804 }
805 
807  return m->nested_enum_count;
808 }
809 
811  return m->nested_ext_count;
812 }
813 
815  return m->real_oneof_count;
816 }
817 
819  return m->layout;
820 }
821 
823  int i) {
824  UPB_ASSERT(0 <= i && i < m->ext_range_count);
825  return &m->ext_ranges[i];
826 }
827 
829  UPB_ASSERT(0 <= i && i < m->field_count);
830  return &m->fields[i];
831 }
832 
834  UPB_ASSERT(0 <= i && i < m->oneof_count);
835  return &m->oneofs[i];
836 }
837 
839  int i) {
840  UPB_ASSERT(0 <= i && i < m->nested_msg_count);
841  return &m->nested_msgs[i];
842 }
843 
845  UPB_ASSERT(0 <= i && i < m->nested_enum_count);
846  return &m->nested_enums[i];
847 }
848 
850  int i) {
851  UPB_ASSERT(0 <= i && i < m->nested_ext_count);
852  return &m->nested_exts[i];
853 }
854 
856  return m->well_known_type;
857 }
858 
859 /* upb_OneofDef ***************************************************************/
860 
862  const upb_OneofDef* o) {
863  return o->opts;
864 }
865 
867  return o->opts != (void*)opt_default;
868 }
869 
870 const char* upb_OneofDef_Name(const upb_OneofDef* o) {
871  return shortdefname(o->full_name);
872 }
873 
875  return o->parent;
876 }
877 
878 int upb_OneofDef_FieldCount(const upb_OneofDef* o) { return o->field_count; }
879 
881  UPB_ASSERT(i < o->field_count);
882  return o->fields[i];
883 }
884 
885 int upb_OneofDef_numfields(const upb_OneofDef* o) { return o->field_count; }
886 
888  // Compute index in our parent's array.
889  return o - o->parent->oneofs;
890 }
891 
892 bool upb_OneofDef_IsSynthetic(const upb_OneofDef* o) { return o->synthetic; }
893 
895  const char* name,
896  size_t length) {
897  upb_value val;
898  return upb_strtable_lookup2(&o->ntof, name, length, &val)
899  ? upb_value_getptr(val)
900  : NULL;
901 }
902 
904  uint32_t num) {
905  upb_value val;
906  return upb_inttable_lookup(&o->itof, num, &val) ? upb_value_getptr(val)
907  : NULL;
908 }
909 
910 /* upb_FileDef ****************************************************************/
911 
913  return f->opts;
914 }
915 
917  return f->opts != (void*)opt_default;
918 }
919 
920 const char* upb_FileDef_Name(const upb_FileDef* f) { return f->name; }
921 
922 const char* upb_FileDef_Package(const upb_FileDef* f) { return f->package; }
923 
924 upb_Syntax upb_FileDef_Syntax(const upb_FileDef* f) { return f->syntax; }
925 
927  return f->top_lvl_msg_count;
928 }
929 
930 int upb_FileDef_DependencyCount(const upb_FileDef* f) { return f->dep_count; }
931 
933  return f->public_dep_count;
934 }
935 
937  return f->weak_dep_count;
938 }
939 
941  return f->public_deps;
942 }
943 
945  return f->weak_deps;
946 }
947 
949  return f->top_lvl_enum_count;
950 }
951 
953  return f->top_lvl_ext_count;
954 }
955 
956 int upb_FileDef_ServiceCount(const upb_FileDef* f) { return f->service_count; }
957 
959  UPB_ASSERT(0 <= i && i < f->dep_count);
960  return f->deps[i];
961 }
962 
964  UPB_ASSERT(0 <= i && i < f->public_dep_count);
965  return f->deps[f->public_deps[i]];
966 }
967 
969  UPB_ASSERT(0 <= i && i < f->public_dep_count);
970  return f->deps[f->weak_deps[i]];
971 }
972 
974  UPB_ASSERT(0 <= i && i < f->top_lvl_msg_count);
975  return &f->top_lvl_msgs[i];
976 }
977 
979  UPB_ASSERT(0 <= i && i < f->top_lvl_enum_count);
980  return &f->top_lvl_enums[i];
981 }
982 
984  UPB_ASSERT(0 <= i && i < f->top_lvl_ext_count);
985  return &f->top_lvl_exts[i];
986 }
987 
989  UPB_ASSERT(0 <= i && i < f->service_count);
990  return &f->services[i];
991 }
992 
993 const upb_DefPool* upb_FileDef_Pool(const upb_FileDef* f) { return f->symtab; }
994 
995 /* upb_MethodDef **************************************************************/
996 
998  const upb_MethodDef* m) {
999  return m->opts;
1000 }
1001 
1003  return m->opts != (void*)opt_default;
1004 }
1005 
1007  return m->full_name;
1008 }
1009 
1010 int upb_MethodDef_Index(const upb_MethodDef* m) { return m->index; }
1011 
1012 const char* upb_MethodDef_Name(const upb_MethodDef* m) {
1013  return shortdefname(m->full_name);
1014 }
1015 
1017  return m->service;
1018 }
1019 
1021  return m->input_type;
1022 }
1023 
1025  return m->output_type;
1026 }
1027 
1029  return m->client_streaming;
1030 }
1031 
1033  return m->server_streaming;
1034 }
1035 
1036 /* upb_ServiceDef *************************************************************/
1037 
1039  const upb_ServiceDef* s) {
1040  return s->opts;
1041 }
1042 
1044  return s->opts != (void*)opt_default;
1045 }
1046 
1048  return s->full_name;
1049 }
1050 
1051 const char* upb_ServiceDef_Name(const upb_ServiceDef* s) {
1052  return shortdefname(s->full_name);
1053 }
1054 
1055 int upb_ServiceDef_Index(const upb_ServiceDef* s) { return s->index; }
1056 
1058  return s->file;
1059 }
1060 
1062  return s->method_count;
1063 }
1064 
1066  return i < 0 || i >= s->method_count ? NULL : &s->methods[i];
1067 }
1068 
1070  const char* name) {
1071  for (int i = 0; i < s->method_count; i++) {
1072  if (strcmp(name, upb_MethodDef_Name(&s->methods[i])) == 0) {
1073  return &s->methods[i];
1074  }
1075  }
1076  return NULL;
1077 }
1078 
1079 /* upb_DefPool ****************************************************************/
1080 
1082  upb_Arena_Free(s->arena);
1083  upb_gfree(s);
1084 }
1085 
1087  upb_DefPool* s = upb_gmalloc(sizeof(*s));
1088 
1089  if (!s) {
1090  return NULL;
1091  }
1092 
1093  s->arena = upb_Arena_New();
1094  s->bytes_loaded = 0;
1095 
1096  if (!upb_strtable_init(&s->syms, 32, s->arena) ||
1097  !upb_strtable_init(&s->files, 4, s->arena) ||
1098  !upb_inttable_init(&s->exts, s->arena)) {
1099  goto err;
1100  }
1101 
1102  s->extreg = upb_ExtensionRegistry_New(s->arena);
1103  if (!s->extreg) goto err;
1104  return s;
1105 
1106 err:
1107  upb_Arena_Free(s->arena);
1108  upb_gfree(s);
1109  return NULL;
1110 }
1111 
1112 static const void* symtab_lookup(const upb_DefPool* s, const char* sym,
1113  upb_deftype_t type) {
1114  upb_value v;
1115  return upb_strtable_lookup(&s->syms, sym, &v) ? unpack_def(v, type) : NULL;
1116 }
1117 
1118 static const void* symtab_lookup2(const upb_DefPool* s, const char* sym,
1119  size_t size, upb_deftype_t type) {
1120  upb_value v;
1121  return upb_strtable_lookup2(&s->syms, sym, size, &v) ? unpack_def(v, type)
1122  : NULL;
1123 }
1124 
1126  const char* sym) {
1127  return symtab_lookup(s, sym, UPB_DEFTYPE_MSG);
1128 }
1129 
1131  const upb_DefPool* s, const char* sym, size_t len) {
1132  return symtab_lookup2(s, sym, len, UPB_DEFTYPE_MSG);
1133 }
1134 
1136  const char* sym) {
1137  return symtab_lookup(s, sym, UPB_DEFTYPE_ENUM);
1138 }
1139 
1141  const char* sym) {
1142  return symtab_lookup(s, sym, UPB_DEFTYPE_ENUMVAL);
1143 }
1144 
1146  const char* name) {
1147  upb_value v;
1148  return upb_strtable_lookup(&s->files, name, &v)
1150  : NULL;
1151 }
1152 
1154  const char* name,
1155  size_t len) {
1156  upb_value v;
1157  return upb_strtable_lookup2(&s->files, name, len, &v)
1159  : NULL;
1160 }
1161 
1163  const upb_DefPool* s, const char* name, size_t size) {
1164  upb_value v;
1165  if (!upb_strtable_lookup2(&s->syms, name, size, &v)) return NULL;
1166 
1167  switch (deftype(v)) {
1168  case UPB_DEFTYPE_FIELD:
1169  return unpack_def(v, UPB_DEFTYPE_FIELD);
1170  case UPB_DEFTYPE_MSG: {
1172  return m->in_message_set ? &m->nested_exts[0] : NULL;
1173  }
1174  default:
1175  break;
1176  }
1177 
1178  return NULL;
1179 }
1180 
1182  const char* sym) {
1183  return upb_DefPool_FindExtensionByNameWithSize(s, sym, strlen(sym));
1184 }
1185 
1187  const char* name) {
1189 }
1190 
1192  const upb_DefPool* s, const char* name, size_t size) {
1194 }
1195 
1197  const char* name) {
1198  upb_value v;
1199  // TODO(haberman): non-extension fields and oneofs.
1200  if (upb_strtable_lookup(&s->syms, name, &v)) {
1201  switch (deftype(v)) {
1202  case UPB_DEFTYPE_EXT: {
1204  return upb_FieldDef_File(f);
1205  }
1206  case UPB_DEFTYPE_MSG: {
1208  return upb_MessageDef_File(m);
1209  }
1210  case UPB_DEFTYPE_ENUM: {
1212  return upb_EnumDef_File(e);
1213  }
1214  case UPB_DEFTYPE_ENUMVAL: {
1217  }
1218  case UPB_DEFTYPE_SERVICE: {
1220  return upb_ServiceDef_File(service);
1221  }
1222  default:
1223  UPB_UNREACHABLE();
1224  }
1225  }
1226 
1227  const char* last_dot = strrchr(name, '.');
1228  if (last_dot) {
1229  const upb_MessageDef* parent =
1231  if (parent) {
1232  const char* shortname = last_dot + 1;
1234  strlen(shortname), NULL, NULL)) {
1235  return upb_MessageDef_File(parent);
1236  }
1237  }
1238  }
1239 
1240  return NULL;
1241 }
1242 
1243 /* Code to build defs from descriptor protos. *********************************/
1244 
1245 /* There is a question of how much validation to do here. It will be difficult
1246  * to perfectly match the amount of validation performed by proto2. But since
1247  * this code is used to directly build defs from Ruby (for example) we do need
1248  * to validate important constraints like uniqueness of names and numbers. */
1249 
1250 #define CHK_OOM(x) \
1251  if (!(x)) { \
1252  symtab_oomerr(ctx); \
1253  }
1254 
1255 typedef struct {
1257  upb_FileDef* file; /* File we are building. */
1258  upb_Arena* arena; /* Allocate defs here. */
1259  upb_Arena* tmp_arena; /* For temporary allocations. */
1260  const upb_MiniTable_File* layout; /* NULL if we should build layouts. */
1261  int enum_count; /* Count of enums built so far. */
1262  int msg_count; /* Count of messages built so far. */
1263  int ext_count; /* Count of extensions built so far. */
1264  upb_Status* status; /* Record errors here. */
1265  jmp_buf err; /* longjmp() on error. */
1266 } symtab_addctx;
1267 
1268 UPB_NORETURN UPB_NOINLINE UPB_PRINTF(2, 3) static void symtab_errf(
1269  symtab_addctx* ctx, const char* fmt, ...) {
1270  va_list argp;
1271  va_start(argp, fmt);
1273  va_end(argp);
1274  UPB_LONGJMP(ctx->err, 1);
1275 }
1276 
1278  upb_Status_setoom(ctx->status);
1279  UPB_LONGJMP(ctx->err, 1);
1280 }
1281 
1283  if (bytes == 0) return NULL;
1284  void* ret = upb_Arena_Malloc(ctx->arena, bytes);
1285  if (!ret) symtab_oomerr(ctx);
1286  return ret;
1287 }
1288 
1289 // We want to copy the options verbatim into the destination options proto.
1290 // We use serialize+parse as our deep copy.
1291 #define SET_OPTIONS(target, desc_type, options_type, proto) \
1292  if (google_protobuf_##desc_type##_has_options(proto)) { \
1293  size_t size; \
1294  char* pb = google_protobuf_##options_type##_serialize( \
1295  google_protobuf_##desc_type##_options(proto), ctx->tmp_arena, &size); \
1296  CHK_OOM(pb); \
1297  target = google_protobuf_##options_type##_parse(pb, size, ctx->arena); \
1298  CHK_OOM(target); \
1299  } else { \
1300  target = (const google_protobuf_##options_type*)opt_default; \
1301  }
1302 
1303 static void check_ident(symtab_addctx* ctx, upb_StringView name, bool full) {
1304  const char* str = name.data;
1305  size_t len = name.size;
1306  bool start = true;
1307  size_t i;
1308  for (i = 0; i < len; i++) {
1309  char c = str[i];
1310  if (c == '.') {
1311  if (start || !full) {
1312  symtab_errf(ctx, "invalid name: unexpected '.' (%.*s)", (int)len, str);
1313  }
1314  start = true;
1315  } else if (start) {
1316  if (!upb_isletter(c)) {
1317  symtab_errf(
1318  ctx,
1319  "invalid name: path components must start with a letter (%.*s)",
1320  (int)len, str);
1321  }
1322  start = false;
1323  } else {
1324  if (!upb_isalphanum(c)) {
1325  symtab_errf(ctx, "invalid name: non-alphanumeric character (%.*s)",
1326  (int)len, str);
1327  }
1328  }
1329  }
1330  if (start) {
1331  symtab_errf(ctx, "invalid name: empty part (%.*s)", (int)len, str);
1332  }
1333 }
1334 
1335 static size_t div_round_up(size_t n, size_t d) { return (n + d - 1) / d; }
1336 
1338  switch (type) {
1339  case kUpb_CType_Double:
1340  case kUpb_CType_Int64:
1341  case kUpb_CType_UInt64:
1342  return 8;
1343  case kUpb_CType_Enum:
1344  case kUpb_CType_Int32:
1345  case kUpb_CType_UInt32:
1346  case kUpb_CType_Float:
1347  return 4;
1348  case kUpb_CType_Bool:
1349  return 1;
1350  case kUpb_CType_Message:
1351  return sizeof(void*);
1352  case kUpb_CType_Bytes:
1353  case kUpb_CType_String:
1354  return sizeof(upb_StringView);
1355  }
1356  UPB_UNREACHABLE();
1357 }
1358 
1361  upb_MapEntry ent;
1362  UPB_ASSERT(sizeof(ent.k) == sizeof(ent.v));
1363  return sizeof(ent.k);
1364  } else if (upb_FieldDef_IsRepeated(f)) {
1365  return sizeof(void*);
1366  } else {
1368  }
1369 }
1370 
1372  size_t size, const upb_MessageDef* m) {
1373  size_t ofs = UPB_ALIGN_UP(l->size, size);
1374  size_t next = ofs + size;
1375 
1376  if (next > UINT16_MAX) {
1377  symtab_errf(ctx, "size of message %s exceeded max size of %zu bytes",
1379  }
1380 
1381  l->size = next;
1382  return ofs;
1383 }
1384 
1385 static int field_number_cmp(const void* p1, const void* p2) {
1386  const upb_MiniTable_Field* f1 = p1;
1387  const upb_MiniTable_Field* f2 = p2;
1388  return f1->number - f2->number;
1389 }
1390 
1393  int i;
1394  int n = upb_MessageDef_numfields(m);
1395  int dense_below = 0;
1396  for (i = 0; i < n; i++) {
1397  upb_FieldDef* f =
1399  UPB_ASSERT(f);
1400  f->layout_index = i;
1401  if (i < UINT8_MAX && fields[i].number == i + 1 &&
1402  (i == 0 || fields[i - 1].number == i)) {
1403  dense_below = i + 1;
1404  }
1405  }
1406  l->dense_below = dense_below;
1407 }
1408 
1411  /* See TableDescriptorType() in upbc/generator.cc for details and
1412  * rationale of these exceptions. */
1413  if (type == kUpb_FieldType_String && f->file->syntax == kUpb_Syntax_Proto2) {
1414  return kUpb_FieldType_Bytes;
1415  } else if (type == kUpb_FieldType_Enum &&
1416  (f->sub.enumdef->file->syntax == kUpb_Syntax_Proto3 ||
1417  UPB_TREAT_PROTO2_ENUMS_LIKE_PROTO3 ||
1418  // TODO(https://github.com/protocolbuffers/upb/issues/541):
1419  // fix map enum values to check for unknown enum values and put
1420  // them in the unknown field set.
1422  return kUpb_FieldType_Int32;
1423  }
1424  return type;
1425 }
1426 
1428  const upb_FieldDef* f) {
1429  field->number = upb_FieldDef_Number(f);
1430  field->descriptortype = map_descriptortype(f);
1431 
1432  if (upb_FieldDef_IsMap(f)) {
1433  field->mode =
1435  } else if (upb_FieldDef_IsRepeated(f)) {
1436  field->mode =
1438  } else {
1439  /* Maps descriptor type -> elem_size_lg2. */
1440  static const uint8_t sizes[] = {
1441  -1, /* invalid descriptor type */
1442  kUpb_FieldRep_8Byte, /* DOUBLE */
1443  kUpb_FieldRep_4Byte, /* FLOAT */
1444  kUpb_FieldRep_8Byte, /* INT64 */
1445  kUpb_FieldRep_8Byte, /* UINT64 */
1446  kUpb_FieldRep_4Byte, /* INT32 */
1447  kUpb_FieldRep_8Byte, /* FIXED64 */
1448  kUpb_FieldRep_4Byte, /* FIXED32 */
1449  kUpb_FieldRep_1Byte, /* BOOL */
1450  kUpb_FieldRep_StringView, /* STRING */
1451  kUpb_FieldRep_Pointer, /* GROUP */
1452  kUpb_FieldRep_Pointer, /* MESSAGE */
1453  kUpb_FieldRep_StringView, /* BYTES */
1454  kUpb_FieldRep_4Byte, /* UINT32 */
1455  kUpb_FieldRep_4Byte, /* ENUM */
1456  kUpb_FieldRep_4Byte, /* SFIXED32 */
1457  kUpb_FieldRep_8Byte, /* SFIXED64 */
1458  kUpb_FieldRep_4Byte, /* SINT32 */
1459  kUpb_FieldRep_8Byte, /* SINT64 */
1460  };
1461  field->mode = kUpb_FieldMode_Scalar |
1462  (sizes[field->descriptortype] << kUpb_FieldRep_Shift);
1463  }
1464 
1465  if (upb_FieldDef_IsPacked(f)) {
1467  }
1468 
1469  if (upb_FieldDef_IsExtension(f)) {
1471  }
1472 }
1473 
1474 /* This function is the dynamic equivalent of message_layout.{cc,h} in upbc.
1475  * It computes a dynamic layout for all of the fields in |m|. */
1477  upb_MiniTable* l = (upb_MiniTable*)m->layout;
1478  size_t field_count = upb_MessageDef_numfields(m);
1479  size_t sublayout_count = 0;
1482 
1483  memset(l, 0, sizeof(*l) + sizeof(_upb_FastTable_Entry));
1484 
1485  /* Count sub-messages. */
1486  for (size_t i = 0; i < field_count; i++) {
1487  const upb_FieldDef* f = &m->fields[i];
1489  sublayout_count++;
1490  }
1492  f->sub.enumdef->file->syntax == kUpb_Syntax_Proto2) {
1493  sublayout_count++;
1494  }
1495  }
1496 
1497  fields = symtab_alloc(ctx, field_count * sizeof(*fields));
1498  subs = symtab_alloc(ctx, sublayout_count * sizeof(*subs));
1499 
1500  l->field_count = upb_MessageDef_numfields(m);
1501  l->fields = fields;
1502  l->subs = subs;
1503  l->table_mask = 0;
1504  l->required_count = 0;
1505 
1509  } else {
1510  l->ext = kUpb_ExtMode_Extendable;
1511  }
1512  } else {
1514  }
1515 
1516  /* TODO(haberman): initialize fast tables so that reflection-based parsing
1517  * can get the same speeds as linked-in types. */
1518  l->fasttable[0].field_parser = &fastdecode_generic;
1519  l->fasttable[0].field_data = 0;
1520 
1522  /* TODO(haberman): refactor this method so this special case is more
1523  * elegant. */
1526  fields[0].number = 1;
1527  fields[1].number = 2;
1528  fields[0].mode = kUpb_FieldMode_Scalar;
1529  fields[1].mode = kUpb_FieldMode_Scalar;
1530  fields[0].presence = 0;
1531  fields[1].presence = 0;
1532  fields[0].descriptortype = map_descriptortype(key);
1533  fields[1].descriptortype = map_descriptortype(val);
1534  fields[0].offset = 0;
1535  fields[1].offset = sizeof(upb_StringView);
1536  fields[1].submsg_index = 0;
1537 
1538  if (upb_FieldDef_CType(val) == kUpb_CType_Message) {
1539  subs[0].submsg = upb_FieldDef_MessageSubDef(val)->layout;
1540  }
1541 
1542  upb_FieldDef* fielddefs = (upb_FieldDef*)&m->fields[0];
1543  UPB_ASSERT(fielddefs[0].number_ == 1);
1544  UPB_ASSERT(fielddefs[1].number_ == 2);
1545  fielddefs[0].layout_index = 0;
1546  fielddefs[1].layout_index = 1;
1547 
1548  l->field_count = 2;
1549  l->size = 2 * sizeof(upb_StringView);
1550  l->size = UPB_ALIGN_UP(l->size, 8);
1551  l->dense_below = 2;
1552  return;
1553  }
1554 
1555  /* Allocate data offsets in three stages:
1556  *
1557  * 1. hasbits.
1558  * 2. regular fields.
1559  * 3. oneof fields.
1560  *
1561  * OPT: There is a lot of room for optimization here to minimize the size.
1562  */
1563 
1564  /* Assign hasbits for required fields first. */
1565  size_t hasbit = 0;
1566 
1567  for (int i = 0; i < m->field_count; i++) {
1568  const upb_FieldDef* f = &m->fields[i];
1571  field->presence = ++hasbit;
1572  if (hasbit >= 63) {
1573  symtab_errf(ctx, "Message with >=63 required fields: %s",
1575  }
1576  l->required_count++;
1577  }
1578  }
1579 
1580  /* Allocate hasbits and set basic field attributes. */
1581  sublayout_count = 0;
1582  for (int i = 0; i < m->field_count; i++) {
1583  const upb_FieldDef* f = &m->fields[i];
1585 
1587 
1588  if (field->descriptortype == kUpb_FieldType_Message ||
1589  field->descriptortype == kUpb_FieldType_Group) {
1590  field->submsg_index = sublayout_count++;
1591  subs[field->submsg_index].submsg = upb_FieldDef_MessageSubDef(f)->layout;
1592  } else if (field->descriptortype == kUpb_FieldType_Enum) {
1593  field->submsg_index = sublayout_count++;
1594  subs[field->submsg_index].subenum = upb_FieldDef_EnumSubDef(f)->layout;
1595  UPB_ASSERT(subs[field->submsg_index].subenum);
1596  }
1597 
1599  /* Hasbit was already assigned. */
1600  } else if (upb_FieldDef_HasPresence(f) &&
1602  /* We don't use hasbit 0, so that 0 can indicate "no presence" in the
1603  * table. This wastes one hasbit, but we don't worry about it for now. */
1604  field->presence = ++hasbit;
1605  } else {
1606  field->presence = 0;
1607  }
1608  }
1609 
1610  /* Account for space used by hasbits. */
1611  l->size = hasbit ? div_round_up(hasbit + 1, 8) : 0;
1612 
1613  /* Allocate non-oneof fields. */
1614  for (int i = 0; i < m->field_count; i++) {
1615  const upb_FieldDef* f = &m->fields[i];
1616  size_t field_size = upb_msg_fielddefsize(f);
1617  size_t index = upb_FieldDef_Index(f);
1618 
1620  /* Oneofs are handled separately below. */
1621  continue;
1622  }
1623 
1624  fields[index].offset = upb_MiniTable_place(ctx, l, field_size, m);
1625  }
1626 
1627  /* Allocate oneof fields. Each oneof field consists of a uint32 for the case
1628  * and space for the actual data. */
1629  for (int i = 0; i < m->oneof_count; i++) {
1630  const upb_OneofDef* o = &m->oneofs[i];
1631  size_t case_size = sizeof(uint32_t); /* Could potentially optimize this. */
1632  size_t field_size = 0;
1633  uint32_t case_offset;
1634  uint32_t data_offset;
1635 
1636  if (upb_OneofDef_IsSynthetic(o)) continue;
1637 
1638  if (o->field_count == 0) {
1639  symtab_errf(ctx, "Oneof must have at least one field (%s)", o->full_name);
1640  }
1641 
1642  /* Calculate field size: the max of all field sizes. */
1643  for (int j = 0; j < o->field_count; j++) {
1644  const upb_FieldDef* f = o->fields[j];
1645  field_size = UPB_MAX(field_size, upb_msg_fielddefsize(f));
1646  }
1647 
1648  /* Align and allocate case offset. */
1649  case_offset = upb_MiniTable_place(ctx, l, case_size, m);
1650  data_offset = upb_MiniTable_place(ctx, l, field_size, m);
1651 
1652  for (int i = 0; i < o->field_count; i++) {
1653  const upb_FieldDef* f = o->fields[i];
1654  fields[upb_FieldDef_Index(f)].offset = data_offset;
1655  fields[upb_FieldDef_Index(f)].presence = ~case_offset;
1656  }
1657  }
1658 
1659  /* Size of the entire structure should be a multiple of its greatest
1660  * alignment. TODO: track overall alignment for real? */
1661  l->size = UPB_ALIGN_UP(l->size, 8);
1662 
1663  /* Sort fields by number. */
1664  if (fields) {
1667  }
1669 }
1670 
1672  char* ret = upb_strdup2(view.data, view.size, ctx->arena);
1673  CHK_OOM(ret);
1674  return ret;
1675 }
1676 
1677 static bool streql2(const char* a, size_t n, const char* b) {
1678  return n == strlen(b) && memcmp(a, b, n) == 0;
1679 }
1680 
1681 static bool streql_view(upb_StringView view, const char* b) {
1682  return streql2(view.data, view.size, b);
1683 }
1684 
1685 static const char* makefullname(symtab_addctx* ctx, const char* prefix,
1686  upb_StringView name) {
1687  if (prefix) {
1688  /* ret = prefix + '.' + name; */
1689  size_t n = strlen(prefix);
1690  char* ret = symtab_alloc(ctx, n + name.size + 2);
1691  strcpy(ret, prefix);
1692  ret[n] = '.';
1693  memcpy(&ret[n + 1], name.data, name.size);
1694  ret[n + 1 + name.size] = '\0';
1695  return ret;
1696  } else {
1697  return strviewdup(ctx, name);
1698  }
1699 }
1700 
1702  int i;
1703  int synthetic_count = 0;
1704  upb_OneofDef* mutable_oneofs = (upb_OneofDef*)m->oneofs;
1705 
1706  for (i = 0; i < m->oneof_count; i++) {
1707  upb_OneofDef* o = &mutable_oneofs[i];
1708 
1709  if (o->synthetic && o->field_count != 1) {
1710  symtab_errf(ctx, "Synthetic oneofs must have one field, not %d: %s",
1711  o->field_count, upb_OneofDef_Name(o));
1712  }
1713 
1714  if (o->synthetic) {
1715  synthetic_count++;
1716  } else if (synthetic_count != 0) {
1717  symtab_errf(ctx, "Synthetic oneofs must be after all other oneofs: %s",
1718  upb_OneofDef_Name(o));
1719  }
1720 
1721  o->fields = symtab_alloc(ctx, sizeof(upb_FieldDef*) * o->field_count);
1722  o->field_count = 0;
1723  }
1724 
1725  for (i = 0; i < m->field_count; i++) {
1726  const upb_FieldDef* f = &m->fields[i];
1728  if (o) {
1729  o->fields[o->field_count++] = f;
1730  }
1731  }
1732 
1733  m->real_oneof_count = m->oneof_count - synthetic_count;
1734 }
1735 
1736 size_t getjsonname(const char* name, char* buf, size_t len) {
1737  size_t src, dst = 0;
1738  bool ucase_next = false;
1739 
1740 #define WRITE(byte) \
1741  ++dst; \
1742  if (dst < len) \
1743  buf[dst - 1] = byte; \
1744  else if (dst == len) \
1745  buf[dst - 1] = '\0'
1746 
1747  if (!name) {
1748  WRITE('\0');
1749  return 0;
1750  }
1751 
1752  /* Implement the transformation as described in the spec:
1753  * 1. upper case all letters after an underscore.
1754  * 2. remove all underscores.
1755  */
1756  for (src = 0; name[src]; src++) {
1757  if (name[src] == '_') {
1758  ucase_next = true;
1759  continue;
1760  }
1761 
1762  if (ucase_next) {
1763  WRITE(toupper(name[src]));
1764  ucase_next = false;
1765  } else {
1766  WRITE(name[src]);
1767  }
1768  }
1769 
1770  WRITE('\0');
1771  return dst;
1772 
1773 #undef WRITE
1774 }
1775 
1776 static char* makejsonname(symtab_addctx* ctx, const char* name) {
1777  size_t size = getjsonname(name, NULL, 0);
1778  char* json_name = symtab_alloc(ctx, size);
1779  getjsonname(name, json_name, size);
1780  return json_name;
1781 }
1782 
1783 /* Adds a symbol |v| to the symtab, which must be a def pointer previously
1784  * packed with pack_def(). The def's pointer to upb_FileDef* must be set before
1785  * adding, so we know which entries to remove if building this file fails. */
1786 static void symtab_add(symtab_addctx* ctx, const char* name, upb_value v) {
1787  // TODO: table should support an operation "tryinsert" to avoid the double
1788  // lookup.
1789  if (upb_strtable_lookup(&ctx->symtab->syms, name, NULL)) {
1790  symtab_errf(ctx, "duplicate symbol '%s'", name);
1791  }
1792  size_t len = strlen(name);
1794  ctx->symtab->arena));
1795 }
1796 
1797 static bool remove_component(char* base, size_t* len) {
1798  if (*len == 0) return false;
1799 
1800  for (size_t i = *len - 1; i > 0; i--) {
1801  if (base[i] == '.') {
1802  *len = i;
1803  return true;
1804  }
1805  }
1806 
1807  *len = 0;
1808  return true;
1809 }
1810 
1811 /* Given a symbol and the base symbol inside which it is defined, find the
1812  * symbol's definition in t. */
1814  const char* from_name_dbg,
1815  const char* base, upb_StringView sym,
1816  upb_deftype_t* type) {
1817  const upb_strtable* t = &ctx->symtab->syms;
1818  if (sym.size == 0) goto notfound;
1819  upb_value v;
1820  if (sym.data[0] == '.') {
1821  /* Symbols starting with '.' are absolute, so we do a single lookup.
1822  * Slice to omit the leading '.' */
1823  if (!upb_strtable_lookup2(t, sym.data + 1, sym.size - 1, &v)) {
1824  goto notfound;
1825  }
1826  } else {
1827  /* Remove components from base until we find an entry or run out. */
1828  size_t baselen = base ? strlen(base) : 0;
1829  char* tmp = malloc(sym.size + baselen + 1);
1830  while (1) {
1831  char* p = tmp;
1832  if (baselen) {
1833  memcpy(p, base, baselen);
1834  p[baselen] = '.';
1835  p += baselen + 1;
1836  }
1837  memcpy(p, sym.data, sym.size);
1838  p += sym.size;
1839  if (upb_strtable_lookup2(t, tmp, p - tmp, &v)) {
1840  break;
1841  }
1842  if (!remove_component(tmp, &baselen)) {
1843  free(tmp);
1844  goto notfound;
1845  }
1846  }
1847  free(tmp);
1848  }
1849 
1850  *type = deftype(v);
1851  return unpack_def(v, *type);
1852 
1853 notfound:
1854  symtab_errf(ctx, "couldn't resolve name '" UPB_STRINGVIEW_FORMAT "'",
1855  UPB_STRINGVIEW_ARGS(sym));
1856 }
1857 
1858 static const void* symtab_resolve(symtab_addctx* ctx, const char* from_name_dbg,
1859  const char* base, upb_StringView sym,
1860  upb_deftype_t type) {
1861  upb_deftype_t found_type;
1862  const void* ret =
1863  symtab_resolveany(ctx, from_name_dbg, base, sym, &found_type);
1864  if (ret && found_type != type) {
1865  symtab_errf(ctx,
1866  "type mismatch when resolving %s: couldn't find "
1867  "name " UPB_STRINGVIEW_FORMAT " with type=%d",
1868  from_name_dbg, UPB_STRINGVIEW_ARGS(sym), (int)type);
1869  }
1870  return ret;
1871 }
1872 
1873 static void create_oneofdef(
1875  const google_protobuf_OneofDescriptorProto* oneof_proto,
1876  const upb_OneofDef* _o) {
1877  upb_OneofDef* o = (upb_OneofDef*)_o;
1879  upb_value v;
1880 
1881  o->parent = m;
1882  o->full_name = makefullname(ctx, m->full_name, name);
1883  o->field_count = 0;
1884  o->synthetic = false;
1885 
1886  SET_OPTIONS(o->opts, OneofDescriptorProto, OneofOptions, oneof_proto);
1887 
1888  upb_value existing_v;
1889  if (upb_strtable_lookup2(&m->ntof, name.data, name.size, &existing_v)) {
1890  symtab_errf(ctx, "duplicate oneof name (%s)", o->full_name);
1891  }
1892 
1894  CHK_OOM(upb_strtable_insert(&m->ntof, name.data, name.size, v, ctx->arena));
1895 
1896  CHK_OOM(upb_inttable_init(&o->itof, ctx->arena));
1897  CHK_OOM(upb_strtable_init(&o->ntof, 4, ctx->arena));
1898 }
1899 
1900 static str_t* newstr(symtab_addctx* ctx, const char* data, size_t len) {
1901  str_t* ret = symtab_alloc(ctx, sizeof(*ret) + len);
1902  CHK_OOM(ret);
1903  ret->len = len;
1904  if (len) memcpy(ret->str, data, len);
1905  ret->str[len] = '\0';
1906  return ret;
1907 }
1908 
1909 static bool upb_DefPool_TryGetChar(const char** src, const char* end,
1910  char* ch) {
1911  if (*src == end) return false;
1912  *ch = **src;
1913  *src += 1;
1914  return true;
1915 }
1916 
1918  const upb_FieldDef* f, const char** src,
1919  const char* end) {
1920  char ch;
1921  if (!upb_DefPool_TryGetChar(src, end, &ch)) return -1;
1922  if ('0' <= ch && ch <= '9') {
1923  return ch - '0';
1924  }
1925  ch = upb_ascii_lower(ch);
1926  if ('a' <= ch && ch <= 'f') {
1927  return ch - 'a' + 0xa;
1928  }
1929  *src -= 1; // Char wasn't actually a hex digit.
1930  return -1;
1931 }
1932 
1934  const upb_FieldDef* f, const char** src,
1935  const char* end) {
1936  char hex_digit = upb_DefPool_TryGetHexDigit(ctx, f, src, end);
1937  if (hex_digit < 0) {
1938  symtab_errf(ctx,
1939  "\\x cannot be followed by non-hex digit in field '%s' default",
1941  return 0;
1942  }
1943  unsigned int ret = hex_digit;
1944  while ((hex_digit = upb_DefPool_TryGetHexDigit(ctx, f, src, end)) >= 0) {
1945  ret = (ret << 4) | hex_digit;
1946  }
1947  if (ret > 0xff) {
1948  symtab_errf(ctx, "Value of hex escape in field %s exceeds 8 bits",
1950  return 0;
1951  }
1952  return ret;
1953 }
1954 
1955 char upb_DefPool_TryGetOctalDigit(const char** src, const char* end) {
1956  char ch;
1957  if (!upb_DefPool_TryGetChar(src, end, &ch)) return -1;
1958  if ('0' <= ch && ch <= '7') {
1959  return ch - '0';
1960  }
1961  *src -= 1; // Char wasn't actually an octal digit.
1962  return -1;
1963 }
1964 
1966  const upb_FieldDef* f,
1967  const char** src, const char* end) {
1968  char ch = 0;
1969  for (int i = 0; i < 3; i++) {
1970  char digit;
1971  if ((digit = upb_DefPool_TryGetOctalDigit(src, end)) >= 0) {
1972  ch = (ch << 3) | digit;
1973  }
1974  }
1975  return ch;
1976 }
1977 
1979  const char** src, const char* end) {
1980  char ch;
1981  if (!upb_DefPool_TryGetChar(src, end, &ch)) {
1982  symtab_errf(ctx, "unterminated escape sequence in field %s",
1984  return 0;
1985  }
1986  switch (ch) {
1987  case 'a':
1988  return '\a';
1989  case 'b':
1990  return '\b';
1991  case 'f':
1992  return '\f';
1993  case 'n':
1994  return '\n';
1995  case 'r':
1996  return '\r';
1997  case 't':
1998  return '\t';
1999  case 'v':
2000  return '\v';
2001  case '\\':
2002  return '\\';
2003  case '\'':
2004  return '\'';
2005  case '\"':
2006  return '\"';
2007  case '?':
2008  return '\?';
2009  case 'x':
2010  case 'X':
2011  return upb_DefPool_ParseHexEscape(ctx, f, src, end);
2012  case '0':
2013  case '1':
2014  case '2':
2015  case '3':
2016  case '4':
2017  case '5':
2018  case '6':
2019  case '7':
2020  *src -= 1;
2021  return upb_DefPool_ParseOctalEscape(ctx, f, src, end);
2022  }
2023  symtab_errf(ctx, "Unknown escape sequence: \\%c", ch);
2024 }
2025 
2027  const char* data, size_t len) {
2028  // Size here is an upper bound; escape sequences could ultimately shrink it.
2029  str_t* ret = symtab_alloc(ctx, sizeof(*ret) + len);
2030  char* dst = &ret->str[0];
2031  const char* src = data;
2032  const char* end = data + len;
2033 
2034  while (src < end) {
2035  if (*src == '\\') {
2036  src++;
2037  *dst++ = upb_DefPool_ParseEscape(ctx, f, &src, end);
2038  } else {
2039  *dst++ = *src++;
2040  }
2041  }
2042 
2043  ret->len = dst - &ret->str[0];
2044  return ret;
2045 }
2046 
2047 static void parse_default(symtab_addctx* ctx, const char* str, size_t len,
2048  upb_FieldDef* f) {
2049  char* end;
2050  char nullz[64];
2051  errno = 0;
2052 
2053  switch (upb_FieldDef_CType(f)) {
2054  case kUpb_CType_Int32:
2055  case kUpb_CType_Int64:
2056  case kUpb_CType_UInt32:
2057  case kUpb_CType_UInt64:
2058  case kUpb_CType_Double:
2059  case kUpb_CType_Float:
2060  /* Standard C number parsing functions expect null-terminated strings. */
2061  if (len >= sizeof(nullz) - 1) {
2062  symtab_errf(ctx, "Default too long: %.*s", (int)len, str);
2063  }
2064  memcpy(nullz, str, len);
2065  nullz[len] = '\0';
2066  str = nullz;
2067  break;
2068  default:
2069  break;
2070  }
2071 
2072  switch (upb_FieldDef_CType(f)) {
2073  case kUpb_CType_Int32: {
2074  long val = strtol(str, &end, 0);
2075  if (val > INT32_MAX || val < INT32_MIN || errno == ERANGE || *end) {
2076  goto invalid;
2077  }
2078  f->defaultval.sint = val;
2079  break;
2080  }
2081  case kUpb_CType_Enum: {
2082  const upb_EnumDef* e = f->sub.enumdef;
2083  const upb_EnumValueDef* ev =
2085  if (!ev) {
2086  goto invalid;
2087  }
2088  f->defaultval.sint = ev->number;
2089  break;
2090  }
2091  case kUpb_CType_Int64: {
2092  long long val = strtoll(str, &end, 0);
2093  if (val > INT64_MAX || val < INT64_MIN || errno == ERANGE || *end) {
2094  goto invalid;
2095  }
2096  f->defaultval.sint = val;
2097  break;
2098  }
2099  case kUpb_CType_UInt32: {
2100  unsigned long val = strtoul(str, &end, 0);
2101  if (val > UINT32_MAX || errno == ERANGE || *end) {
2102  goto invalid;
2103  }
2104  f->defaultval.uint = val;
2105  break;
2106  }
2107  case kUpb_CType_UInt64: {
2108  unsigned long long val = strtoull(str, &end, 0);
2109  if (val > UINT64_MAX || errno == ERANGE || *end) {
2110  goto invalid;
2111  }
2112  f->defaultval.uint = val;
2113  break;
2114  }
2115  case kUpb_CType_Double: {
2116  double val = strtod(str, &end);
2117  if (errno == ERANGE || *end) {
2118  goto invalid;
2119  }
2120  f->defaultval.dbl = val;
2121  break;
2122  }
2123  case kUpb_CType_Float: {
2124  float val = strtof(str, &end);
2125  if (errno == ERANGE || *end) {
2126  goto invalid;
2127  }
2128  f->defaultval.flt = val;
2129  break;
2130  }
2131  case kUpb_CType_Bool: {
2132  if (streql2(str, len, "false")) {
2133  f->defaultval.boolean = false;
2134  } else if (streql2(str, len, "true")) {
2135  f->defaultval.boolean = true;
2136  } else {
2137  goto invalid;
2138  }
2139  break;
2140  }
2141  case kUpb_CType_String:
2142  f->defaultval.str = newstr(ctx, str, len);
2143  break;
2144  case kUpb_CType_Bytes:
2145  f->defaultval.str = unescape(ctx, f, str, len);
2146  break;
2147  case kUpb_CType_Message:
2148  /* Should not have a default value. */
2149  symtab_errf(ctx, "Message should not have a default (%s)",
2151  }
2152 
2153  return;
2154 
2155 invalid:
2156  symtab_errf(ctx, "Invalid default '%.*s' for field %s of type %d", (int)len,
2158 }
2159 
2161  switch (upb_FieldDef_CType(f)) {
2162  case kUpb_CType_Int32:
2163  case kUpb_CType_Int64:
2164  f->defaultval.sint = 0;
2165  break;
2166  case kUpb_CType_UInt64:
2167  case kUpb_CType_UInt32:
2168  f->defaultval.uint = 0;
2169  break;
2170  case kUpb_CType_Double:
2171  case kUpb_CType_Float:
2172  f->defaultval.dbl = 0;
2173  break;
2174  case kUpb_CType_String:
2175  case kUpb_CType_Bytes:
2176  f->defaultval.str = newstr(ctx, NULL, 0);
2177  break;
2178  case kUpb_CType_Bool:
2179  f->defaultval.boolean = false;
2180  break;
2181  case kUpb_CType_Enum:
2182  f->defaultval.sint = f->sub.enumdef->values[0].number;
2183  case kUpb_CType_Message:
2184  break;
2185  }
2186 }
2187 
2188 static void create_fielddef(
2189  symtab_addctx* ctx, const char* prefix, upb_MessageDef* m,
2190  const google_protobuf_FieldDescriptorProto* field_proto,
2191  const upb_FieldDef* _f, bool is_extension) {
2192  upb_FieldDef* f = (upb_FieldDef*)_f;
2194  const char* full_name;
2195  const char* json_name;
2196  const char* shortname;
2197  int32_t field_number;
2198 
2199  f->file = ctx->file; /* Must happen prior to symtab_add(). */
2200 
2202  symtab_errf(ctx, "field has no name");
2203  }
2204 
2206  check_ident(ctx, name, false);
2207  full_name = makefullname(ctx, prefix, name);
2208  shortname = shortdefname(full_name);
2209 
2211  json_name = strviewdup(
2213  f->has_json_name_ = true;
2214  } else {
2215  json_name = makejsonname(ctx, shortname);
2216  f->has_json_name_ = false;
2217  }
2218 
2219  field_number = google_protobuf_FieldDescriptorProto_number(field_proto);
2220 
2221  f->full_name = full_name;
2222  f->json_name = json_name;
2223  f->label_ = (int)google_protobuf_FieldDescriptorProto_label(field_proto);
2224  f->number_ = field_number;
2225  f->scope.oneof = NULL;
2226  f->proto3_optional_ =
2228 
2229  bool has_type = google_protobuf_FieldDescriptorProto_has_type(field_proto);
2230  bool has_type_name =
2232 
2233  f->type_ = (int)google_protobuf_FieldDescriptorProto_type(field_proto);
2234 
2235  if (has_type) {
2236  switch (f->type_) {
2238  case kUpb_FieldType_Group:
2239  case kUpb_FieldType_Enum:
2240  if (!has_type_name) {
2241  symtab_errf(ctx, "field of type %d requires type name (%s)",
2242  (int)f->type_, full_name);
2243  }
2244  break;
2245  default:
2246  if (has_type_name) {
2247  symtab_errf(ctx, "invalid type for field with type_name set (%s, %d)",
2248  full_name, (int)f->type_);
2249  }
2250  }
2251  } else if (has_type_name) {
2252  f->type_ =
2253  FIELD_TYPE_UNSPECIFIED; // We'll fill this in in resolve_fielddef().
2254  }
2255 
2256  if (!is_extension) {
2257  /* direct message field. */
2258  upb_value v, field_v, json_v, existing_v;
2259  size_t json_size;
2260 
2261  if (field_number <= 0 || field_number > kUpb_MaxFieldNumber) {
2262  symtab_errf(ctx, "invalid field number (%u)", field_number);
2263  }
2264 
2265  f->index_ = f - m->fields;
2266  f->msgdef = m;
2267  f->is_extension_ = false;
2268 
2269  field_v = pack_def(f, UPB_DEFTYPE_FIELD);
2271  v = upb_value_constptr(f);
2272  json_size = strlen(json_name);
2273 
2274  if (upb_strtable_lookup(&m->ntof, shortname, &existing_v)) {
2275  symtab_errf(ctx, "duplicate field name (%s)", shortname);
2276  }
2277 
2278  CHK_OOM(upb_strtable_insert(&m->ntof, name.data, name.size, field_v,
2279  ctx->arena));
2280 
2281  if (strcmp(shortname, json_name) != 0) {
2282  if (upb_strtable_lookup(&m->ntof, json_name, &v)) {
2283  symtab_errf(ctx, "duplicate json_name (%s)", json_name);
2284  } else {
2285  CHK_OOM(upb_strtable_insert(&m->ntof, json_name, json_size, json_v,
2286  ctx->arena));
2287  }
2288  }
2289 
2290  if (upb_inttable_lookup(&m->itof, field_number, NULL)) {
2291  symtab_errf(ctx, "duplicate field number (%u)", field_number);
2292  }
2293 
2294  CHK_OOM(upb_inttable_insert(&m->itof, field_number, v, ctx->arena));
2295 
2296  if (ctx->layout) {
2297  const upb_MiniTable_Field* fields = m->layout->fields;
2298  int count = m->layout->field_count;
2299  bool found = false;
2300  for (int i = 0; i < count; i++) {
2301  if (fields[i].number == field_number) {
2302  f->layout_index = i;
2303  found = true;
2304  break;
2305  }
2306  }
2307  UPB_ASSERT(found);
2308  }
2309  } else {
2310  /* extension field. */
2311  f->is_extension_ = true;
2312  f->scope.extension_scope = m;
2313  symtab_add(ctx, full_name, pack_def(f, UPB_DEFTYPE_EXT));
2314  f->layout_index = ctx->ext_count++;
2315  if (ctx->layout) {
2316  UPB_ASSERT(ctx->file->ext_layouts[f->layout_index]->field.number ==
2317  field_number);
2318  }
2319  }
2320 
2321  if (f->type_ < kUpb_FieldType_Double || f->type_ > kUpb_FieldType_SInt64) {
2322  symtab_errf(ctx, "invalid type for field %s (%d)", f->full_name, f->type_);
2323  }
2324 
2325  if (f->label_ < kUpb_Label_Optional || f->label_ > kUpb_Label_Repeated) {
2326  symtab_errf(ctx, "invalid label for field %s (%d)", f->full_name,
2327  f->label_);
2328  }
2329 
2330  /* We can't resolve the subdef or (in the case of extensions) the containing
2331  * message yet, because it may not have been defined yet. We stash a pointer
2332  * to the field_proto until later when we can properly resolve it. */
2333  f->sub.unresolved = field_proto;
2334 
2335  if (f->label_ == kUpb_Label_Required &&
2336  f->file->syntax == kUpb_Syntax_Proto3) {
2337  symtab_errf(ctx, "proto3 fields cannot be required (%s)", f->full_name);
2338  }
2339 
2341  int oneof_index =
2343  upb_OneofDef* oneof;
2344  upb_value v = upb_value_constptr(f);
2345 
2347  symtab_errf(ctx, "fields in oneof must have OPTIONAL label (%s)",
2348  f->full_name);
2349  }
2350 
2351  if (!m) {
2352  symtab_errf(ctx, "oneof_index provided for extension field (%s)",
2353  f->full_name);
2354  }
2355 
2356  if (oneof_index >= m->oneof_count) {
2357  symtab_errf(ctx, "oneof_index out of range (%s)", f->full_name);
2358  }
2359 
2360  oneof = (upb_OneofDef*)&m->oneofs[oneof_index];
2361  f->scope.oneof = oneof;
2362 
2363  oneof->field_count++;
2364  if (f->proto3_optional_) {
2365  oneof->synthetic = true;
2366  }
2367  CHK_OOM(upb_inttable_insert(&oneof->itof, f->number_, v, ctx->arena));
2368  CHK_OOM(
2369  upb_strtable_insert(&oneof->ntof, name.data, name.size, v, ctx->arena));
2370  } else {
2371  if (f->proto3_optional_) {
2372  symtab_errf(ctx, "field with proto3_optional was not in a oneof (%s)",
2373  f->full_name);
2374  }
2375  }
2376 
2377  SET_OPTIONS(f->opts, FieldDescriptorProto, FieldOptions, field_proto);
2378 
2380  f->packed_ = google_protobuf_FieldOptions_packed(f->opts);
2381  } else {
2382  /* Repeated fields default to packed for proto3 only. */
2383  f->packed_ = upb_FieldDef_IsPrimitive(f) &&
2384  f->label_ == kUpb_Label_Repeated &&
2385  f->file->syntax == kUpb_Syntax_Proto3;
2386  }
2387 }
2388 
2389 static void create_service(
2391  const upb_ServiceDef* _s) {
2392  upb_ServiceDef* s = (upb_ServiceDef*)_s;
2394  const google_protobuf_MethodDescriptorProto* const* methods;
2395  size_t i, n;
2396 
2397  s->file = ctx->file; /* Must happen prior to symtab_add. */
2398 
2400  check_ident(ctx, name, false);
2401  s->full_name = makefullname(ctx, ctx->file->package, name);
2402  symtab_add(ctx, s->full_name, pack_def(s, UPB_DEFTYPE_SERVICE));
2403 
2404  methods = google_protobuf_ServiceDescriptorProto_method(svc_proto, &n);
2405 
2406  s->method_count = n;
2407  s->methods = symtab_alloc(ctx, sizeof(*s->methods) * n);
2408 
2409  SET_OPTIONS(s->opts, ServiceDescriptorProto, ServiceOptions, svc_proto);
2410 
2411  for (i = 0; i < n; i++) {
2412  const google_protobuf_MethodDescriptorProto* method_proto = methods[i];
2413  upb_MethodDef* m = (upb_MethodDef*)&s->methods[i];
2416 
2417  m->service = s;
2418  m->full_name = makefullname(ctx, s->full_name, name);
2419  m->index = i;
2420  m->client_streaming =
2422  m->server_streaming =
2424  m->input_type = symtab_resolve(
2425  ctx, m->full_name, m->full_name,
2427  UPB_DEFTYPE_MSG);
2428  m->output_type = symtab_resolve(
2429  ctx, m->full_name, m->full_name,
2431  UPB_DEFTYPE_MSG);
2432 
2433  SET_OPTIONS(m->opts, MethodDescriptorProto, MethodOptions, method_proto);
2434  }
2435 }
2436 
2438  // For assertions only, speed does not matter.
2439  int n = 0;
2440  while (x) {
2441  if (x & 1) n++;
2442  x >>= 1;
2443  }
2444  return n;
2445 }
2446 
2447 static int compare_int32(const void* a_ptr, const void* b_ptr) {
2448  int32_t a = *(int32_t*)a_ptr;
2449  int32_t b = *(int32_t*)b_ptr;
2450  return a < b ? -1 : (a == b ? 0 : 1);
2451 }
2452 
2454  const upb_EnumDef* e) {
2455  int n = 0;
2456  uint64_t mask = 0;
2457 
2458  for (int i = 0; i < e->value_count; i++) {
2459  uint32_t val = (uint32_t)e->values[i].number;
2460  if (val < 64) {
2461  mask |= 1ULL << val;
2462  } else {
2463  n++;
2464  }
2465  }
2466 
2467  int32_t* values = symtab_alloc(ctx, sizeof(*values) * n);
2468 
2469  if (n) {
2470  int32_t* p = values;
2471 
2472  // Add values outside the bitmask range to the list, as described in the
2473  // comments for upb_MiniTable_Enum.
2474  for (int i = 0; i < e->value_count; i++) {
2475  int32_t val = e->values[i].number;
2476  if ((uint32_t)val >= 64) {
2477  *p++ = val;
2478  }
2479  }
2480  UPB_ASSERT(p == values + n);
2481  }
2482 
2483  // Enums can have duplicate values; we must sort+uniq them.
2484  if (values) qsort(values, n, sizeof(*values), &compare_int32);
2485 
2486  int dst = 0;
2487  for (int i = 0; i < n; dst++) {
2488  int32_t val = values[i];
2489  while (i < n && values[i] == val) i++; // Skip duplicates.
2490  values[dst] = val;
2491  }
2492  n = dst;
2493 
2494  UPB_ASSERT(upb_inttable_count(&e->iton) == n + count_bits_debug(mask));
2495 
2497  layout->value_count = n;
2498  layout->mask = mask;
2499  layout->values = values;
2500 
2501  return layout;
2502 }
2503 
2504 static void create_enumvaldef(
2505  symtab_addctx* ctx, const char* prefix,
2507  int i) {
2508  upb_EnumValueDef* val = (upb_EnumValueDef*)&e->values[i];
2511  upb_value v = upb_value_constptr(val);
2512 
2513  val->parent = e; /* Must happen prior to symtab_add(). */
2514  val->full_name = makefullname(ctx, prefix, name);
2517 
2519 
2520  if (i == 0 && e->file->syntax == kUpb_Syntax_Proto3 && val->number != 0) {
2521  symtab_errf(ctx, "for proto3, the first enum value must be zero (%s)",
2522  e->full_name);
2523  }
2524 
2525  CHK_OOM(upb_strtable_insert(&e->ntoi, name.data, name.size, v, ctx->arena));
2526 
2527  // Multiple enumerators can have the same number, first one wins.
2528  if (!upb_inttable_lookup(&e->iton, val->number, NULL)) {
2529  CHK_OOM(upb_inttable_insert(&e->iton, val->number, v, ctx->arena));
2530  }
2531 }
2532 
2533 static void create_enumdef(
2534  symtab_addctx* ctx, const char* prefix,
2535  const google_protobuf_EnumDescriptorProto* enum_proto,
2536  const upb_MessageDef* containing_type, const upb_EnumDef* _e) {
2537  upb_EnumDef* e = (upb_EnumDef*)_e;
2538  ;
2541  size_t i, n;
2542 
2543  e->file = ctx->file; /* Must happen prior to symtab_add() */
2544  e->containing_type = containing_type;
2545 
2547  check_ident(ctx, name, false);
2548 
2549  e->full_name = makefullname(ctx, prefix, name);
2550  symtab_add(ctx, e->full_name, pack_def(e, UPB_DEFTYPE_ENUM));
2551 
2553  CHK_OOM(upb_strtable_init(&e->ntoi, n, ctx->arena));
2554  CHK_OOM(upb_inttable_init(&e->iton, ctx->arena));
2555 
2556  e->defaultval = 0;
2557  e->value_count = n;
2558  e->values = symtab_alloc(ctx, sizeof(*e->values) * n);
2559 
2560  if (n == 0) {
2561  symtab_errf(ctx, "enums must contain at least one value (%s)",
2562  e->full_name);
2563  }
2564 
2565  SET_OPTIONS(e->opts, EnumDescriptorProto, EnumOptions, enum_proto);
2566 
2567  for (i = 0; i < n; i++) {
2569  }
2570 
2571  upb_inttable_compact(&e->iton, ctx->arena);
2572 
2573  if (e->file->syntax == kUpb_Syntax_Proto2) {
2574  if (ctx->layout) {
2575  UPB_ASSERT(ctx->enum_count < ctx->layout->enum_count);
2576  e->layout = ctx->layout->enums[ctx->enum_count++];
2577  UPB_ASSERT(upb_inttable_count(&e->iton) ==
2578  e->layout->value_count + count_bits_debug(e->layout->mask));
2579  } else {
2580  e->layout = create_enumlayout(ctx, e);
2581  }
2582  } else {
2583  e->layout = NULL;
2584  }
2585 }
2586 
2587 static void msgdef_create_nested(
2589  upb_MessageDef* m);
2590 
2591 static void create_msgdef(symtab_addctx* ctx, const char* prefix,
2592  const google_protobuf_DescriptorProto* msg_proto,
2594  const upb_MessageDef* _m) {
2596  const google_protobuf_OneofDescriptorProto* const* oneofs;
2598  const google_protobuf_DescriptorProto_ExtensionRange* const* ext_ranges;
2599  size_t i, n_oneof, n_field, n_ext_range;
2601 
2602  m->file = ctx->file; /* Must happen prior to symtab_add(). */
2603  m->containing_type = containing_type;
2604 
2606  check_ident(ctx, name, false);
2607 
2608  m->full_name = makefullname(ctx, prefix, name);
2609  symtab_add(ctx, m->full_name, pack_def(m, UPB_DEFTYPE_MSG));
2610 
2611  oneofs = google_protobuf_DescriptorProto_oneof_decl(msg_proto, &n_oneof);
2612  fields = google_protobuf_DescriptorProto_field(msg_proto, &n_field);
2613  ext_ranges =
2614  google_protobuf_DescriptorProto_extension_range(msg_proto, &n_ext_range);
2615 
2616  CHK_OOM(upb_inttable_init(&m->itof, ctx->arena));
2617  CHK_OOM(upb_strtable_init(&m->ntof, n_oneof + n_field, ctx->arena));
2618 
2619  if (ctx->layout) {
2620  /* create_fielddef() below depends on this being set. */
2621  UPB_ASSERT(ctx->msg_count < ctx->layout->msg_count);
2622  m->layout = ctx->layout->msgs[ctx->msg_count++];
2623  UPB_ASSERT(n_field == m->layout->field_count);
2624  } else {
2625  /* Allocate now (to allow cross-linking), populate later. */
2626  m->layout =
2627  symtab_alloc(ctx, sizeof(*m->layout) + sizeof(_upb_FastTable_Entry));
2628  }
2629 
2630  SET_OPTIONS(m->opts, DescriptorProto, MessageOptions, msg_proto);
2631 
2632  m->oneof_count = n_oneof;
2633  m->oneofs = symtab_alloc(ctx, sizeof(*m->oneofs) * n_oneof);
2634  for (i = 0; i < n_oneof; i++) {
2635  create_oneofdef(ctx, m, oneofs[i], &m->oneofs[i]);
2636  }
2637 
2638  m->field_count = n_field;
2639  m->fields = symtab_alloc(ctx, sizeof(*m->fields) * n_field);
2640  for (i = 0; i < n_field; i++) {
2641  create_fielddef(ctx, m->full_name, m, fields[i], &m->fields[i],
2642  /* is_extension= */ false);
2643  }
2644 
2645  m->ext_range_count = n_ext_range;
2646  m->ext_ranges = symtab_alloc(ctx, sizeof(*m->ext_ranges) * n_ext_range);
2647  for (i = 0; i < n_ext_range; i++) {
2648  const google_protobuf_DescriptorProto_ExtensionRange* r = ext_ranges[i];
2649  upb_ExtensionRange* r_def = (upb_ExtensionRange*)&m->ext_ranges[i];
2652  int32_t max =
2654  ? INT32_MAX
2655  : kUpb_MaxFieldNumber + 1;
2656 
2657  // A full validation would also check that each range is disjoint, and that
2658  // none of the fields overlap with the extension ranges, but we are just
2659  // sanity checking here.
2660  if (start < 1 || end <= start || end > max) {
2661  symtab_errf(ctx, "Extension range (%d, %d) is invalid, message=%s\n",
2662  (int)start, (int)end, m->full_name);
2663  }
2664 
2665  r_def->start = start;
2666  r_def->end = end;
2669  }
2670 
2671  finalize_oneofs(ctx, m);
2673  upb_inttable_compact(&m->itof, ctx->arena);
2674  msgdef_create_nested(ctx, msg_proto, m);
2675 }
2676 
2679  upb_MessageDef* m) {
2680  size_t n;
2681 
2682  const google_protobuf_EnumDescriptorProto* const* enums =
2684  m->nested_enum_count = n;
2685  m->nested_enums = symtab_alloc(ctx, sizeof(*m->nested_enums) * n);
2686  for (size_t i = 0; i < n; i++) {
2687  m->nested_enum_count = i + 1;
2688  create_enumdef(ctx, m->full_name, enums[i], m, &m->nested_enums[i]);
2689  }
2690 
2691  const google_protobuf_FieldDescriptorProto* const* exts =
2693  m->nested_ext_count = n;
2694  m->nested_exts = symtab_alloc(ctx, sizeof(*m->nested_exts) * n);
2695  for (size_t i = 0; i < n; i++) {
2696  create_fielddef(ctx, m->full_name, m, exts[i], &m->nested_exts[i],
2697  /* is_extension= */ true);
2698  ((upb_FieldDef*)&m->nested_exts[i])->index_ = i;
2699  }
2700 
2701  const google_protobuf_DescriptorProto* const* msgs =
2703  m->nested_msg_count = n;
2704  m->nested_msgs = symtab_alloc(ctx, sizeof(*m->nested_msgs) * n);
2705  for (size_t i = 0; i < n; i++) {
2706  create_msgdef(ctx, m->full_name, msgs[i], m, &m->nested_msgs[i]);
2707  }
2708 }
2709 
2710 static void resolve_subdef(symtab_addctx* ctx, const char* prefix,
2711  upb_FieldDef* f) {
2712  const google_protobuf_FieldDescriptorProto* field_proto = f->sub.unresolved;
2715  bool has_name =
2717  switch ((int)f->type_) {
2718  case FIELD_TYPE_UNSPECIFIED: {
2719  // Type was not specified and must be inferred.
2720  UPB_ASSERT(has_name);
2722  const void* def =
2723  symtab_resolveany(ctx, f->full_name, prefix, name, &type);
2724  switch (type) {
2725  case UPB_DEFTYPE_ENUM:
2726  f->sub.enumdef = def;
2727  f->type_ = kUpb_FieldType_Enum;
2728  break;
2729  case UPB_DEFTYPE_MSG:
2730  f->sub.msgdef = def;
2731  f->type_ = kUpb_FieldType_Message; // It appears there is no way of
2732  // this being a group.
2733  break;
2734  default:
2735  symtab_errf(ctx, "Couldn't resolve type name for field %s",
2736  f->full_name);
2737  }
2738  }
2740  case kUpb_FieldType_Group:
2741  UPB_ASSERT(has_name);
2742  f->sub.msgdef =
2743  symtab_resolve(ctx, f->full_name, prefix, name, UPB_DEFTYPE_MSG);
2744  break;
2745  case kUpb_FieldType_Enum:
2746  UPB_ASSERT(has_name);
2747  f->sub.enumdef =
2748  symtab_resolve(ctx, f->full_name, prefix, name, UPB_DEFTYPE_ENUM);
2749  break;
2750  default:
2751  // No resolution necessary.
2752  break;
2753  }
2754 }
2755 
2756 static void resolve_extension(
2757  symtab_addctx* ctx, const char* prefix, upb_FieldDef* f,
2758  const google_protobuf_FieldDescriptorProto* field_proto) {
2760  symtab_errf(ctx, "extension for field '%s' had no extendee", f->full_name);
2761  }
2762 
2765  const upb_MessageDef* m =
2766  symtab_resolve(ctx, f->full_name, prefix, name, UPB_DEFTYPE_MSG);
2767  f->msgdef = m;
2768 
2769  bool found = false;
2770 
2771  for (int i = 0, n = m->ext_range_count; i < n; i++) {
2772  const upb_ExtensionRange* r = &m->ext_ranges[i];
2773  if (r->start <= f->number_ && f->number_ < r->end) {
2774  found = true;
2775  break;
2776  }
2777  }
2778 
2779  if (!found) {
2780  symtab_errf(ctx,
2781  "field number %u in extension %s has no extension range in "
2782  "message %s",
2783  (unsigned)f->number_, f->full_name, f->msgdef->full_name);
2784  }
2785 
2786  const upb_MiniTable_Extension* ext = ctx->file->ext_layouts[f->layout_index];
2787  if (ctx->layout) {
2788  UPB_ASSERT(upb_FieldDef_Number(f) == ext->field.number);
2789  } else {
2791  fill_fieldlayout(&mut_ext->field, f);
2792  mut_ext->field.presence = 0;
2793  mut_ext->field.offset = 0;
2794  mut_ext->field.submsg_index = 0;
2795  mut_ext->extendee = f->msgdef->layout;
2796  mut_ext->sub.submsg = f->sub.msgdef->layout;
2797  }
2798 
2800  upb_value_constptr(f), ctx->arena));
2801 }
2802 
2803 static void resolve_default(
2805  const google_protobuf_FieldDescriptorProto* field_proto) {
2806  // Have to delay resolving of the default value until now because of the enum
2807  // case, since enum defaults are specified with a label.
2809  upb_StringView defaultval =
2811 
2812  if (f->file->syntax == kUpb_Syntax_Proto3) {
2813  symtab_errf(ctx, "proto3 fields cannot have explicit defaults (%s)",
2814  f->full_name);
2815  }
2816 
2818  symtab_errf(ctx, "message fields cannot have explicit defaults (%s)",
2819  f->full_name);
2820  }
2821 
2822  parse_default(ctx, defaultval.data, defaultval.size, f);
2823  f->has_default = true;
2824  } else {
2826  f->has_default = false;
2827  }
2828 }
2829 
2830 static void resolve_fielddef(symtab_addctx* ctx, const char* prefix,
2831  upb_FieldDef* f) {
2832  // We have to stash this away since resolve_subdef() may overwrite it.
2833  const google_protobuf_FieldDescriptorProto* field_proto = f->sub.unresolved;
2834 
2836  resolve_default(ctx, f, field_proto);
2837 
2838  if (f->is_extension_) {
2839  resolve_extension(ctx, prefix, f, field_proto);
2840  }
2841 }
2842 
2844  for (int i = 0; i < m->field_count; i++) {
2845  resolve_fielddef(ctx, m->full_name, (upb_FieldDef*)&m->fields[i]);
2846  }
2847 
2848  m->in_message_set = false;
2849  for (int i = 0; i < m->nested_ext_count; i++) {
2850  upb_FieldDef* ext = (upb_FieldDef*)&m->nested_exts[i];
2851  resolve_fielddef(ctx, m->full_name, ext);
2852  if (ext->type_ == kUpb_FieldType_Message &&
2853  ext->label_ == kUpb_Label_Optional && ext->sub.msgdef == m &&
2855  ext->msgdef->opts)) {
2856  m->in_message_set = true;
2857  }
2858  }
2859 
2860  if (!ctx->layout) make_layout(ctx, m);
2861 
2862  for (int i = 0; i < m->nested_msg_count; i++) {
2863  resolve_msgdef(ctx, (upb_MessageDef*)&m->nested_msgs[i]);
2864  }
2865 }
2866 
2868  size_t n;
2870  int ext_count = n;
2871 
2872  const google_protobuf_DescriptorProto* const* nested_msgs =
2874  for (size_t i = 0; i < n; i++) {
2875  ext_count += count_exts_in_msg(nested_msgs[i]);
2876  }
2877 
2878  return ext_count;
2879 }
2880 
2881 static void build_filedef(
2883  const google_protobuf_FileDescriptorProto* file_proto) {
2884  const google_protobuf_DescriptorProto* const* msgs;
2885  const google_protobuf_EnumDescriptorProto* const* enums;
2886  const google_protobuf_FieldDescriptorProto* const* exts;
2888  const upb_StringView* strs;
2889  const int32_t* public_deps;
2890  const int32_t* weak_deps;
2891  size_t i, n;
2892 
2893  file->symtab = ctx->symtab;
2894 
2895  /* Count all extensions in the file, to build a flat array of layouts. */
2897  int ext_count = n;
2899  for (int i = 0; i < n; i++) {
2900  ext_count += count_exts_in_msg(msgs[i]);
2901  }
2902  file->ext_count = ext_count;
2903 
2904  if (ctx->layout) {
2905  /* We are using the ext layouts that were passed in. */
2906  file->ext_layouts = ctx->layout->exts;
2907  if (ctx->layout->ext_count != file->ext_count) {
2908  symtab_errf(ctx, "Extension count did not match layout (%d vs %d)",
2909  ctx->layout->ext_count, file->ext_count);
2910  }
2911  } else {
2912  /* We are building ext layouts from scratch. */
2913  file->ext_layouts =
2914  symtab_alloc(ctx, sizeof(*file->ext_layouts) * file->ext_count);
2916  symtab_alloc(ctx, sizeof(*ext) * file->ext_count);
2917  for (int i = 0; i < file->ext_count; i++) {
2918  file->ext_layouts[i] = &ext[i];
2919  }
2920  }
2921 
2923  symtab_errf(ctx, "File has no name");
2924  }
2925 
2926  file->name =
2928 
2930  upb_StringView package =
2931  google_protobuf_FileDescriptorProto_package(file_proto);
2932  check_ident(ctx, package, true);
2933  file->package = strviewdup(ctx, package);
2934  } else {
2935  file->package = NULL;
2936  }
2937 
2941 
2942  if (streql_view(syntax, "proto2")) {
2943  file->syntax = kUpb_Syntax_Proto2;
2944  } else if (streql_view(syntax, "proto3")) {
2945  file->syntax = kUpb_Syntax_Proto3;
2946  } else {
2947  symtab_errf(ctx, "Invalid syntax '" UPB_STRINGVIEW_FORMAT "'",
2949  }
2950  } else {
2951  file->syntax = kUpb_Syntax_Proto2;
2952  }
2953 
2954  /* Read options. */
2955  SET_OPTIONS(file->opts, FileDescriptorProto, FileOptions, file_proto);
2956 
2957  /* Verify dependencies. */
2959  file->dep_count = n;
2960  file->deps = symtab_alloc(ctx, sizeof(*file->deps) * n);
2961 
2962  for (i = 0; i < n; i++) {
2963  upb_StringView str = strs[i];
2964  file->deps[i] =
2966  if (!file->deps[i]) {
2967  symtab_errf(ctx,
2968  "Depends on file '" UPB_STRINGVIEW_FORMAT
2969  "', but it has not been loaded",
2971  }
2972  }
2973 
2974  public_deps =
2976  file->public_dep_count = n;
2977  file->public_deps = symtab_alloc(ctx, sizeof(*file->public_deps) * n);
2978  int32_t* mutable_public_deps = (int32_t*)file->public_deps;
2979  for (i = 0; i < n; i++) {
2980  if (public_deps[i] >= file->dep_count) {
2981  symtab_errf(ctx, "public_dep %d is out of range", (int)public_deps[i]);
2982  }
2983  mutable_public_deps[i] = public_deps[i];
2984  }
2985 
2986  weak_deps =
2988  file->weak_dep_count = n;
2989  file->weak_deps = symtab_alloc(ctx, sizeof(*file->weak_deps) * n);
2990  int32_t* mutable_weak_deps = (int32_t*)file->weak_deps;
2991  for (i = 0; i < n; i++) {
2992  if (weak_deps[i] >= file->dep_count) {
2993  symtab_errf(ctx, "weak_dep %d is out of range", (int)weak_deps[i]);
2994  }
2995  mutable_weak_deps[i] = weak_deps[i];
2996  }
2997 
2998  /* Create enums. */
2999  enums = google_protobuf_FileDescriptorProto_enum_type(file_proto, &n);
3000  file->top_lvl_enum_count = n;
3001  file->top_lvl_enums = symtab_alloc(ctx, sizeof(*file->top_lvl_enums) * n);
3002  for (i = 0; i < n; i++) {
3003  create_enumdef(ctx, file->package, enums[i], NULL, &file->top_lvl_enums[i]);
3004  }
3005 
3006  /* Create extensions. */
3007  exts = google_protobuf_FileDescriptorProto_extension(file_proto, &n);
3008  file->top_lvl_ext_count = n;
3009  file->top_lvl_exts = symtab_alloc(ctx, sizeof(*file->top_lvl_exts) * n);
3010  for (i = 0; i < n; i++) {
3011  create_fielddef(ctx, file->package, NULL, exts[i], &file->top_lvl_exts[i],
3012  /* is_extension= */ true);
3013  ((upb_FieldDef*)&file->top_lvl_exts[i])->index_ = i;
3014  }
3015 
3016  /* Create messages. */
3018  file->top_lvl_msg_count = n;
3019  file->top_lvl_msgs = symtab_alloc(ctx, sizeof(*file->top_lvl_msgs) * n);
3020  for (i = 0; i < n; i++) {
3021  create_msgdef(ctx, file->package, msgs[i], NULL, &file->top_lvl_msgs[i]);
3022  }
3023 
3024  /* Create services. */
3026  file->service_count = n;
3027  file->services = symtab_alloc(ctx, sizeof(*file->services) * n);
3028  for (i = 0; i < n; i++) {
3029  create_service(ctx, services[i], &file->services[i]);
3030  ((upb_ServiceDef*)&file->services[i])->index = i;
3031  }
3032 
3033  /* Now that all names are in the table, build layouts and resolve refs. */
3034  for (i = 0; i < (size_t)file->top_lvl_ext_count; i++) {
3035  resolve_fielddef(ctx, file->package, (upb_FieldDef*)&file->top_lvl_exts[i]);
3036  }
3037 
3038  for (i = 0; i < (size_t)file->top_lvl_msg_count; i++) {
3039  resolve_msgdef(ctx, (upb_MessageDef*)&file->top_lvl_msgs[i]);
3040  }
3041 
3042  if (file->ext_count) {
3043  CHK_OOM(_upb_extreg_add(ctx->symtab->extreg, file->ext_layouts,
3044  file->ext_count));
3045  }
3046 }
3047 
3051  upb_value val;
3052  while (upb_strtable_next2(&s->syms, &key, &val, &iter)) {
3053  const upb_FileDef* f;
3054  switch (deftype(val)) {
3055  case UPB_DEFTYPE_EXT:
3057  break;
3058  case UPB_DEFTYPE_MSG:
3060  break;
3061  case UPB_DEFTYPE_ENUM:
3063  break;
3064  case UPB_DEFTYPE_ENUMVAL:
3065  f = upb_EnumDef_File(
3067  break;
3068  case UPB_DEFTYPE_SERVICE:
3070  break;
3071  default:
3072  UPB_UNREACHABLE();
3073  }
3074 
3075  if (f == file) upb_strtable_removeiter(&s->syms, &iter);
3076  }
3077 }
3078 
3080  upb_DefPool* s, const google_protobuf_FileDescriptorProto* file_proto,
3084  upb_value v;
3085 
3086  if (upb_strtable_lookup2(&s->files, name.data, name.size, &v)) {
3087  if (unpack_def(v, UPB_DEFTYPE_FILE)) {
3088  upb_Status_SetErrorFormat(status, "duplicate file name (%.*s)",
3090  return NULL;
3091  }
3092  const upb_MiniTable_File* registered = unpack_def(v, UPB_DEFTYPE_LAYOUT);
3093  UPB_ASSERT(registered);
3094  if (layout && layout != registered) {
3096  status, "tried to build with a different layout (filename=%.*s)",
3098  return NULL;
3099  }
3100  layout = registered;
3101  }
3102 
3103  ctx.symtab = s;
3104  ctx.layout = layout;
3105  ctx.msg_count = 0;
3106  ctx.enum_count = 0;
3107  ctx.ext_count = 0;
3108  ctx.status = status;
3109  ctx.file = NULL;
3110  ctx.arena = upb_Arena_New();
3111  ctx.tmp_arena = upb_Arena_New();
3112 
3113  if (!ctx.arena || !ctx.tmp_arena) {
3115  if (ctx.tmp_arena) upb_Arena_Free(ctx.tmp_arena);
3117  return NULL;
3118  }
3119 
3120  if (UPB_UNLIKELY(UPB_SETJMP(ctx.err))) {
3122  if (ctx.file) {
3123  remove_filedef(s, ctx.file);
3124  ctx.file = NULL;
3125  }
3126  } else {
3127  ctx.file = symtab_alloc(&ctx, sizeof(*ctx.file));
3128  build_filedef(&ctx, ctx.file, file_proto);
3129  upb_strtable_insert(&s->files, name.data, name.size,
3132  upb_Arena_Fuse(s->arena, ctx.arena);
3133  }
3134 
3136  upb_Arena_Free(ctx.tmp_arena);
3137  return ctx.file;
3138 }
3139 
3141  upb_DefPool* s, const google_protobuf_FileDescriptorProto* file_proto,
3142  upb_Status* status) {
3143  return _upb_DefPool_AddFile(s, file_proto, NULL, status);
3144 }
3145 
3146 /* Include here since we want most of this file to be stdio-free. */
3147 #include <stdio.h>
3148 
3150  bool rebuild_minitable) {
3151  /* Since this function should never fail (it would indicate a bug in upb) we
3152  * print errors to stderr instead of returning error status to the user. */
3153  _upb_DefPool_Init** deps = init->deps;
3155  upb_Arena* arena;
3157 
3159 
3160  if (upb_DefPool_FindFileByName(s, init->filename)) {
3161  return true;
3162  }
3163 
3164  arena = upb_Arena_New();
3165 
3166  for (; *deps; deps++) {
3167  if (!_upb_DefPool_LoadDefInitEx(s, *deps, rebuild_minitable)) goto err;
3168  }
3169 
3171  init->descriptor.data, init->descriptor.size, NULL,
3173  s->bytes_loaded += init->descriptor.size;
3174 
3175  if (!file) {
3177  &status,
3178  "Failed to parse compiled-in descriptor for file '%s'. This should "
3179  "never happen.",
3180  init->filename);
3181  goto err;
3182  }
3183 
3184  const upb_MiniTable_File* mt = rebuild_minitable ? NULL : init->layout;
3185  if (!_upb_DefPool_AddFile(s, file, mt, &status)) {
3186  goto err;
3187  }
3188 
3190  return true;
3191 
3192 err:
3193  fprintf(stderr,
3194  "Error loading compiled-in descriptor for file '%s' (this should "
3195  "never happen): %s\n",
3196  init->filename, upb_Status_ErrorMessage(&status));
3198  return false;
3199 }
3200 
3202  return s->bytes_loaded;
3203 }
3204 
3205 upb_Arena* _upb_DefPool_Arena(const upb_DefPool* s) { return s->arena; }
3206 
3208  const upb_DefPool* s, const upb_MiniTable_Extension* ext) {
3209  upb_value v;
3210  bool ok = upb_inttable_lookup(&s->exts, (uintptr_t)ext, &v);
3211  UPB_ASSERT(ok);
3212  return upb_value_getconstptr(v);
3213 }
3214 
3216  const upb_MessageDef* m,
3217  int32_t fieldnum) {
3219  const upb_MiniTable_Extension* ext = _upb_extreg_get(s->extreg, l, fieldnum);
3220  return ext ? _upb_DefPool_FindExtensionByMiniTable(s, ext) : NULL;
3221 }
3222 
3224  const upb_MiniTable_File* file) {
3225  if (upb_DefPool_FindFileByName(s, filename)) return false;
3227  return upb_strtable_insert(&s->files, filename, strlen(filename), v,
3228  s->arena);
3229 }
3230 
3232  const upb_DefPool* s) {
3233  return s->extreg;
3234 }
3235 
3237  const upb_MessageDef* m,
3238  size_t* count) {
3239  size_t n = 0;
3241  uintptr_t key;
3242  upb_value val;
3243  // This is O(all exts) instead of O(exts for m). If we need this to be
3244  // efficient we may need to make extreg into a two-level table, or have a
3245  // second per-message index.
3246  while (upb_inttable_next2(&s->exts, &key, &val, &iter)) {
3247  const upb_FieldDef* f = upb_value_getconstptr(val);
3248  if (upb_FieldDef_ContainingType(f) == m) n++;
3249  }
3250  const upb_FieldDef** exts = malloc(n * sizeof(*exts));
3252  size_t i = 0;
3253  while (upb_inttable_next2(&s->exts, &key, &val, &iter)) {
3254  const upb_FieldDef* f = upb_value_getconstptr(val);
3255  if (upb_FieldDef_ContainingType(f) == m) exts[i++] = f;
3256  }
3257  *count = n;
3258  return exts;
3259 }
3260 
3261 #undef CHK_OOM
upb_FileDef::top_lvl_enum_count
int top_lvl_enum_count
Definition: upb/upb/def.c:190
upb_FieldDef_IsPrimitive
bool upb_FieldDef_IsPrimitive(const upb_FieldDef *f)
Definition: upb/upb/def.c:655
upb_EnumDef_ContainingType
const upb_MessageDef * upb_EnumDef_ContainingType(const upb_EnumDef *e)
Definition: upb/upb/def.c:398
kUpb_WellKnown_StringValue
@ kUpb_WellKnown_StringValue
Definition: upb/upb/def.h:85
upb_OneofDef_Name
const char * upb_OneofDef_Name(const upb_OneofDef *o)
Definition: upb/upb/def.c:870
xds_interop_client.str
str
Definition: xds_interop_client.py:487
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
upb_MessageDef_FindOneofByNameWithSize
const upb_OneofDef * upb_MessageDef_FindOneofByNameWithSize(const upb_MessageDef *m, const char *name, size_t len)
Definition: upb/upb/def.c:739
upb_FieldDef_Type
upb_FieldType upb_FieldDef_Type(const upb_FieldDef *f)
Definition: upb/upb/def.c:535
symtab_addctx::layout
const upb_MiniTable_File * layout
Definition: upb/upb/def.c:1260
upb_FieldDef_Number
uint32_t upb_FieldDef_Number(const upb_FieldDef *f)
Definition: upb/upb/def.c:541
upb_FileDef::dep_count
int dep_count
Definition: upb/upb/def.c:186
kUpb_MaxFieldNumber
#define kUpb_MaxFieldNumber
Definition: upb/upb/def.h:97
upb_FieldDef_HasDefault
bool upb_FieldDef_HasDefault(const upb_FieldDef *f)
Definition: upb/upb/def.c:664
google_protobuf_MethodDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_MethodDescriptorProto_name(const google_protobuf_MethodDescriptorProto *msg)
Definition: descriptor.upb.h:1557
ctx::arena
upb_Arena * arena
Definition: conformance_upb.c:84
google_protobuf_FieldDescriptorProto_oneof_index
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:1012
upb_MessageDef::itof
upb_inttable itof
Definition: upb/upb/def.c:108
upb_MessageDef::opts
const google_protobuf_MessageOptions * opts
Definition: upb/upb/def.c:101
upb_EnumValueDef::opts
const google_protobuf_EnumValueOptions * opts
Definition: upb/upb/def.c:151
deps
static _upb_DefPool_Init * deps[4]
Definition: certs.upbdefs.c:72
kUpb_CType_String
@ kUpb_CType_String
Definition: upb/upb/upb.h:296
kUpb_FieldRep_4Byte
@ kUpb_FieldRep_4Byte
Definition: msg_internal.h:101
field_number_cmp
static int field_number_cmp(const void *p1, const void *p2)
Definition: upb/upb/def.c:1385
upb_FieldDef_IsPacked
bool upb_FieldDef_IsPacked(const upb_FieldDef *f)
Definition: upb/upb/def.c:547
kUpb_FieldType_SInt64
@ kUpb_FieldType_SInt64
Definition: upb/upb/upb.h:326
upb_FieldType
upb_FieldType
Definition: upb/upb/upb.h:308
filename
const char * filename
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:135
kUpb_CType_UInt32
@ kUpb_CType_UInt32
Definition: upb/upb/upb.h:290
kUpb_FieldType_SFixed64
@ kUpb_FieldType_SFixed64
Definition: upb/upb/upb.h:324
dst
static const char dst[]
Definition: test-fs-copyfile.c:37
upb_inttable_insert
UPB_INLINE bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:942
upb_MethodDef::input_type
const upb_MessageDef * input_type
Definition: upb/upb/def.c:201
test_server.argp
argp
Definition: test_server.py:33
upb_ExtensionRange_HasOptions
bool upb_ExtensionRange_HasOptions(const upb_ExtensionRange *r)
Definition: upb/upb/def.c:475
google_protobuf_FieldDescriptorProto_proto3_optional
UPB_INLINE bool google_protobuf_FieldDescriptorProto_proto3_optional(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:1032
upb_CType
upb_CType
Definition: upb/upb/upb.h:286
resolve_fielddef
static void resolve_fielddef(symtab_addctx *ctx, const char *prefix, upb_FieldDef *f)
Definition: upb/upb/def.c:2830
upb_MiniTable_Sub
Definition: msg_internal.h:154
init
const char * init
Definition: upb/upb/bindings/lua/main.c:49
upb_FieldDef::enumdef
const upb_EnumDef * enumdef
Definition: upb/upb/def.c:76
UPB_DEFTYPE_ENUM
@ UPB_DEFTYPE_ENUM
Definition: upb/upb/def.c:233
opt_default_buf
static const char opt_default_buf[_UPB_MAXOPT_SIZE+sizeof(void *)]
Definition: upb/upb/def.c:53
upb_FileDef::ext_layouts
const upb_MiniTable_Extension ** ext_layouts
Definition: upb/upb/def.c:183
kUpb_CType_Int32
@ kUpb_CType_Int32
Definition: upb/upb/upb.h:289
upb_DefPool_FindEnumByName
const upb_EnumDef * upb_DefPool_FindEnumByName(const upb_DefPool *s, const char *sym)
Definition: upb/upb/def.c:1135
kUpb_FieldType_SInt32
@ kUpb_FieldType_SInt32
Definition: upb/upb/upb.h:325
upb_EnumDef_FindValueByNameWithSize
const upb_EnumValueDef * upb_EnumDef_FindValueByNameWithSize(const upb_EnumDef *def, const char *name, size_t len)
Definition: upb/upb/def.c:409
upb_DefPool_GetAllExtensions
const upb_FieldDef ** upb_DefPool_GetAllExtensions(const upb_DefPool *s, const upb_MessageDef *m, size_t *count)
Definition: upb/upb/def.c:3236
google_protobuf_FileDescriptorProto_dependency
UPB_INLINE upb_StringView const * google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:272
upb_MethodDef_ServerStreaming
bool upb_MethodDef_ServerStreaming(const upb_MethodDef *m)
Definition: upb/upb/def.c:1032
newstr
static str_t * newstr(symtab_addctx *ctx, const char *data, size_t len)
Definition: upb/upb/def.c:1900
ctx
Definition: benchmark-async.c:30
const
#define const
Definition: bloaty/third_party/zlib/zconf.h:230
upb_MessageDef_ExtensionRange
const upb_ExtensionRange * upb_MessageDef_ExtensionRange(const upb_MessageDef *m, int i)
Definition: upb/upb/def.c:822
upb_FieldDef_HasSubDef
bool upb_FieldDef_HasSubDef(const upb_FieldDef *f)
Definition: upb/upb/def.c:666
map_descriptortype
static uint8_t map_descriptortype(const upb_FieldDef *f)
Definition: upb/upb/def.c:1409
google_protobuf_ServiceDescriptorProto
struct google_protobuf_ServiceDescriptorProto google_protobuf_ServiceDescriptorProto
Definition: descriptor.upb.h:61
UPB_DEFTYPE_ONEOF
@ UPB_DEFTYPE_ONEOF
Definition: upb/upb/def.c:239
upb_OneofDef_numfields
int upb_OneofDef_numfields(const upb_OneofDef *o)
Definition: upb/upb/def.c:885
upb_FieldDef::unresolved
const google_protobuf_FieldDescriptorProto * unresolved
Definition: upb/upb/def.c:77
memset
return memset(p, 0, total)
pack_def
static upb_value pack_def(const void *ptr, upb_deftype_t type)
Definition: upb/upb/def.c:261
upb_FileDef_Package
const char * upb_FileDef_Package(const upb_FileDef *f)
Definition: upb/upb/def.c:922
file
const grpc_generator::File * file
Definition: python_private_generator.h:38
google_protobuf_DescriptorProto_ExtensionRange_start
UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange *msg)
Definition: descriptor.upb.h:735
upb_MethodDef::output_type
const upb_MessageDef * output_type
Definition: upb/upb/def.c:202
upb_MessageDef_MiniTable
const upb_MiniTable * upb_MessageDef_MiniTable(const upb_MessageDef *m)
Definition: upb/upb/def.c:818
upb_strtable_init
UPB_INLINE bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:905
UPB_UNLIKELY
#define UPB_UNLIKELY(x)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:62
upb_MiniTable_Enum
Definition: msg_internal.h:136
UPB_DEFTYPE_FIELD
@ UPB_DEFTYPE_FIELD
Definition: upb/upb/def.c:238
UPB_STRINGVIEW_ARGS
#define UPB_STRINGVIEW_ARGS(view)
Definition: upb/upb/upb.h:97
upb_MiniTable_Field
Definition: msg_internal.h:71
upb_MessageDef_Syntax
upb_Syntax upb_MessageDef_Syntax(const upb_MessageDef *m)
Definition: upb/upb/def.c:717
uint16_t
unsigned short uint16_t
Definition: stdint-msvc2008.h:79
upb_FieldDef::file
const upb_FileDef * file
Definition: upb/upb/def.c:58
google_protobuf_DescriptorProto_extension_range
const UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *const * google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:540
kUpb_FieldType_UInt64
@ kUpb_FieldType_UInt64
Definition: upb/upb/upb.h:312
kUpb_LabelFlags_IsPacked
@ kUpb_LabelFlags_IsPacked
Definition: msg_internal.h:94
upb_MessageDef_numfields
int upb_MessageDef_numfields(const upb_MessageDef *m)
Definition: upb/upb/def.c:782
upb_FieldDef::packed_
bool packed_
Definition: upb/upb/def.c:84
xds_manager.f1
f1
Definition: xds_manager.py:42
upb_MessageDef_NestedMessageCount
int upb_MessageDef_NestedMessageCount(const upb_MessageDef *m)
Definition: upb/upb/def.c:802
upb_DefPool_TryGetOctalDigit
char upb_DefPool_TryGetOctalDigit(const char **src, const char *end)
Definition: upb/upb/def.c:1955
FIELD_TYPE_UNSPECIFIED
#define FIELD_TYPE_UNSPECIFIED
Definition: upb/upb/def.c:247
upb_OneofDef_LookupNumber
const upb_FieldDef * upb_OneofDef_LookupNumber(const upb_OneofDef *o, uint32_t num)
Definition: upb/upb/def.c:903
google_protobuf_EnumValueDescriptorProto
struct google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescriptorProto
Definition: descriptor.upb.h:60
upb_DefPool::exts
upb_inttable exts
Definition: upb/upb/def.c:221
upb_StringView::data
const char * data
Definition: upb/upb/upb.h:73
FieldOptions
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:4590
UPB_DEFTYPE_MASK
@ UPB_DEFTYPE_MASK
Definition: upb/upb/def.c:228
upb_value
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:681
upb_EnumValueDef_Name
const char * upb_EnumValueDef_Name(const upb_EnumValueDef *ev)
Definition: upb/upb/def.c:454
upb_MessageDef
Definition: upb/upb/def.c:100
ext
void * ext
Definition: x509v3.h:87
upb_ServiceDef_Name
const char * upb_ServiceDef_Name(const upb_ServiceDef *s)
Definition: upb/upb/def.c:1051
upb_MethodDef_Name
const char * upb_MethodDef_Name(const upb_MethodDef *m)
Definition: upb/upb/def.c:1012
google_protobuf_DescriptorProto_ExtensionRange_end
UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange *msg)
Definition: descriptor.upb.h:745
google_protobuf_FieldDescriptorProto_default_value
UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:993
INT64_MAX
#define INT64_MAX
Definition: stdint-msvc2008.h:139
upb_MessageDef_NestedEnum
const upb_EnumDef * upb_MessageDef_NestedEnum(const upb_MessageDef *m, int i)
Definition: upb/upb/def.c:844
_upb_FileDef_WeakDependencyIndexes
const int32_t * _upb_FileDef_WeakDependencyIndexes(const upb_FileDef *f)
Definition: upb/upb/def.c:944
upb_FileDef::top_lvl_ext_count
int top_lvl_ext_count
Definition: upb/upb/def.c:191
SET_OPTIONS
#define SET_OPTIONS(target, desc_type, options_type, proto)
Definition: upb/upb/def.c:1291
upb_MessageDef_FindByNameWithSize
bool upb_MessageDef_FindByNameWithSize(const upb_MessageDef *m, const char *name, size_t len, const upb_FieldDef **out_f, const upb_OneofDef **out_o)
Definition: upb/upb/def.c:750
string.h
upb_DefPool_ExtensionRegistry
const upb_ExtensionRegistry * upb_DefPool_ExtensionRegistry(const upb_DefPool *s)
Definition: upb/upb/def.c:3231
upb_MiniTable_Sub::submsg
const struct upb_MiniTable * submsg
Definition: msg_internal.h:155
upb_FileDef::top_lvl_enums
const upb_EnumDef * top_lvl_enums
Definition: upb/upb/def.c:180
upb_MessageDef_HasOptions
bool upb_MessageDef_HasOptions(const upb_MessageDef *m)
Definition: upb/upb/def.c:697
upb_MessageDef::nested_enums
const upb_EnumDef * nested_enums
Definition: upb/upb/def.c:118
upb_FileDef_Dependency
const upb_FileDef * upb_FileDef_Dependency(const upb_FileDef *f, int i)
Definition: upb/upb/def.c:958
count_bits_debug
static int count_bits_debug(uint64_t x)
Definition: upb/upb/def.c:2437
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
FileOptions
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:3696
FieldDescriptorProto
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:1851
upb_DefPool_FindEnumByNameval
const upb_EnumValueDef * upb_DefPool_FindEnumByNameval(const upb_DefPool *s, const char *sym)
Definition: upb/upb/def.c:1140
upb_MiniTable_Extension
Definition: msg_internal.h:202
upb_MethodDef_FullName
const char * upb_MethodDef_FullName(const upb_MethodDef *m)
Definition: upb/upb/def.c:1006
kUpb_CType_Bytes
@ kUpb_CType_Bytes
Definition: upb/upb/upb.h:297
google_protobuf_EnumDescriptorProto_value
const UPB_INLINE google_protobuf_EnumValueDescriptorProto *const * google_protobuf_EnumDescriptorProto_value(const google_protobuf_EnumDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:1206
UPB_ALIGN_UP
#define UPB_ALIGN_UP(size, align)
Definition: php-upb.c:93
upb_MethodDef
Definition: upb/upb/def.c:197
google_protobuf_MethodDescriptorProto_output_type
UPB_INLINE upb_StringView google_protobuf_MethodDescriptorProto_output_type(const google_protobuf_MethodDescriptorProto *msg)
Definition: descriptor.upb.h:1577
UPB_UNREACHABLE
#define UPB_UNREACHABLE()
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:145
UINT64_MAX
#define UINT64_MAX
Definition: stdint-msvc2008.h:143
error_ref_leak.err
err
Definition: error_ref_leak.py:35
upb_FieldDef_File
const upb_FileDef * upb_FieldDef_File(const upb_FieldDef *f)
Definition: upb/upb/def.c:561
create_enumvaldef
static void create_enumvaldef(symtab_addctx *ctx, const char *prefix, const google_protobuf_EnumValueDescriptorProto *val_proto, upb_EnumDef *e, int i)
Definition: upb/upb/def.c:2504
between
static bool between(int32_t x, int32_t low, int32_t high)
Definition: upb/upb/def.c:677
upb_MessageDef::file
const upb_FileDef * file
Definition: upb/upb/def.c:103
google_protobuf_DescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto *msg)
Definition: descriptor.upb.h:504
UINT32_MAX
#define UINT32_MAX
Definition: stdint-msvc2008.h:142
upb_OneofDef::parent
const upb_MessageDef * parent
Definition: upb/upb/def.c:159
file
Definition: bloaty/third_party/zlib/examples/gzappend.c:170
_upb_DefPool_FindExtensionByMiniTable
const upb_FieldDef * _upb_DefPool_FindExtensionByMiniTable(const upb_DefPool *s, const upb_MiniTable_Extension *ext)
Definition: upb/upb/def.c:3207
UPB_SETJMP
#define UPB_SETJMP(buf)
Definition: php-upb.c:163
upb_OneofDef_ContainingType
const upb_MessageDef * upb_OneofDef_ContainingType(const upb_OneofDef *o)
Definition: upb/upb/def.c:874
ServiceDescriptorProto
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:3186
upb_MethodDef::index
int index
Definition: upb/upb/def.c:203
google_protobuf_MethodDescriptorProto_client_streaming
UPB_INLINE bool google_protobuf_MethodDescriptorProto_client_streaming(const google_protobuf_MethodDescriptorProto *msg)
Definition: descriptor.upb.h:1596
upb_ServiceDef::index
int index
Definition: upb/upb/def.c:214
status
absl::Status status
Definition: rls.cc:251
kUpb_FieldType_SFixed32
@ kUpb_FieldType_SFixed32
Definition: upb/upb/upb.h:323
upb_MiniTable
Definition: msg_internal.h:185
upb_FieldDef::is_extension_
bool is_extension_
Definition: upb/upb/def.c:83
set_default_default
static void set_default_default(symtab_addctx *ctx, upb_FieldDef *f)
Definition: upb/upb/def.c:2160
ctx
static struct test_ctx ctx
Definition: test-ipc-send-recv.c:65
upb_FieldDef_checktype
bool upb_FieldDef_checktype(int32_t type)
Definition: upb/upb/def.c:682
MethodDescriptorProto
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:3405
setup.name
name
Definition: setup.py:542
upb_OneofDef
Definition: upb/upb/def.c:157
UPB_DEFTYPE_FIELD_JSONNAME
@ UPB_DEFTYPE_FIELD_JSONNAME
Definition: upb/upb/def.c:240
google_protobuf_EnumOptions
struct google_protobuf_EnumOptions google_protobuf_EnumOptions
Definition: descriptor.upb.h:67
upb_FieldDef::label_
upb_Label label_
Definition: upb/upb/def.c:88
google_protobuf_FieldDescriptorProto_number
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:953
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
upb_FieldDef_MiniTable
const upb_MiniTable_Field * upb_FieldDef_MiniTable(const upb_FieldDef *f)
Definition: upb/upb/def.c:627
resolve_extension
static void resolve_extension(symtab_addctx *ctx, const char *prefix, upb_FieldDef *f, const google_protobuf_FieldDescriptorProto *field_proto)
Definition: upb/upb/def.c:2756
upb_strtable_lookup2
bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len, upb_value *v)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1612
upb_FileDef_TopLevelExtensionCount
int upb_FileDef_TopLevelExtensionCount(const upb_FileDef *f)
Definition: upb/upb/def.c:952
upb_FieldDef_checkdescriptortype
bool upb_FieldDef_checkdescriptortype(int32_t type)
Definition: upb/upb/def.c:685
xds_manager.p
p
Definition: xds_manager.py:60
upb_MessageDef_NestedExtensionCount
int upb_MessageDef_NestedExtensionCount(const upb_MessageDef *m)
Definition: upb/upb/def.c:810
upb_MessageDef::oneof_count
int oneof_count
Definition: upb/upb/def.c:122
upb_EnumDef_File
const upb_FileDef * upb_EnumDef_File(const upb_EnumDef *e)
Definition: upb/upb/def.c:396
upb_MethodDef::server_streaming
bool server_streaming
Definition: upb/upb/def.c:205
upb_OneofDef::full_name
const char * full_name
Definition: upb/upb/def.c:160
upb_EnumValueDef_HasOptions
bool upb_EnumValueDef_HasOptions(const upb_EnumValueDef *e)
Definition: upb/upb/def.c:442
google_protobuf_FieldDescriptorProto_extendee
UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:943
google_protobuf_DescriptorProto_oneof_decl
const UPB_INLINE google_protobuf_OneofDescriptorProto *const * google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:567
upb_ServiceDef::opts
const google_protobuf_ServiceOptions * opts
Definition: upb/upb/def.c:209
google_protobuf_OneofDescriptorProto
struct google_protobuf_OneofDescriptorProto google_protobuf_OneofDescriptorProto
Definition: descriptor.upb.h:57
strviewdup
static char * strviewdup(symtab_addctx *ctx, upb_StringView view)
Definition: upb/upb/def.c:1671
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
upb_Status_ErrorMessage
const char * upb_Status_ErrorMessage(const upb_Status *status)
Definition: upb/upb/upb.c:52
symtab_lookup2
static const void * symtab_lookup2(const upb_DefPool *s, const char *sym, size_t size, upb_deftype_t type)
Definition: upb/upb/def.c:1118
google_protobuf_EnumValueDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_EnumValueDescriptorProto_name(const google_protobuf_EnumValueDescriptorProto *msg)
Definition: descriptor.upb.h:1384
streql2
static bool streql2(const char *a, size_t n, const char *b)
Definition: upb/upb/def.c:1677
upb_FileDef::public_dep_count
int public_dep_count
Definition: upb/upb/def.c:187
upb_Arena_New
UPB_INLINE upb_Arena * upb_Arena_New(void)
Definition: upb/upb/upb.h:267
kUpb_CType_Int64
@ kUpb_CType_Int64
Definition: upb/upb/upb.h:294
upb_MessageDef::full_name
const char * full_name
Definition: upb/upb/def.c:105
symtab_addctx::ext_count
int ext_count
Definition: upb/upb/def.c:1263
ExtensionRangeOptions
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:1680
upb_Status_Clear
void upb_Status_Clear(upb_Status *status)
Definition: upb/upb/upb.c:44
google_protobuf_ServiceDescriptorProto_method
const UPB_INLINE google_protobuf_MethodDescriptorProto *const * google_protobuf_ServiceDescriptorProto_method(const google_protobuf_ServiceDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:1476
upb_FieldDef_RealContainingOneof
const upb_OneofDef * upb_FieldDef_RealContainingOneof(const upb_FieldDef *f)
Definition: upb/upb/def.c:575
compare_int32
static int compare_int32(const void *a_ptr, const void *b_ptr)
Definition: upb/upb/def.c:2447
create_service
static void create_service(symtab_addctx *ctx, const google_protobuf_ServiceDescriptorProto *svc_proto, const upb_ServiceDef *_s)
Definition: upb/upb/def.c:2389
upb_WellKnown
upb_WellKnown
Definition: upb/upb/def.h:71
google_protobuf_FieldDescriptorProto
struct google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto
Definition: descriptor.upb.h:56
EnumValueDescriptorProto
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:2972
upb_MethodDef::service
upb_ServiceDef * service
Definition: upb/upb/def.c:199
EnumOptions
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:5086
upb_FileDef_Syntax
upb_Syntax upb_FileDef_Syntax(const upb_FileDef *f)
Definition: upb/upb/def.c:924
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
upb_ServiceDef_FullName
const char * upb_ServiceDef_FullName(const upb_ServiceDef *s)
Definition: upb/upb/def.c:1047
upb_FileDef_TopLevelEnum
const upb_EnumDef * upb_FileDef_TopLevelEnum(const upb_FileDef *f, int i)
Definition: upb/upb/def.c:978
create_msgdef
static void create_msgdef(symtab_addctx *ctx, const char *prefix, const google_protobuf_DescriptorProto *msg_proto, const upb_MessageDef *containing_type, const upb_MessageDef *_m)
Definition: upb/upb/def.c:2591
symtab_addctx::file
upb_FileDef * file
Definition: upb/upb/def.c:1257
upb_EnumDef::file
const upb_FileDef * file
Definition: upb/upb/def.c:137
kUpb_LabelFlags_IsExtension
@ kUpb_LabelFlags_IsExtension
Definition: msg_internal.h:95
python_utils.port_server.stderr
stderr
Definition: port_server.py:51
upb_FieldDef::msgdef
const upb_MessageDef * msgdef
Definition: upb/upb/def.c:59
cmp_fields
int cmp_fields(const void *p1, const void *p2)
Definition: upb/upb/def.c:327
upb_MapEntry::k
union upb_MapEntry::@708 k
google_protobuf_DescriptorProto_ExtensionRange
struct google_protobuf_DescriptorProto_ExtensionRange google_protobuf_DescriptorProto_ExtensionRange
Definition: descriptor.upb.h:53
upb_OneofDef::field_count
int field_count
Definition: upb/upb/def.c:161
kUpb_FieldType_Double
@ kUpb_FieldType_Double
Definition: upb/upb/upb.h:309
upb_FileDef::symtab
const upb_DefPool * symtab
Definition: upb/upb/def.c:184
symtab_addctx::msg_count
int msg_count
Definition: upb/upb/def.c:1262
kUpb_FieldType_Bool
@ kUpb_FieldType_Bool
Definition: upb/upb/upb.h:316
UPB_DEFTYPE_MSG
@ UPB_DEFTYPE_MSG
Definition: upb/upb/def.c:232
makefullname
static const char * makefullname(symtab_addctx *ctx, const char *prefix, upb_StringView name)
Definition: upb/upb/def.c:1685
upb_EnumDef_FindValueByNumber
const upb_EnumValueDef * upb_EnumDef_FindValueByNumber(const upb_EnumDef *def, int32_t num)
Definition: upb/upb/def.c:417
upb_EnumValueDef::number
int32_t number
Definition: upb/upb/def.c:154
upb_inttable_next2
bool upb_inttable_next2(const upb_inttable *t, uintptr_t *key, upb_value *val, intptr_t *iter)
Definition: table.c:800
o
UnboundConversion o
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:97
upb_FieldDef::has_default
bool has_default
Definition: upb/upb/def.c:82
kUpb_ExtMode_NonExtendable
@ kUpb_ExtMode_NonExtendable
Definition: msg_internal.h:160
kUpb_WellKnown_FloatValue
@ kUpb_WellKnown_FloatValue
Definition: upb/upb/def.h:79
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
upb_MessageDef::well_known_type
upb_WellKnown well_known_type
Definition: upb/upb/def.c:128
upb_MessageValue
Definition: upb/upb/reflection.h:40
upb_ServiceDef
Definition: upb/upb/def.c:208
upb_FieldDef_Index
uint32_t upb_FieldDef_Index(const upb_FieldDef *f)
Definition: upb/upb/def.c:537
upb_ServiceDef::method_count
int method_count
Definition: upb/upb/def.c:213
upb_strtable_lookup
UPB_INLINE bool upb_strtable_lookup(const upb_strtable *t, const char *key, upb_value *v)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:965
upb_FileDef::top_lvl_msgs
const upb_MessageDef * top_lvl_msgs
Definition: upb/upb/def.c:179
assign_layout_indices
static void assign_layout_indices(const upb_MessageDef *m, upb_MiniTable *l, upb_MiniTable_Field *fields)
Definition: upb/upb/def.c:1391
google_protobuf_EnumDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto *msg)
Definition: descriptor.upb.h:1197
for
for(map_begin_internal(intern, &it);!map_done(&it);map_next(&it))
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/map.c:207
kUpb_FieldType_Float
@ kUpb_FieldType_Float
Definition: upb/upb/upb.h:310
upb_EnumDef_HasOptions
bool upb_EnumDef_HasOptions(const upb_EnumDef *e)
Definition: upb/upb/def.c:386
upb_FieldDef_Label
upb_Label upb_FieldDef_Label(const upb_FieldDef *f)
Definition: upb/upb/def.c:539
ULL
#define ULL(x)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:57
google_protobuf_FieldDescriptorProto_has_extendee
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:936
google_protobuf_MethodDescriptorProto
struct google_protobuf_MethodDescriptorProto google_protobuf_MethodDescriptorProto
Definition: descriptor.upb.h:62
upb_inttable_compact
UPB_INLINE void upb_inttable_compact(upb_inttable *t)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:1018
upb_MiniTable_Field::presence
int16_t presence
Definition: msg_internal.h:74
upb_Status_setoom
static void upb_Status_setoom(upb_Status *status)
Definition: upb/upb/def.c:333
upb_FieldDef::index_
uint16_t index_
Definition: upb/upb/def.c:80
field_rank
uint32_t field_rank(const upb_FieldDef *f)
Definition: upb/upb/def.c:319
google_protobuf_FieldDescriptorProto_has_oneof_index
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_oneof_index(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:1005
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
upb_MessageDef_FindByJsonNameWithSize
const upb_FieldDef * upb_MessageDef_FindByJsonNameWithSize(const upb_MessageDef *m, const char *name, size_t len)
Definition: upb/upb/def.c:767
start
static uint64_t start
Definition: benchmark-pound.c:74
kUpb_FieldType_UInt32
@ kUpb_FieldType_UInt32
Definition: upb/upb/upb.h:321
upb_Status_SetErrorMessage
void upb_Status_SetErrorMessage(upb_Status *status, const char *msg)
Definition: upb/upb/upb.c:56
UINT8_MAX
#define UINT8_MAX
Definition: stdint-msvc2008.h:140
upb_MessageDef_IsMapEntry
UPB_INLINE bool upb_MessageDef_IsMapEntry(const upb_MessageDef *m)
Definition: upb/upb/def.h:209
upb_MessageDef_WellKnownType
upb_WellKnown upb_MessageDef_WellKnownType(const upb_MessageDef *m)
Definition: upb/upb/def.c:855
kUpb_FieldRep_8Byte
@ kUpb_FieldRep_8Byte
Definition: msg_internal.h:104
c
void c(T a)
Definition: miscompile_with_no_unique_address_test.cc:40
upb_OneofDef::synthetic
bool synthetic
Definition: upb/upb/def.c:162
upb_Status_VSetErrorFormat
void upb_Status_VSetErrorFormat(upb_Status *status, const char *fmt, va_list args)
Definition: upb/upb/upb.c:70
upb_MessageDef_Name
const char * upb_MessageDef_Name(const upb_MessageDef *m)
Definition: upb/upb/def.c:713
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
upb_FieldDef::number_
uint32_t number_
Definition: upb/upb/def.c:79
upb_FileDef_TopLevelExtension
const upb_FieldDef * upb_FileDef_TopLevelExtension(const upb_FileDef *f, int i)
Definition: upb/upb/def.c:983
upb_MethodDef_Options
const google_protobuf_MethodOptions * upb_MethodDef_Options(const upb_MethodDef *m)
Definition: upb/upb/def.c:997
benchmark.syntax
syntax
Definition: benchmark.py:90
DescriptorProto_ExtensionRange
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:936
upb_OneofDef::itof
upb_inttable itof
Definition: upb/upb/def.c:165
google_protobuf_MethodDescriptorProto_input_type
UPB_INLINE upb_StringView google_protobuf_MethodDescriptorProto_input_type(const google_protobuf_MethodDescriptorProto *msg)
Definition: descriptor.upb.h:1567
upb_EnumValueDef_Index
uint32_t upb_EnumValueDef_Index(const upb_EnumValueDef *ev)
Definition: upb/upb/def.c:462
upb_MessageDef_realoneofcount
int upb_MessageDef_realoneofcount(const upb_MessageDef *m)
Definition: upb/upb/def.c:814
upb_FileDef::weak_dep_count
int weak_dep_count
Definition: upb/upb/def.c:188
xds_interop_client.int
int
Definition: xds_interop_client.py:113
symtab_oomerr
UPB_NORETURN static UPB_NOINLINE void symtab_oomerr(symtab_addctx *ctx)
Definition: upb/upb/def.c:1277
upb_FileDef_WeakDependencyCount
int upb_FileDef_WeakDependencyCount(const upb_FileDef *f)
Definition: upb/upb/def.c:936
upb_strdup2
char * upb_strdup2(const char *s, size_t len, upb_alloc *a)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1306
invalid
@ invalid
Definition: base64_test.cc:39
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
kUpb_FieldType_String
@ kUpb_FieldType_String
Definition: upb/upb/upb.h:317
upb_ExtensionRange_Options
const google_protobuf_ExtensionRangeOptions * upb_ExtensionRange_Options(const upb_ExtensionRange *r)
Definition: upb/upb/def.c:470
upb_FieldDef_IsMap
bool upb_FieldDef_IsMap(const upb_FieldDef *f)
Definition: upb/upb/def.c:659
upb_FileDef::top_lvl_exts
const upb_FieldDef * top_lvl_exts
Definition: upb/upb/def.c:181
kUpb_CType_Double
@ kUpb_CType_Double
Definition: upb/upb/upb.h:293
gen_stats_data.found
bool found
Definition: gen_stats_data.py:61
gen_synthetic_protos.label
label
Definition: gen_synthetic_protos.py:102
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
upb_strtable_removeiter
void upb_strtable_removeiter(upb_strtable *t, intptr_t *iter)
Definition: table.c:871
upb_EnumDef_Options
const google_protobuf_EnumOptions * upb_EnumDef_Options(const upb_EnumDef *e)
Definition: upb/upb/def.c:382
upb_EnumDef_CheckNumber
bool upb_EnumDef_CheckNumber(const upb_EnumDef *e, int32_t num)
Definition: upb/upb/def.c:424
descriptor.upb.h
upb_FieldDef::json_name
const char * json_name
Definition: upb/upb/def.c:61
div_round_up
static size_t div_round_up(size_t n, size_t d)
Definition: upb/upb/def.c:1335
upb_FieldDef_HasPresence
bool upb_FieldDef_HasPresence(const upb_FieldDef *f)
Definition: upb/upb/def.c:671
max
int max
Definition: bloaty/third_party/zlib/examples/enough.c:170
upb_StringView::size
size_t size
Definition: upb/upb/upb.h:74
google_protobuf_FieldDescriptorProto_label
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:963
upb_isbetween
static bool upb_isbetween(uint8_t c, uint8_t low, uint8_t high)
Definition: upb/upb/def.c:283
kUpb_WellKnown_BytesValue
@ kUpb_WellKnown_BytesValue
Definition: upb/upb/def.h:86
_upb_DefPool_AddFile
static const upb_FileDef * _upb_DefPool_AddFile(upb_DefPool *s, const google_protobuf_FileDescriptorProto *file_proto, const upb_MiniTable_File *layout, upb_Status *status)
Definition: upb/upb/def.c:3079
upb_OneofDef::opts
const google_protobuf_OneofOptions * opts
Definition: upb/upb/def.c:158
upb_FieldDef::sub
union upb_FieldDef::@700 sub
kUpb_WellKnown_Unspecified
@ kUpb_WellKnown_Unspecified
Definition: upb/upb/def.h:72
google_protobuf_FieldOptions
struct google_protobuf_FieldOptions google_protobuf_FieldOptions
Definition: descriptor.upb.h:65
symtab_resolveany
static const void * symtab_resolveany(symtab_addctx *ctx, const char *from_name_dbg, const char *base, upb_StringView sym, upb_deftype_t *type)
Definition: upb/upb/def.c:1813
upb_FileDef_Options
const google_protobuf_FileOptions * upb_FileDef_Options(const upb_FileDef *f)
Definition: upb/upb/def.c:912
kUpb_WellKnown_Timestamp
@ kUpb_WellKnown_Timestamp
Definition: upb/upb/def.h:76
upb_MessageDef_NestedMessage
const upb_MessageDef * upb_MessageDef_NestedMessage(const upb_MessageDef *m, int i)
Definition: upb/upb/def.c:838
upb_FileDef::opts
const google_protobuf_FileOptions * opts
Definition: upb/upb/def.c:172
upb_DefPool_FindServiceByName
const upb_ServiceDef * upb_DefPool_FindServiceByName(const upb_DefPool *s, const char *name)
Definition: upb/upb/def.c:1186
google_protobuf_FileDescriptorProto_syntax
UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto *msg)
Definition: descriptor.upb.h:348
upb_MessageDef::ext_ranges
const upb_ExtensionRange * ext_ranges
Definition: upb/upb/def.c:116
upb_DefPool::syms
upb_strtable syms
Definition: upb/upb/def.c:219
google_protobuf_FileDescriptorProto_has_name
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto *msg)
Definition: descriptor.upb.h:249
kUpb_Syntax_Proto2
@ kUpb_Syntax_Proto2
Definition: upb/upb/def.h:65
_UPB_MAXOPT_SIZE
#define _UPB_MAXOPT_SIZE
Definition: descriptor.upb.h:3087
make_layout
static void make_layout(symtab_addctx *ctx, const upb_MessageDef *m)
Definition: upb/upb/def.c:1476
upb_MiniTable_Enum_CheckValue
UPB_INLINE bool upb_MiniTable_Enum_CheckValue(const upb_MiniTable_Enum *e, int32_t val)
Definition: msg_internal.h:142
setup.v
v
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
kUpb_FieldType_Enum
@ kUpb_FieldType_Enum
Definition: upb/upb/upb.h:322
_upb_FileDef_PublicDependencyIndexes
const int32_t * _upb_FileDef_PublicDependencyIndexes(const upb_FileDef *f)
Definition: upb/upb/def.c:940
upb_EnumValueDef::parent
const upb_EnumDef * parent
Definition: upb/upb/def.c:152
upb_ExtensionRange::opts
const google_protobuf_ExtensionRangeOptions * opts
Definition: upb/upb/def.c:95
upb_Arena_Malloc
UPB_INLINE void * upb_Arena_Malloc(upb_Arena *a, size_t size)
Definition: upb/upb/upb.h:222
remove_component
static bool remove_component(char *base, size_t *len)
Definition: upb/upb/def.c:1797
google_protobuf_FileDescriptorProto_extension
const UPB_INLINE google_protobuf_FieldDescriptorProto *const * google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:308
upb_EnumDef::full_name
const char * full_name
Definition: upb/upb/def.c:139
upb_EnumDef::opts
const google_protobuf_EnumOptions * opts
Definition: upb/upb/def.c:135
kUpb_FieldType_Fixed32
@ kUpb_FieldType_Fixed32
Definition: upb/upb/upb.h:315
upb_MiniTable_Extension::sub
upb_MiniTable_Sub sub
Definition: msg_internal.h:205
upb_FileDef_TopLevelMessage
const upb_MessageDef * upb_FileDef_TopLevelMessage(const upb_FileDef *f, int i)
Definition: upb/upb/def.c:973
build_filedef
static void build_filedef(symtab_addctx *ctx, upb_FileDef *file, const google_protobuf_FileDescriptorProto *file_proto)
Definition: upb/upb/def.c:2881
upb_FieldDef::defaultval
union upb_FieldDef::@698 defaultval
upb_inttable_init
UPB_INLINE bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:901
_upb_DefPool_Init
Definition: upb/upb/def.h:386
upb_FileDef_Pool
const upb_DefPool * upb_FileDef_Pool(const upb_FileDef *f)
Definition: upb/upb/def.c:993
google_protobuf_MethodDescriptorProto_server_streaming
UPB_INLINE bool google_protobuf_MethodDescriptorProto_server_streaming(const google_protobuf_MethodDescriptorProto *msg)
Definition: descriptor.upb.h:1606
upb_EnumDef::ntoi
upb_strtable ntoi
Definition: upb/upb/def.c:140
create_enumdef
static void create_enumdef(symtab_addctx *ctx, const char *prefix, const google_protobuf_EnumDescriptorProto *enum_proto, const upb_MessageDef *containing_type, const upb_EnumDef *_e)
Definition: upb/upb/def.c:2533
google_protobuf_OneofDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto *msg)
Definition: descriptor.upb.h:1128
upb_OneofDef_FieldCount
int upb_OneofDef_FieldCount(const upb_OneofDef *o)
Definition: upb/upb/def.c:878
upb_FieldDef::flt
float flt
Definition: upb/upb/def.c:66
upb_DefPool_New
upb_DefPool * upb_DefPool_New(void)
Definition: upb/upb/def.c:1086
upb_EnumValueDef
Definition: upb/upb/def.c:150
remove_filedef
static void remove_filedef(upb_DefPool *s, upb_FileDef *file)
Definition: upb/upb/def.c:3048
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
upb_MapEntry::v
union upb_MapEntry::@709 v
upb_inttable
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:848
opt_default
static const char * opt_default
Definition: upb/upb/def.c:54
upb_EnumDef_FullName
const char * upb_EnumDef_FullName(const upb_EnumDef *e)
Definition: upb/upb/def.c:390
kUpb_WellKnown_UInt32Value
@ kUpb_WellKnown_UInt32Value
Definition: upb/upb/def.h:83
upb_Status_SetErrorFormat
void upb_Status_SetErrorFormat(upb_Status *status, const char *fmt,...)
Definition: upb/upb/upb.c:63
_upb_FieldDef_IsProto3Optional
bool _upb_FieldDef_IsProto3Optional(const upb_FieldDef *f)
Definition: upb/upb/def.c:638
symtab_addctx::symtab
upb_DefPool * symtab
Definition: upb/upb/def.c:1256
def
int def(FILE *source, FILE *dest, int level)
Definition: bloaty/third_party/zlib/examples/zpipe.c:36
upb_FieldDef_Default
upb_MessageValue upb_FieldDef_Default(const upb_FieldDef *f)
Definition: upb/upb/def.c:581
google_protobuf_FileDescriptorProto_weak_dependency
UPB_INLINE int32_t const * google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:338
google_protobuf_DescriptorProto_extension
const UPB_INLINE google_protobuf_FieldDescriptorProto *const * google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:549
MessageOptions
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:4359
upb_Syntax
upb_Syntax
Definition: upb/upb/def.h:65
upb_FieldDef::has_json_name_
bool has_json_name_
Definition: upb/upb/def.c:86
google_protobuf_EnumDescriptorProto
struct google_protobuf_EnumDescriptorProto google_protobuf_EnumDescriptorProto
Definition: descriptor.upb.h:58
kUpb_DecodeOption_AliasString
@ kUpb_DecodeOption_AliasString
Definition: decode.h:47
upb_deftype_t
upb_deftype_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3025
upb_FileDef::top_lvl_msg_count
int top_lvl_msg_count
Definition: upb/upb/def.c:189
upb_FieldDef_IsExtension
bool upb_FieldDef_IsExtension(const upb_FieldDef *f)
Definition: upb/upb/def.c:543
upb_MessageValue_sizeof
static size_t upb_MessageValue_sizeof(upb_CType type)
Definition: upb/upb/def.c:1337
shortdefname
static const char * shortdefname(const char *fullname)
Definition: upb/upb/def.c:303
reflection.h
number
int32_t number
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:850
upb_MiniTable_File
Definition: msg_internal.h:208
upb_EnumValueDef::full_name
const char * full_name
Definition: upb/upb/def.c:153
upb_EnumDef::iton
upb_inttable iton
Definition: upb/upb/def.c:141
upb_FileDef_Name
const char * upb_FileDef_Name(const upb_FileDef *f)
Definition: upb/upb/def.c:920
kUpb_WellKnown_BoolValue
@ kUpb_WellKnown_BoolValue
Definition: upb/upb/def.h:87
kUpb_FieldRep_Shift
@ kUpb_FieldRep_Shift
Definition: msg_internal.h:106
UPB_STRINGVIEW_FORMAT
#define UPB_STRINGVIEW_FORMAT
Definition: upb/upb/upb.h:96
unpack_def
static const void * unpack_def(upb_value v, upb_deftype_t type)
Definition: upb/upb/def.c:254
intptr_t
_W64 signed int intptr_t
Definition: stdint-msvc2008.h:118
upb_ServiceDef::full_name
const char * full_name
Definition: upb/upb/def.c:211
upb_OneofDef_HasOptions
bool upb_OneofDef_HasOptions(const upb_OneofDef *o)
Definition: upb/upb/def.c:866
upb_Status
Definition: upb/upb/upb.h:52
UPB_ASSERT
#define UPB_ASSERT(expr)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:135
google_protobuf_FileDescriptorProto_service
const UPB_INLINE google_protobuf_ServiceDescriptorProto *const * google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:299
upb_gfree
UPB_INLINE void upb_gfree(void *ptr)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:344
upb_FileDef::weak_deps
const int32_t * weak_deps
Definition: upb/upb/def.c:178
x
int x
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
upb_ExtensionRange::end
int32_t end
Definition: upb/upb/def.c:97
kUpb_FieldMode_Map
@ kUpb_FieldMode_Map
Definition: msg_internal.h:84
UPB_PRINTF
UPB_NORETURN UPB_NOINLINE UPB_PRINTF(2, 3)
Definition: upb/upb/def.c:1268
google_protobuf_FileDescriptorProto_public_dependency
UPB_INLINE int32_t const * google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:332
google_protobuf_FileDescriptorProto_has_package
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto *msg)
Definition: descriptor.upb.h:259
gen_synthetic_protos.base
base
Definition: gen_synthetic_protos.py:31
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
upb_MiniTable_Field::offset
uint16_t offset
Definition: msg_internal.h:73
upb_MethodDef_Index
int upb_MethodDef_Index(const upb_MethodDef *m)
Definition: upb/upb/def.c:1010
upb_FileDef::ext_count
int ext_count
Definition: upb/upb/def.c:193
phone_pb2.containing_type
containing_type
Definition: phone_pb2.py:199
upb_ServiceDef::file
const upb_FileDef * file
Definition: upb/upb/def.c:210
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint-msvc2008.h:119
upb_EnumValueDef_Options
const google_protobuf_EnumValueOptions * upb_EnumValueDef_Options(const upb_EnumValueDef *e)
Definition: upb/upb/def.c:437
upb_FieldDef_CType
upb_CType upb_FieldDef_CType(const upb_FieldDef *f)
Definition: upb/upb/def.c:500
upb_FileDef_Service
const upb_ServiceDef * upb_FileDef_Service(const upb_FileDef *f, int i)
Definition: upb/upb/def.c:988
upb_MessageDef::nested_exts
const upb_FieldDef * nested_exts
Definition: upb/upb/def.c:119
upb_EnumDef_ValueCount
int upb_EnumDef_ValueCount(const upb_EnumDef *e)
Definition: upb/upb/def.c:407
upb_FieldDef::extension_scope
const upb_MessageDef * extension_scope
Definition: upb/upb/def.c:72
FileDescriptorProto
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:501
upb_ExtensionRange_Start
int32_t upb_ExtensionRange_Start(const upb_ExtensionRange *e)
Definition: upb/upb/def.c:479
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
google_protobuf_FieldDescriptorProto_type_name
UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:983
upb_FileDef_TopLevelEnumCount
int upb_FileDef_TopLevelEnumCount(const upb_FileDef *f)
Definition: upb/upb/def.c:948
upb_ExtensionRange_End
int32_t upb_ExtensionRange_End(const upb_ExtensionRange *e)
Definition: upb/upb/def.c:483
kUpb_Label_Required
@ kUpb_Label_Required
Definition: upb/upb/upb.h:303
upb_OneofDef_Options
const google_protobuf_OneofOptions * upb_OneofDef_Options(const upb_OneofDef *o)
Definition: upb/upb/def.c:861
getjsonname
size_t getjsonname(const char *name, char *buf, size_t len)
Definition: upb/upb/def.c:1736
_upb_DefPool_LoadDefInitEx
bool _upb_DefPool_LoadDefInitEx(upb_DefPool *s, const _upb_DefPool_Init *init, bool rebuild_minitable)
Definition: upb/upb/def.c:3149
upb_MiniTable_Extension::field
upb_MiniTable_Field field
Definition: msg_internal.h:203
google_protobuf_FileDescriptorProto_has_syntax
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto *msg)
Definition: descriptor.upb.h:341
layout
MessageLayout * layout
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:809
upb_MessageDef_Oneof
const upb_OneofDef * upb_MessageDef_Oneof(const upb_MessageDef *m, int i)
Definition: upb/upb/def.c:833
kUpb_ExtMode_Extendable
@ kUpb_ExtMode_Extendable
Definition: msg_internal.h:161
d
static const fe d
Definition: curve25519_tables.h:19
qsort
void qsort(void *a, size_t n, size_t es, int(*cmp)(const void *, const void *))
Definition: qsort.h:130
upb_MethodDef::opts
const google_protobuf_MethodOptions * opts
Definition: upb/upb/def.c:198
google_protobuf_FieldOptions_has_packed
UPB_INLINE bool google_protobuf_FieldOptions_has_packed(const google_protobuf_FieldOptions *msg)
Definition: descriptor.upb.h:2129
upb_MapEntry
Definition: msg_internal.h:593
UPB_DEFTYPE_ENUMVAL
@ UPB_DEFTYPE_ENUMVAL
Definition: upb/upb/def.c:234
upb_FieldDef_MessageSubDef
const upb_MessageDef * upb_FieldDef_MessageSubDef(const upb_FieldDef *f)
Definition: upb/upb/def.c:619
upb_DefPool::extreg
upb_ExtensionRegistry * extreg
Definition: upb/upb/def.c:222
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
upb_FieldDef_checklabel
bool upb_FieldDef_checklabel(int32_t label)
Definition: upb/upb/def.c:681
ServiceOptions
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:5473
upb_MethodDef_InputType
const upb_MessageDef * upb_MethodDef_InputType(const upb_MethodDef *m)
Definition: upb/upb/def.c:1020
google_protobuf_FileDescriptorProto_enum_type
const UPB_INLINE google_protobuf_EnumDescriptorProto *const * google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:290
upb_DefPool_ParseHexEscape
static char upb_DefPool_ParseHexEscape(symtab_addctx *ctx, const upb_FieldDef *f, const char **src, const char *end)
Definition: upb/upb/def.c:1933
upb_FieldDef_EnumSubDef
const upb_EnumDef * upb_FieldDef_EnumSubDef(const upb_FieldDef *f)
Definition: upb/upb/def.c:623
upb_inttable_count
size_t upb_inttable_count(const upb_inttable *t)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1711
upb_DefPool_FindExtensionByNameWithSize
const upb_FieldDef * upb_DefPool_FindExtensionByNameWithSize(const upb_DefPool *s, const char *name, size_t size)
Definition: upb/upb/def.c:1162
upb_MethodDef_HasOptions
bool upb_MethodDef_HasOptions(const upb_MethodDef *m)
Definition: upb/upb/def.c:1002
kUpb_WellKnown_Any
@ kUpb_WellKnown_Any
Definition: upb/upb/def.h:73
upb_FieldDef_HasOptions
bool upb_FieldDef_HasOptions(const upb_FieldDef *f)
Definition: upb/upb/def.c:492
upb_MessageDef::nested_msgs
const upb_MessageDef * nested_msgs
Definition: upb/upb/def.c:117
upb_MiniTable_Extension::extendee
const upb_MiniTable * extendee
Definition: msg_internal.h:204
upb_FieldDef
Definition: upb/upb/def.c:56
create_fielddef
static void create_fielddef(symtab_addctx *ctx, const char *prefix, upb_MessageDef *m, const google_protobuf_FieldDescriptorProto *field_proto, const upb_FieldDef *_f, bool is_extension)
Definition: upb/upb/def.c:2188
upb_deftype_t
upb_deftype_t
Definition: upb/upb/def.c:227
upb_FieldDef::dbl
double dbl
Definition: upb/upb/def.c:65
upb_MessageDef_ExtensionRangeCount
int upb_MessageDef_ExtensionRangeCount(const upb_MessageDef *m)
Definition: upb/upb/def.c:790
google_protobuf_FieldDescriptorProto_json_name
UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:1022
upb_OneofDef_LookupNameWithSize
const upb_FieldDef * upb_OneofDef_LookupNameWithSize(const upb_OneofDef *o, const char *name, size_t length)
Definition: upb/upb/def.c:894
kUpb_CType_Float
@ kUpb_CType_Float
Definition: upb/upb/upb.h:288
upb_ServiceDef_Method
const upb_MethodDef * upb_ServiceDef_Method(const upb_ServiceDef *s, int i)
Definition: upb/upb/def.c:1065
upb_MessageDef::real_oneof_count
int real_oneof_count
Definition: upb/upb/def.c:121
symtab_lookup
static const void * symtab_lookup(const upb_DefPool *s, const char *sym, upb_deftype_t type)
Definition: upb/upb/def.c:1112
upb_DefPool_ParseOctalEscape
static char upb_DefPool_ParseOctalEscape(symtab_addctx *ctx, const upb_FieldDef *f, const char **src, const char *end)
Definition: upb/upb/def.c:1965
upb_MessageDef::layout
const upb_MiniTable * layout
Definition: upb/upb/def.c:102
google_protobuf_FieldDescriptorProto_has_json_name
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_json_name(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:1015
upb_MessageDef::field_count
int field_count
Definition: upb/upb/def.c:120
UPB_INTTABLE_BEGIN
#define UPB_INTTABLE_BEGIN
Definition: table_internal.h:277
upb_DefPool_TryGetChar
static bool upb_DefPool_TryGetChar(const char **src, const char *end, char *ch)
Definition: upb/upb/def.c:1909
upb_FieldDef::type_
upb_FieldType type_
Definition: upb/upb/def.c:87
upb_EnumValueDef_FullName
const char * upb_EnumValueDef_FullName(const upb_EnumValueDef *ev)
Definition: upb/upb/def.c:450
upb_DefPool_FindExtensionByNumber
const upb_FieldDef * upb_DefPool_FindExtensionByNumber(const upb_DefPool *s, const upb_MessageDef *m, int32_t fieldnum)
Definition: upb/upb/def.c:3215
kUpb_FieldType_Fixed64
@ kUpb_FieldType_Fixed64
Definition: upb/upb/upb.h:314
upb_EnumDef_Default
int32_t upb_EnumDef_Default(const upb_EnumDef *e)
Definition: upb/upb/def.c:402
greeter_client.services
services
Definition: no_codegen/greeter_client.py:34
UPB_DEFTYPE_SERVICE
@ UPB_DEFTYPE_SERVICE
Definition: upb/upb/def.c:235
shortname
static const char * shortname(const char *longname)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:8087
upb_FileDef_WeakDependency
const upb_FileDef * upb_FileDef_WeakDependency(const upb_FileDef *f, int i)
Definition: upb/upb/def.c:968
UPB_MAX
#define UPB_MAX(x, y)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:125
upb_MessageDef::oneofs
const upb_OneofDef * oneofs
Definition: upb/upb/def.c:115
upb_ascii_lower
static char upb_ascii_lower(char ch)
Definition: upb/upb/def.c:287
INT64_MIN
#define INT64_MIN
Definition: stdint-msvc2008.h:138
upb_MessageDef_Options
const google_protobuf_MessageOptions * upb_MessageDef_Options(const upb_MessageDef *m)
Definition: upb/upb/def.c:692
symtab_add
static void symtab_add(symtab_addctx *ctx, const char *name, upb_value v)
Definition: upb/upb/def.c:1786
google_protobuf_DescriptorProto_enum_type
const UPB_INLINE google_protobuf_EnumDescriptorProto *const * google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:531
testing::internal::fmt
GTEST_API_ const char * fmt
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1808
upb_msg_fielddefsize
static uint8_t upb_msg_fielddefsize(const upb_FieldDef *f)
Definition: upb/upb/def.c:1359
upb_DefPool::arena
upb_Arena * arena
Definition: upb/upb/def.c:218
upb_EnumDef::defaultval
int32_t defaultval
Definition: upb/upb/def.c:144
number_
int number_
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:2671
upb_MessageDef::nested_ext_count
int nested_ext_count
Definition: upb/upb/def.c:126
INT32_MIN
#define INT32_MIN
Definition: stdint-msvc2008.h:136
upb_FieldDef_ContainingType
const upb_MessageDef * upb_FieldDef_ContainingType(const upb_FieldDef *f)
Definition: upb/upb/def.c:563
kUpb_WellKnown_UInt64Value
@ kUpb_WellKnown_UInt64Value
Definition: upb/upb/def.h:81
google_protobuf_FieldDescriptorProto_has_type_name
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type_name(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:976
upb_MessageDef::ext_range_count
int ext_range_count
Definition: upb/upb/def.c:123
upb_FieldDef::layout_index
uint16_t layout_index
Definition: upb/upb/def.c:81
kUpb_WellKnown_Duration
@ kUpb_WellKnown_Duration
Definition: upb/upb/def.h:75
upb_OneofDef_IsSynthetic
bool upb_OneofDef_IsSynthetic(const upb_OneofDef *o)
Definition: upb/upb/def.c:892
upb_OneofDef_Index
uint32_t upb_OneofDef_Index(const upb_OneofDef *o)
Definition: upb/upb/def.c:887
kUpb_WellKnown_Struct
@ kUpb_WellKnown_Struct
Definition: upb/upb/def.h:90
kUpb_FieldMode_Scalar
@ kUpb_FieldMode_Scalar
Definition: msg_internal.h:86
upb_FileDef::service_count
int service_count
Definition: upb/upb/def.c:192
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
upb_gmalloc
UPB_INLINE void * upb_gmalloc(size_t size)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:336
key
const char * key
Definition: hpack_parser_table.cc:164
upb_FileDef_ServiceCount
int upb_FileDef_ServiceCount(const upb_FileDef *f)
Definition: upb/upb/def.c:956
upb_EnumDef::value_count
int value_count
Definition: upb/upb/def.c:143
upb_isletter
static bool upb_isletter(char c)
Definition: upb/upb/def.c:294
upb_FieldDef::scope
union upb_FieldDef::@699 scope
upb_DefPool_Free
void upb_DefPool_Free(upb_DefPool *s)
Definition: upb/upb/def.c:1081
upb_FieldDef_JsonName
const char * upb_FieldDef_JsonName(const upb_FieldDef *f)
Definition: upb/upb/def.c:553
kUpb_Label_Repeated
@ kUpb_Label_Repeated
Definition: upb/upb/upb.h:304
upb_StringView
Definition: upb/upb/upb.h:72
ctx::symtab
const upb_DefPool * symtab
Definition: conformance_upb.c:85
makejsonname
static char * makejsonname(symtab_addctx *ctx, const char *name)
Definition: upb/upb/def.c:1776
bytes
uint8 bytes[10]
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:153
google_protobuf_FileDescriptorProto_message_type
const UPB_INLINE google_protobuf_DescriptorProto *const * google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:281
upb_FileDef
Definition: upb/upb/def.c:171
parse_default
static void parse_default(symtab_addctx *ctx, const char *str, size_t len, upb_FieldDef *f)
Definition: upb/upb/def.c:2047
google_protobuf_FieldOptions_packed
UPB_INLINE bool google_protobuf_FieldOptions_packed(const google_protobuf_FieldOptions *msg)
Definition: descriptor.upb.h:2136
upb_inttable_lookup
bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1803
upb_FileDef::deps
const upb_FileDef ** deps
Definition: upb/upb/def.c:176
check_ident
static void check_ident(symtab_addctx *ctx, upb_StringView name, bool full)
Definition: upb/upb/def.c:1303
def.h
upb_OneofDef_Field
const upb_FieldDef * upb_OneofDef_Field(const upb_OneofDef *o, int i)
Definition: upb/upb/def.c:880
upb_OneofDef::ntof
upb_strtable ntof
Definition: upb/upb/def.c:164
count
int * count
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:96
google_protobuf_FieldDescriptorProto_has_name
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:926
upb_ExtensionRange
Definition: upb/upb/def.c:94
nullz
static void nullz(upb_status *status)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2187
EnumDescriptorProto
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:2705
upb_MessageDef::containing_type
const upb_MessageDef * containing_type
Definition: upb/upb/def.c:104
EnumValueOptions
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:5287
upb_MessageDef_NestedExtension
const upb_FieldDef * upb_MessageDef_NestedExtension(const upb_MessageDef *m, int i)
Definition: upb/upb/def.c:849
upb_MessageDef_ContainingType
const upb_MessageDef * upb_MessageDef_ContainingType(const upb_MessageDef *m)
Definition: upb/upb/def.c:709
upb_MessageDef::ntof
upb_strtable ntof
Definition: upb/upb/def.c:109
google_protobuf_FieldDescriptorProto_has_type
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:966
UINT16_MAX
#define UINT16_MAX
Definition: stdint-msvc2008.h:141
upb_FileDef::services
const upb_ServiceDef * services
Definition: upb/upb/def.c:182
upb_FieldDef_IsRepeated
bool upb_FieldDef_IsRepeated(const upb_FieldDef *f)
Definition: upb/upb/def.c:651
finalize_oneofs
static void finalize_oneofs(symtab_addctx *ctx, upb_MessageDef *m)
Definition: upb/upb/def.c:1701
upb_DefPool_FindMessageByNameWithSize
const upb_MessageDef * upb_DefPool_FindMessageByNameWithSize(const upb_DefPool *s, const char *sym, size_t len)
Definition: upb/upb/def.c:1130
google_protobuf_DescriptorProto_field
const UPB_INLINE google_protobuf_FieldDescriptorProto *const * google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:513
upb_Status_IsOk
bool upb_Status_IsOk(const upb_Status *status)
Definition: upb/upb/upb.c:50
upb_ServiceDef_Options
const google_protobuf_ServiceOptions * upb_ServiceDef_Options(const upb_ServiceDef *s)
Definition: upb/upb/def.c:1038
CHK_OOM
#define CHK_OOM(x)
Definition: upb/upb/def.c:1250
upb_EnumDef_Name
const char * upb_EnumDef_Name(const upb_EnumDef *e)
Definition: upb/upb/def.c:392
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
upb_FileDef::public_deps
const int32_t * public_deps
Definition: upb/upb/def.c:177
upb_EnumDef::values
const upb_EnumValueDef * values
Definition: upb/upb/def.c:142
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
upb_FieldDef::str
str_t * str
Definition: upb/upb/def.c:68
upb_ServiceDef::methods
upb_MethodDef * methods
Definition: upb/upb/def.c:212
kUpb_FieldType_Group
@ kUpb_FieldType_Group
Definition: upb/upb/upb.h:318
google_protobuf_FieldDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:933
deftype
static upb_deftype_t deftype(upb_value v)
Definition: upb/upb/def.c:249
upb_FieldDef_IsString
bool upb_FieldDef_IsString(const upb_FieldDef *f)
Definition: upb/upb/def.c:646
upb_EnumDef::containing_type
const upb_MessageDef * containing_type
Definition: upb/upb/def.c:138
upb_MessageDef_OneofCount
int upb_MessageDef_OneofCount(const upb_MessageDef *m)
Definition: upb/upb/def.c:798
upb_FieldDef::oneof
const upb_OneofDef * oneof
Definition: upb/upb/def.c:71
next
AllocList * next[kMaxLevel]
Definition: abseil-cpp/absl/base/internal/low_level_alloc.cc:100
profile_analyzer.fields
list fields
Definition: profile_analyzer.py:266
fix_build_deps.r
r
Definition: fix_build_deps.py:491
fill_fieldlayout
static void fill_fieldlayout(upb_MiniTable_Field *field, const upb_FieldDef *f)
Definition: upb/upb/def.c:1427
google_protobuf_ExtensionRangeOptions
struct google_protobuf_ExtensionRangeOptions google_protobuf_ExtensionRangeOptions
Definition: descriptor.upb.h:55
upb_FileDef_PublicDependencyCount
int upb_FileDef_PublicDependencyCount(const upb_FileDef *f)
Definition: upb/upb/def.c:932
symtab_addctx::status
upb_Status * status
Definition: upb/upb/def.c:1264
UPB_DEFTYPE_EXT
@ UPB_DEFTYPE_EXT
Definition: upb/upb/def.c:231
google_protobuf_EnumValueDescriptorProto_number
UPB_INLINE int32_t google_protobuf_EnumValueDescriptorProto_number(const google_protobuf_EnumValueDescriptorProto *msg)
Definition: descriptor.upb.h:1394
google_protobuf_FileDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto *msg)
Definition: descriptor.upb.h:256
WRITE
#define WRITE(byte)
kUpb_ExtMode_IsMessageSet
@ kUpb_ExtMode_IsMessageSet
Definition: msg_internal.h:162
upb_ServiceDef_File
const upb_FileDef * upb_ServiceDef_File(const upb_ServiceDef *s)
Definition: upb/upb/def.c:1057
google_protobuf_OneofOptions
struct google_protobuf_OneofOptions google_protobuf_OneofOptions
Definition: descriptor.upb.h:66
symtab_addctx::arena
upb_Arena * arena
Definition: upb/upb/def.c:1258
values
std::array< int64_t, Size > values
Definition: abseil-cpp/absl/container/btree_benchmark.cc:608
upb_MessageDef::nested_enum_count
int nested_enum_count
Definition: upb/upb/def.c:125
upb_ExtensionRange::start
int32_t start
Definition: upb/upb/def.c:96
prefix
static const char prefix[]
Definition: head_of_line_blocking.cc:28
xds_manager.num
num
Definition: xds_manager.py:56
upb_FieldDef::uint
uint64_t uint
Definition: upb/upb/def.c:64
OneofDescriptorProto
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:2328
upb_isalphanum
static bool upb_isalphanum(char c)
Definition: upb/upb/def.c:299
ok
bool ok
Definition: async_end2end_test.cc:197
DescriptorProto
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:1312
assign_msg_wellknowntype
static void assign_msg_wellknowntype(upb_MessageDef *m)
Definition: upb/upb/def.c:337
_upb_DefPool_BytesLoaded
size_t _upb_DefPool_BytesLoaded(const upb_DefPool *s)
Definition: upb/upb/def.c:3201
UPB_NORETURN
#define UPB_NORETURN
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:79
upb_DefPool_FindExtensionByName
const upb_FieldDef * upb_DefPool_FindExtensionByName(const upb_DefPool *s, const char *sym)
Definition: upb/upb/def.c:1181
OneofOptions
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:4915
resolve_msgdef
static void resolve_msgdef(symtab_addctx *ctx, upb_MessageDef *m)
Definition: upb/upb/def.c:2843
upb_MessageDef_FullName
const char * upb_MessageDef_FullName(const upb_MessageDef *m)
Definition: upb/upb/def.c:701
kUpb_Syntax_Proto3
@ kUpb_Syntax_Proto3
Definition: upb/upb/def.h:65
kUpb_WellKnown_Value
@ kUpb_WellKnown_Value
Definition: upb/upb/def.h:88
kUpb_WellKnown_ListValue
@ kUpb_WellKnown_ListValue
Definition: upb/upb/def.h:89
upb_EnumDef::layout
const upb_MiniTable_Enum * layout
Definition: upb/upb/def.c:136
upb_FieldDef::proto3_optional_
bool proto3_optional_
Definition: upb/upb/def.c:85
upb_MethodDef::full_name
const char * full_name
Definition: upb/upb/def.c:200
upb_MessageDef_File
const upb_FileDef * upb_MessageDef_File(const upb_MessageDef *m)
Definition: upb/upb/def.c:705
kUpb_WellKnown_Int64Value
@ kUpb_WellKnown_Int64Value
Definition: upb/upb/def.h:80
upb_DefPool::files
upb_strtable files
Definition: upb/upb/def.c:220
upb_MessageDef_numoneofs
int upb_MessageDef_numoneofs(const upb_MessageDef *m)
Definition: upb/upb/def.c:784
upb_strtable
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:844
msgdef_create_nested
static void msgdef_create_nested(symtab_addctx *ctx, const google_protobuf_DescriptorProto *msg_proto, upb_MessageDef *m)
Definition: upb/upb/def.c:2677
upb_DefPool_AddFile
const upb_FileDef * upb_DefPool_AddFile(upb_DefPool *s, const google_protobuf_FileDescriptorProto *file_proto, upb_Status *status)
Definition: upb/upb/def.c:3140
upb_ExtensionRegistry_New
upb_ExtensionRegistry * upb_ExtensionRegistry_New(upb_Arena *arena)
Definition: msg.c:384
kUpb_WellKnown_DoubleValue
@ kUpb_WellKnown_DoubleValue
Definition: upb/upb/def.h:78
google_protobuf_MethodOptions
struct google_protobuf_MethodOptions google_protobuf_MethodOptions
Definition: descriptor.upb.h:70
kUpb_FieldType_Message
@ kUpb_FieldType_Message
Definition: upb/upb/upb.h:319
kUpb_WellKnown_Int32Value
@ kUpb_WellKnown_Int32Value
Definition: upb/upb/def.h:82
upb_DefPool_FindFileContainingSymbol
const upb_FileDef * upb_DefPool_FindFileContainingSymbol(const upb_DefPool *s, const char *name)
Definition: upb/upb/def.c:1196
upb_MessageDef::nested_msg_count
int nested_msg_count
Definition: upb/upb/def.c:124
google_protobuf_ServiceDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_ServiceDescriptorProto_name(const google_protobuf_ServiceDescriptorProto *msg)
Definition: descriptor.upb.h:1467
google_protobuf_EnumValueOptions
struct google_protobuf_EnumValueOptions google_protobuf_EnumValueOptions
Definition: descriptor.upb.h:68
_upb_DefPool_Arena
upb_Arena * _upb_DefPool_Arena(const upb_DefPool *s)
Definition: upb/upb/def.c:3205
symtab_addctx::tmp_arena
upb_Arena * tmp_arena
Definition: upb/upb/def.c:1259
symtab_resolve
static const void * symtab_resolve(symtab_addctx *ctx, const char *from_name_dbg, const char *base, upb_StringView sym, upb_deftype_t type)
Definition: upb/upb/def.c:1858
upb_FieldDef_IsSubMessage
bool upb_FieldDef_IsSubMessage(const upb_FieldDef *f)
Definition: upb/upb/def.c:642
kUpb_CType_Bool
@ kUpb_CType_Bool
Definition: upb/upb/upb.h:287
upb_MiniTable_place
static uint32_t upb_MiniTable_place(symtab_addctx *ctx, upb_MiniTable *l, size_t size, const upb_MessageDef *m)
Definition: upb/upb/def.c:1371
upb_FieldDef_ContainingOneof
const upb_OneofDef * upb_FieldDef_ContainingOneof(const upb_FieldDef *f)
Definition: upb/upb/def.c:571
kUpb_CType_Enum
@ kUpb_CType_Enum
Definition: upb/upb/upb.h:291
upb_EnumDef
Definition: upb/upb/def.c:134
upb_FileDef_PublicDependency
const upb_FileDef * upb_FileDef_PublicDependency(const upb_FileDef *f, int i)
Definition: upb/upb/def.c:963
upb_MethodDef::client_streaming
bool client_streaming
Definition: upb/upb/def.c:204
streql_view
static bool streql_view(upb_StringView view, const char *b)
Definition: upb/upb/def.c:1681
upb_MessageDef_NestedEnumCount
int upb_MessageDef_NestedEnumCount(const upb_MessageDef *m)
Definition: upb/upb/def.c:806
symtab_addctx
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3740
_upb_extreg_get
const upb_msglayout_field * _upb_extreg_get(const upb_extreg *r, const upb_msglayout *l, uint32_t num)
Definition: php-upb.c:1835
upb_DefPool_FindServiceByNameWithSize
const upb_ServiceDef * upb_DefPool_FindServiceByNameWithSize(const upb_DefPool *s, const char *name, size_t size)
Definition: upb/upb/def.c:1191
iter
Definition: test_winkernel.cpp:47
google_protobuf_FieldDescriptorProto_type
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:973
google_protobuf_FieldDescriptorProto_has_default_value
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_default_value(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:986
upb_ServiceDef_HasOptions
bool upb_ServiceDef_HasOptions(const upb_ServiceDef *s)
Definition: upb/upb/def.c:1043
upb_MessageDef_numrealoneofs
int upb_MessageDef_numrealoneofs(const upb_MessageDef *m)
Definition: upb/upb/def.c:786
upb_MethodDef_OutputType
const upb_MessageDef * upb_MethodDef_OutputType(const upb_MethodDef *m)
Definition: upb/upb/def.c:1024
xds_manager.f2
f2
Definition: xds_manager.py:85
upb_FieldDef_Name
const char * upb_FieldDef_Name(const upb_FieldDef *f)
Definition: upb/upb/def.c:549
upb_ServiceDef_Index
int upb_ServiceDef_Index(const upb_ServiceDef *s)
Definition: upb/upb/def.c:1055
str_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2920
count_exts_in_msg
static int count_exts_in_msg(const google_protobuf_DescriptorProto *msg_proto)
Definition: upb/upb/def.c:2867
upb_FieldDef::sint
int64_t sint
Definition: upb/upb/def.c:63
upb_EnumValueDef_Enum
const upb_EnumDef * upb_EnumValueDef_Enum(const upb_EnumValueDef *ev)
Definition: upb/upb/def.c:446
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
upb_MessageDef::in_message_set
bool in_message_set
Definition: upb/upb/def.c:127
ch
char ch
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3621
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
autogen_x86imm.tmp
tmp
Definition: autogen_x86imm.py:12
google_protobuf_ServiceOptions
struct google_protobuf_ServiceOptions google_protobuf_ServiceOptions
Definition: descriptor.upb.h:69
upb_Label
upb_Label
Definition: upb/upb/upb.h:301
upb_MessageDef_FieldCount
int upb_MessageDef_FieldCount(const upb_MessageDef *m)
Definition: upb/upb/def.c:794
kUpb_FieldRep_Pointer
@ kUpb_FieldRep_Pointer
Definition: msg_internal.h:103
kUpb_CType_UInt64
@ kUpb_CType_UInt64
Definition: upb/upb/upb.h:295
UPB_DEFTYPE_LAYOUT
@ UPB_DEFTYPE_LAYOUT
Definition: upb/upb/def.c:244
google_protobuf_DescriptorProto
struct google_protobuf_DescriptorProto google_protobuf_DescriptorProto
Definition: descriptor.upb.h:52
service
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod NSString * service
Definition: ProtoMethod.h:25
file::name
char * name
Definition: bloaty/third_party/zlib/examples/gzappend.c:176
upb_FieldDef::opts
const google_protobuf_FieldOptions * opts
Definition: upb/upb/def.c:57
run_grpclb_interop_tests.l
dictionary l
Definition: run_grpclb_interop_tests.py:410
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
kUpb_FieldType_Int32
@ kUpb_FieldType_Int32
Definition: upb/upb/upb.h:313
google_protobuf_DescriptorProto_nested_type
const UPB_INLINE google_protobuf_DescriptorProto *const * google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:522
_upb_extreg_add
bool _upb_extreg_add(upb_extreg *r, const upb_msglayout_ext *e, size_t count)
Definition: php-upb.c:1813
length
std::size_t length
Definition: abseil-cpp/absl/time/internal/test_util.cc:57
kUpb_FieldRep_1Byte
@ kUpb_FieldRep_1Byte
Definition: msg_internal.h:100
kUpb_FieldRep_StringView
@ kUpb_FieldRep_StringView
Definition: msg_internal.h:102
create_oneofdef
static void create_oneofdef(symtab_addctx *ctx, upb_MessageDef *m, const google_protobuf_OneofDescriptorProto *oneof_proto, const upb_OneofDef *_o)
Definition: upb/upb/def.c:1873
upb_FieldDef_ExtensionScope
const upb_MessageDef * upb_FieldDef_ExtensionScope(const upb_FieldDef *f)
Definition: upb/upb/def.c:567
upb_DefPool::bytes_loaded
size_t bytes_loaded
Definition: upb/upb/def.c:223
INT32_MAX
#define INT32_MAX
Definition: stdint-msvc2008.h:137
upb_MessageDef_Field
const upb_FieldDef * upb_MessageDef_Field(const upb_MessageDef *m, int i)
Definition: upb/upb/def.c:828
regress.m
m
Definition: regress/regress.py:25
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
upb_MethodDef_ClientStreaming
bool upb_MethodDef_ClientStreaming(const upb_MethodDef *m)
Definition: upb/upb/def.c:1028
upb_MiniTable_Field::submsg_index
uint16_t submsg_index
Definition: msg_internal.h:75
upb_ServiceDef_MethodCount
int upb_ServiceDef_MethodCount(const upb_ServiceDef *s)
Definition: upb/upb/def.c:1061
kUpb_FieldMode_Array
@ kUpb_FieldMode_Array
Definition: msg_internal.h:85
kUpb_FieldType_Int64
@ kUpb_FieldType_Int64
Definition: upb/upb/upb.h:311
subs
template_param_type subs
Definition: cxa_demangle.cpp:4906
symtab_alloc
void * symtab_alloc(symtab_addctx *ctx, size_t bytes)
Definition: upb/upb/def.c:1282
resolve_subdef
static void resolve_subdef(symtab_addctx *ctx, const char *prefix, upb_FieldDef *f)
Definition: upb/upb/def.c:2710
upb_FieldDef_HasJsonName
bool upb_FieldDef_HasJsonName(const upb_FieldDef *f)
Definition: upb/upb/def.c:557
google_protobuf_FileDescriptorProto_parse_ex
UPB_INLINE google_protobuf_FileDescriptorProto * google_protobuf_FileDescriptorProto_parse_ex(const char *buf, size_t size, const upb_ExtensionRegistry *extreg, int options, upb_Arena *arena)
Definition: descriptor.upb.h:231
fastdecode_generic
const char * fastdecode_generic(struct upb_decstate *d, const char *ptr, upb_msg *msg, intptr_t table, uint64_t hasbits, uint64_t data)
Definition: php-upb.c:933
upb_FieldDef_Options
const google_protobuf_FieldOptions * upb_FieldDef_Options(const upb_FieldDef *f)
Definition: upb/upb/def.c:487
upb_DefPool_FindFileByNameWithSize
const upb_FileDef * upb_DefPool_FindFileByNameWithSize(const upb_DefPool *s, const char *name, size_t len)
Definition: upb/upb/def.c:1153
MethodOptions
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:5659
google_protobuf_FileDescriptorProto
struct google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto
Definition: descriptor.upb.h:51
upb_strtable_insert
UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key, upb_value val)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:953
kUpb_WellKnown_FieldMask
@ kUpb_WellKnown_FieldMask
Definition: upb/upb/def.h:74
upb_strtable_next2
bool upb_strtable_next2(const upb_strtable *t, upb_StringView *key, upb_value *val, intptr_t *iter)
Definition: table.c:855
upb_DefPool
Definition: upb/upb/def.c:217
upb_MessageDef_FindFieldByNumber
const upb_FieldDef * upb_MessageDef_FindFieldByNumber(const upb_MessageDef *m, uint32_t i)
Definition: upb/upb/def.c:721
MessageLayout::value_count
int value_count
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:526
kUpb_Label_Optional
@ kUpb_Label_Optional
Definition: upb/upb/upb.h:302
resolve_default
static void resolve_default(symtab_addctx *ctx, upb_FieldDef *f, const google_protobuf_FieldDescriptorProto *field_proto)
Definition: upb/upb/def.c:2803
google_protobuf_FileOptions
struct google_protobuf_FileOptions google_protobuf_FileOptions
Definition: descriptor.upb.h:63
upb_EnumValueDef_Number
int32_t upb_EnumValueDef_Number(const upb_EnumValueDef *ev)
Definition: upb/upb/def.c:458
upb_Arena
Definition: upb_internal.h:36
upb_MessageDef::fields
const upb_FieldDef * fields
Definition: upb/upb/def.c:114
google_protobuf_MessageOptions
struct google_protobuf_MessageOptions google_protobuf_MessageOptions
Definition: descriptor.upb.h:64
upb_FieldDef::full_name
const char * full_name
Definition: upb/upb/def.c:60
upb_DefPool_FindMessageByName
const upb_MessageDef * upb_DefPool_FindMessageByName(const upb_DefPool *s, const char *sym)
Definition: upb/upb/def.c:1125
upb_FileDef::name
const char * name
Definition: upb/upb/def.c:173
UPB_NOINLINE
#define UPB_NOINLINE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:78
_upb_DefPool_registerlayout
bool _upb_DefPool_registerlayout(upb_DefPool *s, const char *filename, const upb_MiniTable_File *file)
Definition: upb/upb/def.c:3223
upb_MessageDef_FindFieldByNameWithSize
const upb_FieldDef * upb_MessageDef_FindFieldByNameWithSize(const upb_MessageDef *m, const char *name, size_t len)
Definition: upb/upb/def.c:728
upb_Arena_Fuse
bool upb_Arena_Fuse(upb_Arena *a1, upb_Arena *a2)
Definition: upb/upb/upb.c:299
symtab_addctx::enum_count
int enum_count
Definition: upb/upb/def.c:1261
upb_Arena_Free
void upb_Arena_Free(upb_Arena *a)
Definition: upb/upb/upb.c:273
if
if(p->owned &&p->wrapped !=NULL)
Definition: call.c:42
upb_FileDef_HasOptions
bool upb_FileDef_HasOptions(const upb_FileDef *f)
Definition: upb/upb/def.c:916
upb_FileDef::syntax
upb_Syntax syntax
Definition: upb/upb/def.c:194
upb_FieldDef_FullName
const char * upb_FieldDef_FullName(const upb_FieldDef *f)
Definition: upb/upb/def.c:496
UPB_LONGJMP
#define UPB_LONGJMP(buf, val)
Definition: php-upb.c:164
upb_MethodDef_Service
const upb_ServiceDef * upb_MethodDef_Service(const upb_MethodDef *m)
Definition: upb/upb/def.c:1016
upb_ExtensionRegistry
Definition: msg.c:372
errno.h
_upb_FastTable_Entry
Definition: msg_internal.h:131
kUpb_CType_Message
@ kUpb_CType_Message
Definition: upb/upb/upb.h:292
upb_FieldDef::boolean
bool boolean
Definition: upb/upb/def.c:67
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
create_enumlayout
upb_MiniTable_Enum * create_enumlayout(symtab_addctx *ctx, const upb_EnumDef *e)
Definition: upb/upb/def.c:2453
upb_ServiceDef_FindMethodByName
const upb_MethodDef * upb_ServiceDef_FindMethodByName(const upb_ServiceDef *s, const char *name)
Definition: upb/upb/def.c:1069
google_protobuf_MessageOptions_message_set_wire_format
UPB_INLINE bool google_protobuf_MessageOptions_message_set_wire_format(const google_protobuf_MessageOptions *msg)
Definition: descriptor.upb.h:2016
unescape
static str_t * unescape(symtab_addctx *ctx, const upb_FieldDef *f, const char *data, size_t len)
Definition: upb/upb/def.c:2026
upb_FieldDef_checkintfmt
bool upb_FieldDef_checkintfmt(int32_t fmt)
Definition: upb/upb/def.c:683
upb_EnumDef_Value
const upb_EnumValueDef * upb_EnumDef_Value(const upb_EnumDef *e, int i)
Definition: upb/upb/def.c:430
upb_DefPool_ParseEscape
static char upb_DefPool_ParseEscape(symtab_addctx *ctx, const upb_FieldDef *f, const char **src, const char *end)
Definition: upb/upb/def.c:1978
upb_FileDef_TopLevelMessageCount
int upb_FileDef_TopLevelMessageCount(const upb_FileDef *f)
Definition: upb/upb/def.c:926
kUpb_FieldType_Bytes
@ kUpb_FieldType_Bytes
Definition: upb/upb/upb.h:320
upb_OneofDef::fields
const upb_FieldDef ** fields
Definition: upb/upb/def.c:163
_upb_FieldDef_ExtensionMiniTable
const upb_MiniTable_Extension * _upb_FieldDef_ExtensionMiniTable(const upb_FieldDef *f)
Definition: upb/upb/def.c:632
upb_FileDef_DependencyCount
int upb_FileDef_DependencyCount(const upb_FileDef *f)
Definition: upb/upb/def.c:930
upb_FileDef::package
const char * package
Definition: upb/upb/def.c:174
upb_DefPool_TryGetHexDigit
static char upb_DefPool_TryGetHexDigit(symtab_addctx *ctx, const upb_FieldDef *f, const char **src, const char *end)
Definition: upb/upb/def.c:1917
upb_DefPool_FindFileByName
const upb_FileDef * upb_DefPool_FindFileByName(const upb_DefPool *s, const char *name)
Definition: upb/upb/def.c:1145
UPB_DEFTYPE_FILE
@ UPB_DEFTYPE_FILE
Definition: upb/upb/def.c:243


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:09