• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Amalgamated source file */
2 #include <stdint.h>/*
3 * This is where we define macros used across upb.
4 *
5 * All of these macros are undef'd in port_undef.inc to avoid leaking them to
6 * users.
7 *
8 * The correct usage is:
9 *
10 *   #include "upb/foobar.h"
11 *   #include "upb/baz.h"
12 *
13 *   // MUST be last included header.
14 *   #include "upb/port_def.inc"
15 *
16 *   // Code for this file.
17 *   // <...>
18 *
19 *   // Can be omitted for .c files, required for .h.
20 *   #include "upb/port_undef.inc"
21 *
22 * This file is private and must not be included by users!
23 */
24 #include <stdint.h>
25 
26 #if UINTPTR_MAX == 0xffffffff
27 #define UPB_SIZE(size32, size64) size32
28 #else
29 #define UPB_SIZE(size32, size64) size64
30 #endif
31 
32 /* If we always read/write as a consistent type to each address, this shouldn't
33  * violate aliasing.
34  */
35 #define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs)))
36 
37 #define UPB_READ_ONEOF(msg, fieldtype, offset, case_offset, case_val, default) \
38   *UPB_PTR_AT(msg, case_offset, int) == case_val                              \
39       ? *UPB_PTR_AT(msg, offset, fieldtype)                                   \
40       : default
41 
42 #define UPB_WRITE_ONEOF(msg, fieldtype, offset, value, case_offset, case_val) \
43   *UPB_PTR_AT(msg, case_offset, int) = case_val;                             \
44   *UPB_PTR_AT(msg, offset, fieldtype) = value;
45 
46 #define UPB_MAPTYPE_STRING 0
47 
48 /* UPB_INLINE: inline if possible, emit standalone code if required. */
49 #ifdef __cplusplus
50 #define UPB_INLINE inline
51 #elif defined (__GNUC__) || defined(__clang__)
52 #define UPB_INLINE static __inline__
53 #else
54 #define UPB_INLINE static
55 #endif
56 
57 /* Hints to the compiler about likely/unlikely branches. */
58 #if defined (__GNUC__) || defined(__clang__)
59 #define UPB_LIKELY(x) __builtin_expect((x),1)
60 #define UPB_UNLIKELY(x) __builtin_expect((x),0)
61 #else
62 #define UPB_LIKELY(x) (x)
63 #define UPB_UNLIKELY(x) (x)
64 #endif
65 
66 /* Define UPB_BIG_ENDIAN manually if you're on big endian and your compiler
67  * doesn't provide these preprocessor symbols. */
68 #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
69 #define UPB_BIG_ENDIAN
70 #endif
71 
72 /* Macros for function attributes on compilers that support them. */
73 #ifdef __GNUC__
74 #define UPB_FORCEINLINE __inline__ __attribute__((always_inline))
75 #define UPB_NOINLINE __attribute__((noinline))
76 #define UPB_NORETURN __attribute__((__noreturn__))
77 #else  /* !defined(__GNUC__) */
78 #define UPB_FORCEINLINE
79 #define UPB_NOINLINE
80 #define UPB_NORETURN
81 #endif
82 
83 #if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
84 /* C99/C++11 versions. */
85 #include <stdio.h>
86 #define _upb_snprintf snprintf
87 #define _upb_vsnprintf vsnprintf
88 #define _upb_va_copy(a, b) va_copy(a, b)
89 #elif defined(_MSC_VER)
90 /* Microsoft C/C++ versions. */
91 #include <stdarg.h>
92 #include <stdio.h>
93 #if _MSC_VER < 1900
94 int msvc_snprintf(char* s, size_t n, const char* format, ...);
95 int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg);
96 #define UPB_MSVC_VSNPRINTF
97 #define _upb_snprintf msvc_snprintf
98 #define _upb_vsnprintf msvc_vsnprintf
99 #else
100 #define _upb_snprintf snprintf
101 #define _upb_vsnprintf vsnprintf
102 #endif
103 #define _upb_va_copy(a, b) va_copy(a, b)
104 #elif defined __GNUC__
105 /* A few hacky workarounds for functions not in C89.
106  * For internal use only!
107  * TODO(haberman): fix these by including our own implementations, or finding
108  * another workaround.
109  */
110 #define _upb_snprintf __builtin_snprintf
111 #define _upb_vsnprintf __builtin_vsnprintf
112 #define _upb_va_copy(a, b) __va_copy(a, b)
113 #else
114 #error Need implementations of [v]snprintf and va_copy
115 #endif
116 
117 #ifdef __cplusplus
118 #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || \
119     (defined(_MSC_VER) && _MSC_VER >= 1900)
120 /* C++11 is present */
121 #else
122 #error upb requires C++11 for C++ support
123 #endif
124 #endif
125 
126 #define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
127 #define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
128 
129 #define UPB_UNUSED(var) (void)var
130 
131 /* UPB_ASSUME(): in release mode, we tell the compiler to assume this is true.
132  */
133 #ifdef NDEBUG
134 #ifdef __GNUC__
135 #define UPB_ASSUME(expr) if (!(expr)) __builtin_unreachable()
136 #else
137 #define UPB_ASSUME(expr) do {} if (false && (expr))
138 #endif
139 #else
140 #define UPB_ASSUME(expr) assert(expr)
141 #endif
142 
143 /* UPB_ASSERT(): in release mode, we use the expression without letting it be
144  * evaluated.  This prevents "unused variable" warnings. */
145 #ifdef NDEBUG
146 #define UPB_ASSERT(expr) do {} while (false && (expr))
147 #else
148 #define UPB_ASSERT(expr) assert(expr)
149 #endif
150 
151 /* UPB_ASSERT_DEBUGVAR(): assert that uses functions or variables that only
152  * exist in debug mode.  This turns into regular assert. */
153 #define UPB_ASSERT_DEBUGVAR(expr) assert(expr)
154 
155 #if defined(__GNUC__) || defined(__clang__)
156 #define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0)
157 #else
158 #define UPB_UNREACHABLE() do { assert(0); } while(0)
159 #endif
160 
161 /* UPB_INFINITY representing floating-point positive infinity. */
162 #include <math.h>
163 #ifdef INFINITY
164 #define UPB_INFINITY INFINITY
165 #else
166 #define UPB_INFINITY (1.0 / 0.0)
167 #endif
168 /*
169 ** upb_decode: parsing into a upb_msg using a upb_msglayout.
170 */
171 
172 #ifndef UPB_DECODE_H_
173 #define UPB_DECODE_H_
174 
175 /*
176 ** Our memory representation for parsing tables and messages themselves.
177 ** Functions in this file are used by generated code and possibly reflection.
178 **
179 ** The definitions in this file are internal to upb.
180 **/
181 
182 #ifndef UPB_MSG_H_
183 #define UPB_MSG_H_
184 
185 #include <stdint.h>
186 #include <string.h>
187 
188 /*
189 ** upb_table
190 **
191 ** This header is INTERNAL-ONLY!  Its interfaces are not public or stable!
192 ** This file defines very fast int->upb_value (inttable) and string->upb_value
193 ** (strtable) hash tables.
194 **
195 ** The table uses chained scatter with Brent's variation (inspired by the Lua
196 ** implementation of hash tables).  The hash function for strings is Austin
197 ** Appleby's "MurmurHash."
198 **
199 ** The inttable uses uintptr_t as its key, which guarantees it can be used to
200 ** store pointers or integers of at least 32 bits (upb isn't really useful on
201 ** systems where sizeof(void*) < 4).
202 **
203 ** The table must be homogenous (all values of the same type).  In debug
204 ** mode, we check this on insert and lookup.
205 */
206 
207 #ifndef UPB_TABLE_H_
208 #define UPB_TABLE_H_
209 
210 #include <stdint.h>
211 #include <string.h>
212 /*
213 ** This file contains shared definitions that are widely used across upb.
214 */
215 
216 #ifndef UPB_H_
217 #define UPB_H_
218 
219 #include <assert.h>
220 #include <stdarg.h>
221 #include <stdbool.h>
222 #include <stddef.h>
223 #include <stdint.h>
224 #include <string.h>
225 
226 
227 #ifdef __cplusplus
228 extern "C" {
229 #endif
230 
231 /* upb_status *****************************************************************/
232 
233 #define UPB_STATUS_MAX_MESSAGE 127
234 
235 typedef struct {
236   bool ok;
237   char msg[UPB_STATUS_MAX_MESSAGE];  /* Error message; NULL-terminated. */
238 } upb_status;
239 
240 const char *upb_status_errmsg(const upb_status *status);
241 bool upb_ok(const upb_status *status);
242 
243 /* These are no-op if |status| is NULL. */
244 void upb_status_clear(upb_status *status);
245 void upb_status_seterrmsg(upb_status *status, const char *msg);
246 void upb_status_seterrf(upb_status *status, const char *fmt, ...);
247 void upb_status_vseterrf(upb_status *status, const char *fmt, va_list args);
248 
249 /** upb_strview ************************************************************/
250 
251 typedef struct {
252   const char *data;
253   size_t size;
254 } upb_strview;
255 
upb_strview_make(const char * data,size_t size)256 UPB_INLINE upb_strview upb_strview_make(const char *data, size_t size) {
257   upb_strview ret;
258   ret.data = data;
259   ret.size = size;
260   return ret;
261 }
262 
upb_strview_makez(const char * data)263 UPB_INLINE upb_strview upb_strview_makez(const char *data) {
264   return upb_strview_make(data, strlen(data));
265 }
266 
upb_strview_eql(upb_strview a,upb_strview b)267 UPB_INLINE bool upb_strview_eql(upb_strview a, upb_strview b) {
268   return a.size == b.size && memcmp(a.data, b.data, a.size) == 0;
269 }
270 
271 #define UPB_STRVIEW_INIT(ptr, len) {ptr, len}
272 
273 #define UPB_STRVIEW_FORMAT "%.*s"
274 #define UPB_STRVIEW_ARGS(view) (int)(view).size, (view).data
275 
276 /** upb_alloc *****************************************************************/
277 
278 /* A upb_alloc is a possibly-stateful allocator object.
279  *
280  * It could either be an arena allocator (which doesn't require individual
281  * free() calls) or a regular malloc() (which does).  The client must therefore
282  * free memory unless it knows that the allocator is an arena allocator. */
283 
284 struct upb_alloc;
285 typedef struct upb_alloc upb_alloc;
286 
287 /* A malloc()/free() function.
288  * If "size" is 0 then the function acts like free(), otherwise it acts like
289  * realloc().  Only "oldsize" bytes from a previous allocation are preserved. */
290 typedef void *upb_alloc_func(upb_alloc *alloc, void *ptr, size_t oldsize,
291                              size_t size);
292 
293 struct upb_alloc {
294   upb_alloc_func *func;
295 };
296 
upb_malloc(upb_alloc * alloc,size_t size)297 UPB_INLINE void *upb_malloc(upb_alloc *alloc, size_t size) {
298   UPB_ASSERT(alloc);
299   return alloc->func(alloc, NULL, 0, size);
300 }
301 
upb_realloc(upb_alloc * alloc,void * ptr,size_t oldsize,size_t size)302 UPB_INLINE void *upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize,
303                              size_t size) {
304   UPB_ASSERT(alloc);
305   return alloc->func(alloc, ptr, oldsize, size);
306 }
307 
upb_free(upb_alloc * alloc,void * ptr)308 UPB_INLINE void upb_free(upb_alloc *alloc, void *ptr) {
309   assert(alloc);
310   alloc->func(alloc, ptr, 0, 0);
311 }
312 
313 /* The global allocator used by upb.  Uses the standard malloc()/free(). */
314 
315 extern upb_alloc upb_alloc_global;
316 
317 /* Functions that hard-code the global malloc.
318  *
319  * We still get benefit because we can put custom logic into our global
320  * allocator, like injecting out-of-memory faults in debug/testing builds. */
321 
upb_gmalloc(size_t size)322 UPB_INLINE void *upb_gmalloc(size_t size) {
323   return upb_malloc(&upb_alloc_global, size);
324 }
325 
upb_grealloc(void * ptr,size_t oldsize,size_t size)326 UPB_INLINE void *upb_grealloc(void *ptr, size_t oldsize, size_t size) {
327   return upb_realloc(&upb_alloc_global, ptr, oldsize, size);
328 }
329 
upb_gfree(void * ptr)330 UPB_INLINE void upb_gfree(void *ptr) {
331   upb_free(&upb_alloc_global, ptr);
332 }
333 
334 /* upb_arena ******************************************************************/
335 
336 /* upb_arena is a specific allocator implementation that uses arena allocation.
337  * The user provides an allocator that will be used to allocate the underlying
338  * arena blocks.  Arenas by nature do not require the individual allocations
339  * to be freed.  However the Arena does allow users to register cleanup
340  * functions that will run when the arena is destroyed.
341  *
342  * A upb_arena is *not* thread-safe.
343  *
344  * You could write a thread-safe arena allocator that satisfies the
345  * upb_alloc interface, but it would not be as efficient for the
346  * single-threaded case. */
347 
348 typedef void upb_cleanup_func(void *ud);
349 
350 struct upb_arena;
351 typedef struct upb_arena upb_arena;
352 
353 typedef struct {
354   /* We implement the allocator interface.
355    * This must be the first member of upb_arena! */
356   upb_alloc alloc;
357 
358   char *ptr, *end;
359 } _upb_arena_head;
360 
_upb_arena_alignup(size_t size)361 UPB_INLINE size_t _upb_arena_alignup(size_t size) {
362   const size_t maxalign = 16;
363   return ((size + maxalign - 1) / maxalign) * maxalign;
364 }
365 
366 /* Creates an arena from the given initial block (if any -- n may be 0).
367  * Additional blocks will be allocated from |alloc|.  If |alloc| is NULL, this
368  * is a fixed-size arena and cannot grow. */
369 upb_arena *upb_arena_init(void *mem, size_t n, upb_alloc *alloc);
370 void upb_arena_free(upb_arena *a);
371 bool upb_arena_addcleanup(upb_arena *a, void *ud, upb_cleanup_func *func);
372 size_t upb_arena_bytesallocated(const upb_arena *a);
373 void *_upb_arena_slowmalloc(upb_arena *a, size_t size);
374 
upb_arena_alloc(upb_arena * a)375 UPB_INLINE upb_alloc *upb_arena_alloc(upb_arena *a) { return (upb_alloc*)a; }
376 
upb_arena_malloc(upb_arena * a,size_t size)377 UPB_INLINE void *upb_arena_malloc(upb_arena *a, size_t size) {
378   _upb_arena_head *h = (_upb_arena_head*)a;
379   size = _upb_arena_alignup(size);
380   if (UPB_LIKELY((size_t)(h->end - h->ptr) >= size)) {
381     void* ret = h->ptr;
382     h->ptr += size;
383     return ret;
384   } else {
385     return _upb_arena_slowmalloc(a, size);
386   }
387 }
388 
upb_arena_realloc(upb_arena * a,void * ptr,size_t oldsize,size_t size)389 UPB_INLINE void *upb_arena_realloc(upb_arena *a, void *ptr, size_t oldsize,
390                                    size_t size) {
391   if (oldsize == 0) {
392     return upb_arena_malloc(a, size);
393   } else {
394     return upb_realloc(upb_arena_alloc(a), ptr, oldsize, size);
395   }
396 }
397 
upb_arena_new(void)398 UPB_INLINE upb_arena *upb_arena_new(void) {
399   return upb_arena_init(NULL, 0, &upb_alloc_global);
400 }
401 
402 /* Constants ******************************************************************/
403 
404 /* Generic function type. */
405 typedef void upb_func(void);
406 
407 /* A list of types as they are encoded on-the-wire. */
408 typedef enum {
409   UPB_WIRE_TYPE_VARINT      = 0,
410   UPB_WIRE_TYPE_64BIT       = 1,
411   UPB_WIRE_TYPE_DELIMITED   = 2,
412   UPB_WIRE_TYPE_START_GROUP = 3,
413   UPB_WIRE_TYPE_END_GROUP   = 4,
414   UPB_WIRE_TYPE_32BIT       = 5
415 } upb_wiretype_t;
416 
417 /* The types a field can have.  Note that this list is not identical to the
418  * types defined in descriptor.proto, which gives INT32 and SINT32 separate
419  * types (we distinguish the two with the "integer encoding" enum below). */
420 typedef enum {
421   UPB_TYPE_BOOL     = 1,
422   UPB_TYPE_FLOAT    = 2,
423   UPB_TYPE_INT32    = 3,
424   UPB_TYPE_UINT32   = 4,
425   UPB_TYPE_ENUM     = 5,  /* Enum values are int32. */
426   UPB_TYPE_MESSAGE  = 6,
427   UPB_TYPE_DOUBLE   = 7,
428   UPB_TYPE_INT64    = 8,
429   UPB_TYPE_UINT64   = 9,
430   UPB_TYPE_STRING   = 10,
431   UPB_TYPE_BYTES    = 11
432 } upb_fieldtype_t;
433 
434 /* The repeated-ness of each field; this matches descriptor.proto. */
435 typedef enum {
436   UPB_LABEL_OPTIONAL = 1,
437   UPB_LABEL_REQUIRED = 2,
438   UPB_LABEL_REPEATED = 3
439 } upb_label_t;
440 
441 /* Descriptor types, as defined in descriptor.proto. */
442 typedef enum {
443   /* Old (long) names.  TODO(haberman): remove */
444   UPB_DESCRIPTOR_TYPE_DOUBLE   = 1,
445   UPB_DESCRIPTOR_TYPE_FLOAT    = 2,
446   UPB_DESCRIPTOR_TYPE_INT64    = 3,
447   UPB_DESCRIPTOR_TYPE_UINT64   = 4,
448   UPB_DESCRIPTOR_TYPE_INT32    = 5,
449   UPB_DESCRIPTOR_TYPE_FIXED64  = 6,
450   UPB_DESCRIPTOR_TYPE_FIXED32  = 7,
451   UPB_DESCRIPTOR_TYPE_BOOL     = 8,
452   UPB_DESCRIPTOR_TYPE_STRING   = 9,
453   UPB_DESCRIPTOR_TYPE_GROUP    = 10,
454   UPB_DESCRIPTOR_TYPE_MESSAGE  = 11,
455   UPB_DESCRIPTOR_TYPE_BYTES    = 12,
456   UPB_DESCRIPTOR_TYPE_UINT32   = 13,
457   UPB_DESCRIPTOR_TYPE_ENUM     = 14,
458   UPB_DESCRIPTOR_TYPE_SFIXED32 = 15,
459   UPB_DESCRIPTOR_TYPE_SFIXED64 = 16,
460   UPB_DESCRIPTOR_TYPE_SINT32   = 17,
461   UPB_DESCRIPTOR_TYPE_SINT64   = 18,
462 
463   UPB_DTYPE_DOUBLE   = 1,
464   UPB_DTYPE_FLOAT    = 2,
465   UPB_DTYPE_INT64    = 3,
466   UPB_DTYPE_UINT64   = 4,
467   UPB_DTYPE_INT32    = 5,
468   UPB_DTYPE_FIXED64  = 6,
469   UPB_DTYPE_FIXED32  = 7,
470   UPB_DTYPE_BOOL     = 8,
471   UPB_DTYPE_STRING   = 9,
472   UPB_DTYPE_GROUP    = 10,
473   UPB_DTYPE_MESSAGE  = 11,
474   UPB_DTYPE_BYTES    = 12,
475   UPB_DTYPE_UINT32   = 13,
476   UPB_DTYPE_ENUM     = 14,
477   UPB_DTYPE_SFIXED32 = 15,
478   UPB_DTYPE_SFIXED64 = 16,
479   UPB_DTYPE_SINT32   = 17,
480   UPB_DTYPE_SINT64   = 18
481 } upb_descriptortype_t;
482 
483 #define UPB_MAP_BEGIN -1
484 
485 
486 #ifdef __cplusplus
487 }  /* extern "C" */
488 #endif
489 
490 #endif  /* UPB_H_ */
491 
492 
493 #ifdef __cplusplus
494 extern "C" {
495 #endif
496 
497 
498 /* upb_value ******************************************************************/
499 
500 /* A tagged union (stored untagged inside the table) so that we can check that
501  * clients calling table accessors are correctly typed without having to have
502  * an explosion of accessors. */
503 typedef enum {
504   UPB_CTYPE_INT32    = 1,
505   UPB_CTYPE_INT64    = 2,
506   UPB_CTYPE_UINT32   = 3,
507   UPB_CTYPE_UINT64   = 4,
508   UPB_CTYPE_BOOL     = 5,
509   UPB_CTYPE_CSTR     = 6,
510   UPB_CTYPE_PTR      = 7,
511   UPB_CTYPE_CONSTPTR = 8,
512   UPB_CTYPE_FPTR     = 9,
513   UPB_CTYPE_FLOAT    = 10,
514   UPB_CTYPE_DOUBLE   = 11
515 } upb_ctype_t;
516 
517 typedef struct {
518   uint64_t val;
519 } upb_value;
520 
521 /* Like strdup(), which isn't always available since it's not ANSI C. */
522 char *upb_strdup(const char *s, upb_alloc *a);
523 /* Variant that works with a length-delimited rather than NULL-delimited string,
524  * as supported by strtable. */
525 char *upb_strdup2(const char *s, size_t len, upb_alloc *a);
526 
upb_gstrdup(const char * s)527 UPB_INLINE char *upb_gstrdup(const char *s) {
528   return upb_strdup(s, &upb_alloc_global);
529 }
530 
_upb_value_setval(upb_value * v,uint64_t val)531 UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val) {
532   v->val = val;
533 }
534 
_upb_value_val(uint64_t val)535 UPB_INLINE upb_value _upb_value_val(uint64_t val) {
536   upb_value ret;
537   _upb_value_setval(&ret, val);
538   return ret;
539 }
540 
541 /* For each value ctype, define the following set of functions:
542  *
543  * // Get/set an int32 from a upb_value.
544  * int32_t upb_value_getint32(upb_value val);
545  * void upb_value_setint32(upb_value *val, int32_t cval);
546  *
547  * // Construct a new upb_value from an int32.
548  * upb_value upb_value_int32(int32_t val); */
549 #define FUNCS(name, membername, type_t, converter, proto_type) \
550   UPB_INLINE void upb_value_set ## name(upb_value *val, type_t cval) { \
551     val->val = (converter)cval; \
552   } \
553   UPB_INLINE upb_value upb_value_ ## name(type_t val) { \
554     upb_value ret; \
555     upb_value_set ## name(&ret, val); \
556     return ret; \
557   } \
558   UPB_INLINE type_t upb_value_get ## name(upb_value val) { \
559     return (type_t)(converter)val.val; \
560   }
561 
FUNCS(int32,int32,int32_t,int32_t,UPB_CTYPE_INT32)562 FUNCS(int32,    int32,        int32_t,      int32_t,    UPB_CTYPE_INT32)
563 FUNCS(int64,    int64,        int64_t,      int64_t,    UPB_CTYPE_INT64)
564 FUNCS(uint32,   uint32,       uint32_t,     uint32_t,   UPB_CTYPE_UINT32)
565 FUNCS(uint64,   uint64,       uint64_t,     uint64_t,   UPB_CTYPE_UINT64)
566 FUNCS(bool,     _bool,        bool,         bool,       UPB_CTYPE_BOOL)
567 FUNCS(cstr,     cstr,         char*,        uintptr_t,  UPB_CTYPE_CSTR)
568 FUNCS(ptr,      ptr,          void*,        uintptr_t,  UPB_CTYPE_PTR)
569 FUNCS(constptr, constptr,     const void*,  uintptr_t,  UPB_CTYPE_CONSTPTR)
570 FUNCS(fptr,     fptr,         upb_func*,    uintptr_t,  UPB_CTYPE_FPTR)
571 
572 #undef FUNCS
573 
574 UPB_INLINE void upb_value_setfloat(upb_value *val, float cval) {
575   memcpy(&val->val, &cval, sizeof(cval));
576 }
577 
upb_value_setdouble(upb_value * val,double cval)578 UPB_INLINE void upb_value_setdouble(upb_value *val, double cval) {
579   memcpy(&val->val, &cval, sizeof(cval));
580 }
581 
upb_value_float(float cval)582 UPB_INLINE upb_value upb_value_float(float cval) {
583   upb_value ret;
584   upb_value_setfloat(&ret, cval);
585   return ret;
586 }
587 
upb_value_double(double cval)588 UPB_INLINE upb_value upb_value_double(double cval) {
589   upb_value ret;
590   upb_value_setdouble(&ret, cval);
591   return ret;
592 }
593 
594 #undef SET_TYPE
595 
596 
597 /* upb_tabkey *****************************************************************/
598 
599 /* Either:
600  *   1. an actual integer key, or
601  *   2. a pointer to a string prefixed by its uint32_t length, owned by us.
602  *
603  * ...depending on whether this is a string table or an int table.  We would
604  * make this a union of those two types, but C89 doesn't support statically
605  * initializing a non-first union member. */
606 typedef uintptr_t upb_tabkey;
607 
upb_tabstr(upb_tabkey key,uint32_t * len)608 UPB_INLINE char *upb_tabstr(upb_tabkey key, uint32_t *len) {
609   char* mem = (char*)key;
610   if (len) memcpy(len, mem, sizeof(*len));
611   return mem + sizeof(*len);
612 }
613 
614 
615 /* upb_tabval *****************************************************************/
616 
617 typedef struct {
618   uint64_t val;
619 } upb_tabval;
620 
621 #define UPB_TABVALUE_EMPTY_INIT  {-1}
622 
623 /* upb_table ******************************************************************/
624 
625 typedef struct _upb_tabent {
626   upb_tabkey key;
627   upb_tabval val;
628 
629   /* Internal chaining.  This is const so we can create static initializers for
630    * tables.  We cast away const sometimes, but *only* when the containing
631    * upb_table is known to be non-const.  This requires a bit of care, but
632    * the subtlety is confined to table.c. */
633   const struct _upb_tabent *next;
634 } upb_tabent;
635 
636 typedef struct {
637   size_t count;          /* Number of entries in the hash part. */
638   size_t mask;           /* Mask to turn hash value -> bucket. */
639   uint8_t size_lg2;      /* Size of the hashtable part is 2^size_lg2 entries. */
640 
641   /* Hash table entries.
642    * Making this const isn't entirely accurate; what we really want is for it to
643    * have the same const-ness as the table it's inside.  But there's no way to
644    * declare that in C.  So we have to make it const so that we can statically
645    * initialize const hash tables.  Then we cast away const when we have to.
646    */
647   const upb_tabent *entries;
648 } upb_table;
649 
650 typedef struct {
651   upb_table t;
652 } upb_strtable;
653 
654 typedef struct {
655   upb_table t;              /* For entries that don't fit in the array part. */
656   const upb_tabval *array;  /* Array part of the table. See const note above. */
657   size_t array_size;        /* Array part size. */
658   size_t array_count;       /* Array part number of elements. */
659 } upb_inttable;
660 
661 #define UPB_ARRAY_EMPTYENT -1
662 
upb_table_size(const upb_table * t)663 UPB_INLINE size_t upb_table_size(const upb_table *t) {
664   if (t->size_lg2 == 0)
665     return 0;
666   else
667     return 1 << t->size_lg2;
668 }
669 
670 /* Internal-only functions, in .h file only out of necessity. */
upb_tabent_isempty(const upb_tabent * e)671 UPB_INLINE bool upb_tabent_isempty(const upb_tabent *e) {
672   return e->key == 0;
673 }
674 
675 /* Used by some of the unit tests for generic hashing functionality. */
676 uint32_t upb_murmur_hash2(const void * key, size_t len, uint32_t seed);
677 
upb_intkey(uintptr_t key)678 UPB_INLINE uintptr_t upb_intkey(uintptr_t key) {
679   return key;
680 }
681 
upb_inthash(uintptr_t key)682 UPB_INLINE uint32_t upb_inthash(uintptr_t key) {
683   return (uint32_t)key;
684 }
685 
upb_getentry(const upb_table * t,uint32_t hash)686 static const upb_tabent *upb_getentry(const upb_table *t, uint32_t hash) {
687   return t->entries + (hash & t->mask);
688 }
689 
upb_arrhas(upb_tabval key)690 UPB_INLINE bool upb_arrhas(upb_tabval key) {
691   return key.val != (uint64_t)-1;
692 }
693 
694 /* Initialize and uninitialize a table, respectively.  If memory allocation
695  * failed, false is returned that the table is uninitialized. */
696 bool upb_inttable_init2(upb_inttable *table, upb_ctype_t ctype, upb_alloc *a);
697 bool upb_strtable_init2(upb_strtable *table, upb_ctype_t ctype, upb_alloc *a);
698 void upb_inttable_uninit2(upb_inttable *table, upb_alloc *a);
699 void upb_strtable_uninit2(upb_strtable *table, upb_alloc *a);
700 
upb_inttable_init(upb_inttable * table,upb_ctype_t ctype)701 UPB_INLINE bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype) {
702   return upb_inttable_init2(table, ctype, &upb_alloc_global);
703 }
704 
upb_strtable_init(upb_strtable * table,upb_ctype_t ctype)705 UPB_INLINE bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype) {
706   return upb_strtable_init2(table, ctype, &upb_alloc_global);
707 }
708 
upb_inttable_uninit(upb_inttable * table)709 UPB_INLINE void upb_inttable_uninit(upb_inttable *table) {
710   upb_inttable_uninit2(table, &upb_alloc_global);
711 }
712 
upb_strtable_uninit(upb_strtable * table)713 UPB_INLINE void upb_strtable_uninit(upb_strtable *table) {
714   upb_strtable_uninit2(table, &upb_alloc_global);
715 }
716 
717 /* Returns the number of values in the table. */
718 size_t upb_inttable_count(const upb_inttable *t);
upb_strtable_count(const upb_strtable * t)719 UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) {
720   return t->t.count;
721 }
722 
723 void upb_inttable_packedsize(const upb_inttable *t, size_t *size);
724 void upb_strtable_packedsize(const upb_strtable *t, size_t *size);
725 upb_inttable *upb_inttable_pack(const upb_inttable *t, void *p, size_t *ofs,
726                                 size_t size);
727 upb_strtable *upb_strtable_pack(const upb_strtable *t, void *p, size_t *ofs,
728                                 size_t size);
729 void upb_strtable_clear(upb_strtable *t);
730 
731 /* Inserts the given key into the hashtable with the given value.  The key must
732  * not already exist in the hash table.  For string tables, the key must be
733  * NULL-terminated, and the table will make an internal copy of the key.
734  * Inttables must not insert a value of UINTPTR_MAX.
735  *
736  * If a table resize was required but memory allocation failed, false is
737  * returned and the table is unchanged. */
738 bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val,
739                           upb_alloc *a);
740 bool upb_strtable_insert3(upb_strtable *t, const char *key, size_t len,
741                           upb_value val, upb_alloc *a);
742 
upb_inttable_insert(upb_inttable * t,uintptr_t key,upb_value val)743 UPB_INLINE bool upb_inttable_insert(upb_inttable *t, uintptr_t key,
744                                     upb_value val) {
745   return upb_inttable_insert2(t, key, val, &upb_alloc_global);
746 }
747 
upb_strtable_insert2(upb_strtable * t,const char * key,size_t len,upb_value val)748 UPB_INLINE bool upb_strtable_insert2(upb_strtable *t, const char *key,
749                                      size_t len, upb_value val) {
750   return upb_strtable_insert3(t, key, len, val, &upb_alloc_global);
751 }
752 
753 /* For NULL-terminated strings. */
upb_strtable_insert(upb_strtable * t,const char * key,upb_value val)754 UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key,
755                                     upb_value val) {
756   return upb_strtable_insert2(t, key, strlen(key), val);
757 }
758 
759 /* Looks up key in this table, returning "true" if the key was found.
760  * If v is non-NULL, copies the value for this key into *v. */
761 bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v);
762 bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len,
763                           upb_value *v);
764 
765 /* For NULL-terminated strings. */
upb_strtable_lookup(const upb_strtable * t,const char * key,upb_value * v)766 UPB_INLINE bool upb_strtable_lookup(const upb_strtable *t, const char *key,
767                                     upb_value *v) {
768   return upb_strtable_lookup2(t, key, strlen(key), v);
769 }
770 
771 /* Removes an item from the table.  Returns true if the remove was successful,
772  * and stores the removed item in *val if non-NULL. */
773 bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val);
774 bool upb_strtable_remove3(upb_strtable *t, const char *key, size_t len,
775                           upb_value *val, upb_alloc *alloc);
776 
upb_strtable_remove2(upb_strtable * t,const char * key,size_t len,upb_value * val)777 UPB_INLINE bool upb_strtable_remove2(upb_strtable *t, const char *key,
778                                      size_t len, upb_value *val) {
779   return upb_strtable_remove3(t, key, len, val, &upb_alloc_global);
780 }
781 
782 /* For NULL-terminated strings. */
upb_strtable_remove(upb_strtable * t,const char * key,upb_value * v)783 UPB_INLINE bool upb_strtable_remove(upb_strtable *t, const char *key,
784                                     upb_value *v) {
785   return upb_strtable_remove2(t, key, strlen(key), v);
786 }
787 
788 /* Updates an existing entry in an inttable.  If the entry does not exist,
789  * returns false and does nothing.  Unlike insert/remove, this does not
790  * invalidate iterators. */
791 bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val);
792 
793 /* Handy routines for treating an inttable like a stack.  May not be mixed with
794  * other insert/remove calls. */
795 bool upb_inttable_push2(upb_inttable *t, upb_value val, upb_alloc *a);
796 upb_value upb_inttable_pop(upb_inttable *t);
797 
upb_inttable_push(upb_inttable * t,upb_value val)798 UPB_INLINE bool upb_inttable_push(upb_inttable *t, upb_value val) {
799   return upb_inttable_push2(t, val, &upb_alloc_global);
800 }
801 
802 /* Convenience routines for inttables with pointer keys. */
803 bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val,
804                              upb_alloc *a);
805 bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val);
806 bool upb_inttable_lookupptr(
807     const upb_inttable *t, const void *key, upb_value *val);
808 
upb_inttable_insertptr(upb_inttable * t,const void * key,upb_value val)809 UPB_INLINE bool upb_inttable_insertptr(upb_inttable *t, const void *key,
810                                        upb_value val) {
811   return upb_inttable_insertptr2(t, key, val, &upb_alloc_global);
812 }
813 
814 /* Optimizes the table for the current set of entries, for both memory use and
815  * lookup time.  Client should call this after all entries have been inserted;
816  * inserting more entries is legal, but will likely require a table resize. */
817 void upb_inttable_compact2(upb_inttable *t, upb_alloc *a);
818 
upb_inttable_compact(upb_inttable * t)819 UPB_INLINE void upb_inttable_compact(upb_inttable *t) {
820   upb_inttable_compact2(t, &upb_alloc_global);
821 }
822 
823 /* A special-case inlinable version of the lookup routine for 32-bit
824  * integers. */
upb_inttable_lookup32(const upb_inttable * t,uint32_t key,upb_value * v)825 UPB_INLINE bool upb_inttable_lookup32(const upb_inttable *t, uint32_t key,
826                                       upb_value *v) {
827   *v = upb_value_int32(0);  /* Silence compiler warnings. */
828   if (key < t->array_size) {
829     upb_tabval arrval = t->array[key];
830     if (upb_arrhas(arrval)) {
831       _upb_value_setval(v, arrval.val);
832       return true;
833     } else {
834       return false;
835     }
836   } else {
837     const upb_tabent *e;
838     if (t->t.entries == NULL) return false;
839     for (e = upb_getentry(&t->t, upb_inthash(key)); true; e = e->next) {
840       if ((uint32_t)e->key == key) {
841         _upb_value_setval(v, e->val.val);
842         return true;
843       }
844       if (e->next == NULL) return false;
845     }
846   }
847 }
848 
849 /* Exposed for testing only. */
850 bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_alloc *a);
851 
852 /* Iterators ******************************************************************/
853 
854 /* Iterators for int and string tables.  We are subject to some kind of unusual
855  * design constraints:
856  *
857  * For high-level languages:
858  *  - we must be able to guarantee that we don't crash or corrupt memory even if
859  *    the program accesses an invalidated iterator.
860  *
861  * For C++11 range-based for:
862  *  - iterators must be copyable
863  *  - iterators must be comparable
864  *  - it must be possible to construct an "end" value.
865  *
866  * Iteration order is undefined.
867  *
868  * Modifying the table invalidates iterators.  upb_{str,int}table_done() is
869  * guaranteed to work even on an invalidated iterator, as long as the table it
870  * is iterating over has not been freed.  Calling next() or accessing data from
871  * an invalidated iterator yields unspecified elements from the table, but it is
872  * guaranteed not to crash and to return real table elements (except when done()
873  * is true). */
874 
875 
876 /* upb_strtable_iter **********************************************************/
877 
878 /*   upb_strtable_iter i;
879  *   upb_strtable_begin(&i, t);
880  *   for(; !upb_strtable_done(&i); upb_strtable_next(&i)) {
881  *     const char *key = upb_strtable_iter_key(&i);
882  *     const upb_value val = upb_strtable_iter_value(&i);
883  *     // ...
884  *   }
885  */
886 
887 typedef struct {
888   const upb_strtable *t;
889   size_t index;
890 } upb_strtable_iter;
891 
892 void upb_strtable_begin(upb_strtable_iter *i, const upb_strtable *t);
893 void upb_strtable_next(upb_strtable_iter *i);
894 bool upb_strtable_done(const upb_strtable_iter *i);
895 upb_strview upb_strtable_iter_key(const upb_strtable_iter *i);
896 upb_value upb_strtable_iter_value(const upb_strtable_iter *i);
897 void upb_strtable_iter_setdone(upb_strtable_iter *i);
898 bool upb_strtable_iter_isequal(const upb_strtable_iter *i1,
899                                const upb_strtable_iter *i2);
900 
901 
902 /* upb_inttable_iter **********************************************************/
903 
904 /*   upb_inttable_iter i;
905  *   upb_inttable_begin(&i, t);
906  *   for(; !upb_inttable_done(&i); upb_inttable_next(&i)) {
907  *     uintptr_t key = upb_inttable_iter_key(&i);
908  *     upb_value val = upb_inttable_iter_value(&i);
909  *     // ...
910  *   }
911  */
912 
913 typedef struct {
914   const upb_inttable *t;
915   size_t index;
916   bool array_part;
917 } upb_inttable_iter;
918 
str_tabent(const upb_strtable_iter * i)919 UPB_INLINE const upb_tabent *str_tabent(const upb_strtable_iter *i) {
920   return &i->t->t.entries[i->index];
921 }
922 
923 void upb_inttable_begin(upb_inttable_iter *i, const upb_inttable *t);
924 void upb_inttable_next(upb_inttable_iter *i);
925 bool upb_inttable_done(const upb_inttable_iter *i);
926 uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i);
927 upb_value upb_inttable_iter_value(const upb_inttable_iter *i);
928 void upb_inttable_iter_setdone(upb_inttable_iter *i);
929 bool upb_inttable_iter_isequal(const upb_inttable_iter *i1,
930                                const upb_inttable_iter *i2);
931 
932 
933 #ifdef __cplusplus
934 }  /* extern "C" */
935 #endif
936 
937 
938 #endif  /* UPB_TABLE_H_ */
939 
940 
941 #ifdef __cplusplus
942 extern "C" {
943 #endif
944 
945 #define PTR_AT(msg, ofs, type) (type*)((const char*)msg + ofs)
946 
947 typedef void upb_msg;
948 
949 /** upb_msglayout *************************************************************/
950 
951 /* upb_msglayout represents the memory layout of a given upb_msgdef.  The
952  * members are public so generated code can initialize them, but users MUST NOT
953  * read or write any of its members. */
954 
955 /* These aren't real labels according to descriptor.proto, but in the table we
956  * use these for map/packed fields instead of UPB_LABEL_REPEATED. */
957 enum {
958   _UPB_LABEL_MAP = 4,
959   _UPB_LABEL_PACKED = 7  /* Low 3 bits are common with UPB_LABEL_REPEATED. */
960 };
961 
962 typedef struct {
963   uint32_t number;
964   uint16_t offset;
965   int16_t presence;      /* If >0, hasbit_index.  If <0, -oneof_index. */
966   uint16_t submsg_index;  /* undefined if descriptortype != MESSAGE or GROUP. */
967   uint8_t descriptortype;
968   uint8_t label;
969 } upb_msglayout_field;
970 
971 typedef struct upb_msglayout {
972   const struct upb_msglayout *const* submsgs;
973   const upb_msglayout_field *fields;
974   /* Must be aligned to sizeof(void*).  Doesn't include internal members like
975    * unknown fields, extension dict, pointer to msglayout, etc. */
976   uint16_t size;
977   uint16_t field_count;
978   bool extendable;
979 } upb_msglayout;
980 
981 /** upb_msg *******************************************************************/
982 
983 /* Internal members of a upb_msg.  We can change this without breaking binary
984  * compatibility.  We put these before the user's data.  The user's upb_msg*
985  * points after the upb_msg_internal. */
986 
987 /* Used when a message is not extendable. */
988 typedef struct {
989   char *unknown;
990   size_t unknown_len;
991   size_t unknown_size;
992 } upb_msg_internal;
993 
994 /* Used when a message is extendable. */
995 typedef struct {
996   upb_inttable *extdict;
997   upb_msg_internal base;
998 } upb_msg_internal_withext;
999 
1000 /* Maps upb_fieldtype_t -> memory size. */
1001 extern char _upb_fieldtype_to_size[12];
1002 
1003 /* Creates a new messages with the given layout on the given arena. */
1004 upb_msg *_upb_msg_new(const upb_msglayout *l, upb_arena *a);
1005 
1006 /* Adds unknown data (serialized protobuf data) to the given message.  The data
1007  * is copied into the message instance. */
1008 bool _upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
1009                          upb_arena *arena);
1010 
1011 /* Returns a reference to the message's unknown data. */
1012 const char *upb_msg_getunknown(const upb_msg *msg, size_t *len);
1013 
_upb_has_field(const void * msg,size_t idx)1014 UPB_INLINE bool _upb_has_field(const void *msg, size_t idx) {
1015   return (*PTR_AT(msg, idx / 8, const char) & (1 << (idx % 8))) != 0;
1016 }
1017 
_upb_sethas(const void * msg,size_t idx)1018 UPB_INLINE bool _upb_sethas(const void *msg, size_t idx) {
1019   return (*PTR_AT(msg, idx / 8, char)) |= (char)(1 << (idx % 8));
1020 }
1021 
_upb_clearhas(const void * msg,size_t idx)1022 UPB_INLINE bool _upb_clearhas(const void *msg, size_t idx) {
1023   return (*PTR_AT(msg, idx / 8, char)) &= (char)(~(1 << (idx % 8)));
1024 }
1025 
_upb_has_oneof_field(const void * msg,size_t case_ofs,int32_t num)1026 UPB_INLINE bool _upb_has_oneof_field(const void *msg, size_t case_ofs, int32_t num) {
1027   return *PTR_AT(msg, case_ofs, int32_t) == num;
1028 }
1029 
_upb_has_submsg_nohasbit(const void * msg,size_t ofs)1030 UPB_INLINE bool _upb_has_submsg_nohasbit(const void *msg, size_t ofs) {
1031   return *PTR_AT(msg, ofs, const void*) != NULL;
1032 }
1033 
_upb_isrepeated(const upb_msglayout_field * field)1034 UPB_INLINE bool _upb_isrepeated(const upb_msglayout_field *field) {
1035   return (field->label & 3) == UPB_LABEL_REPEATED;
1036 }
1037 
1038 /** upb_array *****************************************************************/
1039 
1040 /* Our internal representation for repeated fields.  */
1041 typedef struct {
1042   uintptr_t data;   /* Tagged ptr: low 3 bits of ptr are lg2(elem size). */
1043   size_t len;   /* Measured in elements. */
1044   size_t size;  /* Measured in elements. */
1045 } upb_array;
1046 
_upb_array_constptr(const upb_array * arr)1047 UPB_INLINE const void *_upb_array_constptr(const upb_array *arr) {
1048   return (void*)(arr->data & ~(uintptr_t)7);
1049 }
1050 
_upb_array_ptr(upb_array * arr)1051 UPB_INLINE void *_upb_array_ptr(upb_array *arr) {
1052   return (void*)_upb_array_constptr(arr);
1053 }
1054 
1055 /* Creates a new array on the given arena. */
1056 upb_array *_upb_array_new(upb_arena *a, upb_fieldtype_t type);
1057 
1058 /* Resizes the capacity of the array to be at least min_size. */
1059 bool _upb_array_realloc(upb_array *arr, size_t min_size, upb_arena *arena);
1060 
1061 /* Fallback functions for when the accessors require a resize. */
1062 void *_upb_array_resize_fallback(upb_array **arr_ptr, size_t size,
1063                                  upb_fieldtype_t type, upb_arena *arena);
1064 bool _upb_array_append_fallback(upb_array **arr_ptr, const void *value,
1065                                 upb_fieldtype_t type, upb_arena *arena);
1066 
_upb_array_accessor(const void * msg,size_t ofs,size_t * size)1067 UPB_INLINE const void *_upb_array_accessor(const void *msg, size_t ofs,
1068                                            size_t *size) {
1069   const upb_array *arr = *PTR_AT(msg, ofs, const upb_array*);
1070   if (arr) {
1071     if (size) *size = arr->len;
1072     return _upb_array_constptr(arr);
1073   } else {
1074     if (size) *size = 0;
1075     return NULL;
1076   }
1077 }
1078 
_upb_array_mutable_accessor(void * msg,size_t ofs,size_t * size)1079 UPB_INLINE void *_upb_array_mutable_accessor(void *msg, size_t ofs,
1080                                              size_t *size) {
1081   upb_array *arr = *PTR_AT(msg, ofs, upb_array*);
1082   if (arr) {
1083     if (size) *size = arr->len;
1084     return _upb_array_ptr(arr);
1085   } else {
1086     if (size) *size = 0;
1087     return NULL;
1088   }
1089 }
1090 
_upb_array_resize_accessor(void * msg,size_t ofs,size_t size,upb_fieldtype_t type,upb_arena * arena)1091 UPB_INLINE void *_upb_array_resize_accessor(void *msg, size_t ofs, size_t size,
1092                                             upb_fieldtype_t type,
1093                                             upb_arena *arena) {
1094   upb_array **arr_ptr = PTR_AT(msg, ofs, upb_array*);
1095   upb_array *arr = *arr_ptr;
1096   if (!arr || arr->size < size) {
1097     return _upb_array_resize_fallback(arr_ptr, size, type, arena);
1098   }
1099   arr->len = size;
1100   return _upb_array_ptr(arr);
1101 }
1102 
1103 
_upb_array_append_accessor(void * msg,size_t ofs,size_t elem_size,upb_fieldtype_t type,const void * value,upb_arena * arena)1104 UPB_INLINE bool _upb_array_append_accessor(void *msg, size_t ofs,
1105                                            size_t elem_size,
1106                                            upb_fieldtype_t type,
1107                                            const void *value,
1108                                            upb_arena *arena) {
1109   upb_array **arr_ptr = PTR_AT(msg, ofs, upb_array*);
1110   upb_array *arr = *arr_ptr;
1111   void* ptr;
1112   if (!arr || arr->len == arr->size) {
1113     return _upb_array_append_fallback(arr_ptr, value, type, arena);
1114   }
1115   ptr = _upb_array_ptr(arr);
1116   memcpy(PTR_AT(ptr, arr->len * elem_size, char), value, elem_size);
1117   arr->len++;
1118   return true;
1119 }
1120 
1121 /** upb_map *******************************************************************/
1122 
1123 /* Right now we use strmaps for everything.  We'll likely want to use
1124  * integer-specific maps for integer-keyed maps.*/
1125 typedef struct {
1126   /* Size of key and val, based on the map type.  Strings are represented as '0'
1127    * because they must be handled specially. */
1128   char key_size;
1129   char val_size;
1130 
1131   upb_strtable table;
1132 } upb_map;
1133 
1134 /* Map entries aren't actually stored, they are only used during parsing.  For
1135  * parsing, it helps a lot if all map entry messages have the same layout.
1136  * The compiler and def.c must ensure that all map entries have this layout. */
1137 typedef struct {
1138   upb_msg_internal internal;
1139   union {
1140     upb_strview str;  /* For str/bytes. */
1141     upb_value val;    /* For all other types. */
1142   } k;
1143   union {
1144     upb_strview str;  /* For str/bytes. */
1145     upb_value val;    /* For all other types. */
1146   } v;
1147 } upb_map_entry;
1148 
1149 /* Creates a new map on the given arena with this key/value type. */
1150 upb_map *_upb_map_new(upb_arena *a, size_t key_size, size_t value_size);
1151 
1152 /* Converting between internal table representation and user values.
1153  *
1154  * _upb_map_tokey() and _upb_map_fromkey() are inverses.
1155  * _upb_map_tovalue() and _upb_map_fromvalue() are inverses.
1156  *
1157  * These functions account for the fact that strings are treated differently
1158  * from other types when stored in a map.
1159  */
1160 
_upb_map_tokey(const void * key,size_t size)1161 UPB_INLINE upb_strview _upb_map_tokey(const void *key, size_t size) {
1162   if (size == UPB_MAPTYPE_STRING) {
1163     return *(upb_strview*)key;
1164   } else {
1165     return upb_strview_make((const char*)key, size);
1166   }
1167 }
1168 
_upb_map_fromkey(upb_strview key,void * out,size_t size)1169 UPB_INLINE void _upb_map_fromkey(upb_strview key, void* out, size_t size) {
1170   if (size == UPB_MAPTYPE_STRING) {
1171     memcpy(out, &key, sizeof(key));
1172   } else {
1173     memcpy(out, key.data, size);
1174   }
1175 }
1176 
_upb_map_tovalue(const void * val,size_t size,upb_arena * a)1177 UPB_INLINE upb_value _upb_map_tovalue(const void *val, size_t size,
1178                                       upb_arena *a) {
1179   upb_value ret = {0};
1180   if (size == UPB_MAPTYPE_STRING) {
1181     upb_strview *strp = (upb_strview*)upb_arena_malloc(a, sizeof(*strp));
1182     *strp = *(upb_strview*)val;
1183     memcpy(&ret, &strp, sizeof(strp));
1184   } else {
1185     memcpy(&ret, val, size);
1186   }
1187   return ret;
1188 }
1189 
_upb_map_fromvalue(upb_value val,void * out,size_t size)1190 UPB_INLINE void _upb_map_fromvalue(upb_value val, void* out, size_t size) {
1191   if (size == UPB_MAPTYPE_STRING) {
1192     const upb_strview *strp = (const upb_strview*)upb_value_getptr(val);
1193     memcpy(out, strp, sizeof(upb_strview));
1194   } else {
1195     memcpy(out, &val, size);
1196   }
1197 }
1198 
1199 /* Map operations, shared by reflection and generated code. */
1200 
_upb_map_size(const upb_map * map)1201 UPB_INLINE size_t _upb_map_size(const upb_map *map) {
1202   return map->table.t.count;
1203 }
1204 
_upb_map_get(const upb_map * map,const void * key,size_t key_size,void * val,size_t val_size)1205 UPB_INLINE bool _upb_map_get(const upb_map *map, const void *key,
1206                              size_t key_size, void *val, size_t val_size) {
1207   upb_value tabval;
1208   upb_strview k = _upb_map_tokey(key, key_size);
1209   bool ret = upb_strtable_lookup2(&map->table, k.data, k.size, &tabval);
1210   if (ret) {
1211     _upb_map_fromvalue(tabval, val, val_size);
1212   }
1213   return ret;
1214 }
1215 
_upb_map_next(const upb_map * map,size_t * iter)1216 UPB_INLINE void* _upb_map_next(const upb_map *map, size_t *iter) {
1217   upb_strtable_iter it;
1218   it.t = &map->table;
1219   it.index = *iter;
1220   upb_strtable_next(&it);
1221   if (upb_strtable_done(&it)) return NULL;
1222   *iter = it.index;
1223   return (void*)str_tabent(&it);
1224 }
1225 
_upb_map_set(upb_map * map,const void * key,size_t key_size,void * val,size_t val_size,upb_arena * arena)1226 UPB_INLINE bool _upb_map_set(upb_map *map, const void *key, size_t key_size,
1227                              void *val, size_t val_size, upb_arena *arena) {
1228   upb_strview strkey = _upb_map_tokey(key, key_size);
1229   upb_value tabval = _upb_map_tovalue(val, val_size, arena);
1230   upb_alloc *a = upb_arena_alloc(arena);
1231 
1232   /* TODO(haberman): add overwrite operation to minimize number of lookups. */
1233   upb_strtable_remove3(&map->table, strkey.data, strkey.size, NULL, a);
1234   return upb_strtable_insert3(&map->table, strkey.data, strkey.size, tabval, a);
1235 }
1236 
_upb_map_delete(upb_map * map,const void * key,size_t key_size)1237 UPB_INLINE bool _upb_map_delete(upb_map *map, const void *key, size_t key_size) {
1238   upb_strview k = _upb_map_tokey(key, key_size);
1239   return upb_strtable_remove3(&map->table, k.data, k.size, NULL, NULL);
1240 }
1241 
_upb_map_clear(upb_map * map)1242 UPB_INLINE void _upb_map_clear(upb_map *map) {
1243   upb_strtable_clear(&map->table);
1244 }
1245 
1246 /* Message map operations, these get the map from the message first. */
1247 
_upb_msg_map_size(const upb_msg * msg,size_t ofs)1248 UPB_INLINE size_t _upb_msg_map_size(const upb_msg *msg, size_t ofs) {
1249   upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
1250   return map ? _upb_map_size(map) : 0;
1251 }
1252 
_upb_msg_map_get(const upb_msg * msg,size_t ofs,const void * key,size_t key_size,void * val,size_t val_size)1253 UPB_INLINE bool _upb_msg_map_get(const upb_msg *msg, size_t ofs,
1254                                  const void *key, size_t key_size, void *val,
1255                                  size_t val_size) {
1256   upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
1257   if (!map) return false;
1258   return _upb_map_get(map, key, key_size, val, val_size);
1259 }
1260 
_upb_msg_map_next(const upb_msg * msg,size_t ofs,size_t * iter)1261 UPB_INLINE void *_upb_msg_map_next(const upb_msg *msg, size_t ofs,
1262                                    size_t *iter) {
1263   upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
1264   if (!map) return NULL;
1265   return _upb_map_next(map, iter);
1266 }
1267 
_upb_msg_map_set(upb_msg * msg,size_t ofs,const void * key,size_t key_size,void * val,size_t val_size,upb_arena * arena)1268 UPB_INLINE bool _upb_msg_map_set(upb_msg *msg, size_t ofs, const void *key,
1269                                  size_t key_size, void *val, size_t val_size,
1270                                  upb_arena *arena) {
1271   upb_map **map = PTR_AT(msg, ofs, upb_map *);
1272   if (!*map) {
1273     *map = _upb_map_new(arena, key_size, val_size);
1274   }
1275   return _upb_map_set(*map, key, key_size, val, val_size, arena);
1276 }
1277 
_upb_msg_map_delete(upb_msg * msg,size_t ofs,const void * key,size_t key_size)1278 UPB_INLINE bool _upb_msg_map_delete(upb_msg *msg, size_t ofs, const void *key,
1279                                     size_t key_size) {
1280   upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
1281   if (!map) return false;
1282   return _upb_map_delete(map, key, key_size);
1283 }
1284 
_upb_msg_map_clear(upb_msg * msg,size_t ofs)1285 UPB_INLINE void _upb_msg_map_clear(upb_msg *msg, size_t ofs) {
1286   upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
1287   if (!map) return;
1288   _upb_map_clear(map);
1289 }
1290 
1291 /* Accessing map key/value from a pointer, used by generated code only. */
1292 
_upb_msg_map_key(const void * msg,void * key,size_t size)1293 UPB_INLINE void _upb_msg_map_key(const void* msg, void* key, size_t size) {
1294   const upb_tabent *ent = (const upb_tabent*)msg;
1295   uint32_t u32len;
1296   upb_strview k;
1297   k.data = upb_tabstr(ent->key, &u32len);
1298   k.size = u32len;
1299   _upb_map_fromkey(k, key, size);
1300 }
1301 
_upb_msg_map_value(const void * msg,void * val,size_t size)1302 UPB_INLINE void _upb_msg_map_value(const void* msg, void* val, size_t size) {
1303   const upb_tabent *ent = (const upb_tabent*)msg;
1304   upb_value v;
1305   _upb_value_setval(&v, ent->val.val);
1306   _upb_map_fromvalue(v, val, size);
1307 }
1308 
_upb_msg_map_set_value(void * msg,const void * val,size_t size)1309 UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val, size_t size) {
1310   upb_tabent *ent = (upb_tabent*)msg;
1311   /* This is like _upb_map_tovalue() except the entry already exists so we can
1312    * reuse the allocated upb_strview for string fields. */
1313   if (size == UPB_MAPTYPE_STRING) {
1314     upb_strview *strp = (upb_strview*)ent->val.val;
1315     memcpy(strp, val, sizeof(*strp));
1316   } else {
1317     memcpy(&ent->val.val, val, size);
1318   }
1319 }
1320 
1321 #undef PTR_AT
1322 
1323 #ifdef __cplusplus
1324 }  /* extern "C" */
1325 #endif
1326 
1327 
1328 #endif /* UPB_MSG_H_ */
1329 
1330 #ifdef __cplusplus
1331 extern "C" {
1332 #endif
1333 
1334 bool upb_decode(const char *buf, size_t size, upb_msg *msg,
1335                 const upb_msglayout *l, upb_arena *arena);
1336 
1337 #ifdef __cplusplus
1338 }  /* extern "C" */
1339 #endif
1340 
1341 #endif  /* UPB_DECODE_H_ */
1342 /*
1343 ** upb_encode: parsing into a upb_msg using a upb_msglayout.
1344 */
1345 
1346 #ifndef UPB_ENCODE_H_
1347 #define UPB_ENCODE_H_
1348 
1349 
1350 #ifdef __cplusplus
1351 extern "C" {
1352 #endif
1353 
1354 char *upb_encode(const void *msg, const upb_msglayout *l, upb_arena *arena,
1355                  size_t *size);
1356 
1357 #ifdef __cplusplus
1358 }  /* extern "C" */
1359 #endif
1360 
1361 #endif  /* UPB_ENCODE_H_ */
1362 /* This file was generated by upbc (the upb compiler) from the input
1363  * file:
1364  *
1365  *     google/protobuf/descriptor.proto
1366  *
1367  * Do not edit -- your changes will be discarded when the file is
1368  * regenerated. */
1369 
1370 #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_
1371 #define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_
1372 
1373 
1374 
1375 #ifdef __cplusplus
1376 extern "C" {
1377 #endif
1378 
1379 struct google_protobuf_FileDescriptorSet;
1380 struct google_protobuf_FileDescriptorProto;
1381 struct google_protobuf_DescriptorProto;
1382 struct google_protobuf_DescriptorProto_ExtensionRange;
1383 struct google_protobuf_DescriptorProto_ReservedRange;
1384 struct google_protobuf_ExtensionRangeOptions;
1385 struct google_protobuf_FieldDescriptorProto;
1386 struct google_protobuf_OneofDescriptorProto;
1387 struct google_protobuf_EnumDescriptorProto;
1388 struct google_protobuf_EnumDescriptorProto_EnumReservedRange;
1389 struct google_protobuf_EnumValueDescriptorProto;
1390 struct google_protobuf_ServiceDescriptorProto;
1391 struct google_protobuf_MethodDescriptorProto;
1392 struct google_protobuf_FileOptions;
1393 struct google_protobuf_MessageOptions;
1394 struct google_protobuf_FieldOptions;
1395 struct google_protobuf_OneofOptions;
1396 struct google_protobuf_EnumOptions;
1397 struct google_protobuf_EnumValueOptions;
1398 struct google_protobuf_ServiceOptions;
1399 struct google_protobuf_MethodOptions;
1400 struct google_protobuf_UninterpretedOption;
1401 struct google_protobuf_UninterpretedOption_NamePart;
1402 struct google_protobuf_SourceCodeInfo;
1403 struct google_protobuf_SourceCodeInfo_Location;
1404 struct google_protobuf_GeneratedCodeInfo;
1405 struct google_protobuf_GeneratedCodeInfo_Annotation;
1406 typedef struct google_protobuf_FileDescriptorSet google_protobuf_FileDescriptorSet;
1407 typedef struct google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto;
1408 typedef struct google_protobuf_DescriptorProto google_protobuf_DescriptorProto;
1409 typedef struct google_protobuf_DescriptorProto_ExtensionRange google_protobuf_DescriptorProto_ExtensionRange;
1410 typedef struct google_protobuf_DescriptorProto_ReservedRange google_protobuf_DescriptorProto_ReservedRange;
1411 typedef struct google_protobuf_ExtensionRangeOptions google_protobuf_ExtensionRangeOptions;
1412 typedef struct google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto;
1413 typedef struct google_protobuf_OneofDescriptorProto google_protobuf_OneofDescriptorProto;
1414 typedef struct google_protobuf_EnumDescriptorProto google_protobuf_EnumDescriptorProto;
1415 typedef struct google_protobuf_EnumDescriptorProto_EnumReservedRange google_protobuf_EnumDescriptorProto_EnumReservedRange;
1416 typedef struct google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescriptorProto;
1417 typedef struct google_protobuf_ServiceDescriptorProto google_protobuf_ServiceDescriptorProto;
1418 typedef struct google_protobuf_MethodDescriptorProto google_protobuf_MethodDescriptorProto;
1419 typedef struct google_protobuf_FileOptions google_protobuf_FileOptions;
1420 typedef struct google_protobuf_MessageOptions google_protobuf_MessageOptions;
1421 typedef struct google_protobuf_FieldOptions google_protobuf_FieldOptions;
1422 typedef struct google_protobuf_OneofOptions google_protobuf_OneofOptions;
1423 typedef struct google_protobuf_EnumOptions google_protobuf_EnumOptions;
1424 typedef struct google_protobuf_EnumValueOptions google_protobuf_EnumValueOptions;
1425 typedef struct google_protobuf_ServiceOptions google_protobuf_ServiceOptions;
1426 typedef struct google_protobuf_MethodOptions google_protobuf_MethodOptions;
1427 typedef struct google_protobuf_UninterpretedOption google_protobuf_UninterpretedOption;
1428 typedef struct google_protobuf_UninterpretedOption_NamePart google_protobuf_UninterpretedOption_NamePart;
1429 typedef struct google_protobuf_SourceCodeInfo google_protobuf_SourceCodeInfo;
1430 typedef struct google_protobuf_SourceCodeInfo_Location google_protobuf_SourceCodeInfo_Location;
1431 typedef struct google_protobuf_GeneratedCodeInfo google_protobuf_GeneratedCodeInfo;
1432 typedef struct google_protobuf_GeneratedCodeInfo_Annotation google_protobuf_GeneratedCodeInfo_Annotation;
1433 extern const upb_msglayout google_protobuf_FileDescriptorSet_msginit;
1434 extern const upb_msglayout google_protobuf_FileDescriptorProto_msginit;
1435 extern const upb_msglayout google_protobuf_DescriptorProto_msginit;
1436 extern const upb_msglayout google_protobuf_DescriptorProto_ExtensionRange_msginit;
1437 extern const upb_msglayout google_protobuf_DescriptorProto_ReservedRange_msginit;
1438 extern const upb_msglayout google_protobuf_ExtensionRangeOptions_msginit;
1439 extern const upb_msglayout google_protobuf_FieldDescriptorProto_msginit;
1440 extern const upb_msglayout google_protobuf_OneofDescriptorProto_msginit;
1441 extern const upb_msglayout google_protobuf_EnumDescriptorProto_msginit;
1442 extern const upb_msglayout google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit;
1443 extern const upb_msglayout google_protobuf_EnumValueDescriptorProto_msginit;
1444 extern const upb_msglayout google_protobuf_ServiceDescriptorProto_msginit;
1445 extern const upb_msglayout google_protobuf_MethodDescriptorProto_msginit;
1446 extern const upb_msglayout google_protobuf_FileOptions_msginit;
1447 extern const upb_msglayout google_protobuf_MessageOptions_msginit;
1448 extern const upb_msglayout google_protobuf_FieldOptions_msginit;
1449 extern const upb_msglayout google_protobuf_OneofOptions_msginit;
1450 extern const upb_msglayout google_protobuf_EnumOptions_msginit;
1451 extern const upb_msglayout google_protobuf_EnumValueOptions_msginit;
1452 extern const upb_msglayout google_protobuf_ServiceOptions_msginit;
1453 extern const upb_msglayout google_protobuf_MethodOptions_msginit;
1454 extern const upb_msglayout google_protobuf_UninterpretedOption_msginit;
1455 extern const upb_msglayout google_protobuf_UninterpretedOption_NamePart_msginit;
1456 extern const upb_msglayout google_protobuf_SourceCodeInfo_msginit;
1457 extern const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit;
1458 extern const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit;
1459 extern const upb_msglayout google_protobuf_GeneratedCodeInfo_Annotation_msginit;
1460 
1461 typedef enum {
1462   google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1,
1463   google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2,
1464   google_protobuf_FieldDescriptorProto_LABEL_REPEATED = 3
1465 } google_protobuf_FieldDescriptorProto_Label;
1466 
1467 typedef enum {
1468   google_protobuf_FieldDescriptorProto_TYPE_DOUBLE = 1,
1469   google_protobuf_FieldDescriptorProto_TYPE_FLOAT = 2,
1470   google_protobuf_FieldDescriptorProto_TYPE_INT64 = 3,
1471   google_protobuf_FieldDescriptorProto_TYPE_UINT64 = 4,
1472   google_protobuf_FieldDescriptorProto_TYPE_INT32 = 5,
1473   google_protobuf_FieldDescriptorProto_TYPE_FIXED64 = 6,
1474   google_protobuf_FieldDescriptorProto_TYPE_FIXED32 = 7,
1475   google_protobuf_FieldDescriptorProto_TYPE_BOOL = 8,
1476   google_protobuf_FieldDescriptorProto_TYPE_STRING = 9,
1477   google_protobuf_FieldDescriptorProto_TYPE_GROUP = 10,
1478   google_protobuf_FieldDescriptorProto_TYPE_MESSAGE = 11,
1479   google_protobuf_FieldDescriptorProto_TYPE_BYTES = 12,
1480   google_protobuf_FieldDescriptorProto_TYPE_UINT32 = 13,
1481   google_protobuf_FieldDescriptorProto_TYPE_ENUM = 14,
1482   google_protobuf_FieldDescriptorProto_TYPE_SFIXED32 = 15,
1483   google_protobuf_FieldDescriptorProto_TYPE_SFIXED64 = 16,
1484   google_protobuf_FieldDescriptorProto_TYPE_SINT32 = 17,
1485   google_protobuf_FieldDescriptorProto_TYPE_SINT64 = 18
1486 } google_protobuf_FieldDescriptorProto_Type;
1487 
1488 typedef enum {
1489   google_protobuf_FieldOptions_STRING = 0,
1490   google_protobuf_FieldOptions_CORD = 1,
1491   google_protobuf_FieldOptions_STRING_PIECE = 2
1492 } google_protobuf_FieldOptions_CType;
1493 
1494 typedef enum {
1495   google_protobuf_FieldOptions_JS_NORMAL = 0,
1496   google_protobuf_FieldOptions_JS_STRING = 1,
1497   google_protobuf_FieldOptions_JS_NUMBER = 2
1498 } google_protobuf_FieldOptions_JSType;
1499 
1500 typedef enum {
1501   google_protobuf_FileOptions_SPEED = 1,
1502   google_protobuf_FileOptions_CODE_SIZE = 2,
1503   google_protobuf_FileOptions_LITE_RUNTIME = 3
1504 } google_protobuf_FileOptions_OptimizeMode;
1505 
1506 typedef enum {
1507   google_protobuf_MethodOptions_IDEMPOTENCY_UNKNOWN = 0,
1508   google_protobuf_MethodOptions_NO_SIDE_EFFECTS = 1,
1509   google_protobuf_MethodOptions_IDEMPOTENT = 2
1510 } google_protobuf_MethodOptions_IdempotencyLevel;
1511 
1512 
1513 /* google.protobuf.FileDescriptorSet */
1514 
google_protobuf_FileDescriptorSet_new(upb_arena * arena)1515 UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_new(upb_arena *arena) {
1516   return (google_protobuf_FileDescriptorSet *)_upb_msg_new(&google_protobuf_FileDescriptorSet_msginit, arena);
1517 }
google_protobuf_FileDescriptorSet_parse(const char * buf,size_t size,upb_arena * arena)1518 UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_parse(const char *buf, size_t size,
1519                         upb_arena *arena) {
1520   google_protobuf_FileDescriptorSet *ret = google_protobuf_FileDescriptorSet_new(arena);
1521   return (ret && upb_decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, arena)) ? ret : NULL;
1522 }
google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet * msg,upb_arena * arena,size_t * len)1523 UPB_INLINE char *google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet *msg, upb_arena *arena, size_t *len) {
1524   return upb_encode(msg, &google_protobuf_FileDescriptorSet_msginit, arena, len);
1525 }
1526 
google_protobuf_FileDescriptorSet_has_file(const google_protobuf_FileDescriptorSet * msg)1527 UPB_INLINE bool google_protobuf_FileDescriptorSet_has_file(const google_protobuf_FileDescriptorSet *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet * msg,size_t * len)1528 UPB_INLINE const google_protobuf_FileDescriptorProto* const* google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet *msg, size_t *len) { return (const google_protobuf_FileDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
1529 
google_protobuf_FileDescriptorSet_mutable_file(google_protobuf_FileDescriptorSet * msg,size_t * len)1530 UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_mutable_file(google_protobuf_FileDescriptorSet *msg, size_t *len) {
1531   return (google_protobuf_FileDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len);
1532 }
google_protobuf_FileDescriptorSet_resize_file(google_protobuf_FileDescriptorSet * msg,size_t len,upb_arena * arena)1533 UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_resize_file(google_protobuf_FileDescriptorSet *msg, size_t len, upb_arena *arena) {
1534   return (google_protobuf_FileDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_TYPE_MESSAGE, arena);
1535 }
google_protobuf_FileDescriptorSet_add_file(google_protobuf_FileDescriptorSet * msg,upb_arena * arena)1536 UPB_INLINE struct google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorSet_add_file(google_protobuf_FileDescriptorSet *msg, upb_arena *arena) {
1537   struct google_protobuf_FileDescriptorProto* sub = (struct google_protobuf_FileDescriptorProto*)_upb_msg_new(&google_protobuf_FileDescriptorProto_msginit, arena);
1538   bool ok = _upb_array_append_accessor(
1539       msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1540   if (!ok) return NULL;
1541   return sub;
1542 }
1543 
1544 /* google.protobuf.FileDescriptorProto */
1545 
google_protobuf_FileDescriptorProto_new(upb_arena * arena)1546 UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_new(upb_arena *arena) {
1547   return (google_protobuf_FileDescriptorProto *)_upb_msg_new(&google_protobuf_FileDescriptorProto_msginit, arena);
1548 }
google_protobuf_FileDescriptorProto_parse(const char * buf,size_t size,upb_arena * arena)1549 UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_parse(const char *buf, size_t size,
1550                         upb_arena *arena) {
1551   google_protobuf_FileDescriptorProto *ret = google_protobuf_FileDescriptorProto_new(arena);
1552   return (ret && upb_decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, arena)) ? ret : NULL;
1553 }
google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto * msg,upb_arena * arena,size_t * len)1554 UPB_INLINE char *google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto *msg, upb_arena *arena, size_t *len) {
1555   return upb_encode(msg, &google_protobuf_FileDescriptorProto_msginit, arena, len);
1556 }
1557 
google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto * msg)1558 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 1); }
google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto * msg)1559 UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto * msg)1560 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 2); }
google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto * msg)1561 UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview); }
google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto * msg,size_t * len)1562 UPB_INLINE upb_strview const* google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len); }
google_protobuf_FileDescriptorProto_has_message_type(const google_protobuf_FileDescriptorProto * msg)1563 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_message_type(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(40, 80)); }
google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto * msg,size_t * len)1564 UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(40, 80), len); }
google_protobuf_FileDescriptorProto_has_enum_type(const google_protobuf_FileDescriptorProto * msg)1565 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_enum_type(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(44, 88)); }
google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto * msg,size_t * len)1566 UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(44, 88), len); }
google_protobuf_FileDescriptorProto_has_service(const google_protobuf_FileDescriptorProto * msg)1567 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_service(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(48, 96)); }
google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto * msg,size_t * len)1568 UPB_INLINE const google_protobuf_ServiceDescriptorProto* const* google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_ServiceDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(48, 96), len); }
google_protobuf_FileDescriptorProto_has_extension(const google_protobuf_FileDescriptorProto * msg)1569 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_extension(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(52, 104)); }
google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto * msg,size_t * len)1570 UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(52, 104), len); }
google_protobuf_FileDescriptorProto_has_options(const google_protobuf_FileDescriptorProto * msg)1571 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_options(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 4); }
google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto * msg)1572 UPB_INLINE const google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 56), const google_protobuf_FileOptions*); }
google_protobuf_FileDescriptorProto_has_source_code_info(const google_protobuf_FileDescriptorProto * msg)1573 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_source_code_info(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 5); }
google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto * msg)1574 UPB_INLINE const google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(32, 64), const google_protobuf_SourceCodeInfo*); }
google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto * msg,size_t * len)1575 UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(56, 112), len); }
google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto * msg,size_t * len)1576 UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(60, 120), len); }
google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto * msg)1577 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 3); }
google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto * msg)1578 UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(20, 40), upb_strview); }
1579 
google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto * msg,upb_strview value)1580 UPB_INLINE void google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto *msg, upb_strview value) {
1581   _upb_sethas(msg, 1);
1582   *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
1583 }
google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto * msg,upb_strview value)1584 UPB_INLINE void google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto *msg, upb_strview value) {
1585   _upb_sethas(msg, 2);
1586   *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview) = value;
1587 }
google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto * msg,size_t * len)1588 UPB_INLINE upb_strview* google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) {
1589   return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 72), len);
1590 }
google_protobuf_FileDescriptorProto_resize_dependency(google_protobuf_FileDescriptorProto * msg,size_t len,upb_arena * arena)1591 UPB_INLINE upb_strview* google_protobuf_FileDescriptorProto_resize_dependency(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
1592   return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(36, 72), len, UPB_TYPE_STRING, arena);
1593 }
google_protobuf_FileDescriptorProto_add_dependency(google_protobuf_FileDescriptorProto * msg,upb_strview val,upb_arena * arena)1594 UPB_INLINE bool google_protobuf_FileDescriptorProto_add_dependency(google_protobuf_FileDescriptorProto *msg, upb_strview val, upb_arena *arena) {
1595   return _upb_array_append_accessor(msg, UPB_SIZE(36, 72), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val,
1596       arena);
1597 }
google_protobuf_FileDescriptorProto_mutable_message_type(google_protobuf_FileDescriptorProto * msg,size_t * len)1598 UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_mutable_message_type(google_protobuf_FileDescriptorProto *msg, size_t *len) {
1599   return (google_protobuf_DescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(40, 80), len);
1600 }
google_protobuf_FileDescriptorProto_resize_message_type(google_protobuf_FileDescriptorProto * msg,size_t len,upb_arena * arena)1601 UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_resize_message_type(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
1602   return (google_protobuf_DescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(40, 80), len, UPB_TYPE_MESSAGE, arena);
1603 }
google_protobuf_FileDescriptorProto_add_message_type(google_protobuf_FileDescriptorProto * msg,upb_arena * arena)1604 UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_FileDescriptorProto_add_message_type(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
1605   struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)_upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena);
1606   bool ok = _upb_array_append_accessor(
1607       msg, UPB_SIZE(40, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1608   if (!ok) return NULL;
1609   return sub;
1610 }
google_protobuf_FileDescriptorProto_mutable_enum_type(google_protobuf_FileDescriptorProto * msg,size_t * len)1611 UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_mutable_enum_type(google_protobuf_FileDescriptorProto *msg, size_t *len) {
1612   return (google_protobuf_EnumDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(44, 88), len);
1613 }
google_protobuf_FileDescriptorProto_resize_enum_type(google_protobuf_FileDescriptorProto * msg,size_t len,upb_arena * arena)1614 UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_resize_enum_type(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
1615   return (google_protobuf_EnumDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(44, 88), len, UPB_TYPE_MESSAGE, arena);
1616 }
google_protobuf_FileDescriptorProto_add_enum_type(google_protobuf_FileDescriptorProto * msg,upb_arena * arena)1617 UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_FileDescriptorProto_add_enum_type(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
1618   struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)_upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena);
1619   bool ok = _upb_array_append_accessor(
1620       msg, UPB_SIZE(44, 88), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1621   if (!ok) return NULL;
1622   return sub;
1623 }
google_protobuf_FileDescriptorProto_mutable_service(google_protobuf_FileDescriptorProto * msg,size_t * len)1624 UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_mutable_service(google_protobuf_FileDescriptorProto *msg, size_t *len) {
1625   return (google_protobuf_ServiceDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(48, 96), len);
1626 }
google_protobuf_FileDescriptorProto_resize_service(google_protobuf_FileDescriptorProto * msg,size_t len,upb_arena * arena)1627 UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_resize_service(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
1628   return (google_protobuf_ServiceDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(48, 96), len, UPB_TYPE_MESSAGE, arena);
1629 }
google_protobuf_FileDescriptorProto_add_service(google_protobuf_FileDescriptorProto * msg,upb_arena * arena)1630 UPB_INLINE struct google_protobuf_ServiceDescriptorProto* google_protobuf_FileDescriptorProto_add_service(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
1631   struct google_protobuf_ServiceDescriptorProto* sub = (struct google_protobuf_ServiceDescriptorProto*)_upb_msg_new(&google_protobuf_ServiceDescriptorProto_msginit, arena);
1632   bool ok = _upb_array_append_accessor(
1633       msg, UPB_SIZE(48, 96), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1634   if (!ok) return NULL;
1635   return sub;
1636 }
google_protobuf_FileDescriptorProto_mutable_extension(google_protobuf_FileDescriptorProto * msg,size_t * len)1637 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_mutable_extension(google_protobuf_FileDescriptorProto *msg, size_t *len) {
1638   return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(52, 104), len);
1639 }
google_protobuf_FileDescriptorProto_resize_extension(google_protobuf_FileDescriptorProto * msg,size_t len,upb_arena * arena)1640 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_resize_extension(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
1641   return (google_protobuf_FieldDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(52, 104), len, UPB_TYPE_MESSAGE, arena);
1642 }
google_protobuf_FileDescriptorProto_add_extension(google_protobuf_FileDescriptorProto * msg,upb_arena * arena)1643 UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_FileDescriptorProto_add_extension(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
1644   struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena);
1645   bool ok = _upb_array_append_accessor(
1646       msg, UPB_SIZE(52, 104), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1647   if (!ok) return NULL;
1648   return sub;
1649 }
google_protobuf_FileDescriptorProto_set_options(google_protobuf_FileDescriptorProto * msg,google_protobuf_FileOptions * value)1650 UPB_INLINE void google_protobuf_FileDescriptorProto_set_options(google_protobuf_FileDescriptorProto *msg, google_protobuf_FileOptions* value) {
1651   _upb_sethas(msg, 4);
1652   *UPB_PTR_AT(msg, UPB_SIZE(28, 56), google_protobuf_FileOptions*) = value;
1653 }
google_protobuf_FileDescriptorProto_mutable_options(google_protobuf_FileDescriptorProto * msg,upb_arena * arena)1654 UPB_INLINE struct google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_mutable_options(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
1655   struct google_protobuf_FileOptions* sub = (struct google_protobuf_FileOptions*)google_protobuf_FileDescriptorProto_options(msg);
1656   if (sub == NULL) {
1657     sub = (struct google_protobuf_FileOptions*)_upb_msg_new(&google_protobuf_FileOptions_msginit, arena);
1658     if (!sub) return NULL;
1659     google_protobuf_FileDescriptorProto_set_options(msg, sub);
1660   }
1661   return sub;
1662 }
google_protobuf_FileDescriptorProto_set_source_code_info(google_protobuf_FileDescriptorProto * msg,google_protobuf_SourceCodeInfo * value)1663 UPB_INLINE void google_protobuf_FileDescriptorProto_set_source_code_info(google_protobuf_FileDescriptorProto *msg, google_protobuf_SourceCodeInfo* value) {
1664   _upb_sethas(msg, 5);
1665   *UPB_PTR_AT(msg, UPB_SIZE(32, 64), google_protobuf_SourceCodeInfo*) = value;
1666 }
google_protobuf_FileDescriptorProto_mutable_source_code_info(google_protobuf_FileDescriptorProto * msg,upb_arena * arena)1667 UPB_INLINE struct google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_mutable_source_code_info(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
1668   struct google_protobuf_SourceCodeInfo* sub = (struct google_protobuf_SourceCodeInfo*)google_protobuf_FileDescriptorProto_source_code_info(msg);
1669   if (sub == NULL) {
1670     sub = (struct google_protobuf_SourceCodeInfo*)_upb_msg_new(&google_protobuf_SourceCodeInfo_msginit, arena);
1671     if (!sub) return NULL;
1672     google_protobuf_FileDescriptorProto_set_source_code_info(msg, sub);
1673   }
1674   return sub;
1675 }
google_protobuf_FileDescriptorProto_mutable_public_dependency(google_protobuf_FileDescriptorProto * msg,size_t * len)1676 UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_public_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) {
1677   return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(56, 112), len);
1678 }
google_protobuf_FileDescriptorProto_resize_public_dependency(google_protobuf_FileDescriptorProto * msg,size_t len,upb_arena * arena)1679 UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_public_dependency(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
1680   return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(56, 112), len, UPB_TYPE_INT32, arena);
1681 }
google_protobuf_FileDescriptorProto_add_public_dependency(google_protobuf_FileDescriptorProto * msg,int32_t val,upb_arena * arena)1682 UPB_INLINE bool google_protobuf_FileDescriptorProto_add_public_dependency(google_protobuf_FileDescriptorProto *msg, int32_t val, upb_arena *arena) {
1683   return _upb_array_append_accessor(msg, UPB_SIZE(56, 112), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val,
1684       arena);
1685 }
google_protobuf_FileDescriptorProto_mutable_weak_dependency(google_protobuf_FileDescriptorProto * msg,size_t * len)1686 UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_weak_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) {
1687   return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(60, 120), len);
1688 }
google_protobuf_FileDescriptorProto_resize_weak_dependency(google_protobuf_FileDescriptorProto * msg,size_t len,upb_arena * arena)1689 UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_weak_dependency(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
1690   return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(60, 120), len, UPB_TYPE_INT32, arena);
1691 }
google_protobuf_FileDescriptorProto_add_weak_dependency(google_protobuf_FileDescriptorProto * msg,int32_t val,upb_arena * arena)1692 UPB_INLINE bool google_protobuf_FileDescriptorProto_add_weak_dependency(google_protobuf_FileDescriptorProto *msg, int32_t val, upb_arena *arena) {
1693   return _upb_array_append_accessor(msg, UPB_SIZE(60, 120), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val,
1694       arena);
1695 }
google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto * msg,upb_strview value)1696 UPB_INLINE void google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto *msg, upb_strview value) {
1697   _upb_sethas(msg, 3);
1698   *UPB_PTR_AT(msg, UPB_SIZE(20, 40), upb_strview) = value;
1699 }
1700 
1701 /* google.protobuf.DescriptorProto */
1702 
google_protobuf_DescriptorProto_new(upb_arena * arena)1703 UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_new(upb_arena *arena) {
1704   return (google_protobuf_DescriptorProto *)_upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena);
1705 }
google_protobuf_DescriptorProto_parse(const char * buf,size_t size,upb_arena * arena)1706 UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_parse(const char *buf, size_t size,
1707                         upb_arena *arena) {
1708   google_protobuf_DescriptorProto *ret = google_protobuf_DescriptorProto_new(arena);
1709   return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, arena)) ? ret : NULL;
1710 }
google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto * msg,upb_arena * arena,size_t * len)1711 UPB_INLINE char *google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto *msg, upb_arena *arena, size_t *len) {
1712   return upb_encode(msg, &google_protobuf_DescriptorProto_msginit, arena, len);
1713 }
1714 
google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto * msg)1715 UPB_INLINE bool google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto *msg) { return _upb_has_field(msg, 1); }
google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto * msg)1716 UPB_INLINE upb_strview google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
google_protobuf_DescriptorProto_has_field(const google_protobuf_DescriptorProto * msg)1717 UPB_INLINE bool google_protobuf_DescriptorProto_has_field(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(16, 32)); }
google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto * msg,size_t * len)1718 UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); }
google_protobuf_DescriptorProto_has_nested_type(const google_protobuf_DescriptorProto * msg)1719 UPB_INLINE bool google_protobuf_DescriptorProto_has_nested_type(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(20, 40)); }
google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto * msg,size_t * len)1720 UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); }
google_protobuf_DescriptorProto_has_enum_type(const google_protobuf_DescriptorProto * msg)1721 UPB_INLINE bool google_protobuf_DescriptorProto_has_enum_type(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(24, 48)); }
google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto * msg,size_t * len)1722 UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); }
google_protobuf_DescriptorProto_has_extension_range(const google_protobuf_DescriptorProto * msg)1723 UPB_INLINE bool google_protobuf_DescriptorProto_has_extension_range(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(28, 56)); }
google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto * msg,size_t * len)1724 UPB_INLINE const google_protobuf_DescriptorProto_ExtensionRange* const* google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto_ExtensionRange* const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); }
google_protobuf_DescriptorProto_has_extension(const google_protobuf_DescriptorProto * msg)1725 UPB_INLINE bool google_protobuf_DescriptorProto_has_extension(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(32, 64)); }
google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto * msg,size_t * len)1726 UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(32, 64), len); }
google_protobuf_DescriptorProto_has_options(const google_protobuf_DescriptorProto * msg)1727 UPB_INLINE bool google_protobuf_DescriptorProto_has_options(const google_protobuf_DescriptorProto *msg) { return _upb_has_field(msg, 2); }
google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto * msg)1728 UPB_INLINE const google_protobuf_MessageOptions* google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_MessageOptions*); }
google_protobuf_DescriptorProto_has_oneof_decl(const google_protobuf_DescriptorProto * msg)1729 UPB_INLINE bool google_protobuf_DescriptorProto_has_oneof_decl(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(36, 72)); }
google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto * msg,size_t * len)1730 UPB_INLINE const google_protobuf_OneofDescriptorProto* const* google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_OneofDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len); }
google_protobuf_DescriptorProto_has_reserved_range(const google_protobuf_DescriptorProto * msg)1731 UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_range(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(40, 80)); }
google_protobuf_DescriptorProto_reserved_range(const google_protobuf_DescriptorProto * msg,size_t * len)1732 UPB_INLINE const google_protobuf_DescriptorProto_ReservedRange* const* google_protobuf_DescriptorProto_reserved_range(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto_ReservedRange* const*)_upb_array_accessor(msg, UPB_SIZE(40, 80), len); }
google_protobuf_DescriptorProto_reserved_name(const google_protobuf_DescriptorProto * msg,size_t * len)1733 UPB_INLINE upb_strview const* google_protobuf_DescriptorProto_reserved_name(const google_protobuf_DescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(44, 88), len); }
1734 
google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto * msg,upb_strview value)1735 UPB_INLINE void google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto *msg, upb_strview value) {
1736   _upb_sethas(msg, 1);
1737   *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
1738 }
google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto * msg,size_t * len)1739 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto *msg, size_t *len) {
1740   return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len);
1741 }
google_protobuf_DescriptorProto_resize_field(google_protobuf_DescriptorProto * msg,size_t len,upb_arena * arena)1742 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_field(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
1743   return (google_protobuf_FieldDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_TYPE_MESSAGE, arena);
1744 }
google_protobuf_DescriptorProto_add_field(google_protobuf_DescriptorProto * msg,upb_arena * arena)1745 UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_field(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
1746   struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena);
1747   bool ok = _upb_array_append_accessor(
1748       msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1749   if (!ok) return NULL;
1750   return sub;
1751 }
google_protobuf_DescriptorProto_mutable_nested_type(google_protobuf_DescriptorProto * msg,size_t * len)1752 UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_mutable_nested_type(google_protobuf_DescriptorProto *msg, size_t *len) {
1753   return (google_protobuf_DescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len);
1754 }
google_protobuf_DescriptorProto_resize_nested_type(google_protobuf_DescriptorProto * msg,size_t len,upb_arena * arena)1755 UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_resize_nested_type(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
1756   return (google_protobuf_DescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_TYPE_MESSAGE, arena);
1757 }
google_protobuf_DescriptorProto_add_nested_type(google_protobuf_DescriptorProto * msg,upb_arena * arena)1758 UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_add_nested_type(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
1759   struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)_upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena);
1760   bool ok = _upb_array_append_accessor(
1761       msg, UPB_SIZE(20, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1762   if (!ok) return NULL;
1763   return sub;
1764 }
google_protobuf_DescriptorProto_mutable_enum_type(google_protobuf_DescriptorProto * msg,size_t * len)1765 UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_mutable_enum_type(google_protobuf_DescriptorProto *msg, size_t *len) {
1766   return (google_protobuf_EnumDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len);
1767 }
google_protobuf_DescriptorProto_resize_enum_type(google_protobuf_DescriptorProto * msg,size_t len,upb_arena * arena)1768 UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_resize_enum_type(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
1769   return (google_protobuf_EnumDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_TYPE_MESSAGE, arena);
1770 }
google_protobuf_DescriptorProto_add_enum_type(google_protobuf_DescriptorProto * msg,upb_arena * arena)1771 UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_DescriptorProto_add_enum_type(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
1772   struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)_upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena);
1773   bool ok = _upb_array_append_accessor(
1774       msg, UPB_SIZE(24, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1775   if (!ok) return NULL;
1776   return sub;
1777 }
google_protobuf_DescriptorProto_mutable_extension_range(google_protobuf_DescriptorProto * msg,size_t * len)1778 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_mutable_extension_range(google_protobuf_DescriptorProto *msg, size_t *len) {
1779   return (google_protobuf_DescriptorProto_ExtensionRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len);
1780 }
google_protobuf_DescriptorProto_resize_extension_range(google_protobuf_DescriptorProto * msg,size_t len,upb_arena * arena)1781 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_resize_extension_range(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
1782   return (google_protobuf_DescriptorProto_ExtensionRange**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 56), len, UPB_TYPE_MESSAGE, arena);
1783 }
google_protobuf_DescriptorProto_add_extension_range(google_protobuf_DescriptorProto * msg,upb_arena * arena)1784 UPB_INLINE struct google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_add_extension_range(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
1785   struct google_protobuf_DescriptorProto_ExtensionRange* sub = (struct google_protobuf_DescriptorProto_ExtensionRange*)_upb_msg_new(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena);
1786   bool ok = _upb_array_append_accessor(
1787       msg, UPB_SIZE(28, 56), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1788   if (!ok) return NULL;
1789   return sub;
1790 }
google_protobuf_DescriptorProto_mutable_extension(google_protobuf_DescriptorProto * msg,size_t * len)1791 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_extension(google_protobuf_DescriptorProto *msg, size_t *len) {
1792   return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 64), len);
1793 }
google_protobuf_DescriptorProto_resize_extension(google_protobuf_DescriptorProto * msg,size_t len,upb_arena * arena)1794 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_extension(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
1795   return (google_protobuf_FieldDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(32, 64), len, UPB_TYPE_MESSAGE, arena);
1796 }
google_protobuf_DescriptorProto_add_extension(google_protobuf_DescriptorProto * msg,upb_arena * arena)1797 UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_extension(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
1798   struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena);
1799   bool ok = _upb_array_append_accessor(
1800       msg, UPB_SIZE(32, 64), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1801   if (!ok) return NULL;
1802   return sub;
1803 }
google_protobuf_DescriptorProto_set_options(google_protobuf_DescriptorProto * msg,google_protobuf_MessageOptions * value)1804 UPB_INLINE void google_protobuf_DescriptorProto_set_options(google_protobuf_DescriptorProto *msg, google_protobuf_MessageOptions* value) {
1805   _upb_sethas(msg, 2);
1806   *UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_MessageOptions*) = value;
1807 }
google_protobuf_DescriptorProto_mutable_options(google_protobuf_DescriptorProto * msg,upb_arena * arena)1808 UPB_INLINE struct google_protobuf_MessageOptions* google_protobuf_DescriptorProto_mutable_options(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
1809   struct google_protobuf_MessageOptions* sub = (struct google_protobuf_MessageOptions*)google_protobuf_DescriptorProto_options(msg);
1810   if (sub == NULL) {
1811     sub = (struct google_protobuf_MessageOptions*)_upb_msg_new(&google_protobuf_MessageOptions_msginit, arena);
1812     if (!sub) return NULL;
1813     google_protobuf_DescriptorProto_set_options(msg, sub);
1814   }
1815   return sub;
1816 }
google_protobuf_DescriptorProto_mutable_oneof_decl(google_protobuf_DescriptorProto * msg,size_t * len)1817 UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_mutable_oneof_decl(google_protobuf_DescriptorProto *msg, size_t *len) {
1818   return (google_protobuf_OneofDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 72), len);
1819 }
google_protobuf_DescriptorProto_resize_oneof_decl(google_protobuf_DescriptorProto * msg,size_t len,upb_arena * arena)1820 UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_resize_oneof_decl(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
1821   return (google_protobuf_OneofDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(36, 72), len, UPB_TYPE_MESSAGE, arena);
1822 }
google_protobuf_DescriptorProto_add_oneof_decl(google_protobuf_DescriptorProto * msg,upb_arena * arena)1823 UPB_INLINE struct google_protobuf_OneofDescriptorProto* google_protobuf_DescriptorProto_add_oneof_decl(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
1824   struct google_protobuf_OneofDescriptorProto* sub = (struct google_protobuf_OneofDescriptorProto*)_upb_msg_new(&google_protobuf_OneofDescriptorProto_msginit, arena);
1825   bool ok = _upb_array_append_accessor(
1826       msg, UPB_SIZE(36, 72), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1827   if (!ok) return NULL;
1828   return sub;
1829 }
google_protobuf_DescriptorProto_mutable_reserved_range(google_protobuf_DescriptorProto * msg,size_t * len)1830 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_mutable_reserved_range(google_protobuf_DescriptorProto *msg, size_t *len) {
1831   return (google_protobuf_DescriptorProto_ReservedRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(40, 80), len);
1832 }
google_protobuf_DescriptorProto_resize_reserved_range(google_protobuf_DescriptorProto * msg,size_t len,upb_arena * arena)1833 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_resize_reserved_range(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
1834   return (google_protobuf_DescriptorProto_ReservedRange**)_upb_array_resize_accessor(msg, UPB_SIZE(40, 80), len, UPB_TYPE_MESSAGE, arena);
1835 }
google_protobuf_DescriptorProto_add_reserved_range(google_protobuf_DescriptorProto * msg,upb_arena * arena)1836 UPB_INLINE struct google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_add_reserved_range(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
1837   struct google_protobuf_DescriptorProto_ReservedRange* sub = (struct google_protobuf_DescriptorProto_ReservedRange*)_upb_msg_new(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena);
1838   bool ok = _upb_array_append_accessor(
1839       msg, UPB_SIZE(40, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1840   if (!ok) return NULL;
1841   return sub;
1842 }
google_protobuf_DescriptorProto_mutable_reserved_name(google_protobuf_DescriptorProto * msg,size_t * len)1843 UPB_INLINE upb_strview* google_protobuf_DescriptorProto_mutable_reserved_name(google_protobuf_DescriptorProto *msg, size_t *len) {
1844   return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(44, 88), len);
1845 }
google_protobuf_DescriptorProto_resize_reserved_name(google_protobuf_DescriptorProto * msg,size_t len,upb_arena * arena)1846 UPB_INLINE upb_strview* google_protobuf_DescriptorProto_resize_reserved_name(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
1847   return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(44, 88), len, UPB_TYPE_STRING, arena);
1848 }
google_protobuf_DescriptorProto_add_reserved_name(google_protobuf_DescriptorProto * msg,upb_strview val,upb_arena * arena)1849 UPB_INLINE bool google_protobuf_DescriptorProto_add_reserved_name(google_protobuf_DescriptorProto *msg, upb_strview val, upb_arena *arena) {
1850   return _upb_array_append_accessor(msg, UPB_SIZE(44, 88), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val,
1851       arena);
1852 }
1853 
1854 /* google.protobuf.DescriptorProto.ExtensionRange */
1855 
google_protobuf_DescriptorProto_ExtensionRange_new(upb_arena * arena)1856 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_new(upb_arena *arena) {
1857   return (google_protobuf_DescriptorProto_ExtensionRange *)_upb_msg_new(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena);
1858 }
google_protobuf_DescriptorProto_ExtensionRange_parse(const char * buf,size_t size,upb_arena * arena)1859 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_parse(const char *buf, size_t size,
1860                         upb_arena *arena) {
1861   google_protobuf_DescriptorProto_ExtensionRange *ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena);
1862   return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena)) ? ret : NULL;
1863 }
google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange * msg,upb_arena * arena,size_t * len)1864 UPB_INLINE char *google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange *msg, upb_arena *arena, size_t *len) {
1865   return upb_encode(msg, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena, len);
1866 }
1867 
google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange * msg)1868 UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_has_field(msg, 1); }
google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange * msg)1869 UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
google_protobuf_DescriptorProto_ExtensionRange_has_end(const google_protobuf_DescriptorProto_ExtensionRange * msg)1870 UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_end(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_has_field(msg, 2); }
google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange * msg)1871 UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
google_protobuf_DescriptorProto_ExtensionRange_has_options(const google_protobuf_DescriptorProto_ExtensionRange * msg)1872 UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_options(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_has_field(msg, 3); }
google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange * msg)1873 UPB_INLINE const google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 16), const google_protobuf_ExtensionRangeOptions*); }
1874 
google_protobuf_DescriptorProto_ExtensionRange_set_start(google_protobuf_DescriptorProto_ExtensionRange * msg,int32_t value)1875 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_start(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) {
1876   _upb_sethas(msg, 1);
1877   *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
1878 }
google_protobuf_DescriptorProto_ExtensionRange_set_end(google_protobuf_DescriptorProto_ExtensionRange * msg,int32_t value)1879 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_end(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) {
1880   _upb_sethas(msg, 2);
1881   *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
1882 }
google_protobuf_DescriptorProto_ExtensionRange_set_options(google_protobuf_DescriptorProto_ExtensionRange * msg,google_protobuf_ExtensionRangeOptions * value)1883 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_options(google_protobuf_DescriptorProto_ExtensionRange *msg, google_protobuf_ExtensionRangeOptions* value) {
1884   _upb_sethas(msg, 3);
1885   *UPB_PTR_AT(msg, UPB_SIZE(12, 16), google_protobuf_ExtensionRangeOptions*) = value;
1886 }
google_protobuf_DescriptorProto_ExtensionRange_mutable_options(google_protobuf_DescriptorProto_ExtensionRange * msg,upb_arena * arena)1887 UPB_INLINE struct google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_mutable_options(google_protobuf_DescriptorProto_ExtensionRange *msg, upb_arena *arena) {
1888   struct google_protobuf_ExtensionRangeOptions* sub = (struct google_protobuf_ExtensionRangeOptions*)google_protobuf_DescriptorProto_ExtensionRange_options(msg);
1889   if (sub == NULL) {
1890     sub = (struct google_protobuf_ExtensionRangeOptions*)_upb_msg_new(&google_protobuf_ExtensionRangeOptions_msginit, arena);
1891     if (!sub) return NULL;
1892     google_protobuf_DescriptorProto_ExtensionRange_set_options(msg, sub);
1893   }
1894   return sub;
1895 }
1896 
1897 /* google.protobuf.DescriptorProto.ReservedRange */
1898 
google_protobuf_DescriptorProto_ReservedRange_new(upb_arena * arena)1899 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_new(upb_arena *arena) {
1900   return (google_protobuf_DescriptorProto_ReservedRange *)_upb_msg_new(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena);
1901 }
google_protobuf_DescriptorProto_ReservedRange_parse(const char * buf,size_t size,upb_arena * arena)1902 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_parse(const char *buf, size_t size,
1903                         upb_arena *arena) {
1904   google_protobuf_DescriptorProto_ReservedRange *ret = google_protobuf_DescriptorProto_ReservedRange_new(arena);
1905   return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena)) ? ret : NULL;
1906 }
google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange * msg,upb_arena * arena,size_t * len)1907 UPB_INLINE char *google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange *msg, upb_arena *arena, size_t *len) {
1908   return upb_encode(msg, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena, len);
1909 }
1910 
google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange * msg)1911 UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange *msg) { return _upb_has_field(msg, 1); }
google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange * msg)1912 UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
google_protobuf_DescriptorProto_ReservedRange_has_end(const google_protobuf_DescriptorProto_ReservedRange * msg)1913 UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_end(const google_protobuf_DescriptorProto_ReservedRange *msg) { return _upb_has_field(msg, 2); }
google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange * msg)1914 UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
1915 
google_protobuf_DescriptorProto_ReservedRange_set_start(google_protobuf_DescriptorProto_ReservedRange * msg,int32_t value)1916 UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_start(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) {
1917   _upb_sethas(msg, 1);
1918   *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
1919 }
google_protobuf_DescriptorProto_ReservedRange_set_end(google_protobuf_DescriptorProto_ReservedRange * msg,int32_t value)1920 UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_end(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) {
1921   _upb_sethas(msg, 2);
1922   *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
1923 }
1924 
1925 /* google.protobuf.ExtensionRangeOptions */
1926 
google_protobuf_ExtensionRangeOptions_new(upb_arena * arena)1927 UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_new(upb_arena *arena) {
1928   return (google_protobuf_ExtensionRangeOptions *)_upb_msg_new(&google_protobuf_ExtensionRangeOptions_msginit, arena);
1929 }
google_protobuf_ExtensionRangeOptions_parse(const char * buf,size_t size,upb_arena * arena)1930 UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_parse(const char *buf, size_t size,
1931                         upb_arena *arena) {
1932   google_protobuf_ExtensionRangeOptions *ret = google_protobuf_ExtensionRangeOptions_new(arena);
1933   return (ret && upb_decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, arena)) ? ret : NULL;
1934 }
google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions * msg,upb_arena * arena,size_t * len)1935 UPB_INLINE char *google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions *msg, upb_arena *arena, size_t *len) {
1936   return upb_encode(msg, &google_protobuf_ExtensionRangeOptions_msginit, arena, len);
1937 }
1938 
google_protobuf_ExtensionRangeOptions_has_uninterpreted_option(const google_protobuf_ExtensionRangeOptions * msg)1939 UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_uninterpreted_option(const google_protobuf_ExtensionRangeOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
google_protobuf_ExtensionRangeOptions_uninterpreted_option(const google_protobuf_ExtensionRangeOptions * msg,size_t * len)1940 UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ExtensionRangeOptions_uninterpreted_option(const google_protobuf_ExtensionRangeOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
1941 
google_protobuf_ExtensionRangeOptions_mutable_uninterpreted_option(google_protobuf_ExtensionRangeOptions * msg,size_t * len)1942 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_mutable_uninterpreted_option(google_protobuf_ExtensionRangeOptions *msg, size_t *len) {
1943   return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len);
1944 }
google_protobuf_ExtensionRangeOptions_resize_uninterpreted_option(google_protobuf_ExtensionRangeOptions * msg,size_t len,upb_arena * arena)1945 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_resize_uninterpreted_option(google_protobuf_ExtensionRangeOptions *msg, size_t len, upb_arena *arena) {
1946   return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_TYPE_MESSAGE, arena);
1947 }
google_protobuf_ExtensionRangeOptions_add_uninterpreted_option(google_protobuf_ExtensionRangeOptions * msg,upb_arena * arena)1948 UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ExtensionRangeOptions_add_uninterpreted_option(google_protobuf_ExtensionRangeOptions *msg, upb_arena *arena) {
1949   struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
1950   bool ok = _upb_array_append_accessor(
1951       msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
1952   if (!ok) return NULL;
1953   return sub;
1954 }
1955 
1956 /* google.protobuf.FieldDescriptorProto */
1957 
google_protobuf_FieldDescriptorProto_new(upb_arena * arena)1958 UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_new(upb_arena *arena) {
1959   return (google_protobuf_FieldDescriptorProto *)_upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena);
1960 }
google_protobuf_FieldDescriptorProto_parse(const char * buf,size_t size,upb_arena * arena)1961 UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_parse(const char *buf, size_t size,
1962                         upb_arena *arena) {
1963   google_protobuf_FieldDescriptorProto *ret = google_protobuf_FieldDescriptorProto_new(arena);
1964   return (ret && upb_decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, arena)) ? ret : NULL;
1965 }
google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto * msg,upb_arena * arena,size_t * len)1966 UPB_INLINE char *google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto *msg, upb_arena *arena, size_t *len) {
1967   return upb_encode(msg, &google_protobuf_FieldDescriptorProto_msginit, arena, len);
1968 }
1969 
google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto * msg)1970 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 6); }
google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto * msg)1971 UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(36, 40), upb_strview); }
google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto * msg)1972 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 7); }
google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto * msg)1973 UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(44, 56), upb_strview); }
google_protobuf_FieldDescriptorProto_has_number(const google_protobuf_FieldDescriptorProto * msg)1974 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_number(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 3); }
google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto * msg)1975 UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), int32_t); }
google_protobuf_FieldDescriptorProto_has_label(const google_protobuf_FieldDescriptorProto * msg)1976 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_label(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 1); }
google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto * msg)1977 UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
google_protobuf_FieldDescriptorProto_has_type(const google_protobuf_FieldDescriptorProto * msg)1978 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 2); }
google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto * msg)1979 UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t); }
google_protobuf_FieldDescriptorProto_has_type_name(const google_protobuf_FieldDescriptorProto * msg)1980 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 8); }
google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto * msg)1981 UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(52, 72), upb_strview); }
google_protobuf_FieldDescriptorProto_has_default_value(const google_protobuf_FieldDescriptorProto * msg)1982 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_default_value(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 9); }
google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto * msg)1983 UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(60, 88), upb_strview); }
google_protobuf_FieldDescriptorProto_has_options(const google_protobuf_FieldDescriptorProto * msg)1984 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_options(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 11); }
google_protobuf_FieldDescriptorProto_options(const google_protobuf_FieldDescriptorProto * msg)1985 UPB_INLINE const google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_options(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(76, 120), const google_protobuf_FieldOptions*); }
google_protobuf_FieldDescriptorProto_has_oneof_index(const google_protobuf_FieldDescriptorProto * msg)1986 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_oneof_index(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 4); }
google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto * msg)1987 UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 28), int32_t); }
google_protobuf_FieldDescriptorProto_has_json_name(const google_protobuf_FieldDescriptorProto * msg)1988 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_json_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 10); }
google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto * msg)1989 UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(68, 104), upb_strview); }
google_protobuf_FieldDescriptorProto_has_proto3_optional(const google_protobuf_FieldDescriptorProto * msg)1990 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_proto3_optional(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 5); }
google_protobuf_FieldDescriptorProto_proto3_optional(const google_protobuf_FieldDescriptorProto * msg)1991 UPB_INLINE bool google_protobuf_FieldDescriptorProto_proto3_optional(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(32, 32), bool); }
1992 
google_protobuf_FieldDescriptorProto_set_name(google_protobuf_FieldDescriptorProto * msg,upb_strview value)1993 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
1994   _upb_sethas(msg, 6);
1995   *UPB_PTR_AT(msg, UPB_SIZE(36, 40), upb_strview) = value;
1996 }
google_protobuf_FieldDescriptorProto_set_extendee(google_protobuf_FieldDescriptorProto * msg,upb_strview value)1997 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_extendee(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
1998   _upb_sethas(msg, 7);
1999   *UPB_PTR_AT(msg, UPB_SIZE(44, 56), upb_strview) = value;
2000 }
google_protobuf_FieldDescriptorProto_set_number(google_protobuf_FieldDescriptorProto * msg,int32_t value)2001 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_number(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
2002   _upb_sethas(msg, 3);
2003   *UPB_PTR_AT(msg, UPB_SIZE(24, 24), int32_t) = value;
2004 }
google_protobuf_FieldDescriptorProto_set_label(google_protobuf_FieldDescriptorProto * msg,int32_t value)2005 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_label(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
2006   _upb_sethas(msg, 1);
2007   *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
2008 }
google_protobuf_FieldDescriptorProto_set_type(google_protobuf_FieldDescriptorProto * msg,int32_t value)2009 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
2010   _upb_sethas(msg, 2);
2011   *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t) = value;
2012 }
google_protobuf_FieldDescriptorProto_set_type_name(google_protobuf_FieldDescriptorProto * msg,upb_strview value)2013 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
2014   _upb_sethas(msg, 8);
2015   *UPB_PTR_AT(msg, UPB_SIZE(52, 72), upb_strview) = value;
2016 }
google_protobuf_FieldDescriptorProto_set_default_value(google_protobuf_FieldDescriptorProto * msg,upb_strview value)2017 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_default_value(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
2018   _upb_sethas(msg, 9);
2019   *UPB_PTR_AT(msg, UPB_SIZE(60, 88), upb_strview) = value;
2020 }
google_protobuf_FieldDescriptorProto_set_options(google_protobuf_FieldDescriptorProto * msg,google_protobuf_FieldOptions * value)2021 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_options(google_protobuf_FieldDescriptorProto *msg, google_protobuf_FieldOptions* value) {
2022   _upb_sethas(msg, 11);
2023   *UPB_PTR_AT(msg, UPB_SIZE(76, 120), google_protobuf_FieldOptions*) = value;
2024 }
google_protobuf_FieldDescriptorProto_mutable_options(google_protobuf_FieldDescriptorProto * msg,upb_arena * arena)2025 UPB_INLINE struct google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_mutable_options(google_protobuf_FieldDescriptorProto *msg, upb_arena *arena) {
2026   struct google_protobuf_FieldOptions* sub = (struct google_protobuf_FieldOptions*)google_protobuf_FieldDescriptorProto_options(msg);
2027   if (sub == NULL) {
2028     sub = (struct google_protobuf_FieldOptions*)_upb_msg_new(&google_protobuf_FieldOptions_msginit, arena);
2029     if (!sub) return NULL;
2030     google_protobuf_FieldDescriptorProto_set_options(msg, sub);
2031   }
2032   return sub;
2033 }
google_protobuf_FieldDescriptorProto_set_oneof_index(google_protobuf_FieldDescriptorProto * msg,int32_t value)2034 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_oneof_index(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
2035   _upb_sethas(msg, 4);
2036   *UPB_PTR_AT(msg, UPB_SIZE(28, 28), int32_t) = value;
2037 }
google_protobuf_FieldDescriptorProto_set_json_name(google_protobuf_FieldDescriptorProto * msg,upb_strview value)2038 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_json_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
2039   _upb_sethas(msg, 10);
2040   *UPB_PTR_AT(msg, UPB_SIZE(68, 104), upb_strview) = value;
2041 }
google_protobuf_FieldDescriptorProto_set_proto3_optional(google_protobuf_FieldDescriptorProto * msg,bool value)2042 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_proto3_optional(google_protobuf_FieldDescriptorProto *msg, bool value) {
2043   _upb_sethas(msg, 5);
2044   *UPB_PTR_AT(msg, UPB_SIZE(32, 32), bool) = value;
2045 }
2046 
2047 /* google.protobuf.OneofDescriptorProto */
2048 
google_protobuf_OneofDescriptorProto_new(upb_arena * arena)2049 UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_new(upb_arena *arena) {
2050   return (google_protobuf_OneofDescriptorProto *)_upb_msg_new(&google_protobuf_OneofDescriptorProto_msginit, arena);
2051 }
google_protobuf_OneofDescriptorProto_parse(const char * buf,size_t size,upb_arena * arena)2052 UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_parse(const char *buf, size_t size,
2053                         upb_arena *arena) {
2054   google_protobuf_OneofDescriptorProto *ret = google_protobuf_OneofDescriptorProto_new(arena);
2055   return (ret && upb_decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, arena)) ? ret : NULL;
2056 }
google_protobuf_OneofDescriptorProto_serialize(const google_protobuf_OneofDescriptorProto * msg,upb_arena * arena,size_t * len)2057 UPB_INLINE char *google_protobuf_OneofDescriptorProto_serialize(const google_protobuf_OneofDescriptorProto *msg, upb_arena *arena, size_t *len) {
2058   return upb_encode(msg, &google_protobuf_OneofDescriptorProto_msginit, arena, len);
2059 }
2060 
google_protobuf_OneofDescriptorProto_has_name(const google_protobuf_OneofDescriptorProto * msg)2061 UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_name(const google_protobuf_OneofDescriptorProto *msg) { return _upb_has_field(msg, 1); }
google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto * msg)2062 UPB_INLINE upb_strview google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
google_protobuf_OneofDescriptorProto_has_options(const google_protobuf_OneofDescriptorProto * msg)2063 UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_options(const google_protobuf_OneofDescriptorProto *msg) { return _upb_has_field(msg, 2); }
google_protobuf_OneofDescriptorProto_options(const google_protobuf_OneofDescriptorProto * msg)2064 UPB_INLINE const google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_options(const google_protobuf_OneofDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_OneofOptions*); }
2065 
google_protobuf_OneofDescriptorProto_set_name(google_protobuf_OneofDescriptorProto * msg,upb_strview value)2066 UPB_INLINE void google_protobuf_OneofDescriptorProto_set_name(google_protobuf_OneofDescriptorProto *msg, upb_strview value) {
2067   _upb_sethas(msg, 1);
2068   *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
2069 }
google_protobuf_OneofDescriptorProto_set_options(google_protobuf_OneofDescriptorProto * msg,google_protobuf_OneofOptions * value)2070 UPB_INLINE void google_protobuf_OneofDescriptorProto_set_options(google_protobuf_OneofDescriptorProto *msg, google_protobuf_OneofOptions* value) {
2071   _upb_sethas(msg, 2);
2072   *UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_OneofOptions*) = value;
2073 }
google_protobuf_OneofDescriptorProto_mutable_options(google_protobuf_OneofDescriptorProto * msg,upb_arena * arena)2074 UPB_INLINE struct google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_mutable_options(google_protobuf_OneofDescriptorProto *msg, upb_arena *arena) {
2075   struct google_protobuf_OneofOptions* sub = (struct google_protobuf_OneofOptions*)google_protobuf_OneofDescriptorProto_options(msg);
2076   if (sub == NULL) {
2077     sub = (struct google_protobuf_OneofOptions*)_upb_msg_new(&google_protobuf_OneofOptions_msginit, arena);
2078     if (!sub) return NULL;
2079     google_protobuf_OneofDescriptorProto_set_options(msg, sub);
2080   }
2081   return sub;
2082 }
2083 
2084 /* google.protobuf.EnumDescriptorProto */
2085 
google_protobuf_EnumDescriptorProto_new(upb_arena * arena)2086 UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_new(upb_arena *arena) {
2087   return (google_protobuf_EnumDescriptorProto *)_upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena);
2088 }
google_protobuf_EnumDescriptorProto_parse(const char * buf,size_t size,upb_arena * arena)2089 UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_parse(const char *buf, size_t size,
2090                         upb_arena *arena) {
2091   google_protobuf_EnumDescriptorProto *ret = google_protobuf_EnumDescriptorProto_new(arena);
2092   return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, arena)) ? ret : NULL;
2093 }
google_protobuf_EnumDescriptorProto_serialize(const google_protobuf_EnumDescriptorProto * msg,upb_arena * arena,size_t * len)2094 UPB_INLINE char *google_protobuf_EnumDescriptorProto_serialize(const google_protobuf_EnumDescriptorProto *msg, upb_arena *arena, size_t *len) {
2095   return upb_encode(msg, &google_protobuf_EnumDescriptorProto_msginit, arena, len);
2096 }
2097 
google_protobuf_EnumDescriptorProto_has_name(const google_protobuf_EnumDescriptorProto * msg)2098 UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_name(const google_protobuf_EnumDescriptorProto *msg) { return _upb_has_field(msg, 1); }
google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto * msg)2099 UPB_INLINE upb_strview google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
google_protobuf_EnumDescriptorProto_has_value(const google_protobuf_EnumDescriptorProto * msg)2100 UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_value(const google_protobuf_EnumDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(16, 32)); }
google_protobuf_EnumDescriptorProto_value(const google_protobuf_EnumDescriptorProto * msg,size_t * len)2101 UPB_INLINE const google_protobuf_EnumValueDescriptorProto* const* google_protobuf_EnumDescriptorProto_value(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumValueDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); }
google_protobuf_EnumDescriptorProto_has_options(const google_protobuf_EnumDescriptorProto * msg)2102 UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_options(const google_protobuf_EnumDescriptorProto *msg) { return _upb_has_field(msg, 2); }
google_protobuf_EnumDescriptorProto_options(const google_protobuf_EnumDescriptorProto * msg)2103 UPB_INLINE const google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_options(const google_protobuf_EnumDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_EnumOptions*); }
google_protobuf_EnumDescriptorProto_has_reserved_range(const google_protobuf_EnumDescriptorProto * msg)2104 UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_range(const google_protobuf_EnumDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(20, 40)); }
google_protobuf_EnumDescriptorProto_reserved_range(const google_protobuf_EnumDescriptorProto * msg,size_t * len)2105 UPB_INLINE const google_protobuf_EnumDescriptorProto_EnumReservedRange* const* google_protobuf_EnumDescriptorProto_reserved_range(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto_EnumReservedRange* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); }
google_protobuf_EnumDescriptorProto_reserved_name(const google_protobuf_EnumDescriptorProto * msg,size_t * len)2106 UPB_INLINE upb_strview const* google_protobuf_EnumDescriptorProto_reserved_name(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); }
2107 
google_protobuf_EnumDescriptorProto_set_name(google_protobuf_EnumDescriptorProto * msg,upb_strview value)2108 UPB_INLINE void google_protobuf_EnumDescriptorProto_set_name(google_protobuf_EnumDescriptorProto *msg, upb_strview value) {
2109   _upb_sethas(msg, 1);
2110   *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
2111 }
google_protobuf_EnumDescriptorProto_mutable_value(google_protobuf_EnumDescriptorProto * msg,size_t * len)2112 UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_mutable_value(google_protobuf_EnumDescriptorProto *msg, size_t *len) {
2113   return (google_protobuf_EnumValueDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len);
2114 }
google_protobuf_EnumDescriptorProto_resize_value(google_protobuf_EnumDescriptorProto * msg,size_t len,upb_arena * arena)2115 UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_resize_value(google_protobuf_EnumDescriptorProto *msg, size_t len, upb_arena *arena) {
2116   return (google_protobuf_EnumValueDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_TYPE_MESSAGE, arena);
2117 }
google_protobuf_EnumDescriptorProto_add_value(google_protobuf_EnumDescriptorProto * msg,upb_arena * arena)2118 UPB_INLINE struct google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumDescriptorProto_add_value(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) {
2119   struct google_protobuf_EnumValueDescriptorProto* sub = (struct google_protobuf_EnumValueDescriptorProto*)_upb_msg_new(&google_protobuf_EnumValueDescriptorProto_msginit, arena);
2120   bool ok = _upb_array_append_accessor(
2121       msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2122   if (!ok) return NULL;
2123   return sub;
2124 }
google_protobuf_EnumDescriptorProto_set_options(google_protobuf_EnumDescriptorProto * msg,google_protobuf_EnumOptions * value)2125 UPB_INLINE void google_protobuf_EnumDescriptorProto_set_options(google_protobuf_EnumDescriptorProto *msg, google_protobuf_EnumOptions* value) {
2126   _upb_sethas(msg, 2);
2127   *UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_EnumOptions*) = value;
2128 }
google_protobuf_EnumDescriptorProto_mutable_options(google_protobuf_EnumDescriptorProto * msg,upb_arena * arena)2129 UPB_INLINE struct google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_mutable_options(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) {
2130   struct google_protobuf_EnumOptions* sub = (struct google_protobuf_EnumOptions*)google_protobuf_EnumDescriptorProto_options(msg);
2131   if (sub == NULL) {
2132     sub = (struct google_protobuf_EnumOptions*)_upb_msg_new(&google_protobuf_EnumOptions_msginit, arena);
2133     if (!sub) return NULL;
2134     google_protobuf_EnumDescriptorProto_set_options(msg, sub);
2135   }
2136   return sub;
2137 }
google_protobuf_EnumDescriptorProto_mutable_reserved_range(google_protobuf_EnumDescriptorProto * msg,size_t * len)2138 UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange** google_protobuf_EnumDescriptorProto_mutable_reserved_range(google_protobuf_EnumDescriptorProto *msg, size_t *len) {
2139   return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len);
2140 }
google_protobuf_EnumDescriptorProto_resize_reserved_range(google_protobuf_EnumDescriptorProto * msg,size_t len,upb_arena * arena)2141 UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange** google_protobuf_EnumDescriptorProto_resize_reserved_range(google_protobuf_EnumDescriptorProto *msg, size_t len, upb_arena *arena) {
2142   return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_TYPE_MESSAGE, arena);
2143 }
google_protobuf_EnumDescriptorProto_add_reserved_range(google_protobuf_EnumDescriptorProto * msg,upb_arena * arena)2144 UPB_INLINE struct google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_add_reserved_range(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) {
2145   struct google_protobuf_EnumDescriptorProto_EnumReservedRange* sub = (struct google_protobuf_EnumDescriptorProto_EnumReservedRange*)_upb_msg_new(&google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena);
2146   bool ok = _upb_array_append_accessor(
2147       msg, UPB_SIZE(20, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2148   if (!ok) return NULL;
2149   return sub;
2150 }
google_protobuf_EnumDescriptorProto_mutable_reserved_name(google_protobuf_EnumDescriptorProto * msg,size_t * len)2151 UPB_INLINE upb_strview* google_protobuf_EnumDescriptorProto_mutable_reserved_name(google_protobuf_EnumDescriptorProto *msg, size_t *len) {
2152   return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len);
2153 }
google_protobuf_EnumDescriptorProto_resize_reserved_name(google_protobuf_EnumDescriptorProto * msg,size_t len,upb_arena * arena)2154 UPB_INLINE upb_strview* google_protobuf_EnumDescriptorProto_resize_reserved_name(google_protobuf_EnumDescriptorProto *msg, size_t len, upb_arena *arena) {
2155   return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_TYPE_STRING, arena);
2156 }
google_protobuf_EnumDescriptorProto_add_reserved_name(google_protobuf_EnumDescriptorProto * msg,upb_strview val,upb_arena * arena)2157 UPB_INLINE bool google_protobuf_EnumDescriptorProto_add_reserved_name(google_protobuf_EnumDescriptorProto *msg, upb_strview val, upb_arena *arena) {
2158   return _upb_array_append_accessor(msg, UPB_SIZE(24, 48), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val,
2159       arena);
2160 }
2161 
2162 /* google.protobuf.EnumDescriptorProto.EnumReservedRange */
2163 
google_protobuf_EnumDescriptorProto_EnumReservedRange_new(upb_arena * arena)2164 UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_new(upb_arena *arena) {
2165   return (google_protobuf_EnumDescriptorProto_EnumReservedRange *)_upb_msg_new(&google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena);
2166 }
google_protobuf_EnumDescriptorProto_EnumReservedRange_parse(const char * buf,size_t size,upb_arena * arena)2167 UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_parse(const char *buf, size_t size,
2168                         upb_arena *arena) {
2169   google_protobuf_EnumDescriptorProto_EnumReservedRange *ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena);
2170   return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena)) ? ret : NULL;
2171 }
google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize(const google_protobuf_EnumDescriptorProto_EnumReservedRange * msg,upb_arena * arena,size_t * len)2172 UPB_INLINE char *google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, upb_arena *arena, size_t *len) {
2173   return upb_encode(msg, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena, len);
2174 }
2175 
google_protobuf_EnumDescriptorProto_EnumReservedRange_has_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange * msg)2176 UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return _upb_has_field(msg, 1); }
google_protobuf_EnumDescriptorProto_EnumReservedRange_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange * msg)2177 UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
google_protobuf_EnumDescriptorProto_EnumReservedRange_has_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange * msg)2178 UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return _upb_has_field(msg, 2); }
google_protobuf_EnumDescriptorProto_EnumReservedRange_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange * msg)2179 UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
2180 
google_protobuf_EnumDescriptorProto_EnumReservedRange_set_start(google_protobuf_EnumDescriptorProto_EnumReservedRange * msg,int32_t value)2181 UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_start(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) {
2182   _upb_sethas(msg, 1);
2183   *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
2184 }
google_protobuf_EnumDescriptorProto_EnumReservedRange_set_end(google_protobuf_EnumDescriptorProto_EnumReservedRange * msg,int32_t value)2185 UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_end(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) {
2186   _upb_sethas(msg, 2);
2187   *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
2188 }
2189 
2190 /* google.protobuf.EnumValueDescriptorProto */
2191 
google_protobuf_EnumValueDescriptorProto_new(upb_arena * arena)2192 UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_new(upb_arena *arena) {
2193   return (google_protobuf_EnumValueDescriptorProto *)_upb_msg_new(&google_protobuf_EnumValueDescriptorProto_msginit, arena);
2194 }
google_protobuf_EnumValueDescriptorProto_parse(const char * buf,size_t size,upb_arena * arena)2195 UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_parse(const char *buf, size_t size,
2196                         upb_arena *arena) {
2197   google_protobuf_EnumValueDescriptorProto *ret = google_protobuf_EnumValueDescriptorProto_new(arena);
2198   return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, arena)) ? ret : NULL;
2199 }
google_protobuf_EnumValueDescriptorProto_serialize(const google_protobuf_EnumValueDescriptorProto * msg,upb_arena * arena,size_t * len)2200 UPB_INLINE char *google_protobuf_EnumValueDescriptorProto_serialize(const google_protobuf_EnumValueDescriptorProto *msg, upb_arena *arena, size_t *len) {
2201   return upb_encode(msg, &google_protobuf_EnumValueDescriptorProto_msginit, arena, len);
2202 }
2203 
google_protobuf_EnumValueDescriptorProto_has_name(const google_protobuf_EnumValueDescriptorProto * msg)2204 UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_name(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_has_field(msg, 2); }
google_protobuf_EnumValueDescriptorProto_name(const google_protobuf_EnumValueDescriptorProto * msg)2205 UPB_INLINE upb_strview google_protobuf_EnumValueDescriptorProto_name(const google_protobuf_EnumValueDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), upb_strview); }
google_protobuf_EnumValueDescriptorProto_has_number(const google_protobuf_EnumValueDescriptorProto * msg)2206 UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_number(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_has_field(msg, 1); }
google_protobuf_EnumValueDescriptorProto_number(const google_protobuf_EnumValueDescriptorProto * msg)2207 UPB_INLINE int32_t google_protobuf_EnumValueDescriptorProto_number(const google_protobuf_EnumValueDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
google_protobuf_EnumValueDescriptorProto_has_options(const google_protobuf_EnumValueDescriptorProto * msg)2208 UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_options(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_has_field(msg, 3); }
google_protobuf_EnumValueDescriptorProto_options(const google_protobuf_EnumValueDescriptorProto * msg)2209 UPB_INLINE const google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_options(const google_protobuf_EnumValueDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 24), const google_protobuf_EnumValueOptions*); }
2210 
google_protobuf_EnumValueDescriptorProto_set_name(google_protobuf_EnumValueDescriptorProto * msg,upb_strview value)2211 UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_name(google_protobuf_EnumValueDescriptorProto *msg, upb_strview value) {
2212   _upb_sethas(msg, 2);
2213   *UPB_PTR_AT(msg, UPB_SIZE(8, 8), upb_strview) = value;
2214 }
google_protobuf_EnumValueDescriptorProto_set_number(google_protobuf_EnumValueDescriptorProto * msg,int32_t value)2215 UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_number(google_protobuf_EnumValueDescriptorProto *msg, int32_t value) {
2216   _upb_sethas(msg, 1);
2217   *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
2218 }
google_protobuf_EnumValueDescriptorProto_set_options(google_protobuf_EnumValueDescriptorProto * msg,google_protobuf_EnumValueOptions * value)2219 UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_options(google_protobuf_EnumValueDescriptorProto *msg, google_protobuf_EnumValueOptions* value) {
2220   _upb_sethas(msg, 3);
2221   *UPB_PTR_AT(msg, UPB_SIZE(16, 24), google_protobuf_EnumValueOptions*) = value;
2222 }
google_protobuf_EnumValueDescriptorProto_mutable_options(google_protobuf_EnumValueDescriptorProto * msg,upb_arena * arena)2223 UPB_INLINE struct google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_mutable_options(google_protobuf_EnumValueDescriptorProto *msg, upb_arena *arena) {
2224   struct google_protobuf_EnumValueOptions* sub = (struct google_protobuf_EnumValueOptions*)google_protobuf_EnumValueDescriptorProto_options(msg);
2225   if (sub == NULL) {
2226     sub = (struct google_protobuf_EnumValueOptions*)_upb_msg_new(&google_protobuf_EnumValueOptions_msginit, arena);
2227     if (!sub) return NULL;
2228     google_protobuf_EnumValueDescriptorProto_set_options(msg, sub);
2229   }
2230   return sub;
2231 }
2232 
2233 /* google.protobuf.ServiceDescriptorProto */
2234 
google_protobuf_ServiceDescriptorProto_new(upb_arena * arena)2235 UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_new(upb_arena *arena) {
2236   return (google_protobuf_ServiceDescriptorProto *)_upb_msg_new(&google_protobuf_ServiceDescriptorProto_msginit, arena);
2237 }
google_protobuf_ServiceDescriptorProto_parse(const char * buf,size_t size,upb_arena * arena)2238 UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_parse(const char *buf, size_t size,
2239                         upb_arena *arena) {
2240   google_protobuf_ServiceDescriptorProto *ret = google_protobuf_ServiceDescriptorProto_new(arena);
2241   return (ret && upb_decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, arena)) ? ret : NULL;
2242 }
google_protobuf_ServiceDescriptorProto_serialize(const google_protobuf_ServiceDescriptorProto * msg,upb_arena * arena,size_t * len)2243 UPB_INLINE char *google_protobuf_ServiceDescriptorProto_serialize(const google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena, size_t *len) {
2244   return upb_encode(msg, &google_protobuf_ServiceDescriptorProto_msginit, arena, len);
2245 }
2246 
google_protobuf_ServiceDescriptorProto_has_name(const google_protobuf_ServiceDescriptorProto * msg)2247 UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_name(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_has_field(msg, 1); }
google_protobuf_ServiceDescriptorProto_name(const google_protobuf_ServiceDescriptorProto * msg)2248 UPB_INLINE upb_strview google_protobuf_ServiceDescriptorProto_name(const google_protobuf_ServiceDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
google_protobuf_ServiceDescriptorProto_has_method(const google_protobuf_ServiceDescriptorProto * msg)2249 UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_method(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(16, 32)); }
google_protobuf_ServiceDescriptorProto_method(const google_protobuf_ServiceDescriptorProto * msg,size_t * len)2250 UPB_INLINE const google_protobuf_MethodDescriptorProto* const* google_protobuf_ServiceDescriptorProto_method(const google_protobuf_ServiceDescriptorProto *msg, size_t *len) { return (const google_protobuf_MethodDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); }
google_protobuf_ServiceDescriptorProto_has_options(const google_protobuf_ServiceDescriptorProto * msg)2251 UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_options(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_has_field(msg, 2); }
google_protobuf_ServiceDescriptorProto_options(const google_protobuf_ServiceDescriptorProto * msg)2252 UPB_INLINE const google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_options(const google_protobuf_ServiceDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_ServiceOptions*); }
2253 
google_protobuf_ServiceDescriptorProto_set_name(google_protobuf_ServiceDescriptorProto * msg,upb_strview value)2254 UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_name(google_protobuf_ServiceDescriptorProto *msg, upb_strview value) {
2255   _upb_sethas(msg, 1);
2256   *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
2257 }
google_protobuf_ServiceDescriptorProto_mutable_method(google_protobuf_ServiceDescriptorProto * msg,size_t * len)2258 UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_mutable_method(google_protobuf_ServiceDescriptorProto *msg, size_t *len) {
2259   return (google_protobuf_MethodDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len);
2260 }
google_protobuf_ServiceDescriptorProto_resize_method(google_protobuf_ServiceDescriptorProto * msg,size_t len,upb_arena * arena)2261 UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_resize_method(google_protobuf_ServiceDescriptorProto *msg, size_t len, upb_arena *arena) {
2262   return (google_protobuf_MethodDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_TYPE_MESSAGE, arena);
2263 }
google_protobuf_ServiceDescriptorProto_add_method(google_protobuf_ServiceDescriptorProto * msg,upb_arena * arena)2264 UPB_INLINE struct google_protobuf_MethodDescriptorProto* google_protobuf_ServiceDescriptorProto_add_method(google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena) {
2265   struct google_protobuf_MethodDescriptorProto* sub = (struct google_protobuf_MethodDescriptorProto*)_upb_msg_new(&google_protobuf_MethodDescriptorProto_msginit, arena);
2266   bool ok = _upb_array_append_accessor(
2267       msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2268   if (!ok) return NULL;
2269   return sub;
2270 }
google_protobuf_ServiceDescriptorProto_set_options(google_protobuf_ServiceDescriptorProto * msg,google_protobuf_ServiceOptions * value)2271 UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_options(google_protobuf_ServiceDescriptorProto *msg, google_protobuf_ServiceOptions* value) {
2272   _upb_sethas(msg, 2);
2273   *UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_ServiceOptions*) = value;
2274 }
google_protobuf_ServiceDescriptorProto_mutable_options(google_protobuf_ServiceDescriptorProto * msg,upb_arena * arena)2275 UPB_INLINE struct google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_mutable_options(google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena) {
2276   struct google_protobuf_ServiceOptions* sub = (struct google_protobuf_ServiceOptions*)google_protobuf_ServiceDescriptorProto_options(msg);
2277   if (sub == NULL) {
2278     sub = (struct google_protobuf_ServiceOptions*)_upb_msg_new(&google_protobuf_ServiceOptions_msginit, arena);
2279     if (!sub) return NULL;
2280     google_protobuf_ServiceDescriptorProto_set_options(msg, sub);
2281   }
2282   return sub;
2283 }
2284 
2285 /* google.protobuf.MethodDescriptorProto */
2286 
google_protobuf_MethodDescriptorProto_new(upb_arena * arena)2287 UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_new(upb_arena *arena) {
2288   return (google_protobuf_MethodDescriptorProto *)_upb_msg_new(&google_protobuf_MethodDescriptorProto_msginit, arena);
2289 }
google_protobuf_MethodDescriptorProto_parse(const char * buf,size_t size,upb_arena * arena)2290 UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_parse(const char *buf, size_t size,
2291                         upb_arena *arena) {
2292   google_protobuf_MethodDescriptorProto *ret = google_protobuf_MethodDescriptorProto_new(arena);
2293   return (ret && upb_decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, arena)) ? ret : NULL;
2294 }
google_protobuf_MethodDescriptorProto_serialize(const google_protobuf_MethodDescriptorProto * msg,upb_arena * arena,size_t * len)2295 UPB_INLINE char *google_protobuf_MethodDescriptorProto_serialize(const google_protobuf_MethodDescriptorProto *msg, upb_arena *arena, size_t *len) {
2296   return upb_encode(msg, &google_protobuf_MethodDescriptorProto_msginit, arena, len);
2297 }
2298 
google_protobuf_MethodDescriptorProto_has_name(const google_protobuf_MethodDescriptorProto * msg)2299 UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_name(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 3); }
google_protobuf_MethodDescriptorProto_name(const google_protobuf_MethodDescriptorProto * msg)2300 UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_name(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
google_protobuf_MethodDescriptorProto_has_input_type(const google_protobuf_MethodDescriptorProto * msg)2301 UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_input_type(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 4); }
google_protobuf_MethodDescriptorProto_input_type(const google_protobuf_MethodDescriptorProto * msg)2302 UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_input_type(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview); }
google_protobuf_MethodDescriptorProto_has_output_type(const google_protobuf_MethodDescriptorProto * msg)2303 UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_output_type(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 5); }
google_protobuf_MethodDescriptorProto_output_type(const google_protobuf_MethodDescriptorProto * msg)2304 UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_output_type(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(20, 40), upb_strview); }
google_protobuf_MethodDescriptorProto_has_options(const google_protobuf_MethodDescriptorProto * msg)2305 UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_options(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 6); }
google_protobuf_MethodDescriptorProto_options(const google_protobuf_MethodDescriptorProto * msg)2306 UPB_INLINE const google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_options(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 56), const google_protobuf_MethodOptions*); }
google_protobuf_MethodDescriptorProto_has_client_streaming(const google_protobuf_MethodDescriptorProto * msg)2307 UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_client_streaming(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 1); }
google_protobuf_MethodDescriptorProto_client_streaming(const google_protobuf_MethodDescriptorProto * msg)2308 UPB_INLINE bool google_protobuf_MethodDescriptorProto_client_streaming(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
google_protobuf_MethodDescriptorProto_has_server_streaming(const google_protobuf_MethodDescriptorProto * msg)2309 UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_server_streaming(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 2); }
google_protobuf_MethodDescriptorProto_server_streaming(const google_protobuf_MethodDescriptorProto * msg)2310 UPB_INLINE bool google_protobuf_MethodDescriptorProto_server_streaming(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool); }
2311 
google_protobuf_MethodDescriptorProto_set_name(google_protobuf_MethodDescriptorProto * msg,upb_strview value)2312 UPB_INLINE void google_protobuf_MethodDescriptorProto_set_name(google_protobuf_MethodDescriptorProto *msg, upb_strview value) {
2313   _upb_sethas(msg, 3);
2314   *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
2315 }
google_protobuf_MethodDescriptorProto_set_input_type(google_protobuf_MethodDescriptorProto * msg,upb_strview value)2316 UPB_INLINE void google_protobuf_MethodDescriptorProto_set_input_type(google_protobuf_MethodDescriptorProto *msg, upb_strview value) {
2317   _upb_sethas(msg, 4);
2318   *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview) = value;
2319 }
google_protobuf_MethodDescriptorProto_set_output_type(google_protobuf_MethodDescriptorProto * msg,upb_strview value)2320 UPB_INLINE void google_protobuf_MethodDescriptorProto_set_output_type(google_protobuf_MethodDescriptorProto *msg, upb_strview value) {
2321   _upb_sethas(msg, 5);
2322   *UPB_PTR_AT(msg, UPB_SIZE(20, 40), upb_strview) = value;
2323 }
google_protobuf_MethodDescriptorProto_set_options(google_protobuf_MethodDescriptorProto * msg,google_protobuf_MethodOptions * value)2324 UPB_INLINE void google_protobuf_MethodDescriptorProto_set_options(google_protobuf_MethodDescriptorProto *msg, google_protobuf_MethodOptions* value) {
2325   _upb_sethas(msg, 6);
2326   *UPB_PTR_AT(msg, UPB_SIZE(28, 56), google_protobuf_MethodOptions*) = value;
2327 }
google_protobuf_MethodDescriptorProto_mutable_options(google_protobuf_MethodDescriptorProto * msg,upb_arena * arena)2328 UPB_INLINE struct google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_mutable_options(google_protobuf_MethodDescriptorProto *msg, upb_arena *arena) {
2329   struct google_protobuf_MethodOptions* sub = (struct google_protobuf_MethodOptions*)google_protobuf_MethodDescriptorProto_options(msg);
2330   if (sub == NULL) {
2331     sub = (struct google_protobuf_MethodOptions*)_upb_msg_new(&google_protobuf_MethodOptions_msginit, arena);
2332     if (!sub) return NULL;
2333     google_protobuf_MethodDescriptorProto_set_options(msg, sub);
2334   }
2335   return sub;
2336 }
google_protobuf_MethodDescriptorProto_set_client_streaming(google_protobuf_MethodDescriptorProto * msg,bool value)2337 UPB_INLINE void google_protobuf_MethodDescriptorProto_set_client_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) {
2338   _upb_sethas(msg, 1);
2339   *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
2340 }
google_protobuf_MethodDescriptorProto_set_server_streaming(google_protobuf_MethodDescriptorProto * msg,bool value)2341 UPB_INLINE void google_protobuf_MethodDescriptorProto_set_server_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) {
2342   _upb_sethas(msg, 2);
2343   *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool) = value;
2344 }
2345 
2346 /* google.protobuf.FileOptions */
2347 
google_protobuf_FileOptions_new(upb_arena * arena)2348 UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_new(upb_arena *arena) {
2349   return (google_protobuf_FileOptions *)_upb_msg_new(&google_protobuf_FileOptions_msginit, arena);
2350 }
google_protobuf_FileOptions_parse(const char * buf,size_t size,upb_arena * arena)2351 UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_parse(const char *buf, size_t size,
2352                         upb_arena *arena) {
2353   google_protobuf_FileOptions *ret = google_protobuf_FileOptions_new(arena);
2354   return (ret && upb_decode(buf, size, ret, &google_protobuf_FileOptions_msginit, arena)) ? ret : NULL;
2355 }
google_protobuf_FileOptions_serialize(const google_protobuf_FileOptions * msg,upb_arena * arena,size_t * len)2356 UPB_INLINE char *google_protobuf_FileOptions_serialize(const google_protobuf_FileOptions *msg, upb_arena *arena, size_t *len) {
2357   return upb_encode(msg, &google_protobuf_FileOptions_msginit, arena, len);
2358 }
2359 
google_protobuf_FileOptions_has_java_package(const google_protobuf_FileOptions * msg)2360 UPB_INLINE bool google_protobuf_FileOptions_has_java_package(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 11); }
google_protobuf_FileOptions_java_package(const google_protobuf_FileOptions * msg)2361 UPB_INLINE upb_strview google_protobuf_FileOptions_java_package(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 32), upb_strview); }
google_protobuf_FileOptions_has_java_outer_classname(const google_protobuf_FileOptions * msg)2362 UPB_INLINE bool google_protobuf_FileOptions_has_java_outer_classname(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 12); }
google_protobuf_FileOptions_java_outer_classname(const google_protobuf_FileOptions * msg)2363 UPB_INLINE upb_strview google_protobuf_FileOptions_java_outer_classname(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(36, 48), upb_strview); }
google_protobuf_FileOptions_has_optimize_for(const google_protobuf_FileOptions * msg)2364 UPB_INLINE bool google_protobuf_FileOptions_has_optimize_for(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 1); }
google_protobuf_FileOptions_optimize_for(const google_protobuf_FileOptions * msg)2365 UPB_INLINE int32_t google_protobuf_FileOptions_optimize_for(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
google_protobuf_FileOptions_has_java_multiple_files(const google_protobuf_FileOptions * msg)2366 UPB_INLINE bool google_protobuf_FileOptions_has_java_multiple_files(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 2); }
google_protobuf_FileOptions_java_multiple_files(const google_protobuf_FileOptions * msg)2367 UPB_INLINE bool google_protobuf_FileOptions_java_multiple_files(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), bool); }
google_protobuf_FileOptions_has_go_package(const google_protobuf_FileOptions * msg)2368 UPB_INLINE bool google_protobuf_FileOptions_has_go_package(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 13); }
google_protobuf_FileOptions_go_package(const google_protobuf_FileOptions * msg)2369 UPB_INLINE upb_strview google_protobuf_FileOptions_go_package(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(44, 64), upb_strview); }
google_protobuf_FileOptions_has_cc_generic_services(const google_protobuf_FileOptions * msg)2370 UPB_INLINE bool google_protobuf_FileOptions_has_cc_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 3); }
google_protobuf_FileOptions_cc_generic_services(const google_protobuf_FileOptions * msg)2371 UPB_INLINE bool google_protobuf_FileOptions_cc_generic_services(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(17, 17), bool); }
google_protobuf_FileOptions_has_java_generic_services(const google_protobuf_FileOptions * msg)2372 UPB_INLINE bool google_protobuf_FileOptions_has_java_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 4); }
google_protobuf_FileOptions_java_generic_services(const google_protobuf_FileOptions * msg)2373 UPB_INLINE bool google_protobuf_FileOptions_java_generic_services(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(18, 18), bool); }
google_protobuf_FileOptions_has_py_generic_services(const google_protobuf_FileOptions * msg)2374 UPB_INLINE bool google_protobuf_FileOptions_has_py_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 5); }
google_protobuf_FileOptions_py_generic_services(const google_protobuf_FileOptions * msg)2375 UPB_INLINE bool google_protobuf_FileOptions_py_generic_services(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(19, 19), bool); }
google_protobuf_FileOptions_has_java_generate_equals_and_hash(const google_protobuf_FileOptions * msg)2376 UPB_INLINE bool google_protobuf_FileOptions_has_java_generate_equals_and_hash(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 6); }
google_protobuf_FileOptions_java_generate_equals_and_hash(const google_protobuf_FileOptions * msg)2377 UPB_INLINE bool google_protobuf_FileOptions_java_generate_equals_and_hash(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(20, 20), bool); }
google_protobuf_FileOptions_has_deprecated(const google_protobuf_FileOptions * msg)2378 UPB_INLINE bool google_protobuf_FileOptions_has_deprecated(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 7); }
google_protobuf_FileOptions_deprecated(const google_protobuf_FileOptions * msg)2379 UPB_INLINE bool google_protobuf_FileOptions_deprecated(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(21, 21), bool); }
google_protobuf_FileOptions_has_java_string_check_utf8(const google_protobuf_FileOptions * msg)2380 UPB_INLINE bool google_protobuf_FileOptions_has_java_string_check_utf8(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 8); }
google_protobuf_FileOptions_java_string_check_utf8(const google_protobuf_FileOptions * msg)2381 UPB_INLINE bool google_protobuf_FileOptions_java_string_check_utf8(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(22, 22), bool); }
google_protobuf_FileOptions_has_cc_enable_arenas(const google_protobuf_FileOptions * msg)2382 UPB_INLINE bool google_protobuf_FileOptions_has_cc_enable_arenas(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 9); }
google_protobuf_FileOptions_cc_enable_arenas(const google_protobuf_FileOptions * msg)2383 UPB_INLINE bool google_protobuf_FileOptions_cc_enable_arenas(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(23, 23), bool); }
google_protobuf_FileOptions_has_objc_class_prefix(const google_protobuf_FileOptions * msg)2384 UPB_INLINE bool google_protobuf_FileOptions_has_objc_class_prefix(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 14); }
google_protobuf_FileOptions_objc_class_prefix(const google_protobuf_FileOptions * msg)2385 UPB_INLINE upb_strview google_protobuf_FileOptions_objc_class_prefix(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(52, 80), upb_strview); }
google_protobuf_FileOptions_has_csharp_namespace(const google_protobuf_FileOptions * msg)2386 UPB_INLINE bool google_protobuf_FileOptions_has_csharp_namespace(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 15); }
google_protobuf_FileOptions_csharp_namespace(const google_protobuf_FileOptions * msg)2387 UPB_INLINE upb_strview google_protobuf_FileOptions_csharp_namespace(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(60, 96), upb_strview); }
google_protobuf_FileOptions_has_swift_prefix(const google_protobuf_FileOptions * msg)2388 UPB_INLINE bool google_protobuf_FileOptions_has_swift_prefix(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 16); }
google_protobuf_FileOptions_swift_prefix(const google_protobuf_FileOptions * msg)2389 UPB_INLINE upb_strview google_protobuf_FileOptions_swift_prefix(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(68, 112), upb_strview); }
google_protobuf_FileOptions_has_php_class_prefix(const google_protobuf_FileOptions * msg)2390 UPB_INLINE bool google_protobuf_FileOptions_has_php_class_prefix(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 17); }
google_protobuf_FileOptions_php_class_prefix(const google_protobuf_FileOptions * msg)2391 UPB_INLINE upb_strview google_protobuf_FileOptions_php_class_prefix(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(76, 128), upb_strview); }
google_protobuf_FileOptions_has_php_namespace(const google_protobuf_FileOptions * msg)2392 UPB_INLINE bool google_protobuf_FileOptions_has_php_namespace(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 18); }
google_protobuf_FileOptions_php_namespace(const google_protobuf_FileOptions * msg)2393 UPB_INLINE upb_strview google_protobuf_FileOptions_php_namespace(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(84, 144), upb_strview); }
google_protobuf_FileOptions_has_php_generic_services(const google_protobuf_FileOptions * msg)2394 UPB_INLINE bool google_protobuf_FileOptions_has_php_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 10); }
google_protobuf_FileOptions_php_generic_services(const google_protobuf_FileOptions * msg)2395 UPB_INLINE bool google_protobuf_FileOptions_php_generic_services(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), bool); }
google_protobuf_FileOptions_has_php_metadata_namespace(const google_protobuf_FileOptions * msg)2396 UPB_INLINE bool google_protobuf_FileOptions_has_php_metadata_namespace(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 19); }
google_protobuf_FileOptions_php_metadata_namespace(const google_protobuf_FileOptions * msg)2397 UPB_INLINE upb_strview google_protobuf_FileOptions_php_metadata_namespace(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(92, 160), upb_strview); }
google_protobuf_FileOptions_has_ruby_package(const google_protobuf_FileOptions * msg)2398 UPB_INLINE bool google_protobuf_FileOptions_has_ruby_package(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 20); }
google_protobuf_FileOptions_ruby_package(const google_protobuf_FileOptions * msg)2399 UPB_INLINE upb_strview google_protobuf_FileOptions_ruby_package(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(100, 176), upb_strview); }
google_protobuf_FileOptions_has_uninterpreted_option(const google_protobuf_FileOptions * msg)2400 UPB_INLINE bool google_protobuf_FileOptions_has_uninterpreted_option(const google_protobuf_FileOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(108, 192)); }
google_protobuf_FileOptions_uninterpreted_option(const google_protobuf_FileOptions * msg,size_t * len)2401 UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FileOptions_uninterpreted_option(const google_protobuf_FileOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(108, 192), len); }
2402 
google_protobuf_FileOptions_set_java_package(google_protobuf_FileOptions * msg,upb_strview value)2403 UPB_INLINE void google_protobuf_FileOptions_set_java_package(google_protobuf_FileOptions *msg, upb_strview value) {
2404   _upb_sethas(msg, 11);
2405   *UPB_PTR_AT(msg, UPB_SIZE(28, 32), upb_strview) = value;
2406 }
google_protobuf_FileOptions_set_java_outer_classname(google_protobuf_FileOptions * msg,upb_strview value)2407 UPB_INLINE void google_protobuf_FileOptions_set_java_outer_classname(google_protobuf_FileOptions *msg, upb_strview value) {
2408   _upb_sethas(msg, 12);
2409   *UPB_PTR_AT(msg, UPB_SIZE(36, 48), upb_strview) = value;
2410 }
google_protobuf_FileOptions_set_optimize_for(google_protobuf_FileOptions * msg,int32_t value)2411 UPB_INLINE void google_protobuf_FileOptions_set_optimize_for(google_protobuf_FileOptions *msg, int32_t value) {
2412   _upb_sethas(msg, 1);
2413   *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
2414 }
google_protobuf_FileOptions_set_java_multiple_files(google_protobuf_FileOptions * msg,bool value)2415 UPB_INLINE void google_protobuf_FileOptions_set_java_multiple_files(google_protobuf_FileOptions *msg, bool value) {
2416   _upb_sethas(msg, 2);
2417   *UPB_PTR_AT(msg, UPB_SIZE(16, 16), bool) = value;
2418 }
google_protobuf_FileOptions_set_go_package(google_protobuf_FileOptions * msg,upb_strview value)2419 UPB_INLINE void google_protobuf_FileOptions_set_go_package(google_protobuf_FileOptions *msg, upb_strview value) {
2420   _upb_sethas(msg, 13);
2421   *UPB_PTR_AT(msg, UPB_SIZE(44, 64), upb_strview) = value;
2422 }
google_protobuf_FileOptions_set_cc_generic_services(google_protobuf_FileOptions * msg,bool value)2423 UPB_INLINE void google_protobuf_FileOptions_set_cc_generic_services(google_protobuf_FileOptions *msg, bool value) {
2424   _upb_sethas(msg, 3);
2425   *UPB_PTR_AT(msg, UPB_SIZE(17, 17), bool) = value;
2426 }
google_protobuf_FileOptions_set_java_generic_services(google_protobuf_FileOptions * msg,bool value)2427 UPB_INLINE void google_protobuf_FileOptions_set_java_generic_services(google_protobuf_FileOptions *msg, bool value) {
2428   _upb_sethas(msg, 4);
2429   *UPB_PTR_AT(msg, UPB_SIZE(18, 18), bool) = value;
2430 }
google_protobuf_FileOptions_set_py_generic_services(google_protobuf_FileOptions * msg,bool value)2431 UPB_INLINE void google_protobuf_FileOptions_set_py_generic_services(google_protobuf_FileOptions *msg, bool value) {
2432   _upb_sethas(msg, 5);
2433   *UPB_PTR_AT(msg, UPB_SIZE(19, 19), bool) = value;
2434 }
google_protobuf_FileOptions_set_java_generate_equals_and_hash(google_protobuf_FileOptions * msg,bool value)2435 UPB_INLINE void google_protobuf_FileOptions_set_java_generate_equals_and_hash(google_protobuf_FileOptions *msg, bool value) {
2436   _upb_sethas(msg, 6);
2437   *UPB_PTR_AT(msg, UPB_SIZE(20, 20), bool) = value;
2438 }
google_protobuf_FileOptions_set_deprecated(google_protobuf_FileOptions * msg,bool value)2439 UPB_INLINE void google_protobuf_FileOptions_set_deprecated(google_protobuf_FileOptions *msg, bool value) {
2440   _upb_sethas(msg, 7);
2441   *UPB_PTR_AT(msg, UPB_SIZE(21, 21), bool) = value;
2442 }
google_protobuf_FileOptions_set_java_string_check_utf8(google_protobuf_FileOptions * msg,bool value)2443 UPB_INLINE void google_protobuf_FileOptions_set_java_string_check_utf8(google_protobuf_FileOptions *msg, bool value) {
2444   _upb_sethas(msg, 8);
2445   *UPB_PTR_AT(msg, UPB_SIZE(22, 22), bool) = value;
2446 }
google_protobuf_FileOptions_set_cc_enable_arenas(google_protobuf_FileOptions * msg,bool value)2447 UPB_INLINE void google_protobuf_FileOptions_set_cc_enable_arenas(google_protobuf_FileOptions *msg, bool value) {
2448   _upb_sethas(msg, 9);
2449   *UPB_PTR_AT(msg, UPB_SIZE(23, 23), bool) = value;
2450 }
google_protobuf_FileOptions_set_objc_class_prefix(google_protobuf_FileOptions * msg,upb_strview value)2451 UPB_INLINE void google_protobuf_FileOptions_set_objc_class_prefix(google_protobuf_FileOptions *msg, upb_strview value) {
2452   _upb_sethas(msg, 14);
2453   *UPB_PTR_AT(msg, UPB_SIZE(52, 80), upb_strview) = value;
2454 }
google_protobuf_FileOptions_set_csharp_namespace(google_protobuf_FileOptions * msg,upb_strview value)2455 UPB_INLINE void google_protobuf_FileOptions_set_csharp_namespace(google_protobuf_FileOptions *msg, upb_strview value) {
2456   _upb_sethas(msg, 15);
2457   *UPB_PTR_AT(msg, UPB_SIZE(60, 96), upb_strview) = value;
2458 }
google_protobuf_FileOptions_set_swift_prefix(google_protobuf_FileOptions * msg,upb_strview value)2459 UPB_INLINE void google_protobuf_FileOptions_set_swift_prefix(google_protobuf_FileOptions *msg, upb_strview value) {
2460   _upb_sethas(msg, 16);
2461   *UPB_PTR_AT(msg, UPB_SIZE(68, 112), upb_strview) = value;
2462 }
google_protobuf_FileOptions_set_php_class_prefix(google_protobuf_FileOptions * msg,upb_strview value)2463 UPB_INLINE void google_protobuf_FileOptions_set_php_class_prefix(google_protobuf_FileOptions *msg, upb_strview value) {
2464   _upb_sethas(msg, 17);
2465   *UPB_PTR_AT(msg, UPB_SIZE(76, 128), upb_strview) = value;
2466 }
google_protobuf_FileOptions_set_php_namespace(google_protobuf_FileOptions * msg,upb_strview value)2467 UPB_INLINE void google_protobuf_FileOptions_set_php_namespace(google_protobuf_FileOptions *msg, upb_strview value) {
2468   _upb_sethas(msg, 18);
2469   *UPB_PTR_AT(msg, UPB_SIZE(84, 144), upb_strview) = value;
2470 }
google_protobuf_FileOptions_set_php_generic_services(google_protobuf_FileOptions * msg,bool value)2471 UPB_INLINE void google_protobuf_FileOptions_set_php_generic_services(google_protobuf_FileOptions *msg, bool value) {
2472   _upb_sethas(msg, 10);
2473   *UPB_PTR_AT(msg, UPB_SIZE(24, 24), bool) = value;
2474 }
google_protobuf_FileOptions_set_php_metadata_namespace(google_protobuf_FileOptions * msg,upb_strview value)2475 UPB_INLINE void google_protobuf_FileOptions_set_php_metadata_namespace(google_protobuf_FileOptions *msg, upb_strview value) {
2476   _upb_sethas(msg, 19);
2477   *UPB_PTR_AT(msg, UPB_SIZE(92, 160), upb_strview) = value;
2478 }
google_protobuf_FileOptions_set_ruby_package(google_protobuf_FileOptions * msg,upb_strview value)2479 UPB_INLINE void google_protobuf_FileOptions_set_ruby_package(google_protobuf_FileOptions *msg, upb_strview value) {
2480   _upb_sethas(msg, 20);
2481   *UPB_PTR_AT(msg, UPB_SIZE(100, 176), upb_strview) = value;
2482 }
google_protobuf_FileOptions_mutable_uninterpreted_option(google_protobuf_FileOptions * msg,size_t * len)2483 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_mutable_uninterpreted_option(google_protobuf_FileOptions *msg, size_t *len) {
2484   return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(108, 192), len);
2485 }
google_protobuf_FileOptions_resize_uninterpreted_option(google_protobuf_FileOptions * msg,size_t len,upb_arena * arena)2486 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_resize_uninterpreted_option(google_protobuf_FileOptions *msg, size_t len, upb_arena *arena) {
2487   return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(108, 192), len, UPB_TYPE_MESSAGE, arena);
2488 }
google_protobuf_FileOptions_add_uninterpreted_option(google_protobuf_FileOptions * msg,upb_arena * arena)2489 UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FileOptions_add_uninterpreted_option(google_protobuf_FileOptions *msg, upb_arena *arena) {
2490   struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
2491   bool ok = _upb_array_append_accessor(
2492       msg, UPB_SIZE(108, 192), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2493   if (!ok) return NULL;
2494   return sub;
2495 }
2496 
2497 /* google.protobuf.MessageOptions */
2498 
google_protobuf_MessageOptions_new(upb_arena * arena)2499 UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_new(upb_arena *arena) {
2500   return (google_protobuf_MessageOptions *)_upb_msg_new(&google_protobuf_MessageOptions_msginit, arena);
2501 }
google_protobuf_MessageOptions_parse(const char * buf,size_t size,upb_arena * arena)2502 UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_parse(const char *buf, size_t size,
2503                         upb_arena *arena) {
2504   google_protobuf_MessageOptions *ret = google_protobuf_MessageOptions_new(arena);
2505   return (ret && upb_decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, arena)) ? ret : NULL;
2506 }
google_protobuf_MessageOptions_serialize(const google_protobuf_MessageOptions * msg,upb_arena * arena,size_t * len)2507 UPB_INLINE char *google_protobuf_MessageOptions_serialize(const google_protobuf_MessageOptions *msg, upb_arena *arena, size_t *len) {
2508   return upb_encode(msg, &google_protobuf_MessageOptions_msginit, arena, len);
2509 }
2510 
google_protobuf_MessageOptions_has_message_set_wire_format(const google_protobuf_MessageOptions * msg)2511 UPB_INLINE bool google_protobuf_MessageOptions_has_message_set_wire_format(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 1); }
google_protobuf_MessageOptions_message_set_wire_format(const google_protobuf_MessageOptions * msg)2512 UPB_INLINE bool google_protobuf_MessageOptions_message_set_wire_format(const google_protobuf_MessageOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
google_protobuf_MessageOptions_has_no_standard_descriptor_accessor(const google_protobuf_MessageOptions * msg)2513 UPB_INLINE bool google_protobuf_MessageOptions_has_no_standard_descriptor_accessor(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 2); }
google_protobuf_MessageOptions_no_standard_descriptor_accessor(const google_protobuf_MessageOptions * msg)2514 UPB_INLINE bool google_protobuf_MessageOptions_no_standard_descriptor_accessor(const google_protobuf_MessageOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool); }
google_protobuf_MessageOptions_has_deprecated(const google_protobuf_MessageOptions * msg)2515 UPB_INLINE bool google_protobuf_MessageOptions_has_deprecated(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 3); }
google_protobuf_MessageOptions_deprecated(const google_protobuf_MessageOptions * msg)2516 UPB_INLINE bool google_protobuf_MessageOptions_deprecated(const google_protobuf_MessageOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(3, 3), bool); }
google_protobuf_MessageOptions_has_map_entry(const google_protobuf_MessageOptions * msg)2517 UPB_INLINE bool google_protobuf_MessageOptions_has_map_entry(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 4); }
google_protobuf_MessageOptions_map_entry(const google_protobuf_MessageOptions * msg)2518 UPB_INLINE bool google_protobuf_MessageOptions_map_entry(const google_protobuf_MessageOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), bool); }
google_protobuf_MessageOptions_has_uninterpreted_option(const google_protobuf_MessageOptions * msg)2519 UPB_INLINE bool google_protobuf_MessageOptions_has_uninterpreted_option(const google_protobuf_MessageOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(8, 8)); }
google_protobuf_MessageOptions_uninterpreted_option(const google_protobuf_MessageOptions * msg,size_t * len)2520 UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MessageOptions_uninterpreted_option(const google_protobuf_MessageOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(8, 8), len); }
2521 
google_protobuf_MessageOptions_set_message_set_wire_format(google_protobuf_MessageOptions * msg,bool value)2522 UPB_INLINE void google_protobuf_MessageOptions_set_message_set_wire_format(google_protobuf_MessageOptions *msg, bool value) {
2523   _upb_sethas(msg, 1);
2524   *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
2525 }
google_protobuf_MessageOptions_set_no_standard_descriptor_accessor(google_protobuf_MessageOptions * msg,bool value)2526 UPB_INLINE void google_protobuf_MessageOptions_set_no_standard_descriptor_accessor(google_protobuf_MessageOptions *msg, bool value) {
2527   _upb_sethas(msg, 2);
2528   *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool) = value;
2529 }
google_protobuf_MessageOptions_set_deprecated(google_protobuf_MessageOptions * msg,bool value)2530 UPB_INLINE void google_protobuf_MessageOptions_set_deprecated(google_protobuf_MessageOptions *msg, bool value) {
2531   _upb_sethas(msg, 3);
2532   *UPB_PTR_AT(msg, UPB_SIZE(3, 3), bool) = value;
2533 }
google_protobuf_MessageOptions_set_map_entry(google_protobuf_MessageOptions * msg,bool value)2534 UPB_INLINE void google_protobuf_MessageOptions_set_map_entry(google_protobuf_MessageOptions *msg, bool value) {
2535   _upb_sethas(msg, 4);
2536   *UPB_PTR_AT(msg, UPB_SIZE(4, 4), bool) = value;
2537 }
google_protobuf_MessageOptions_mutable_uninterpreted_option(google_protobuf_MessageOptions * msg,size_t * len)2538 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_mutable_uninterpreted_option(google_protobuf_MessageOptions *msg, size_t *len) {
2539   return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(8, 8), len);
2540 }
google_protobuf_MessageOptions_resize_uninterpreted_option(google_protobuf_MessageOptions * msg,size_t len,upb_arena * arena)2541 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_resize_uninterpreted_option(google_protobuf_MessageOptions *msg, size_t len, upb_arena *arena) {
2542   return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(8, 8), len, UPB_TYPE_MESSAGE, arena);
2543 }
google_protobuf_MessageOptions_add_uninterpreted_option(google_protobuf_MessageOptions * msg,upb_arena * arena)2544 UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MessageOptions_add_uninterpreted_option(google_protobuf_MessageOptions *msg, upb_arena *arena) {
2545   struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
2546   bool ok = _upb_array_append_accessor(
2547       msg, UPB_SIZE(8, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2548   if (!ok) return NULL;
2549   return sub;
2550 }
2551 
2552 /* google.protobuf.FieldOptions */
2553 
google_protobuf_FieldOptions_new(upb_arena * arena)2554 UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_new(upb_arena *arena) {
2555   return (google_protobuf_FieldOptions *)_upb_msg_new(&google_protobuf_FieldOptions_msginit, arena);
2556 }
google_protobuf_FieldOptions_parse(const char * buf,size_t size,upb_arena * arena)2557 UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_parse(const char *buf, size_t size,
2558                         upb_arena *arena) {
2559   google_protobuf_FieldOptions *ret = google_protobuf_FieldOptions_new(arena);
2560   return (ret && upb_decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, arena)) ? ret : NULL;
2561 }
google_protobuf_FieldOptions_serialize(const google_protobuf_FieldOptions * msg,upb_arena * arena,size_t * len)2562 UPB_INLINE char *google_protobuf_FieldOptions_serialize(const google_protobuf_FieldOptions *msg, upb_arena *arena, size_t *len) {
2563   return upb_encode(msg, &google_protobuf_FieldOptions_msginit, arena, len);
2564 }
2565 
google_protobuf_FieldOptions_has_ctype(const google_protobuf_FieldOptions * msg)2566 UPB_INLINE bool google_protobuf_FieldOptions_has_ctype(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 1); }
google_protobuf_FieldOptions_ctype(const google_protobuf_FieldOptions * msg)2567 UPB_INLINE int32_t google_protobuf_FieldOptions_ctype(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
google_protobuf_FieldOptions_has_packed(const google_protobuf_FieldOptions * msg)2568 UPB_INLINE bool google_protobuf_FieldOptions_has_packed(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 3); }
google_protobuf_FieldOptions_packed(const google_protobuf_FieldOptions * msg)2569 UPB_INLINE bool google_protobuf_FieldOptions_packed(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), bool); }
google_protobuf_FieldOptions_has_deprecated(const google_protobuf_FieldOptions * msg)2570 UPB_INLINE bool google_protobuf_FieldOptions_has_deprecated(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 4); }
google_protobuf_FieldOptions_deprecated(const google_protobuf_FieldOptions * msg)2571 UPB_INLINE bool google_protobuf_FieldOptions_deprecated(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(25, 25), bool); }
google_protobuf_FieldOptions_has_lazy(const google_protobuf_FieldOptions * msg)2572 UPB_INLINE bool google_protobuf_FieldOptions_has_lazy(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 5); }
google_protobuf_FieldOptions_lazy(const google_protobuf_FieldOptions * msg)2573 UPB_INLINE bool google_protobuf_FieldOptions_lazy(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(26, 26), bool); }
google_protobuf_FieldOptions_has_jstype(const google_protobuf_FieldOptions * msg)2574 UPB_INLINE bool google_protobuf_FieldOptions_has_jstype(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 2); }
google_protobuf_FieldOptions_jstype(const google_protobuf_FieldOptions * msg)2575 UPB_INLINE int32_t google_protobuf_FieldOptions_jstype(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t); }
google_protobuf_FieldOptions_has_weak(const google_protobuf_FieldOptions * msg)2576 UPB_INLINE bool google_protobuf_FieldOptions_has_weak(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 6); }
google_protobuf_FieldOptions_weak(const google_protobuf_FieldOptions * msg)2577 UPB_INLINE bool google_protobuf_FieldOptions_weak(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(27, 27), bool); }
google_protobuf_FieldOptions_has_uninterpreted_option(const google_protobuf_FieldOptions * msg)2578 UPB_INLINE bool google_protobuf_FieldOptions_has_uninterpreted_option(const google_protobuf_FieldOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(28, 32)); }
google_protobuf_FieldOptions_uninterpreted_option(const google_protobuf_FieldOptions * msg,size_t * len)2579 UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FieldOptions_uninterpreted_option(const google_protobuf_FieldOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(28, 32), len); }
2580 
google_protobuf_FieldOptions_set_ctype(google_protobuf_FieldOptions * msg,int32_t value)2581 UPB_INLINE void google_protobuf_FieldOptions_set_ctype(google_protobuf_FieldOptions *msg, int32_t value) {
2582   _upb_sethas(msg, 1);
2583   *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
2584 }
google_protobuf_FieldOptions_set_packed(google_protobuf_FieldOptions * msg,bool value)2585 UPB_INLINE void google_protobuf_FieldOptions_set_packed(google_protobuf_FieldOptions *msg, bool value) {
2586   _upb_sethas(msg, 3);
2587   *UPB_PTR_AT(msg, UPB_SIZE(24, 24), bool) = value;
2588 }
google_protobuf_FieldOptions_set_deprecated(google_protobuf_FieldOptions * msg,bool value)2589 UPB_INLINE void google_protobuf_FieldOptions_set_deprecated(google_protobuf_FieldOptions *msg, bool value) {
2590   _upb_sethas(msg, 4);
2591   *UPB_PTR_AT(msg, UPB_SIZE(25, 25), bool) = value;
2592 }
google_protobuf_FieldOptions_set_lazy(google_protobuf_FieldOptions * msg,bool value)2593 UPB_INLINE void google_protobuf_FieldOptions_set_lazy(google_protobuf_FieldOptions *msg, bool value) {
2594   _upb_sethas(msg, 5);
2595   *UPB_PTR_AT(msg, UPB_SIZE(26, 26), bool) = value;
2596 }
google_protobuf_FieldOptions_set_jstype(google_protobuf_FieldOptions * msg,int32_t value)2597 UPB_INLINE void google_protobuf_FieldOptions_set_jstype(google_protobuf_FieldOptions *msg, int32_t value) {
2598   _upb_sethas(msg, 2);
2599   *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t) = value;
2600 }
google_protobuf_FieldOptions_set_weak(google_protobuf_FieldOptions * msg,bool value)2601 UPB_INLINE void google_protobuf_FieldOptions_set_weak(google_protobuf_FieldOptions *msg, bool value) {
2602   _upb_sethas(msg, 6);
2603   *UPB_PTR_AT(msg, UPB_SIZE(27, 27), bool) = value;
2604 }
google_protobuf_FieldOptions_mutable_uninterpreted_option(google_protobuf_FieldOptions * msg,size_t * len)2605 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_mutable_uninterpreted_option(google_protobuf_FieldOptions *msg, size_t *len) {
2606   return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 32), len);
2607 }
google_protobuf_FieldOptions_resize_uninterpreted_option(google_protobuf_FieldOptions * msg,size_t len,upb_arena * arena)2608 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_resize_uninterpreted_option(google_protobuf_FieldOptions *msg, size_t len, upb_arena *arena) {
2609   return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 32), len, UPB_TYPE_MESSAGE, arena);
2610 }
google_protobuf_FieldOptions_add_uninterpreted_option(google_protobuf_FieldOptions * msg,upb_arena * arena)2611 UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FieldOptions_add_uninterpreted_option(google_protobuf_FieldOptions *msg, upb_arena *arena) {
2612   struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
2613   bool ok = _upb_array_append_accessor(
2614       msg, UPB_SIZE(28, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2615   if (!ok) return NULL;
2616   return sub;
2617 }
2618 
2619 /* google.protobuf.OneofOptions */
2620 
google_protobuf_OneofOptions_new(upb_arena * arena)2621 UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_new(upb_arena *arena) {
2622   return (google_protobuf_OneofOptions *)_upb_msg_new(&google_protobuf_OneofOptions_msginit, arena);
2623 }
google_protobuf_OneofOptions_parse(const char * buf,size_t size,upb_arena * arena)2624 UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_parse(const char *buf, size_t size,
2625                         upb_arena *arena) {
2626   google_protobuf_OneofOptions *ret = google_protobuf_OneofOptions_new(arena);
2627   return (ret && upb_decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, arena)) ? ret : NULL;
2628 }
google_protobuf_OneofOptions_serialize(const google_protobuf_OneofOptions * msg,upb_arena * arena,size_t * len)2629 UPB_INLINE char *google_protobuf_OneofOptions_serialize(const google_protobuf_OneofOptions *msg, upb_arena *arena, size_t *len) {
2630   return upb_encode(msg, &google_protobuf_OneofOptions_msginit, arena, len);
2631 }
2632 
google_protobuf_OneofOptions_has_uninterpreted_option(const google_protobuf_OneofOptions * msg)2633 UPB_INLINE bool google_protobuf_OneofOptions_has_uninterpreted_option(const google_protobuf_OneofOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
google_protobuf_OneofOptions_uninterpreted_option(const google_protobuf_OneofOptions * msg,size_t * len)2634 UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_OneofOptions_uninterpreted_option(const google_protobuf_OneofOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
2635 
google_protobuf_OneofOptions_mutable_uninterpreted_option(google_protobuf_OneofOptions * msg,size_t * len)2636 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_mutable_uninterpreted_option(google_protobuf_OneofOptions *msg, size_t *len) {
2637   return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len);
2638 }
google_protobuf_OneofOptions_resize_uninterpreted_option(google_protobuf_OneofOptions * msg,size_t len,upb_arena * arena)2639 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_resize_uninterpreted_option(google_protobuf_OneofOptions *msg, size_t len, upb_arena *arena) {
2640   return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_TYPE_MESSAGE, arena);
2641 }
google_protobuf_OneofOptions_add_uninterpreted_option(google_protobuf_OneofOptions * msg,upb_arena * arena)2642 UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_OneofOptions_add_uninterpreted_option(google_protobuf_OneofOptions *msg, upb_arena *arena) {
2643   struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
2644   bool ok = _upb_array_append_accessor(
2645       msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2646   if (!ok) return NULL;
2647   return sub;
2648 }
2649 
2650 /* google.protobuf.EnumOptions */
2651 
google_protobuf_EnumOptions_new(upb_arena * arena)2652 UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_new(upb_arena *arena) {
2653   return (google_protobuf_EnumOptions *)_upb_msg_new(&google_protobuf_EnumOptions_msginit, arena);
2654 }
google_protobuf_EnumOptions_parse(const char * buf,size_t size,upb_arena * arena)2655 UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_parse(const char *buf, size_t size,
2656                         upb_arena *arena) {
2657   google_protobuf_EnumOptions *ret = google_protobuf_EnumOptions_new(arena);
2658   return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, arena)) ? ret : NULL;
2659 }
google_protobuf_EnumOptions_serialize(const google_protobuf_EnumOptions * msg,upb_arena * arena,size_t * len)2660 UPB_INLINE char *google_protobuf_EnumOptions_serialize(const google_protobuf_EnumOptions *msg, upb_arena *arena, size_t *len) {
2661   return upb_encode(msg, &google_protobuf_EnumOptions_msginit, arena, len);
2662 }
2663 
google_protobuf_EnumOptions_has_allow_alias(const google_protobuf_EnumOptions * msg)2664 UPB_INLINE bool google_protobuf_EnumOptions_has_allow_alias(const google_protobuf_EnumOptions *msg) { return _upb_has_field(msg, 1); }
google_protobuf_EnumOptions_allow_alias(const google_protobuf_EnumOptions * msg)2665 UPB_INLINE bool google_protobuf_EnumOptions_allow_alias(const google_protobuf_EnumOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
google_protobuf_EnumOptions_has_deprecated(const google_protobuf_EnumOptions * msg)2666 UPB_INLINE bool google_protobuf_EnumOptions_has_deprecated(const google_protobuf_EnumOptions *msg) { return _upb_has_field(msg, 2); }
google_protobuf_EnumOptions_deprecated(const google_protobuf_EnumOptions * msg)2667 UPB_INLINE bool google_protobuf_EnumOptions_deprecated(const google_protobuf_EnumOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool); }
google_protobuf_EnumOptions_has_uninterpreted_option(const google_protobuf_EnumOptions * msg)2668 UPB_INLINE bool google_protobuf_EnumOptions_has_uninterpreted_option(const google_protobuf_EnumOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(4, 8)); }
google_protobuf_EnumOptions_uninterpreted_option(const google_protobuf_EnumOptions * msg,size_t * len)2669 UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumOptions_uninterpreted_option(const google_protobuf_EnumOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); }
2670 
google_protobuf_EnumOptions_set_allow_alias(google_protobuf_EnumOptions * msg,bool value)2671 UPB_INLINE void google_protobuf_EnumOptions_set_allow_alias(google_protobuf_EnumOptions *msg, bool value) {
2672   _upb_sethas(msg, 1);
2673   *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
2674 }
google_protobuf_EnumOptions_set_deprecated(google_protobuf_EnumOptions * msg,bool value)2675 UPB_INLINE void google_protobuf_EnumOptions_set_deprecated(google_protobuf_EnumOptions *msg, bool value) {
2676   _upb_sethas(msg, 2);
2677   *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool) = value;
2678 }
google_protobuf_EnumOptions_mutable_uninterpreted_option(google_protobuf_EnumOptions * msg,size_t * len)2679 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_mutable_uninterpreted_option(google_protobuf_EnumOptions *msg, size_t *len) {
2680   return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len);
2681 }
google_protobuf_EnumOptions_resize_uninterpreted_option(google_protobuf_EnumOptions * msg,size_t len,upb_arena * arena)2682 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_resize_uninterpreted_option(google_protobuf_EnumOptions *msg, size_t len, upb_arena *arena) {
2683   return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_TYPE_MESSAGE, arena);
2684 }
google_protobuf_EnumOptions_add_uninterpreted_option(google_protobuf_EnumOptions * msg,upb_arena * arena)2685 UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumOptions_add_uninterpreted_option(google_protobuf_EnumOptions *msg, upb_arena *arena) {
2686   struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
2687   bool ok = _upb_array_append_accessor(
2688       msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2689   if (!ok) return NULL;
2690   return sub;
2691 }
2692 
2693 /* google.protobuf.EnumValueOptions */
2694 
google_protobuf_EnumValueOptions_new(upb_arena * arena)2695 UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_new(upb_arena *arena) {
2696   return (google_protobuf_EnumValueOptions *)_upb_msg_new(&google_protobuf_EnumValueOptions_msginit, arena);
2697 }
google_protobuf_EnumValueOptions_parse(const char * buf,size_t size,upb_arena * arena)2698 UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_parse(const char *buf, size_t size,
2699                         upb_arena *arena) {
2700   google_protobuf_EnumValueOptions *ret = google_protobuf_EnumValueOptions_new(arena);
2701   return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, arena)) ? ret : NULL;
2702 }
google_protobuf_EnumValueOptions_serialize(const google_protobuf_EnumValueOptions * msg,upb_arena * arena,size_t * len)2703 UPB_INLINE char *google_protobuf_EnumValueOptions_serialize(const google_protobuf_EnumValueOptions *msg, upb_arena *arena, size_t *len) {
2704   return upb_encode(msg, &google_protobuf_EnumValueOptions_msginit, arena, len);
2705 }
2706 
google_protobuf_EnumValueOptions_has_deprecated(const google_protobuf_EnumValueOptions * msg)2707 UPB_INLINE bool google_protobuf_EnumValueOptions_has_deprecated(const google_protobuf_EnumValueOptions *msg) { return _upb_has_field(msg, 1); }
google_protobuf_EnumValueOptions_deprecated(const google_protobuf_EnumValueOptions * msg)2708 UPB_INLINE bool google_protobuf_EnumValueOptions_deprecated(const google_protobuf_EnumValueOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
google_protobuf_EnumValueOptions_has_uninterpreted_option(const google_protobuf_EnumValueOptions * msg)2709 UPB_INLINE bool google_protobuf_EnumValueOptions_has_uninterpreted_option(const google_protobuf_EnumValueOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(4, 8)); }
google_protobuf_EnumValueOptions_uninterpreted_option(const google_protobuf_EnumValueOptions * msg,size_t * len)2710 UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumValueOptions_uninterpreted_option(const google_protobuf_EnumValueOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); }
2711 
google_protobuf_EnumValueOptions_set_deprecated(google_protobuf_EnumValueOptions * msg,bool value)2712 UPB_INLINE void google_protobuf_EnumValueOptions_set_deprecated(google_protobuf_EnumValueOptions *msg, bool value) {
2713   _upb_sethas(msg, 1);
2714   *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
2715 }
google_protobuf_EnumValueOptions_mutable_uninterpreted_option(google_protobuf_EnumValueOptions * msg,size_t * len)2716 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_mutable_uninterpreted_option(google_protobuf_EnumValueOptions *msg, size_t *len) {
2717   return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len);
2718 }
google_protobuf_EnumValueOptions_resize_uninterpreted_option(google_protobuf_EnumValueOptions * msg,size_t len,upb_arena * arena)2719 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_resize_uninterpreted_option(google_protobuf_EnumValueOptions *msg, size_t len, upb_arena *arena) {
2720   return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_TYPE_MESSAGE, arena);
2721 }
google_protobuf_EnumValueOptions_add_uninterpreted_option(google_protobuf_EnumValueOptions * msg,upb_arena * arena)2722 UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumValueOptions_add_uninterpreted_option(google_protobuf_EnumValueOptions *msg, upb_arena *arena) {
2723   struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
2724   bool ok = _upb_array_append_accessor(
2725       msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2726   if (!ok) return NULL;
2727   return sub;
2728 }
2729 
2730 /* google.protobuf.ServiceOptions */
2731 
google_protobuf_ServiceOptions_new(upb_arena * arena)2732 UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_new(upb_arena *arena) {
2733   return (google_protobuf_ServiceOptions *)_upb_msg_new(&google_protobuf_ServiceOptions_msginit, arena);
2734 }
google_protobuf_ServiceOptions_parse(const char * buf,size_t size,upb_arena * arena)2735 UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_parse(const char *buf, size_t size,
2736                         upb_arena *arena) {
2737   google_protobuf_ServiceOptions *ret = google_protobuf_ServiceOptions_new(arena);
2738   return (ret && upb_decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, arena)) ? ret : NULL;
2739 }
google_protobuf_ServiceOptions_serialize(const google_protobuf_ServiceOptions * msg,upb_arena * arena,size_t * len)2740 UPB_INLINE char *google_protobuf_ServiceOptions_serialize(const google_protobuf_ServiceOptions *msg, upb_arena *arena, size_t *len) {
2741   return upb_encode(msg, &google_protobuf_ServiceOptions_msginit, arena, len);
2742 }
2743 
google_protobuf_ServiceOptions_has_deprecated(const google_protobuf_ServiceOptions * msg)2744 UPB_INLINE bool google_protobuf_ServiceOptions_has_deprecated(const google_protobuf_ServiceOptions *msg) { return _upb_has_field(msg, 1); }
google_protobuf_ServiceOptions_deprecated(const google_protobuf_ServiceOptions * msg)2745 UPB_INLINE bool google_protobuf_ServiceOptions_deprecated(const google_protobuf_ServiceOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
google_protobuf_ServiceOptions_has_uninterpreted_option(const google_protobuf_ServiceOptions * msg)2746 UPB_INLINE bool google_protobuf_ServiceOptions_has_uninterpreted_option(const google_protobuf_ServiceOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(4, 8)); }
google_protobuf_ServiceOptions_uninterpreted_option(const google_protobuf_ServiceOptions * msg,size_t * len)2747 UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ServiceOptions_uninterpreted_option(const google_protobuf_ServiceOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); }
2748 
google_protobuf_ServiceOptions_set_deprecated(google_protobuf_ServiceOptions * msg,bool value)2749 UPB_INLINE void google_protobuf_ServiceOptions_set_deprecated(google_protobuf_ServiceOptions *msg, bool value) {
2750   _upb_sethas(msg, 1);
2751   *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
2752 }
google_protobuf_ServiceOptions_mutable_uninterpreted_option(google_protobuf_ServiceOptions * msg,size_t * len)2753 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_mutable_uninterpreted_option(google_protobuf_ServiceOptions *msg, size_t *len) {
2754   return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len);
2755 }
google_protobuf_ServiceOptions_resize_uninterpreted_option(google_protobuf_ServiceOptions * msg,size_t len,upb_arena * arena)2756 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_resize_uninterpreted_option(google_protobuf_ServiceOptions *msg, size_t len, upb_arena *arena) {
2757   return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_TYPE_MESSAGE, arena);
2758 }
google_protobuf_ServiceOptions_add_uninterpreted_option(google_protobuf_ServiceOptions * msg,upb_arena * arena)2759 UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ServiceOptions_add_uninterpreted_option(google_protobuf_ServiceOptions *msg, upb_arena *arena) {
2760   struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
2761   bool ok = _upb_array_append_accessor(
2762       msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2763   if (!ok) return NULL;
2764   return sub;
2765 }
2766 
2767 /* google.protobuf.MethodOptions */
2768 
google_protobuf_MethodOptions_new(upb_arena * arena)2769 UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_new(upb_arena *arena) {
2770   return (google_protobuf_MethodOptions *)_upb_msg_new(&google_protobuf_MethodOptions_msginit, arena);
2771 }
google_protobuf_MethodOptions_parse(const char * buf,size_t size,upb_arena * arena)2772 UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_parse(const char *buf, size_t size,
2773                         upb_arena *arena) {
2774   google_protobuf_MethodOptions *ret = google_protobuf_MethodOptions_new(arena);
2775   return (ret && upb_decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, arena)) ? ret : NULL;
2776 }
google_protobuf_MethodOptions_serialize(const google_protobuf_MethodOptions * msg,upb_arena * arena,size_t * len)2777 UPB_INLINE char *google_protobuf_MethodOptions_serialize(const google_protobuf_MethodOptions *msg, upb_arena *arena, size_t *len) {
2778   return upb_encode(msg, &google_protobuf_MethodOptions_msginit, arena, len);
2779 }
2780 
google_protobuf_MethodOptions_has_deprecated(const google_protobuf_MethodOptions * msg)2781 UPB_INLINE bool google_protobuf_MethodOptions_has_deprecated(const google_protobuf_MethodOptions *msg) { return _upb_has_field(msg, 2); }
google_protobuf_MethodOptions_deprecated(const google_protobuf_MethodOptions * msg)2782 UPB_INLINE bool google_protobuf_MethodOptions_deprecated(const google_protobuf_MethodOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), bool); }
google_protobuf_MethodOptions_has_idempotency_level(const google_protobuf_MethodOptions * msg)2783 UPB_INLINE bool google_protobuf_MethodOptions_has_idempotency_level(const google_protobuf_MethodOptions *msg) { return _upb_has_field(msg, 1); }
google_protobuf_MethodOptions_idempotency_level(const google_protobuf_MethodOptions * msg)2784 UPB_INLINE int32_t google_protobuf_MethodOptions_idempotency_level(const google_protobuf_MethodOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
google_protobuf_MethodOptions_has_uninterpreted_option(const google_protobuf_MethodOptions * msg)2785 UPB_INLINE bool google_protobuf_MethodOptions_has_uninterpreted_option(const google_protobuf_MethodOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(20, 24)); }
google_protobuf_MethodOptions_uninterpreted_option(const google_protobuf_MethodOptions * msg,size_t * len)2786 UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MethodOptions_uninterpreted_option(const google_protobuf_MethodOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(20, 24), len); }
2787 
google_protobuf_MethodOptions_set_deprecated(google_protobuf_MethodOptions * msg,bool value)2788 UPB_INLINE void google_protobuf_MethodOptions_set_deprecated(google_protobuf_MethodOptions *msg, bool value) {
2789   _upb_sethas(msg, 2);
2790   *UPB_PTR_AT(msg, UPB_SIZE(16, 16), bool) = value;
2791 }
google_protobuf_MethodOptions_set_idempotency_level(google_protobuf_MethodOptions * msg,int32_t value)2792 UPB_INLINE void google_protobuf_MethodOptions_set_idempotency_level(google_protobuf_MethodOptions *msg, int32_t value) {
2793   _upb_sethas(msg, 1);
2794   *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
2795 }
google_protobuf_MethodOptions_mutable_uninterpreted_option(google_protobuf_MethodOptions * msg,size_t * len)2796 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_mutable_uninterpreted_option(google_protobuf_MethodOptions *msg, size_t *len) {
2797   return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 24), len);
2798 }
google_protobuf_MethodOptions_resize_uninterpreted_option(google_protobuf_MethodOptions * msg,size_t len,upb_arena * arena)2799 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_resize_uninterpreted_option(google_protobuf_MethodOptions *msg, size_t len, upb_arena *arena) {
2800   return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 24), len, UPB_TYPE_MESSAGE, arena);
2801 }
google_protobuf_MethodOptions_add_uninterpreted_option(google_protobuf_MethodOptions * msg,upb_arena * arena)2802 UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MethodOptions_add_uninterpreted_option(google_protobuf_MethodOptions *msg, upb_arena *arena) {
2803   struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
2804   bool ok = _upb_array_append_accessor(
2805       msg, UPB_SIZE(20, 24), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2806   if (!ok) return NULL;
2807   return sub;
2808 }
2809 
2810 /* google.protobuf.UninterpretedOption */
2811 
google_protobuf_UninterpretedOption_new(upb_arena * arena)2812 UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_new(upb_arena *arena) {
2813   return (google_protobuf_UninterpretedOption *)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
2814 }
google_protobuf_UninterpretedOption_parse(const char * buf,size_t size,upb_arena * arena)2815 UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_parse(const char *buf, size_t size,
2816                         upb_arena *arena) {
2817   google_protobuf_UninterpretedOption *ret = google_protobuf_UninterpretedOption_new(arena);
2818   return (ret && upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, arena)) ? ret : NULL;
2819 }
google_protobuf_UninterpretedOption_serialize(const google_protobuf_UninterpretedOption * msg,upb_arena * arena,size_t * len)2820 UPB_INLINE char *google_protobuf_UninterpretedOption_serialize(const google_protobuf_UninterpretedOption *msg, upb_arena *arena, size_t *len) {
2821   return upb_encode(msg, &google_protobuf_UninterpretedOption_msginit, arena, len);
2822 }
2823 
google_protobuf_UninterpretedOption_has_name(const google_protobuf_UninterpretedOption * msg)2824 UPB_INLINE bool google_protobuf_UninterpretedOption_has_name(const google_protobuf_UninterpretedOption *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(56, 80)); }
google_protobuf_UninterpretedOption_name(const google_protobuf_UninterpretedOption * msg,size_t * len)2825 UPB_INLINE const google_protobuf_UninterpretedOption_NamePart* const* google_protobuf_UninterpretedOption_name(const google_protobuf_UninterpretedOption *msg, size_t *len) { return (const google_protobuf_UninterpretedOption_NamePart* const*)_upb_array_accessor(msg, UPB_SIZE(56, 80), len); }
google_protobuf_UninterpretedOption_has_identifier_value(const google_protobuf_UninterpretedOption * msg)2826 UPB_INLINE bool google_protobuf_UninterpretedOption_has_identifier_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 4); }
google_protobuf_UninterpretedOption_identifier_value(const google_protobuf_UninterpretedOption * msg)2827 UPB_INLINE upb_strview google_protobuf_UninterpretedOption_identifier_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(32, 32), upb_strview); }
google_protobuf_UninterpretedOption_has_positive_int_value(const google_protobuf_UninterpretedOption * msg)2828 UPB_INLINE bool google_protobuf_UninterpretedOption_has_positive_int_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 1); }
google_protobuf_UninterpretedOption_positive_int_value(const google_protobuf_UninterpretedOption * msg)2829 UPB_INLINE uint64_t google_protobuf_UninterpretedOption_positive_int_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), uint64_t); }
google_protobuf_UninterpretedOption_has_negative_int_value(const google_protobuf_UninterpretedOption * msg)2830 UPB_INLINE bool google_protobuf_UninterpretedOption_has_negative_int_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 2); }
google_protobuf_UninterpretedOption_negative_int_value(const google_protobuf_UninterpretedOption * msg)2831 UPB_INLINE int64_t google_protobuf_UninterpretedOption_negative_int_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int64_t); }
google_protobuf_UninterpretedOption_has_double_value(const google_protobuf_UninterpretedOption * msg)2832 UPB_INLINE bool google_protobuf_UninterpretedOption_has_double_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 3); }
google_protobuf_UninterpretedOption_double_value(const google_protobuf_UninterpretedOption * msg)2833 UPB_INLINE double google_protobuf_UninterpretedOption_double_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), double); }
google_protobuf_UninterpretedOption_has_string_value(const google_protobuf_UninterpretedOption * msg)2834 UPB_INLINE bool google_protobuf_UninterpretedOption_has_string_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 5); }
google_protobuf_UninterpretedOption_string_value(const google_protobuf_UninterpretedOption * msg)2835 UPB_INLINE upb_strview google_protobuf_UninterpretedOption_string_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(40, 48), upb_strview); }
google_protobuf_UninterpretedOption_has_aggregate_value(const google_protobuf_UninterpretedOption * msg)2836 UPB_INLINE bool google_protobuf_UninterpretedOption_has_aggregate_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 6); }
google_protobuf_UninterpretedOption_aggregate_value(const google_protobuf_UninterpretedOption * msg)2837 UPB_INLINE upb_strview google_protobuf_UninterpretedOption_aggregate_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(48, 64), upb_strview); }
2838 
google_protobuf_UninterpretedOption_mutable_name(google_protobuf_UninterpretedOption * msg,size_t * len)2839 UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_mutable_name(google_protobuf_UninterpretedOption *msg, size_t *len) {
2840   return (google_protobuf_UninterpretedOption_NamePart**)_upb_array_mutable_accessor(msg, UPB_SIZE(56, 80), len);
2841 }
google_protobuf_UninterpretedOption_resize_name(google_protobuf_UninterpretedOption * msg,size_t len,upb_arena * arena)2842 UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_resize_name(google_protobuf_UninterpretedOption *msg, size_t len, upb_arena *arena) {
2843   return (google_protobuf_UninterpretedOption_NamePart**)_upb_array_resize_accessor(msg, UPB_SIZE(56, 80), len, UPB_TYPE_MESSAGE, arena);
2844 }
google_protobuf_UninterpretedOption_add_name(google_protobuf_UninterpretedOption * msg,upb_arena * arena)2845 UPB_INLINE struct google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_add_name(google_protobuf_UninterpretedOption *msg, upb_arena *arena) {
2846   struct google_protobuf_UninterpretedOption_NamePart* sub = (struct google_protobuf_UninterpretedOption_NamePart*)_upb_msg_new(&google_protobuf_UninterpretedOption_NamePart_msginit, arena);
2847   bool ok = _upb_array_append_accessor(
2848       msg, UPB_SIZE(56, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2849   if (!ok) return NULL;
2850   return sub;
2851 }
google_protobuf_UninterpretedOption_set_identifier_value(google_protobuf_UninterpretedOption * msg,upb_strview value)2852 UPB_INLINE void google_protobuf_UninterpretedOption_set_identifier_value(google_protobuf_UninterpretedOption *msg, upb_strview value) {
2853   _upb_sethas(msg, 4);
2854   *UPB_PTR_AT(msg, UPB_SIZE(32, 32), upb_strview) = value;
2855 }
google_protobuf_UninterpretedOption_set_positive_int_value(google_protobuf_UninterpretedOption * msg,uint64_t value)2856 UPB_INLINE void google_protobuf_UninterpretedOption_set_positive_int_value(google_protobuf_UninterpretedOption *msg, uint64_t value) {
2857   _upb_sethas(msg, 1);
2858   *UPB_PTR_AT(msg, UPB_SIZE(8, 8), uint64_t) = value;
2859 }
google_protobuf_UninterpretedOption_set_negative_int_value(google_protobuf_UninterpretedOption * msg,int64_t value)2860 UPB_INLINE void google_protobuf_UninterpretedOption_set_negative_int_value(google_protobuf_UninterpretedOption *msg, int64_t value) {
2861   _upb_sethas(msg, 2);
2862   *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int64_t) = value;
2863 }
google_protobuf_UninterpretedOption_set_double_value(google_protobuf_UninterpretedOption * msg,double value)2864 UPB_INLINE void google_protobuf_UninterpretedOption_set_double_value(google_protobuf_UninterpretedOption *msg, double value) {
2865   _upb_sethas(msg, 3);
2866   *UPB_PTR_AT(msg, UPB_SIZE(24, 24), double) = value;
2867 }
google_protobuf_UninterpretedOption_set_string_value(google_protobuf_UninterpretedOption * msg,upb_strview value)2868 UPB_INLINE void google_protobuf_UninterpretedOption_set_string_value(google_protobuf_UninterpretedOption *msg, upb_strview value) {
2869   _upb_sethas(msg, 5);
2870   *UPB_PTR_AT(msg, UPB_SIZE(40, 48), upb_strview) = value;
2871 }
google_protobuf_UninterpretedOption_set_aggregate_value(google_protobuf_UninterpretedOption * msg,upb_strview value)2872 UPB_INLINE void google_protobuf_UninterpretedOption_set_aggregate_value(google_protobuf_UninterpretedOption *msg, upb_strview value) {
2873   _upb_sethas(msg, 6);
2874   *UPB_PTR_AT(msg, UPB_SIZE(48, 64), upb_strview) = value;
2875 }
2876 
2877 /* google.protobuf.UninterpretedOption.NamePart */
2878 
google_protobuf_UninterpretedOption_NamePart_new(upb_arena * arena)2879 UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_new(upb_arena *arena) {
2880   return (google_protobuf_UninterpretedOption_NamePart *)_upb_msg_new(&google_protobuf_UninterpretedOption_NamePart_msginit, arena);
2881 }
google_protobuf_UninterpretedOption_NamePart_parse(const char * buf,size_t size,upb_arena * arena)2882 UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_parse(const char *buf, size_t size,
2883                         upb_arena *arena) {
2884   google_protobuf_UninterpretedOption_NamePart *ret = google_protobuf_UninterpretedOption_NamePart_new(arena);
2885   return (ret && upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, arena)) ? ret : NULL;
2886 }
google_protobuf_UninterpretedOption_NamePart_serialize(const google_protobuf_UninterpretedOption_NamePart * msg,upb_arena * arena,size_t * len)2887 UPB_INLINE char *google_protobuf_UninterpretedOption_NamePart_serialize(const google_protobuf_UninterpretedOption_NamePart *msg, upb_arena *arena, size_t *len) {
2888   return upb_encode(msg, &google_protobuf_UninterpretedOption_NamePart_msginit, arena, len);
2889 }
2890 
google_protobuf_UninterpretedOption_NamePart_has_name_part(const google_protobuf_UninterpretedOption_NamePart * msg)2891 UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_name_part(const google_protobuf_UninterpretedOption_NamePart *msg) { return _upb_has_field(msg, 2); }
google_protobuf_UninterpretedOption_NamePart_name_part(const google_protobuf_UninterpretedOption_NamePart * msg)2892 UPB_INLINE upb_strview google_protobuf_UninterpretedOption_NamePart_name_part(const google_protobuf_UninterpretedOption_NamePart *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
google_protobuf_UninterpretedOption_NamePart_has_is_extension(const google_protobuf_UninterpretedOption_NamePart * msg)2893 UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_is_extension(const google_protobuf_UninterpretedOption_NamePart *msg) { return _upb_has_field(msg, 1); }
google_protobuf_UninterpretedOption_NamePart_is_extension(const google_protobuf_UninterpretedOption_NamePart * msg)2894 UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_is_extension(const google_protobuf_UninterpretedOption_NamePart *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
2895 
google_protobuf_UninterpretedOption_NamePart_set_name_part(google_protobuf_UninterpretedOption_NamePart * msg,upb_strview value)2896 UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_name_part(google_protobuf_UninterpretedOption_NamePart *msg, upb_strview value) {
2897   _upb_sethas(msg, 2);
2898   *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
2899 }
google_protobuf_UninterpretedOption_NamePart_set_is_extension(google_protobuf_UninterpretedOption_NamePart * msg,bool value)2900 UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_is_extension(google_protobuf_UninterpretedOption_NamePart *msg, bool value) {
2901   _upb_sethas(msg, 1);
2902   *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
2903 }
2904 
2905 /* google.protobuf.SourceCodeInfo */
2906 
google_protobuf_SourceCodeInfo_new(upb_arena * arena)2907 UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_new(upb_arena *arena) {
2908   return (google_protobuf_SourceCodeInfo *)_upb_msg_new(&google_protobuf_SourceCodeInfo_msginit, arena);
2909 }
google_protobuf_SourceCodeInfo_parse(const char * buf,size_t size,upb_arena * arena)2910 UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_parse(const char *buf, size_t size,
2911                         upb_arena *arena) {
2912   google_protobuf_SourceCodeInfo *ret = google_protobuf_SourceCodeInfo_new(arena);
2913   return (ret && upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, arena)) ? ret : NULL;
2914 }
google_protobuf_SourceCodeInfo_serialize(const google_protobuf_SourceCodeInfo * msg,upb_arena * arena,size_t * len)2915 UPB_INLINE char *google_protobuf_SourceCodeInfo_serialize(const google_protobuf_SourceCodeInfo *msg, upb_arena *arena, size_t *len) {
2916   return upb_encode(msg, &google_protobuf_SourceCodeInfo_msginit, arena, len);
2917 }
2918 
google_protobuf_SourceCodeInfo_has_location(const google_protobuf_SourceCodeInfo * msg)2919 UPB_INLINE bool google_protobuf_SourceCodeInfo_has_location(const google_protobuf_SourceCodeInfo *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
google_protobuf_SourceCodeInfo_location(const google_protobuf_SourceCodeInfo * msg,size_t * len)2920 UPB_INLINE const google_protobuf_SourceCodeInfo_Location* const* google_protobuf_SourceCodeInfo_location(const google_protobuf_SourceCodeInfo *msg, size_t *len) { return (const google_protobuf_SourceCodeInfo_Location* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
2921 
google_protobuf_SourceCodeInfo_mutable_location(google_protobuf_SourceCodeInfo * msg,size_t * len)2922 UPB_INLINE google_protobuf_SourceCodeInfo_Location** google_protobuf_SourceCodeInfo_mutable_location(google_protobuf_SourceCodeInfo *msg, size_t *len) {
2923   return (google_protobuf_SourceCodeInfo_Location**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len);
2924 }
google_protobuf_SourceCodeInfo_resize_location(google_protobuf_SourceCodeInfo * msg,size_t len,upb_arena * arena)2925 UPB_INLINE google_protobuf_SourceCodeInfo_Location** google_protobuf_SourceCodeInfo_resize_location(google_protobuf_SourceCodeInfo *msg, size_t len, upb_arena *arena) {
2926   return (google_protobuf_SourceCodeInfo_Location**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_TYPE_MESSAGE, arena);
2927 }
google_protobuf_SourceCodeInfo_add_location(google_protobuf_SourceCodeInfo * msg,upb_arena * arena)2928 UPB_INLINE struct google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_add_location(google_protobuf_SourceCodeInfo *msg, upb_arena *arena) {
2929   struct google_protobuf_SourceCodeInfo_Location* sub = (struct google_protobuf_SourceCodeInfo_Location*)_upb_msg_new(&google_protobuf_SourceCodeInfo_Location_msginit, arena);
2930   bool ok = _upb_array_append_accessor(
2931       msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
2932   if (!ok) return NULL;
2933   return sub;
2934 }
2935 
2936 /* google.protobuf.SourceCodeInfo.Location */
2937 
google_protobuf_SourceCodeInfo_Location_new(upb_arena * arena)2938 UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_new(upb_arena *arena) {
2939   return (google_protobuf_SourceCodeInfo_Location *)_upb_msg_new(&google_protobuf_SourceCodeInfo_Location_msginit, arena);
2940 }
google_protobuf_SourceCodeInfo_Location_parse(const char * buf,size_t size,upb_arena * arena)2941 UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_parse(const char *buf, size_t size,
2942                         upb_arena *arena) {
2943   google_protobuf_SourceCodeInfo_Location *ret = google_protobuf_SourceCodeInfo_Location_new(arena);
2944   return (ret && upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, arena)) ? ret : NULL;
2945 }
google_protobuf_SourceCodeInfo_Location_serialize(const google_protobuf_SourceCodeInfo_Location * msg,upb_arena * arena,size_t * len)2946 UPB_INLINE char *google_protobuf_SourceCodeInfo_Location_serialize(const google_protobuf_SourceCodeInfo_Location *msg, upb_arena *arena, size_t *len) {
2947   return upb_encode(msg, &google_protobuf_SourceCodeInfo_Location_msginit, arena, len);
2948 }
2949 
google_protobuf_SourceCodeInfo_Location_path(const google_protobuf_SourceCodeInfo_Location * msg,size_t * len)2950 UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_path(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); }
google_protobuf_SourceCodeInfo_Location_span(const google_protobuf_SourceCodeInfo_Location * msg,size_t * len)2951 UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_span(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); }
google_protobuf_SourceCodeInfo_Location_has_leading_comments(const google_protobuf_SourceCodeInfo_Location * msg)2952 UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_leading_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return _upb_has_field(msg, 1); }
google_protobuf_SourceCodeInfo_Location_leading_comments(const google_protobuf_SourceCodeInfo_Location * msg)2953 UPB_INLINE upb_strview google_protobuf_SourceCodeInfo_Location_leading_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
google_protobuf_SourceCodeInfo_Location_has_trailing_comments(const google_protobuf_SourceCodeInfo_Location * msg)2954 UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_trailing_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return _upb_has_field(msg, 2); }
google_protobuf_SourceCodeInfo_Location_trailing_comments(const google_protobuf_SourceCodeInfo_Location * msg)2955 UPB_INLINE upb_strview google_protobuf_SourceCodeInfo_Location_trailing_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview); }
google_protobuf_SourceCodeInfo_Location_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location * msg,size_t * len)2956 UPB_INLINE upb_strview const* google_protobuf_SourceCodeInfo_Location_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); }
2957 
google_protobuf_SourceCodeInfo_Location_mutable_path(google_protobuf_SourceCodeInfo_Location * msg,size_t * len)2958 UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_path(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) {
2959   return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len);
2960 }
google_protobuf_SourceCodeInfo_Location_resize_path(google_protobuf_SourceCodeInfo_Location * msg,size_t len,upb_arena * arena)2961 UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_resize_path(google_protobuf_SourceCodeInfo_Location *msg, size_t len, upb_arena *arena) {
2962   return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_TYPE_INT32, arena);
2963 }
google_protobuf_SourceCodeInfo_Location_add_path(google_protobuf_SourceCodeInfo_Location * msg,int32_t val,upb_arena * arena)2964 UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_path(google_protobuf_SourceCodeInfo_Location *msg, int32_t val, upb_arena *arena) {
2965   return _upb_array_append_accessor(msg, UPB_SIZE(20, 40), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val,
2966       arena);
2967 }
google_protobuf_SourceCodeInfo_Location_mutable_span(google_protobuf_SourceCodeInfo_Location * msg,size_t * len)2968 UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_span(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) {
2969   return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len);
2970 }
google_protobuf_SourceCodeInfo_Location_resize_span(google_protobuf_SourceCodeInfo_Location * msg,size_t len,upb_arena * arena)2971 UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_resize_span(google_protobuf_SourceCodeInfo_Location *msg, size_t len, upb_arena *arena) {
2972   return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_TYPE_INT32, arena);
2973 }
google_protobuf_SourceCodeInfo_Location_add_span(google_protobuf_SourceCodeInfo_Location * msg,int32_t val,upb_arena * arena)2974 UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_span(google_protobuf_SourceCodeInfo_Location *msg, int32_t val, upb_arena *arena) {
2975   return _upb_array_append_accessor(msg, UPB_SIZE(24, 48), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val,
2976       arena);
2977 }
google_protobuf_SourceCodeInfo_Location_set_leading_comments(google_protobuf_SourceCodeInfo_Location * msg,upb_strview value)2978 UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_leading_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview value) {
2979   _upb_sethas(msg, 1);
2980   *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
2981 }
google_protobuf_SourceCodeInfo_Location_set_trailing_comments(google_protobuf_SourceCodeInfo_Location * msg,upb_strview value)2982 UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_trailing_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview value) {
2983   _upb_sethas(msg, 2);
2984   *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview) = value;
2985 }
google_protobuf_SourceCodeInfo_Location_mutable_leading_detached_comments(google_protobuf_SourceCodeInfo_Location * msg,size_t * len)2986 UPB_INLINE upb_strview* google_protobuf_SourceCodeInfo_Location_mutable_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) {
2987   return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len);
2988 }
google_protobuf_SourceCodeInfo_Location_resize_leading_detached_comments(google_protobuf_SourceCodeInfo_Location * msg,size_t len,upb_arena * arena)2989 UPB_INLINE upb_strview* google_protobuf_SourceCodeInfo_Location_resize_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, size_t len, upb_arena *arena) {
2990   return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(28, 56), len, UPB_TYPE_STRING, arena);
2991 }
google_protobuf_SourceCodeInfo_Location_add_leading_detached_comments(google_protobuf_SourceCodeInfo_Location * msg,upb_strview val,upb_arena * arena)2992 UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview val, upb_arena *arena) {
2993   return _upb_array_append_accessor(msg, UPB_SIZE(28, 56), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val,
2994       arena);
2995 }
2996 
2997 /* google.protobuf.GeneratedCodeInfo */
2998 
google_protobuf_GeneratedCodeInfo_new(upb_arena * arena)2999 UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_new(upb_arena *arena) {
3000   return (google_protobuf_GeneratedCodeInfo *)_upb_msg_new(&google_protobuf_GeneratedCodeInfo_msginit, arena);
3001 }
google_protobuf_GeneratedCodeInfo_parse(const char * buf,size_t size,upb_arena * arena)3002 UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_parse(const char *buf, size_t size,
3003                         upb_arena *arena) {
3004   google_protobuf_GeneratedCodeInfo *ret = google_protobuf_GeneratedCodeInfo_new(arena);
3005   return (ret && upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, arena)) ? ret : NULL;
3006 }
google_protobuf_GeneratedCodeInfo_serialize(const google_protobuf_GeneratedCodeInfo * msg,upb_arena * arena,size_t * len)3007 UPB_INLINE char *google_protobuf_GeneratedCodeInfo_serialize(const google_protobuf_GeneratedCodeInfo *msg, upb_arena *arena, size_t *len) {
3008   return upb_encode(msg, &google_protobuf_GeneratedCodeInfo_msginit, arena, len);
3009 }
3010 
google_protobuf_GeneratedCodeInfo_has_annotation(const google_protobuf_GeneratedCodeInfo * msg)3011 UPB_INLINE bool google_protobuf_GeneratedCodeInfo_has_annotation(const google_protobuf_GeneratedCodeInfo *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
google_protobuf_GeneratedCodeInfo_annotation(const google_protobuf_GeneratedCodeInfo * msg,size_t * len)3012 UPB_INLINE const google_protobuf_GeneratedCodeInfo_Annotation* const* google_protobuf_GeneratedCodeInfo_annotation(const google_protobuf_GeneratedCodeInfo *msg, size_t *len) { return (const google_protobuf_GeneratedCodeInfo_Annotation* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
3013 
google_protobuf_GeneratedCodeInfo_mutable_annotation(google_protobuf_GeneratedCodeInfo * msg,size_t * len)3014 UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation** google_protobuf_GeneratedCodeInfo_mutable_annotation(google_protobuf_GeneratedCodeInfo *msg, size_t *len) {
3015   return (google_protobuf_GeneratedCodeInfo_Annotation**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len);
3016 }
google_protobuf_GeneratedCodeInfo_resize_annotation(google_protobuf_GeneratedCodeInfo * msg,size_t len,upb_arena * arena)3017 UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation** google_protobuf_GeneratedCodeInfo_resize_annotation(google_protobuf_GeneratedCodeInfo *msg, size_t len, upb_arena *arena) {
3018   return (google_protobuf_GeneratedCodeInfo_Annotation**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_TYPE_MESSAGE, arena);
3019 }
google_protobuf_GeneratedCodeInfo_add_annotation(google_protobuf_GeneratedCodeInfo * msg,upb_arena * arena)3020 UPB_INLINE struct google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_add_annotation(google_protobuf_GeneratedCodeInfo *msg, upb_arena *arena) {
3021   struct google_protobuf_GeneratedCodeInfo_Annotation* sub = (struct google_protobuf_GeneratedCodeInfo_Annotation*)_upb_msg_new(&google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena);
3022   bool ok = _upb_array_append_accessor(
3023       msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
3024   if (!ok) return NULL;
3025   return sub;
3026 }
3027 
3028 /* google.protobuf.GeneratedCodeInfo.Annotation */
3029 
google_protobuf_GeneratedCodeInfo_Annotation_new(upb_arena * arena)3030 UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_new(upb_arena *arena) {
3031   return (google_protobuf_GeneratedCodeInfo_Annotation *)_upb_msg_new(&google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena);
3032 }
google_protobuf_GeneratedCodeInfo_Annotation_parse(const char * buf,size_t size,upb_arena * arena)3033 UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_parse(const char *buf, size_t size,
3034                         upb_arena *arena) {
3035   google_protobuf_GeneratedCodeInfo_Annotation *ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena);
3036   return (ret && upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena)) ? ret : NULL;
3037 }
google_protobuf_GeneratedCodeInfo_Annotation_serialize(const google_protobuf_GeneratedCodeInfo_Annotation * msg,upb_arena * arena,size_t * len)3038 UPB_INLINE char *google_protobuf_GeneratedCodeInfo_Annotation_serialize(const google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_arena *arena, size_t *len) {
3039   return upb_encode(msg, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena, len);
3040 }
3041 
google_protobuf_GeneratedCodeInfo_Annotation_path(const google_protobuf_GeneratedCodeInfo_Annotation * msg,size_t * len)3042 UPB_INLINE int32_t const* google_protobuf_GeneratedCodeInfo_Annotation_path(const google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(20, 32), len); }
google_protobuf_GeneratedCodeInfo_Annotation_has_source_file(const google_protobuf_GeneratedCodeInfo_Annotation * msg)3043 UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_source_file(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_has_field(msg, 3); }
google_protobuf_GeneratedCodeInfo_Annotation_source_file(const google_protobuf_GeneratedCodeInfo_Annotation * msg)3044 UPB_INLINE upb_strview google_protobuf_GeneratedCodeInfo_Annotation_source_file(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 16), upb_strview); }
google_protobuf_GeneratedCodeInfo_Annotation_has_begin(const google_protobuf_GeneratedCodeInfo_Annotation * msg)3045 UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_begin(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_has_field(msg, 1); }
google_protobuf_GeneratedCodeInfo_Annotation_begin(const google_protobuf_GeneratedCodeInfo_Annotation * msg)3046 UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_begin(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
google_protobuf_GeneratedCodeInfo_Annotation_has_end(const google_protobuf_GeneratedCodeInfo_Annotation * msg)3047 UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_end(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_has_field(msg, 2); }
google_protobuf_GeneratedCodeInfo_Annotation_end(const google_protobuf_GeneratedCodeInfo_Annotation * msg)3048 UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_end(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
3049 
google_protobuf_GeneratedCodeInfo_Annotation_mutable_path(google_protobuf_GeneratedCodeInfo_Annotation * msg,size_t * len)3050 UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_mutable_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t *len) {
3051   return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 32), len);
3052 }
google_protobuf_GeneratedCodeInfo_Annotation_resize_path(google_protobuf_GeneratedCodeInfo_Annotation * msg,size_t len,upb_arena * arena)3053 UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_resize_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t len, upb_arena *arena) {
3054   return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(20, 32), len, UPB_TYPE_INT32, arena);
3055 }
google_protobuf_GeneratedCodeInfo_Annotation_add_path(google_protobuf_GeneratedCodeInfo_Annotation * msg,int32_t val,upb_arena * arena)3056 UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_add_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t val, upb_arena *arena) {
3057   return _upb_array_append_accessor(msg, UPB_SIZE(20, 32), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val,
3058       arena);
3059 }
google_protobuf_GeneratedCodeInfo_Annotation_set_source_file(google_protobuf_GeneratedCodeInfo_Annotation * msg,upb_strview value)3060 UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_source_file(google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_strview value) {
3061   _upb_sethas(msg, 3);
3062   *UPB_PTR_AT(msg, UPB_SIZE(12, 16), upb_strview) = value;
3063 }
google_protobuf_GeneratedCodeInfo_Annotation_set_begin(google_protobuf_GeneratedCodeInfo_Annotation * msg,int32_t value)3064 UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_begin(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) {
3065   _upb_sethas(msg, 1);
3066   *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
3067 }
google_protobuf_GeneratedCodeInfo_Annotation_set_end(google_protobuf_GeneratedCodeInfo_Annotation * msg,int32_t value)3068 UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_end(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) {
3069   _upb_sethas(msg, 2);
3070   *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
3071 }
3072 
3073 #ifdef __cplusplus
3074 }  /* extern "C" */
3075 #endif
3076 
3077 
3078 #endif  /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ */
3079 /*
3080 ** Defs are upb's internal representation of the constructs that can appear
3081 ** in a .proto file:
3082 **
3083 ** - upb_msgdef: describes a "message" construct.
3084 ** - upb_fielddef: describes a message field.
3085 ** - upb_filedef: describes a .proto file and its defs.
3086 ** - upb_enumdef: describes an enum.
3087 ** - upb_oneofdef: describes a oneof.
3088 **
3089 ** TODO: definitions of services.
3090 */
3091 
3092 #ifndef UPB_DEF_H_
3093 #define UPB_DEF_H_
3094 
3095 
3096 
3097 #ifdef __cplusplus
3098 extern "C" {
3099 #endif  /* __cplusplus */
3100 
3101 struct upb_enumdef;
3102 typedef struct upb_enumdef upb_enumdef;
3103 struct upb_fielddef;
3104 typedef struct upb_fielddef upb_fielddef;
3105 struct upb_filedef;
3106 typedef struct upb_filedef upb_filedef;
3107 struct upb_msgdef;
3108 typedef struct upb_msgdef upb_msgdef;
3109 struct upb_oneofdef;
3110 typedef struct upb_oneofdef upb_oneofdef;
3111 struct upb_symtab;
3112 typedef struct upb_symtab upb_symtab;
3113 
3114 typedef enum {
3115   UPB_SYNTAX_PROTO2 = 2,
3116   UPB_SYNTAX_PROTO3 = 3
3117 } upb_syntax_t;
3118 
3119 /* All the different kind of well known type messages. For simplicity of check,
3120  * number wrappers and string wrappers are grouped together. Make sure the
3121  * order and merber of these groups are not changed.
3122  */
3123 typedef enum {
3124   UPB_WELLKNOWN_UNSPECIFIED,
3125   UPB_WELLKNOWN_ANY,
3126   UPB_WELLKNOWN_FIELDMASK,
3127   UPB_WELLKNOWN_DURATION,
3128   UPB_WELLKNOWN_TIMESTAMP,
3129   /* number wrappers */
3130   UPB_WELLKNOWN_DOUBLEVALUE,
3131   UPB_WELLKNOWN_FLOATVALUE,
3132   UPB_WELLKNOWN_INT64VALUE,
3133   UPB_WELLKNOWN_UINT64VALUE,
3134   UPB_WELLKNOWN_INT32VALUE,
3135   UPB_WELLKNOWN_UINT32VALUE,
3136   /* string wrappers */
3137   UPB_WELLKNOWN_STRINGVALUE,
3138   UPB_WELLKNOWN_BYTESVALUE,
3139   UPB_WELLKNOWN_BOOLVALUE,
3140   UPB_WELLKNOWN_VALUE,
3141   UPB_WELLKNOWN_LISTVALUE,
3142   UPB_WELLKNOWN_STRUCT
3143 } upb_wellknowntype_t;
3144 
3145 /* upb_fielddef ***************************************************************/
3146 
3147 /* Maximum field number allowed for FieldDefs.  This is an inherent limit of the
3148  * protobuf wire format. */
3149 #define UPB_MAX_FIELDNUMBER ((1 << 29) - 1)
3150 
3151 const char *upb_fielddef_fullname(const upb_fielddef *f);
3152 upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f);
3153 upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f);
3154 upb_label_t upb_fielddef_label(const upb_fielddef *f);
3155 uint32_t upb_fielddef_number(const upb_fielddef *f);
3156 const char *upb_fielddef_name(const upb_fielddef *f);
3157 const char *upb_fielddef_jsonname(const upb_fielddef *f);
3158 bool upb_fielddef_isextension(const upb_fielddef *f);
3159 bool upb_fielddef_lazy(const upb_fielddef *f);
3160 bool upb_fielddef_packed(const upb_fielddef *f);
3161 const upb_filedef *upb_fielddef_file(const upb_fielddef *f);
3162 const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f);
3163 const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f);
3164 const upb_oneofdef *upb_fielddef_realcontainingoneof(const upb_fielddef *f);
3165 uint32_t upb_fielddef_index(const upb_fielddef *f);
3166 bool upb_fielddef_issubmsg(const upb_fielddef *f);
3167 bool upb_fielddef_isstring(const upb_fielddef *f);
3168 bool upb_fielddef_isseq(const upb_fielddef *f);
3169 bool upb_fielddef_isprimitive(const upb_fielddef *f);
3170 bool upb_fielddef_ismap(const upb_fielddef *f);
3171 int64_t upb_fielddef_defaultint64(const upb_fielddef *f);
3172 int32_t upb_fielddef_defaultint32(const upb_fielddef *f);
3173 uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f);
3174 uint32_t upb_fielddef_defaultuint32(const upb_fielddef *f);
3175 bool upb_fielddef_defaultbool(const upb_fielddef *f);
3176 float upb_fielddef_defaultfloat(const upb_fielddef *f);
3177 double upb_fielddef_defaultdouble(const upb_fielddef *f);
3178 const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len);
3179 bool upb_fielddef_hassubdef(const upb_fielddef *f);
3180 bool upb_fielddef_haspresence(const upb_fielddef *f);
3181 const upb_msgdef *upb_fielddef_msgsubdef(const upb_fielddef *f);
3182 const upb_enumdef *upb_fielddef_enumsubdef(const upb_fielddef *f);
3183 const upb_msglayout_field *upb_fielddef_layout(const upb_fielddef *f);
3184 
3185 /* Internal only. */
3186 uint32_t upb_fielddef_selectorbase(const upb_fielddef *f);
3187 
3188 /* upb_oneofdef ***************************************************************/
3189 
3190 typedef upb_inttable_iter upb_oneof_iter;
3191 
3192 const char *upb_oneofdef_name(const upb_oneofdef *o);
3193 const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o);
3194 int upb_oneofdef_numfields(const upb_oneofdef *o);
3195 uint32_t upb_oneofdef_index(const upb_oneofdef *o);
3196 bool upb_oneofdef_issynthetic(const upb_oneofdef *o);
3197 
3198 /* Oneof lookups:
3199  * - ntof:  look up a field by name.
3200  * - ntofz: look up a field by name (as a null-terminated string).
3201  * - itof:  look up a field by number. */
3202 const upb_fielddef *upb_oneofdef_ntof(const upb_oneofdef *o,
3203                                       const char *name, size_t length);
upb_oneofdef_ntofz(const upb_oneofdef * o,const char * name)3204 UPB_INLINE const upb_fielddef *upb_oneofdef_ntofz(const upb_oneofdef *o,
3205                                                   const char *name) {
3206   return upb_oneofdef_ntof(o, name, strlen(name));
3207 }
3208 const upb_fielddef *upb_oneofdef_itof(const upb_oneofdef *o, uint32_t num);
3209 
3210 /*  upb_oneof_iter i;
3211  *  for(upb_oneof_begin(&i, e); !upb_oneof_done(&i); upb_oneof_next(&i)) {
3212  *    // ...
3213  *  }
3214  */
3215 void upb_oneof_begin(upb_oneof_iter *iter, const upb_oneofdef *o);
3216 void upb_oneof_next(upb_oneof_iter *iter);
3217 bool upb_oneof_done(upb_oneof_iter *iter);
3218 upb_fielddef *upb_oneof_iter_field(const upb_oneof_iter *iter);
3219 void upb_oneof_iter_setdone(upb_oneof_iter *iter);
3220 bool upb_oneof_iter_isequal(const upb_oneof_iter *iter1,
3221                             const upb_oneof_iter *iter2);
3222 
3223 /* upb_msgdef *****************************************************************/
3224 
3225 typedef upb_inttable_iter upb_msg_field_iter;
3226 typedef upb_strtable_iter upb_msg_oneof_iter;
3227 
3228 /* Well-known field tag numbers for map-entry messages. */
3229 #define UPB_MAPENTRY_KEY   1
3230 #define UPB_MAPENTRY_VALUE 2
3231 
3232 /* Well-known field tag numbers for Any messages. */
3233 #define UPB_ANY_TYPE 1
3234 #define UPB_ANY_VALUE 2
3235 
3236 /* Well-known field tag numbers for timestamp messages. */
3237 #define UPB_DURATION_SECONDS 1
3238 #define UPB_DURATION_NANOS 2
3239 
3240 /* Well-known field tag numbers for duration messages. */
3241 #define UPB_TIMESTAMP_SECONDS 1
3242 #define UPB_TIMESTAMP_NANOS 2
3243 
3244 const char *upb_msgdef_fullname(const upb_msgdef *m);
3245 const upb_filedef *upb_msgdef_file(const upb_msgdef *m);
3246 const char *upb_msgdef_name(const upb_msgdef *m);
3247 int upb_msgdef_numfields(const upb_msgdef *m);
3248 int upb_msgdef_numoneofs(const upb_msgdef *m);
3249 int upb_msgdef_numrealoneofs(const upb_msgdef *m);
3250 upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m);
3251 bool upb_msgdef_mapentry(const upb_msgdef *m);
3252 upb_wellknowntype_t upb_msgdef_wellknowntype(const upb_msgdef *m);
3253 bool upb_msgdef_isnumberwrapper(const upb_msgdef *m);
3254 const upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i);
3255 const upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name,
3256                                     size_t len);
3257 const upb_oneofdef *upb_msgdef_ntoo(const upb_msgdef *m, const char *name,
3258                                     size_t len);
3259 const upb_msglayout *upb_msgdef_layout(const upb_msgdef *m);
3260 const upb_fielddef *_upb_msgdef_field(const upb_msgdef *m, int i);
3261 
upb_msgdef_ntooz(const upb_msgdef * m,const char * name)3262 UPB_INLINE const upb_oneofdef *upb_msgdef_ntooz(const upb_msgdef *m,
3263                                                const char *name) {
3264   return upb_msgdef_ntoo(m, name, strlen(name));
3265 }
3266 
upb_msgdef_ntofz(const upb_msgdef * m,const char * name)3267 UPB_INLINE const upb_fielddef *upb_msgdef_ntofz(const upb_msgdef *m,
3268                                                 const char *name) {
3269   return upb_msgdef_ntof(m, name, strlen(name));
3270 }
3271 
3272 /* Internal-only. */
3273 size_t upb_msgdef_selectorcount(const upb_msgdef *m);
3274 uint32_t upb_msgdef_submsgfieldcount(const upb_msgdef *m);
3275 
3276 /* Lookup of either field or oneof by name.  Returns whether either was found.
3277  * If the return is true, then the found def will be set, and the non-found
3278  * one set to NULL. */
3279 bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len,
3280                            const upb_fielddef **f, const upb_oneofdef **o);
3281 
upb_msgdef_lookupnamez(const upb_msgdef * m,const char * name,const upb_fielddef ** f,const upb_oneofdef ** o)3282 UPB_INLINE bool upb_msgdef_lookupnamez(const upb_msgdef *m, const char *name,
3283                                        const upb_fielddef **f,
3284                                        const upb_oneofdef **o) {
3285   return upb_msgdef_lookupname(m, name, strlen(name), f, o);
3286 }
3287 
3288 /* Returns a field by either JSON name or regular proto name. */
3289 const upb_fielddef *upb_msgdef_lookupjsonname(const upb_msgdef *m,
3290                                               const char *name, size_t len);
3291 
3292 /* Iteration over fields and oneofs.  For example:
3293  *
3294  * upb_msg_field_iter i;
3295  * for(upb_msg_field_begin(&i, m);
3296  *     !upb_msg_field_done(&i);
3297  *     upb_msg_field_next(&i)) {
3298  *   upb_fielddef *f = upb_msg_iter_field(&i);
3299  *   // ...
3300  * }
3301  *
3302  * For C we don't have separate iterators for const and non-const.
3303  * It is the caller's responsibility to cast the upb_fielddef* to
3304  * const if the upb_msgdef* is const. */
3305 void upb_msg_field_begin(upb_msg_field_iter *iter, const upb_msgdef *m);
3306 void upb_msg_field_next(upb_msg_field_iter *iter);
3307 bool upb_msg_field_done(const upb_msg_field_iter *iter);
3308 upb_fielddef *upb_msg_iter_field(const upb_msg_field_iter *iter);
3309 void upb_msg_field_iter_setdone(upb_msg_field_iter *iter);
3310 bool upb_msg_field_iter_isequal(const upb_msg_field_iter * iter1,
3311                                 const upb_msg_field_iter * iter2);
3312 
3313 /* Similar to above, we also support iterating through the oneofs in a
3314  * msgdef. */
3315 void upb_msg_oneof_begin(upb_msg_oneof_iter * iter, const upb_msgdef *m);
3316 void upb_msg_oneof_next(upb_msg_oneof_iter * iter);
3317 bool upb_msg_oneof_done(const upb_msg_oneof_iter *iter);
3318 const upb_oneofdef *upb_msg_iter_oneof(const upb_msg_oneof_iter *iter);
3319 void upb_msg_oneof_iter_setdone(upb_msg_oneof_iter * iter);
3320 bool upb_msg_oneof_iter_isequal(const upb_msg_oneof_iter *iter1,
3321                                 const upb_msg_oneof_iter *iter2);
3322 
3323 /* upb_enumdef ****************************************************************/
3324 
3325 typedef upb_strtable_iter upb_enum_iter;
3326 
3327 const char *upb_enumdef_fullname(const upb_enumdef *e);
3328 const char *upb_enumdef_name(const upb_enumdef *e);
3329 const upb_filedef *upb_enumdef_file(const upb_enumdef *e);
3330 int32_t upb_enumdef_default(const upb_enumdef *e);
3331 int upb_enumdef_numvals(const upb_enumdef *e);
3332 
3333 /* Enum lookups:
3334  * - ntoi:  look up a name with specified length.
3335  * - ntoiz: look up a name provided as a null-terminated string.
3336  * - iton:  look up an integer, returning the name as a null-terminated
3337  *          string. */
3338 bool upb_enumdef_ntoi(const upb_enumdef *e, const char *name, size_t len,
3339                       int32_t *num);
upb_enumdef_ntoiz(const upb_enumdef * e,const char * name,int32_t * num)3340 UPB_INLINE bool upb_enumdef_ntoiz(const upb_enumdef *e,
3341                                   const char *name, int32_t *num) {
3342   return upb_enumdef_ntoi(e, name, strlen(name), num);
3343 }
3344 const char *upb_enumdef_iton(const upb_enumdef *e, int32_t num);
3345 
3346 /*  upb_enum_iter i;
3347  *  for(upb_enum_begin(&i, e); !upb_enum_done(&i); upb_enum_next(&i)) {
3348  *    // ...
3349  *  }
3350  */
3351 void upb_enum_begin(upb_enum_iter *iter, const upb_enumdef *e);
3352 void upb_enum_next(upb_enum_iter *iter);
3353 bool upb_enum_done(upb_enum_iter *iter);
3354 const char *upb_enum_iter_name(upb_enum_iter *iter);
3355 int32_t upb_enum_iter_number(upb_enum_iter *iter);
3356 
3357 /* upb_filedef ****************************************************************/
3358 
3359 const char *upb_filedef_name(const upb_filedef *f);
3360 const char *upb_filedef_package(const upb_filedef *f);
3361 const char *upb_filedef_phpprefix(const upb_filedef *f);
3362 const char *upb_filedef_phpnamespace(const upb_filedef *f);
3363 upb_syntax_t upb_filedef_syntax(const upb_filedef *f);
3364 int upb_filedef_depcount(const upb_filedef *f);
3365 int upb_filedef_msgcount(const upb_filedef *f);
3366 int upb_filedef_enumcount(const upb_filedef *f);
3367 const upb_filedef *upb_filedef_dep(const upb_filedef *f, int i);
3368 const upb_msgdef *upb_filedef_msg(const upb_filedef *f, int i);
3369 const upb_enumdef *upb_filedef_enum(const upb_filedef *f, int i);
3370 
3371 /* upb_symtab *****************************************************************/
3372 
3373 upb_symtab *upb_symtab_new(void);
3374 void upb_symtab_free(upb_symtab* s);
3375 const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
3376 const upb_msgdef *upb_symtab_lookupmsg2(
3377     const upb_symtab *s, const char *sym, size_t len);
3378 const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
3379 const upb_filedef *upb_symtab_lookupfile(const upb_symtab *s, const char *name);
3380 int upb_symtab_filecount(const upb_symtab *s);
3381 const upb_filedef *upb_symtab_addfile(
3382     upb_symtab *s, const google_protobuf_FileDescriptorProto *file,
3383     upb_status *status);
3384 
3385 /* For generated code only: loads a generated descriptor. */
3386 typedef struct upb_def_init {
3387   struct upb_def_init **deps;     /* Dependencies of this file. */
3388   const upb_msglayout **layouts;  /* Pre-order layouts of all messages. */
3389   const char *filename;
3390   upb_strview descriptor;         /* Serialized descriptor. */
3391 } upb_def_init;
3392 
3393 bool _upb_symtab_loaddefinit(upb_symtab *s, const upb_def_init *init);
3394 
3395 
3396 #ifdef __cplusplus
3397 }  /* extern "C" */
3398 #endif  /* __cplusplus */
3399 
3400 #endif /* UPB_DEF_H_ */
3401 
3402 #ifndef UPB_REFLECTION_H_
3403 #define UPB_REFLECTION_H_
3404 
3405 
3406 
3407 typedef union {
3408   bool bool_val;
3409   float float_val;
3410   double double_val;
3411   int32_t int32_val;
3412   int64_t int64_val;
3413   uint32_t uint32_val;
3414   uint64_t uint64_val;
3415   const upb_map* map_val;
3416   const upb_msg* msg_val;
3417   const upb_array* array_val;
3418   upb_strview str_val;
3419 } upb_msgval;
3420 
3421 typedef union {
3422   upb_map* map;
3423   upb_msg* msg;
3424   upb_array* array;
3425 } upb_mutmsgval;
3426 
3427 /** upb_msg *******************************************************************/
3428 
3429 /* Creates a new message of the given type in the given arena. */
3430 upb_msg *upb_msg_new(const upb_msgdef *m, upb_arena *a);
3431 
3432 /* Returns the value associated with this field. */
3433 upb_msgval upb_msg_get(const upb_msg *msg, const upb_fielddef *f);
3434 
3435 /* Returns a mutable pointer to a map, array, or submessage value.  If the given
3436  * arena is non-NULL this will construct a new object if it was not previously
3437  * present.  May not be called for primitive fields. */
3438 upb_mutmsgval upb_msg_mutable(upb_msg *msg, const upb_fielddef *f, upb_arena *a);
3439 
3440 /* May only be called for fields where upb_fielddef_haspresence(f) == true. */
3441 bool upb_msg_has(const upb_msg *msg, const upb_fielddef *f);
3442 
3443 /* Returns whether any field is set in the oneof. */
3444 bool upb_msg_hasoneof(const upb_msg *msg, const upb_oneofdef *o);
3445 
3446 /* Sets the given field to the given value.  For a msg/array/map/string, the
3447  * value must be in the same arena.  */
3448 void upb_msg_set(upb_msg *msg, const upb_fielddef *f, upb_msgval val,
3449                  upb_arena *a);
3450 
3451 /* Clears any field presence and sets the value back to its default. */
3452 void upb_msg_clearfield(upb_msg *msg, const upb_fielddef *f);
3453 
3454 /* Iterate over present fields.
3455  *
3456  * size_t iter = UPB_MSG_BEGIN;
3457  * const upb_fielddef *f;
3458  * upb_msgval val;
3459  * while (upb_msg_next(msg, m, ext_pool, &f, &val, &iter)) {
3460  *   process_field(f, val);
3461  * }
3462  *
3463  * If ext_pool is NULL, no extensions will be returned.  If the given symtab
3464  * returns extensions that don't match what is in this message, those extensions
3465  * will be skipped.
3466  */
3467 
3468 #define UPB_MSG_BEGIN -1
3469 bool upb_msg_next(const upb_msg *msg, const upb_msgdef *m,
3470                   const upb_symtab *ext_pool, const upb_fielddef **f,
3471                   upb_msgval *val, size_t *iter);
3472 
3473 /* Adds unknown data (serialized protobuf data) to the given message.  The data
3474  * is copied into the message instance. */
3475 void upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
3476                         upb_arena *arena);
3477 
3478 /* Returns a reference to the message's unknown data. */
3479 const char *upb_msg_getunknown(const upb_msg *msg, size_t *len);
3480 
3481 /** upb_array *****************************************************************/
3482 
3483 /* Creates a new array on the given arena that holds elements of this type. */
3484 upb_array *upb_array_new(upb_arena *a, upb_fieldtype_t type);
3485 
3486 /* Returns the size of the array. */
3487 size_t upb_array_size(const upb_array *arr);
3488 
3489 /* Returns the given element, which must be within the array's current size. */
3490 upb_msgval upb_array_get(const upb_array *arr, size_t i);
3491 
3492 /* Sets the given element, which must be within the array's current size. */
3493 void upb_array_set(upb_array *arr, size_t i, upb_msgval val);
3494 
3495 /* Appends an element to the array.  Returns false on allocation failure. */
3496 bool upb_array_append(upb_array *array, upb_msgval val, upb_arena *arena);
3497 
3498 /* Changes the size of a vector.  New elements are initialized to empty/0.
3499  * Returns false on allocation failure. */
3500 bool upb_array_resize(upb_array *array, size_t size, upb_arena *arena);
3501 
3502 /** upb_map *******************************************************************/
3503 
3504 /* Creates a new map on the given arena with the given key/value size. */
3505 upb_map *upb_map_new(upb_arena *a, upb_fieldtype_t key_type,
3506                      upb_fieldtype_t value_type);
3507 
3508 /* Returns the number of entries in the map. */
3509 size_t upb_map_size(const upb_map *map);
3510 
3511 /* Stores a value for the given key into |*val| (or the zero value if the key is
3512  * not present).  Returns whether the key was present.  The |val| pointer may be
3513  * NULL, in which case the function tests whether the given key is present.  */
3514 bool upb_map_get(const upb_map *map, upb_msgval key, upb_msgval *val);
3515 
3516 /* Removes all entries in the map. */
3517 void upb_map_clear(upb_map *map);
3518 
3519 /* Sets the given key to the given value.  Returns true if this was a new key in
3520  * the map, or false if an existing key was replaced. */
3521 bool upb_map_set(upb_map *map, upb_msgval key, upb_msgval val,
3522                  upb_arena *arena);
3523 
3524 /* Deletes this key from the table.  Returns true if the key was present. */
3525 bool upb_map_delete(upb_map *map, upb_msgval key);
3526 
3527 /* Map iteration:
3528  *
3529  * size_t iter = UPB_MAP_BEGIN;
3530  * while (upb_mapiter_next(map, &iter)) {
3531  *   upb_msgval key = upb_mapiter_key(map, iter);
3532  *   upb_msgval val = upb_mapiter_value(map, iter);
3533  *
3534  *   // If mutating is desired.
3535  *   upb_mapiter_setvalue(map, iter, value2);
3536  * }
3537  */
3538 
3539 /* Advances to the next entry.  Returns false if no more entries are present. */
3540 bool upb_mapiter_next(const upb_map *map, size_t *iter);
3541 
3542 /* Returns the key and value for this entry of the map. */
3543 upb_msgval upb_mapiter_key(const upb_map *map, size_t iter);
3544 upb_msgval upb_mapiter_value(const upb_map *map, size_t iter);
3545 
3546 /* Sets the value for this entry.  The iterator must not be done, and the
3547  * iterator must not have been initialized const. */
3548 void upb_mapiter_setvalue(upb_map *map, size_t iter, upb_msgval value);
3549 
3550 
3551 #endif /* UPB_REFLECTION_H_ */
3552 /*
3553 ** upb::Handlers (upb_handlers)
3554 **
3555 ** A upb_handlers is like a virtual table for a upb_msgdef.  Each field of the
3556 ** message can have associated functions that will be called when we are
3557 ** parsing or visiting a stream of data.  This is similar to how handlers work
3558 ** in SAX (the Simple API for XML).
3559 **
3560 ** The handlers have no idea where the data is coming from, so a single set of
3561 ** handlers could be used with two completely different data sources (for
3562 ** example, a parser and a visitor over in-memory objects).  This decoupling is
3563 ** the most important feature of upb, because it allows parsers and serializers
3564 ** to be highly reusable.
3565 **
3566 ** This is a mixed C/C++ interface that offers a full API to both languages.
3567 ** See the top-level README for more information.
3568 */
3569 
3570 #ifndef UPB_HANDLERS_H
3571 #define UPB_HANDLERS_H
3572 
3573 
3574 
3575 #ifdef __cplusplus
3576 namespace upb {
3577 class HandlersPtr;
3578 class HandlerCache;
3579 template <class T> class Handler;
3580 template <class T> struct CanonicalType;
3581 }  /* namespace upb */
3582 #endif
3583 
3584 
3585 /* The maximum depth that the handler graph can have.  This is a resource limit
3586  * for the C stack since we sometimes need to recursively traverse the graph.
3587  * Cycles are ok; the traversal will stop when it detects a cycle, but we must
3588  * hit the cycle before the maximum depth is reached.
3589  *
3590  * If having a single static limit is too inflexible, we can add another variant
3591  * of Handlers::Freeze that allows specifying this as a parameter. */
3592 #define UPB_MAX_HANDLER_DEPTH 64
3593 
3594 /* All the different types of handlers that can be registered.
3595  * Only needed for the advanced functions in upb::Handlers. */
3596 typedef enum {
3597   UPB_HANDLER_INT32,
3598   UPB_HANDLER_INT64,
3599   UPB_HANDLER_UINT32,
3600   UPB_HANDLER_UINT64,
3601   UPB_HANDLER_FLOAT,
3602   UPB_HANDLER_DOUBLE,
3603   UPB_HANDLER_BOOL,
3604   UPB_HANDLER_STARTSTR,
3605   UPB_HANDLER_STRING,
3606   UPB_HANDLER_ENDSTR,
3607   UPB_HANDLER_STARTSUBMSG,
3608   UPB_HANDLER_ENDSUBMSG,
3609   UPB_HANDLER_STARTSEQ,
3610   UPB_HANDLER_ENDSEQ
3611 } upb_handlertype_t;
3612 
3613 #define UPB_HANDLER_MAX (UPB_HANDLER_ENDSEQ+1)
3614 
3615 #define UPB_BREAK NULL
3616 
3617 /* A convenient definition for when no closure is needed. */
3618 extern char _upb_noclosure;
3619 #define UPB_NO_CLOSURE &_upb_noclosure
3620 
3621 /* A selector refers to a specific field handler in the Handlers object
3622  * (for example: the STARTSUBMSG handler for field "field15"). */
3623 typedef int32_t upb_selector_t;
3624 
3625 /* Static selectors for upb::Handlers. */
3626 #define UPB_STARTMSG_SELECTOR 0
3627 #define UPB_ENDMSG_SELECTOR 1
3628 #define UPB_UNKNOWN_SELECTOR 2
3629 #define UPB_STATIC_SELECTOR_COUNT 3  /* Warning: also in upb/def.c. */
3630 
3631 /* Static selectors for upb::BytesHandler. */
3632 #define UPB_STARTSTR_SELECTOR 0
3633 #define UPB_STRING_SELECTOR 1
3634 #define UPB_ENDSTR_SELECTOR 2
3635 
3636 #ifdef __cplusplus
UniquePtrForType()3637 template<class T> const void *UniquePtrForType() {
3638   static const char ch = 0;
3639   return &ch;
3640 }
3641 #endif
3642 
3643 /* upb_handlers ************************************************************/
3644 
3645 /* Handler attributes, to be registered with the handler itself. */
3646 typedef struct {
3647   const void *handler_data;
3648   const void *closure_type;
3649   const void *return_closure_type;
3650   bool alwaysok;
3651 } upb_handlerattr;
3652 
3653 #define UPB_HANDLERATTR_INIT {NULL, NULL, NULL, false}
3654 
3655 /* Bufhandle, data passed along with a buffer to indicate its provenance. */
3656 typedef struct {
3657   /* The beginning of the buffer.  This may be different than the pointer
3658    * passed to a StringBuf handler because the handler may receive data
3659    * that is from the middle or end of a larger buffer. */
3660   const char *buf;
3661 
3662   /* The offset within the attached object where this buffer begins.  Only
3663    * meaningful if there is an attached object. */
3664   size_t objofs;
3665 
3666   /* The attached object (if any) and a pointer representing its type. */
3667   const void *obj;
3668   const void *objtype;
3669 
3670 #ifdef __cplusplus
3671   template <class T>
SetAttachedObject__anon699c251f4c083672   void SetAttachedObject(const T* _obj) {
3673     obj = _obj;
3674     objtype = UniquePtrForType<T>();
3675   }
3676 
3677   template <class T>
GetAttachedObject__anon699c251f4c083678   const T *GetAttachedObject() const {
3679     return objtype == UniquePtrForType<T>() ? static_cast<const T *>(obj)
3680                                             : NULL;
3681   }
3682 #endif
3683 } upb_bufhandle;
3684 
3685 #define UPB_BUFHANDLE_INIT {NULL, 0, NULL, NULL}
3686 
3687 /* Handler function typedefs. */
3688 typedef void upb_handlerfree(void *d);
3689 typedef bool upb_unknown_handlerfunc(void *c, const void *hd, const char *buf,
3690                                      size_t n);
3691 typedef bool upb_startmsg_handlerfunc(void *c, const void*);
3692 typedef bool upb_endmsg_handlerfunc(void *c, const void *, upb_status *status);
3693 typedef void* upb_startfield_handlerfunc(void *c, const void *hd);
3694 typedef bool upb_endfield_handlerfunc(void *c, const void *hd);
3695 typedef bool upb_int32_handlerfunc(void *c, const void *hd, int32_t val);
3696 typedef bool upb_int64_handlerfunc(void *c, const void *hd, int64_t val);
3697 typedef bool upb_uint32_handlerfunc(void *c, const void *hd, uint32_t val);
3698 typedef bool upb_uint64_handlerfunc(void *c, const void *hd, uint64_t val);
3699 typedef bool upb_float_handlerfunc(void *c, const void *hd, float val);
3700 typedef bool upb_double_handlerfunc(void *c, const void *hd, double val);
3701 typedef bool upb_bool_handlerfunc(void *c, const void *hd, bool val);
3702 typedef void *upb_startstr_handlerfunc(void *c, const void *hd,
3703                                        size_t size_hint);
3704 typedef size_t upb_string_handlerfunc(void *c, const void *hd, const char *buf,
3705                                       size_t n, const upb_bufhandle* handle);
3706 
3707 struct upb_handlers;
3708 typedef struct upb_handlers upb_handlers;
3709 
3710 #ifdef __cplusplus
3711 extern "C" {
3712 #endif
3713 
3714 /* Mutating accessors. */
3715 const upb_status *upb_handlers_status(upb_handlers *h);
3716 void upb_handlers_clearerr(upb_handlers *h);
3717 const upb_msgdef *upb_handlers_msgdef(const upb_handlers *h);
3718 bool upb_handlers_addcleanup(upb_handlers *h, void *p, upb_handlerfree *hfree);
3719 bool upb_handlers_setunknown(upb_handlers *h, upb_unknown_handlerfunc *func,
3720                              const upb_handlerattr *attr);
3721 bool upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handlerfunc *func,
3722                               const upb_handlerattr *attr);
3723 bool upb_handlers_setendmsg(upb_handlers *h, upb_endmsg_handlerfunc *func,
3724                             const upb_handlerattr *attr);
3725 bool upb_handlers_setint32(upb_handlers *h, const upb_fielddef *f,
3726                            upb_int32_handlerfunc *func,
3727                            const upb_handlerattr *attr);
3728 bool upb_handlers_setint64(upb_handlers *h, const upb_fielddef *f,
3729                            upb_int64_handlerfunc *func,
3730                            const upb_handlerattr *attr);
3731 bool upb_handlers_setuint32(upb_handlers *h, const upb_fielddef *f,
3732                             upb_uint32_handlerfunc *func,
3733                             const upb_handlerattr *attr);
3734 bool upb_handlers_setuint64(upb_handlers *h, const upb_fielddef *f,
3735                             upb_uint64_handlerfunc *func,
3736                             const upb_handlerattr *attr);
3737 bool upb_handlers_setfloat(upb_handlers *h, const upb_fielddef *f,
3738                            upb_float_handlerfunc *func,
3739                            const upb_handlerattr *attr);
3740 bool upb_handlers_setdouble(upb_handlers *h, const upb_fielddef *f,
3741                             upb_double_handlerfunc *func,
3742                             const upb_handlerattr *attr);
3743 bool upb_handlers_setbool(upb_handlers *h, const upb_fielddef *f,
3744                           upb_bool_handlerfunc *func,
3745                           const upb_handlerattr *attr);
3746 bool upb_handlers_setstartstr(upb_handlers *h, const upb_fielddef *f,
3747                               upb_startstr_handlerfunc *func,
3748                               const upb_handlerattr *attr);
3749 bool upb_handlers_setstring(upb_handlers *h, const upb_fielddef *f,
3750                             upb_string_handlerfunc *func,
3751                             const upb_handlerattr *attr);
3752 bool upb_handlers_setendstr(upb_handlers *h, const upb_fielddef *f,
3753                             upb_endfield_handlerfunc *func,
3754                             const upb_handlerattr *attr);
3755 bool upb_handlers_setstartseq(upb_handlers *h, const upb_fielddef *f,
3756                               upb_startfield_handlerfunc *func,
3757                               const upb_handlerattr *attr);
3758 bool upb_handlers_setstartsubmsg(upb_handlers *h, const upb_fielddef *f,
3759                                  upb_startfield_handlerfunc *func,
3760                                  const upb_handlerattr *attr);
3761 bool upb_handlers_setendsubmsg(upb_handlers *h, const upb_fielddef *f,
3762                                upb_endfield_handlerfunc *func,
3763                                const upb_handlerattr *attr);
3764 bool upb_handlers_setendseq(upb_handlers *h, const upb_fielddef *f,
3765                             upb_endfield_handlerfunc *func,
3766                             const upb_handlerattr *attr);
3767 
3768 /* Read-only accessors. */
3769 const upb_handlers *upb_handlers_getsubhandlers(const upb_handlers *h,
3770                                                 const upb_fielddef *f);
3771 const upb_handlers *upb_handlers_getsubhandlers_sel(const upb_handlers *h,
3772                                                     upb_selector_t sel);
3773 upb_func *upb_handlers_gethandler(const upb_handlers *h, upb_selector_t s,
3774                                   const void **handler_data);
3775 bool upb_handlers_getattr(const upb_handlers *h, upb_selector_t s,
3776                           upb_handlerattr *attr);
3777 
3778 /* "Static" methods */
3779 upb_handlertype_t upb_handlers_getprimitivehandlertype(const upb_fielddef *f);
3780 bool upb_handlers_getselector(const upb_fielddef *f, upb_handlertype_t type,
3781                               upb_selector_t *s);
upb_handlers_getendselector(upb_selector_t start)3782 UPB_INLINE upb_selector_t upb_handlers_getendselector(upb_selector_t start) {
3783   return start + 1;
3784 }
3785 
3786 #ifdef __cplusplus
3787 }  /* extern "C" */
3788 
3789 namespace upb {
3790 typedef upb_handlers Handlers;
3791 }
3792 
3793 /* Convenience macros for creating a Handler object that is wrapped with a
3794  * type-safe wrapper function that converts the "void*" parameters/returns
3795  * of the underlying C API into nice C++ function.
3796  *
3797  * Sample usage:
3798  *   void OnValue1(MyClosure* c, const MyHandlerData* d, int32_t val) {
3799  *     // do stuff ...
3800  *   }
3801  *
3802  *   // Handler that doesn't need any data bound to it.
3803  *   void OnValue2(MyClosure* c, int32_t val) {
3804  *     // do stuff ...
3805  *   }
3806  *
3807  *   // Handler that returns bool so it can return failure if necessary.
3808  *   bool OnValue3(MyClosure* c, int32_t val) {
3809  *     // do stuff ...
3810  *     return ok;
3811  *   }
3812  *
3813  *   // Member function handler.
3814  *   class MyClosure {
3815  *    public:
3816  *     void OnValue(int32_t val) {
3817  *       // do stuff ...
3818  *     }
3819  *   };
3820  *
3821  *   // Takes ownership of the MyHandlerData.
3822  *   handlers->SetInt32Handler(f1, UpbBind(OnValue1, new MyHandlerData(...)));
3823  *   handlers->SetInt32Handler(f2, UpbMakeHandler(OnValue2));
3824  *   handlers->SetInt32Handler(f1, UpbMakeHandler(OnValue3));
3825  *   handlers->SetInt32Handler(f2, UpbMakeHandler(&MyClosure::OnValue));
3826  */
3827 
3828 /* In C++11, the "template" disambiguator can appear even outside templates,
3829  * so all calls can safely use this pair of macros. */
3830 
3831 #define UpbMakeHandler(f) upb::MatchFunc(f).template GetFunc<f>()
3832 
3833 /* We have to be careful to only evaluate "d" once. */
3834 #define UpbBind(f, d) upb::MatchFunc(f).template GetFunc<f>((d))
3835 
3836 /* Handler: a struct that contains the (handler, data, deleter) tuple that is
3837  * used to register all handlers.  Users can Make() these directly but it's
3838  * more convenient to use the UpbMakeHandler/UpbBind macros above. */
3839 template <class T> class upb::Handler {
3840  public:
3841   /* The underlying, handler function signature that upb uses internally. */
3842   typedef T FuncPtr;
3843 
3844   /* Intentionally implicit. */
3845   template <class F> Handler(F func);
~Handler()3846   ~Handler() { UPB_ASSERT(registered_); }
3847 
3848   void AddCleanup(upb_handlers* h) const;
handler()3849   FuncPtr handler() const { return handler_; }
attr()3850   const upb_handlerattr& attr() const { return attr_; }
3851 
3852  private:
3853   Handler(const Handler&) = delete;
3854   Handler& operator=(const Handler&) = delete;
3855 
3856   FuncPtr handler_;
3857   mutable upb_handlerattr attr_;
3858   mutable bool registered_;
3859   void *cleanup_data_;
3860   upb_handlerfree *cleanup_func_;
3861 };
3862 
3863 /* A upb::Handlers object represents the set of handlers associated with a
3864  * message in the graph of messages.  You can think of it as a big virtual
3865  * table with functions corresponding to all the events that can fire while
3866  * parsing or visiting a message of a specific type.
3867  *
3868  * Any handlers that are not set behave as if they had successfully consumed
3869  * the value.  Any unset Start* handlers will propagate their closure to the
3870  * inner frame.
3871  *
3872  * The easiest way to create the *Handler objects needed by the Set* methods is
3873  * with the UpbBind() and UpbMakeHandler() macros; see below. */
3874 class upb::HandlersPtr {
3875  public:
HandlersPtr(upb_handlers * ptr)3876   HandlersPtr(upb_handlers* ptr) : ptr_(ptr) {}
3877 
ptr()3878   upb_handlers* ptr() const { return ptr_; }
3879 
3880   typedef upb_selector_t Selector;
3881   typedef upb_handlertype_t Type;
3882 
3883   typedef Handler<void *(*)(void *, const void *)> StartFieldHandler;
3884   typedef Handler<bool (*)(void *, const void *)> EndFieldHandler;
3885   typedef Handler<bool (*)(void *, const void *)> StartMessageHandler;
3886   typedef Handler<bool (*)(void *, const void *, upb_status *)>
3887       EndMessageHandler;
3888   typedef Handler<void *(*)(void *, const void *, size_t)> StartStringHandler;
3889   typedef Handler<size_t (*)(void *, const void *, const char *, size_t,
3890                              const upb_bufhandle *)>
3891       StringHandler;
3892 
3893   template <class T> struct ValueHandler {
3894     typedef Handler<bool(*)(void *, const void *, T)> H;
3895   };
3896 
3897   typedef ValueHandler<int32_t>::H     Int32Handler;
3898   typedef ValueHandler<int64_t>::H     Int64Handler;
3899   typedef ValueHandler<uint32_t>::H    UInt32Handler;
3900   typedef ValueHandler<uint64_t>::H    UInt64Handler;
3901   typedef ValueHandler<float>::H       FloatHandler;
3902   typedef ValueHandler<double>::H      DoubleHandler;
3903   typedef ValueHandler<bool>::H        BoolHandler;
3904 
3905   /* Any function pointer can be converted to this and converted back to its
3906    * correct type. */
3907   typedef void GenericFunction();
3908 
3909   typedef void HandlersCallback(const void *closure, upb_handlers *h);
3910 
3911   /* Returns the msgdef associated with this handlers object. */
message_def()3912   MessageDefPtr message_def() const {
3913     return MessageDefPtr(upb_handlers_msgdef(ptr()));
3914   }
3915 
3916   /* Adds the given pointer and function to the list of cleanup functions that
3917    * will be run when these handlers are freed.  If this pointer has previously
3918    * been registered, the function returns false and does nothing. */
AddCleanup(void * ptr,upb_handlerfree * cleanup)3919   bool AddCleanup(void *ptr, upb_handlerfree *cleanup) {
3920     return upb_handlers_addcleanup(ptr_, ptr, cleanup);
3921   }
3922 
3923   /* Sets the startmsg handler for the message, which is defined as follows:
3924    *
3925    *   bool startmsg(MyType* closure) {
3926    *     // Called when the message begins.  Returns true if processing should
3927    *     // continue.
3928    *     return true;
3929    *   }
3930    */
SetStartMessageHandler(const StartMessageHandler & h)3931   bool SetStartMessageHandler(const StartMessageHandler &h) {
3932     h.AddCleanup(ptr());
3933     return upb_handlers_setstartmsg(ptr(), h.handler(), &h.attr());
3934   }
3935 
3936   /* Sets the endmsg handler for the message, which is defined as follows:
3937    *
3938    *   bool endmsg(MyType* closure, upb_status *status) {
3939    *     // Called when processing of this message ends, whether in success or
3940    *     // failure.  "status" indicates the final status of processing, and
3941    *     // can also be modified in-place to update the final status.
3942    *   }
3943    */
SetEndMessageHandler(const EndMessageHandler & h)3944   bool SetEndMessageHandler(const EndMessageHandler& h) {
3945     h.AddCleanup(ptr());
3946     return upb_handlers_setendmsg(ptr(), h.handler(), &h.attr());
3947   }
3948 
3949   /* Sets the value handler for the given field, which is defined as follows
3950    * (this is for an int32 field; other field types will pass their native
3951    * C/C++ type for "val"):
3952    *
3953    *   bool OnValue(MyClosure* c, const MyHandlerData* d, int32_t val) {
3954    *     // Called when the field's value is encountered.  "d" contains
3955    *     // whatever data was bound to this field when it was registered.
3956    *     // Returns true if processing should continue.
3957    *     return true;
3958    *   }
3959    *
3960    *   handers->SetInt32Handler(f, UpbBind(OnValue, new MyHandlerData(...)));
3961    *
3962    * The value type must exactly match f->type().
3963    * For example, a handler that takes an int32_t parameter may only be used for
3964    * fields of type UPB_TYPE_INT32 and UPB_TYPE_ENUM.
3965    *
3966    * Returns false if the handler failed to register; in this case the cleanup
3967    * handler (if any) will be called immediately.
3968    */
SetInt32Handler(FieldDefPtr f,const Int32Handler & h)3969   bool SetInt32Handler(FieldDefPtr f, const Int32Handler &h) {
3970     h.AddCleanup(ptr());
3971     return upb_handlers_setint32(ptr(), f.ptr(), h.handler(), &h.attr());
3972   }
3973 
SetInt64Handler(FieldDefPtr f,const Int64Handler & h)3974   bool SetInt64Handler (FieldDefPtr f,  const Int64Handler& h) {
3975     h.AddCleanup(ptr());
3976     return upb_handlers_setint64(ptr(), f.ptr(), h.handler(), &h.attr());
3977   }
3978 
SetUInt32Handler(FieldDefPtr f,const UInt32Handler & h)3979   bool SetUInt32Handler(FieldDefPtr f, const UInt32Handler& h) {
3980     h.AddCleanup(ptr());
3981     return upb_handlers_setuint32(ptr(), f.ptr(), h.handler(), &h.attr());
3982   }
3983 
SetUInt64Handler(FieldDefPtr f,const UInt64Handler & h)3984   bool SetUInt64Handler(FieldDefPtr f, const UInt64Handler& h) {
3985     h.AddCleanup(ptr());
3986     return upb_handlers_setuint64(ptr(), f.ptr(), h.handler(), &h.attr());
3987   }
3988 
SetFloatHandler(FieldDefPtr f,const FloatHandler & h)3989   bool SetFloatHandler (FieldDefPtr f,  const FloatHandler& h) {
3990     h.AddCleanup(ptr());
3991     return upb_handlers_setfloat(ptr(), f.ptr(), h.handler(), &h.attr());
3992   }
3993 
SetDoubleHandler(FieldDefPtr f,const DoubleHandler & h)3994   bool SetDoubleHandler(FieldDefPtr f, const DoubleHandler& h) {
3995     h.AddCleanup(ptr());
3996     return upb_handlers_setdouble(ptr(), f.ptr(), h.handler(), &h.attr());
3997   }
3998 
SetBoolHandler(FieldDefPtr f,const BoolHandler & h)3999   bool SetBoolHandler(FieldDefPtr f, const BoolHandler &h) {
4000     h.AddCleanup(ptr());
4001     return upb_handlers_setbool(ptr(), f.ptr(), h.handler(), &h.attr());
4002   }
4003 
4004   /* Like the previous, but templated on the type on the value (ie. int32).
4005    * This is mostly useful to call from other templates.  To call this you must
4006    * specify the template parameter explicitly, ie:
4007    *   h->SetValueHandler<T>(f, UpbBind(MyHandler<T>, MyData)); */
4008   template <class T>
4009   bool SetValueHandler(
4010       FieldDefPtr f,
4011       const typename ValueHandler<typename CanonicalType<T>::Type>::H &handler);
4012 
4013   /* Sets handlers for a string field, which are defined as follows:
4014    *
4015    *   MySubClosure* startstr(MyClosure* c, const MyHandlerData* d,
4016    *                          size_t size_hint) {
4017    *     // Called when a string value begins.  The return value indicates the
4018    *     // closure for the string.  "size_hint" indicates the size of the
4019    *     // string if it is known, however if the string is length-delimited
4020    *     // and the end-of-string is not available size_hint will be zero.
4021    *     // This case is indistinguishable from the case where the size is
4022    *     // known to be zero.
4023    *     //
4024    *     // TODO(haberman): is it important to distinguish these cases?
4025    *     // If we had ssize_t as a type we could make -1 "unknown", but
4026    *     // ssize_t is POSIX (not ANSI) and therefore less portable.
4027    *     // In practice I suspect it won't be important to distinguish.
4028    *     return closure;
4029    *   }
4030    *
4031    *   size_t str(MyClosure* closure, const MyHandlerData* d,
4032    *              const char *str, size_t len) {
4033    *     // Called for each buffer of string data; the multiple physical buffers
4034    *     // are all part of the same logical string.  The return value indicates
4035    *     // how many bytes were consumed.  If this number is less than "len",
4036    *     // this will also indicate that processing should be halted for now,
4037    *     // like returning false or UPB_BREAK from any other callback.  If
4038    *     // number is greater than "len", the excess bytes will be skipped over
4039    *     // and not passed to the callback.
4040    *     return len;
4041    *   }
4042    *
4043    *   bool endstr(MyClosure* c, const MyHandlerData* d) {
4044    *     // Called when a string value ends.  Return value indicates whether
4045    *     // processing should continue.
4046    *     return true;
4047    *   }
4048    */
SetStartStringHandler(FieldDefPtr f,const StartStringHandler & h)4049   bool SetStartStringHandler(FieldDefPtr f, const StartStringHandler &h) {
4050     h.AddCleanup(ptr());
4051     return upb_handlers_setstartstr(ptr(), f.ptr(), h.handler(), &h.attr());
4052   }
4053 
SetStringHandler(FieldDefPtr f,const StringHandler & h)4054   bool SetStringHandler(FieldDefPtr f, const StringHandler& h) {
4055     h.AddCleanup(ptr());
4056     return upb_handlers_setstring(ptr(), f.ptr(), h.handler(), &h.attr());
4057   }
4058 
SetEndStringHandler(FieldDefPtr f,const EndFieldHandler & h)4059   bool SetEndStringHandler(FieldDefPtr f, const EndFieldHandler& h) {
4060     h.AddCleanup(ptr());
4061     return upb_handlers_setendstr(ptr(), f.ptr(), h.handler(), &h.attr());
4062   }
4063 
4064   /* Sets the startseq handler, which is defined as follows:
4065    *
4066    *   MySubClosure *startseq(MyClosure* c, const MyHandlerData* d) {
4067    *     // Called when a sequence (repeated field) begins.  The returned
4068    *     // pointer indicates the closure for the sequence (or UPB_BREAK
4069    *     // to interrupt processing).
4070    *     return closure;
4071    *   }
4072    *
4073    *   h->SetStartSequenceHandler(f, UpbBind(startseq, new MyHandlerData(...)));
4074    *
4075    * Returns "false" if "f" does not belong to this message or is not a
4076    * repeated field.
4077    */
SetStartSequenceHandler(FieldDefPtr f,const StartFieldHandler & h)4078   bool SetStartSequenceHandler(FieldDefPtr f, const StartFieldHandler &h) {
4079     h.AddCleanup(ptr());
4080     return upb_handlers_setstartseq(ptr(), f.ptr(), h.handler(), &h.attr());
4081   }
4082 
4083   /* Sets the startsubmsg handler for the given field, which is defined as
4084    * follows:
4085    *
4086    *   MySubClosure* startsubmsg(MyClosure* c, const MyHandlerData* d) {
4087    *     // Called when a submessage begins.  The returned pointer indicates the
4088    *     // closure for the sequence (or UPB_BREAK to interrupt processing).
4089    *     return closure;
4090    *   }
4091    *
4092    *   h->SetStartSubMessageHandler(f, UpbBind(startsubmsg,
4093    *                                           new MyHandlerData(...)));
4094    *
4095    * Returns "false" if "f" does not belong to this message or is not a
4096    * submessage/group field.
4097    */
SetStartSubMessageHandler(FieldDefPtr f,const StartFieldHandler & h)4098   bool SetStartSubMessageHandler(FieldDefPtr f, const StartFieldHandler& h) {
4099     h.AddCleanup(ptr());
4100     return upb_handlers_setstartsubmsg(ptr(), f.ptr(), h.handler(), &h.attr());
4101   }
4102 
4103   /* Sets the endsubmsg handler for the given field, which is defined as
4104    * follows:
4105    *
4106    *   bool endsubmsg(MyClosure* c, const MyHandlerData* d) {
4107    *     // Called when a submessage ends.  Returns true to continue processing.
4108    *     return true;
4109    *   }
4110    *
4111    * Returns "false" if "f" does not belong to this message or is not a
4112    * submessage/group field.
4113    */
SetEndSubMessageHandler(FieldDefPtr f,const EndFieldHandler & h)4114   bool SetEndSubMessageHandler(FieldDefPtr f, const EndFieldHandler &h) {
4115     h.AddCleanup(ptr());
4116     return upb_handlers_setendsubmsg(ptr(), f.ptr(), h.handler(), &h.attr());
4117   }
4118 
4119   /* Starts the endsubseq handler for the given field, which is defined as
4120    * follows:
4121    *
4122    *   bool endseq(MyClosure* c, const MyHandlerData* d) {
4123    *     // Called when a sequence ends.  Returns true continue processing.
4124    *     return true;
4125    *   }
4126    *
4127    * Returns "false" if "f" does not belong to this message or is not a
4128    * repeated field.
4129    */
SetEndSequenceHandler(FieldDefPtr f,const EndFieldHandler & h)4130   bool SetEndSequenceHandler(FieldDefPtr f, const EndFieldHandler &h) {
4131     h.AddCleanup(ptr());
4132     return upb_handlers_setendseq(ptr(), f.ptr(), h.handler(), &h.attr());
4133   }
4134 
4135  private:
4136   upb_handlers* ptr_;
4137 };
4138 
4139 #endif  /* __cplusplus */
4140 
4141 /* upb_handlercache ***********************************************************/
4142 
4143 /* A upb_handlercache lazily builds and caches upb_handlers.  You pass it a
4144  * function (with optional closure) that can build handlers for a given
4145  * message on-demand, and the cache maintains a map of msgdef->handlers. */
4146 
4147 #ifdef __cplusplus
4148 extern "C" {
4149 #endif
4150 
4151 struct upb_handlercache;
4152 typedef struct upb_handlercache upb_handlercache;
4153 
4154 typedef void upb_handlers_callback(const void *closure, upb_handlers *h);
4155 
4156 upb_handlercache *upb_handlercache_new(upb_handlers_callback *callback,
4157                                        const void *closure);
4158 void upb_handlercache_free(upb_handlercache *cache);
4159 const upb_handlers *upb_handlercache_get(upb_handlercache *cache,
4160                                          const upb_msgdef *md);
4161 bool upb_handlercache_addcleanup(upb_handlercache *h, void *p,
4162                                  upb_handlerfree *hfree);
4163 
4164 #ifdef __cplusplus
4165 }  /* extern "C" */
4166 
4167 class upb::HandlerCache {
4168  public:
HandlerCache(upb_handlers_callback * callback,const void * closure)4169   HandlerCache(upb_handlers_callback *callback, const void *closure)
4170       : ptr_(upb_handlercache_new(callback, closure), upb_handlercache_free) {}
4171   HandlerCache(HandlerCache&&) = default;
4172   HandlerCache& operator=(HandlerCache&&) = default;
HandlerCache(upb_handlercache * c)4173   HandlerCache(upb_handlercache* c) : ptr_(c, upb_handlercache_free) {}
4174 
ptr()4175   upb_handlercache* ptr() { return ptr_.get(); }
4176 
Get(MessageDefPtr md)4177   const upb_handlers *Get(MessageDefPtr md) {
4178     return upb_handlercache_get(ptr_.get(), md.ptr());
4179   }
4180 
4181  private:
4182   std::unique_ptr<upb_handlercache, decltype(&upb_handlercache_free)> ptr_;
4183 };
4184 
4185 #endif  /* __cplusplus */
4186 
4187 /* upb_byteshandler ***********************************************************/
4188 
4189 typedef struct {
4190   upb_func *func;
4191 
4192   /* It is wasteful to include the entire attributes here:
4193    *
4194    * * Some of the information is redundant (like storing the closure type
4195    *   separately for each handler that must match).
4196    * * Some of the info is only needed prior to freeze() (like closure types).
4197    * * alignment padding wastes a lot of space for alwaysok_.
4198    *
4199    * If/when the size and locality of handlers is an issue, we can optimize this
4200    * not to store the entire attr like this.  We do not expose the table's
4201    * layout to allow this optimization in the future. */
4202   upb_handlerattr attr;
4203 } upb_handlers_tabent;
4204 
4205 #define UPB_TABENT_INIT {NULL, UPB_HANDLERATTR_INIT}
4206 
4207 typedef struct {
4208   upb_handlers_tabent table[3];
4209 } upb_byteshandler;
4210 
4211 #define UPB_BYTESHANDLER_INIT                             \
4212   {                                                       \
4213     { UPB_TABENT_INIT, UPB_TABENT_INIT, UPB_TABENT_INIT } \
4214   }
4215 
upb_byteshandler_init(upb_byteshandler * handler)4216 UPB_INLINE void upb_byteshandler_init(upb_byteshandler *handler) {
4217   upb_byteshandler init = UPB_BYTESHANDLER_INIT;
4218   *handler = init;
4219 }
4220 
4221 #ifdef __cplusplus
4222 extern "C" {
4223 #endif
4224 
4225 /* Caller must ensure that "d" outlives the handlers. */
4226 bool upb_byteshandler_setstartstr(upb_byteshandler *h,
4227                                   upb_startstr_handlerfunc *func, void *d);
4228 bool upb_byteshandler_setstring(upb_byteshandler *h,
4229                                 upb_string_handlerfunc *func, void *d);
4230 bool upb_byteshandler_setendstr(upb_byteshandler *h,
4231                                 upb_endfield_handlerfunc *func, void *d);
4232 
4233 #ifdef __cplusplus
4234 }  /* extern "C" */
4235 
4236 namespace upb {
4237 typedef upb_byteshandler BytesHandler;
4238 }
4239 #endif
4240 
4241 /** Message handlers ******************************************************************/
4242 
4243 #ifdef __cplusplus
4244 extern "C" {
4245 #endif
4246 
4247 /* These are the handlers used internally by upb_msgfactory_getmergehandlers().
4248  * They write scalar data to a known offset from the message pointer.
4249  *
4250  * These would be trivial for anyone to implement themselves, but it's better
4251  * to use these because some JITs will recognize and specialize these instead
4252  * of actually calling the function. */
4253 
4254 /* Sets a handler for the given primitive field that will write the data at the
4255  * given offset.  If hasbit > 0, also sets a hasbit at the given bit offset
4256  * (addressing each byte low to high). */
4257 bool upb_msg_setscalarhandler(upb_handlers *h,
4258                               const upb_fielddef *f,
4259                               size_t offset,
4260                               int32_t hasbit);
4261 
4262 /* If the given handler is a msghandlers_primitive field, returns true and sets
4263  * *type, *offset and *hasbit.  Otherwise returns false. */
4264 bool upb_msg_getscalarhandlerdata(const upb_handlers *h,
4265                                   upb_selector_t s,
4266                                   upb_fieldtype_t *type,
4267                                   size_t *offset,
4268                                   int32_t *hasbit);
4269 
4270 
4271 
4272 #ifdef __cplusplus
4273 }  /* extern "C" */
4274 #endif
4275 
4276 
4277 /*
4278 ** Inline definitions for handlers.h, which are particularly long and a bit
4279 ** tricky.
4280 */
4281 
4282 #ifndef UPB_HANDLERS_INL_H_
4283 #define UPB_HANDLERS_INL_H_
4284 
4285 #include <limits.h>
4286 #include <stddef.h>
4287 
4288 
4289 #ifdef __cplusplus
4290 
4291 /* Type detection and typedefs for integer types.
4292  * For platforms where there are multiple 32-bit or 64-bit types, we need to be
4293  * able to enumerate them so we can properly create overloads for all variants.
4294  *
4295  * If any platform existed where there were three integer types with the same
4296  * size, this would have to become more complicated.  For example, short, int,
4297  * and long could all be 32-bits.  Even more diabolically, short, int, long,
4298  * and long long could all be 64 bits and still be standard-compliant.
4299  * However, few platforms are this strange, and it's unlikely that upb will be
4300  * used on the strangest ones. */
4301 
4302 /* Can't count on stdint.h limits like INT32_MAX, because in C++ these are
4303  * only defined when __STDC_LIMIT_MACROS are defined before the *first* include
4304  * of stdint.h.  We can't guarantee that someone else didn't include these first
4305  * without defining __STDC_LIMIT_MACROS. */
4306 #define UPB_INT32_MAX 0x7fffffffLL
4307 #define UPB_INT32_MIN (-UPB_INT32_MAX - 1)
4308 #define UPB_INT64_MAX 0x7fffffffffffffffLL
4309 #define UPB_INT64_MIN (-UPB_INT64_MAX - 1)
4310 
4311 #if INT_MAX == UPB_INT32_MAX && INT_MIN == UPB_INT32_MIN
4312 #define UPB_INT_IS_32BITS 1
4313 #endif
4314 
4315 #if LONG_MAX == UPB_INT32_MAX && LONG_MIN == UPB_INT32_MIN
4316 #define UPB_LONG_IS_32BITS 1
4317 #endif
4318 
4319 #if LONG_MAX == UPB_INT64_MAX && LONG_MIN == UPB_INT64_MIN
4320 #define UPB_LONG_IS_64BITS 1
4321 #endif
4322 
4323 #if LLONG_MAX == UPB_INT64_MAX && LLONG_MIN == UPB_INT64_MIN
4324 #define UPB_LLONG_IS_64BITS 1
4325 #endif
4326 
4327 /* We use macros instead of typedefs so we can undefine them later and avoid
4328  * leaking them outside this header file. */
4329 #if UPB_INT_IS_32BITS
4330 #define UPB_INT32_T int
4331 #define UPB_UINT32_T unsigned int
4332 
4333 #if UPB_LONG_IS_32BITS
4334 #define UPB_TWO_32BIT_TYPES 1
4335 #define UPB_INT32ALT_T long
4336 #define UPB_UINT32ALT_T unsigned long
4337 #endif  /* UPB_LONG_IS_32BITS */
4338 
4339 #elif UPB_LONG_IS_32BITS  /* && !UPB_INT_IS_32BITS */
4340 #define UPB_INT32_T long
4341 #define UPB_UINT32_T unsigned long
4342 #endif  /* UPB_INT_IS_32BITS */
4343 
4344 
4345 #if UPB_LONG_IS_64BITS
4346 #define UPB_INT64_T long
4347 #define UPB_UINT64_T unsigned long
4348 
4349 #if UPB_LLONG_IS_64BITS
4350 #define UPB_TWO_64BIT_TYPES 1
4351 #define UPB_INT64ALT_T long long
4352 #define UPB_UINT64ALT_T unsigned long long
4353 #endif  /* UPB_LLONG_IS_64BITS */
4354 
4355 #elif UPB_LLONG_IS_64BITS  /* && !UPB_LONG_IS_64BITS */
4356 #define UPB_INT64_T long long
4357 #define UPB_UINT64_T unsigned long long
4358 #endif  /* UPB_LONG_IS_64BITS */
4359 
4360 #undef UPB_INT32_MAX
4361 #undef UPB_INT32_MIN
4362 #undef UPB_INT64_MAX
4363 #undef UPB_INT64_MIN
4364 #undef UPB_INT_IS_32BITS
4365 #undef UPB_LONG_IS_32BITS
4366 #undef UPB_LONG_IS_64BITS
4367 #undef UPB_LLONG_IS_64BITS
4368 
4369 
4370 namespace upb {
4371 
4372 typedef void CleanupFunc(void *ptr);
4373 
4374 /* Template to remove "const" from "const T*" and just return "T*".
4375  *
4376  * We define a nonsense default because otherwise it will fail to instantiate as
4377  * a function parameter type even in cases where we don't expect any caller to
4378  * actually match the overload. */
4379 class CouldntRemoveConst {};
4380 template <class T> struct remove_constptr { typedef CouldntRemoveConst type; };
4381 template <class T> struct remove_constptr<const T *> { typedef T *type; };
4382 
4383 /* Template that we use below to remove a template specialization from
4384  * consideration if it matches a specific type. */
4385 template <class T, class U> struct disable_if_same { typedef void Type; };
4386 template <class T> struct disable_if_same<T, T> {};
4387 
4388 template <class T> void DeletePointer(void *p) { delete static_cast<T>(p); }
4389 
4390 template <class T1, class T2>
4391 struct FirstUnlessVoidOrBool {
4392   typedef T1 value;
4393 };
4394 
4395 template <class T2>
4396 struct FirstUnlessVoidOrBool<void, T2> {
4397   typedef T2 value;
4398 };
4399 
4400 template <class T2>
4401 struct FirstUnlessVoidOrBool<bool, T2> {
4402   typedef T2 value;
4403 };
4404 
4405 template<class T, class U>
4406 struct is_same {
4407   static bool value;
4408 };
4409 
4410 template<class T>
4411 struct is_same<T, T> {
4412   static bool value;
4413 };
4414 
4415 template<class T, class U>
4416 bool is_same<T, U>::value = false;
4417 
4418 template<class T>
4419 bool is_same<T, T>::value = true;
4420 
4421 /* FuncInfo *******************************************************************/
4422 
4423 /* Info about the user's original, pre-wrapped function. */
4424 template <class C, class R = void>
4425 struct FuncInfo {
4426   /* The type of the closure that the function takes (its first param). */
4427   typedef C Closure;
4428 
4429   /* The return type. */
4430   typedef R Return;
4431 };
4432 
4433 /* Func ***********************************************************************/
4434 
4435 /* Func1, Func2, Func3: Template classes representing a function and its
4436  * signature.
4437  *
4438  * Since the function is a template parameter, calling the function can be
4439  * inlined at compile-time and does not require a function pointer at runtime.
4440  * These functions are not bound to a handler data so have no data or cleanup
4441  * handler. */
4442 struct UnboundFunc {
4443   CleanupFunc *GetCleanup() { return nullptr; }
4444   void *GetData() { return nullptr; }
4445 };
4446 
4447 template <class R, class P1, R F(P1), class I>
4448 struct Func1 : public UnboundFunc {
4449   typedef R Return;
4450   typedef I FuncInfo;
4451   static R Call(P1 p1) { return F(p1); }
4452 };
4453 
4454 template <class R, class P1, class P2, R F(P1, P2), class I>
4455 struct Func2 : public UnboundFunc {
4456   typedef R Return;
4457   typedef I FuncInfo;
4458   static R Call(P1 p1, P2 p2) { return F(p1, p2); }
4459 };
4460 
4461 template <class R, class P1, class P2, class P3, R F(P1, P2, P3), class I>
4462 struct Func3 : public UnboundFunc {
4463   typedef R Return;
4464   typedef I FuncInfo;
4465   static R Call(P1 p1, P2 p2, P3 p3) { return F(p1, p2, p3); }
4466 };
4467 
4468 template <class R, class P1, class P2, class P3, class P4, R F(P1, P2, P3, P4),
4469           class I>
4470 struct Func4 : public UnboundFunc {
4471   typedef R Return;
4472   typedef I FuncInfo;
4473   static R Call(P1 p1, P2 p2, P3 p3, P4 p4) { return F(p1, p2, p3, p4); }
4474 };
4475 
4476 template <class R, class P1, class P2, class P3, class P4, class P5,
4477           R F(P1, P2, P3, P4, P5), class I>
4478 struct Func5 : public UnboundFunc {
4479   typedef R Return;
4480   typedef I FuncInfo;
4481   static R Call(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
4482     return F(p1, p2, p3, p4, p5);
4483   }
4484 };
4485 
4486 /* BoundFunc ******************************************************************/
4487 
4488 /* BoundFunc2, BoundFunc3: Like Func2/Func3 except also contains a value that
4489  * shall be bound to the function's second parameter.
4490  *
4491  * Note that the second parameter is a const pointer, but our stored bound value
4492  * is non-const so we can free it when the handlers are destroyed. */
4493 template <class T>
4494 struct BoundFunc {
4495   typedef typename remove_constptr<T>::type MutableP2;
4496   explicit BoundFunc(MutableP2 data_) : data(data_) {}
4497   CleanupFunc *GetCleanup() { return &DeletePointer<MutableP2>; }
4498   MutableP2 GetData() { return data; }
4499   MutableP2 data;
4500 };
4501 
4502 template <class R, class P1, class P2, R F(P1, P2), class I>
4503 struct BoundFunc2 : public BoundFunc<P2> {
4504   typedef BoundFunc<P2> Base;
4505   typedef I FuncInfo;
4506   explicit BoundFunc2(typename Base::MutableP2 arg) : Base(arg) {}
4507 };
4508 
4509 template <class R, class P1, class P2, class P3, R F(P1, P2, P3), class I>
4510 struct BoundFunc3 : public BoundFunc<P2> {
4511   typedef BoundFunc<P2> Base;
4512   typedef I FuncInfo;
4513   explicit BoundFunc3(typename Base::MutableP2 arg) : Base(arg) {}
4514 };
4515 
4516 template <class R, class P1, class P2, class P3, class P4, R F(P1, P2, P3, P4),
4517           class I>
4518 struct BoundFunc4 : public BoundFunc<P2> {
4519   typedef BoundFunc<P2> Base;
4520   typedef I FuncInfo;
4521   explicit BoundFunc4(typename Base::MutableP2 arg) : Base(arg) {}
4522 };
4523 
4524 template <class R, class P1, class P2, class P3, class P4, class P5,
4525           R F(P1, P2, P3, P4, P5), class I>
4526 struct BoundFunc5 : public BoundFunc<P2> {
4527   typedef BoundFunc<P2> Base;
4528   typedef I FuncInfo;
4529   explicit BoundFunc5(typename Base::MutableP2 arg) : Base(arg) {}
4530 };
4531 
4532 /* FuncSig ********************************************************************/
4533 
4534 /* FuncSig1, FuncSig2, FuncSig3: template classes reflecting a function
4535  * *signature*, but without a specific function attached.
4536  *
4537  * These classes contain member functions that can be invoked with a
4538  * specific function to return a Func/BoundFunc class. */
4539 template <class R, class P1>
4540 struct FuncSig1 {
4541   template <R F(P1)>
4542   Func1<R, P1, F, FuncInfo<P1, R> > GetFunc() {
4543     return Func1<R, P1, F, FuncInfo<P1, R> >();
4544   }
4545 };
4546 
4547 template <class R, class P1, class P2>
4548 struct FuncSig2 {
4549   template <R F(P1, P2)>
4550   Func2<R, P1, P2, F, FuncInfo<P1, R> > GetFunc() {
4551     return Func2<R, P1, P2, F, FuncInfo<P1, R> >();
4552   }
4553 
4554   template <R F(P1, P2)>
4555   BoundFunc2<R, P1, P2, F, FuncInfo<P1, R> > GetFunc(
4556       typename remove_constptr<P2>::type param2) {
4557     return BoundFunc2<R, P1, P2, F, FuncInfo<P1, R> >(param2);
4558   }
4559 };
4560 
4561 template <class R, class P1, class P2, class P3>
4562 struct FuncSig3 {
4563   template <R F(P1, P2, P3)>
4564   Func3<R, P1, P2, P3, F, FuncInfo<P1, R> > GetFunc() {
4565     return Func3<R, P1, P2, P3, F, FuncInfo<P1, R> >();
4566   }
4567 
4568   template <R F(P1, P2, P3)>
4569   BoundFunc3<R, P1, P2, P3, F, FuncInfo<P1, R> > GetFunc(
4570       typename remove_constptr<P2>::type param2) {
4571     return BoundFunc3<R, P1, P2, P3, F, FuncInfo<P1, R> >(param2);
4572   }
4573 };
4574 
4575 template <class R, class P1, class P2, class P3, class P4>
4576 struct FuncSig4 {
4577   template <R F(P1, P2, P3, P4)>
4578   Func4<R, P1, P2, P3, P4, F, FuncInfo<P1, R> > GetFunc() {
4579     return Func4<R, P1, P2, P3, P4, F, FuncInfo<P1, R> >();
4580   }
4581 
4582   template <R F(P1, P2, P3, P4)>
4583   BoundFunc4<R, P1, P2, P3, P4, F, FuncInfo<P1, R> > GetFunc(
4584       typename remove_constptr<P2>::type param2) {
4585     return BoundFunc4<R, P1, P2, P3, P4, F, FuncInfo<P1, R> >(param2);
4586   }
4587 };
4588 
4589 template <class R, class P1, class P2, class P3, class P4, class P5>
4590 struct FuncSig5 {
4591   template <R F(P1, P2, P3, P4, P5)>
4592   Func5<R, P1, P2, P3, P4, P5, F, FuncInfo<P1, R> > GetFunc() {
4593     return Func5<R, P1, P2, P3, P4, P5, F, FuncInfo<P1, R> >();
4594   }
4595 
4596   template <R F(P1, P2, P3, P4, P5)>
4597   BoundFunc5<R, P1, P2, P3, P4, P5, F, FuncInfo<P1, R> > GetFunc(
4598       typename remove_constptr<P2>::type param2) {
4599     return BoundFunc5<R, P1, P2, P3, P4, P5, F, FuncInfo<P1, R> >(param2);
4600   }
4601 };
4602 
4603 /* Overloaded template function that can construct the appropriate FuncSig*
4604  * class given a function pointer by deducing the template parameters. */
4605 template <class R, class P1>
4606 inline FuncSig1<R, P1> MatchFunc(R (*f)(P1)) {
4607   UPB_UNUSED(f);  /* Only used for template parameter deduction. */
4608   return FuncSig1<R, P1>();
4609 }
4610 
4611 template <class R, class P1, class P2>
4612 inline FuncSig2<R, P1, P2> MatchFunc(R (*f)(P1, P2)) {
4613   UPB_UNUSED(f);  /* Only used for template parameter deduction. */
4614   return FuncSig2<R, P1, P2>();
4615 }
4616 
4617 template <class R, class P1, class P2, class P3>
4618 inline FuncSig3<R, P1, P2, P3> MatchFunc(R (*f)(P1, P2, P3)) {
4619   UPB_UNUSED(f);  /* Only used for template parameter deduction. */
4620   return FuncSig3<R, P1, P2, P3>();
4621 }
4622 
4623 template <class R, class P1, class P2, class P3, class P4>
4624 inline FuncSig4<R, P1, P2, P3, P4> MatchFunc(R (*f)(P1, P2, P3, P4)) {
4625   UPB_UNUSED(f);  /* Only used for template parameter deduction. */
4626   return FuncSig4<R, P1, P2, P3, P4>();
4627 }
4628 
4629 template <class R, class P1, class P2, class P3, class P4, class P5>
4630 inline FuncSig5<R, P1, P2, P3, P4, P5> MatchFunc(R (*f)(P1, P2, P3, P4, P5)) {
4631   UPB_UNUSED(f);  /* Only used for template parameter deduction. */
4632   return FuncSig5<R, P1, P2, P3, P4, P5>();
4633 }
4634 
4635 /* MethodSig ******************************************************************/
4636 
4637 /* CallMethod*: a function template that calls a given method. */
4638 template <class R, class C, R (C::*F)()>
4639 R CallMethod0(C *obj) {
4640   return ((*obj).*F)();
4641 }
4642 
4643 template <class R, class C, class P1, R (C::*F)(P1)>
4644 R CallMethod1(C *obj, P1 arg1) {
4645   return ((*obj).*F)(arg1);
4646 }
4647 
4648 template <class R, class C, class P1, class P2, R (C::*F)(P1, P2)>
4649 R CallMethod2(C *obj, P1 arg1, P2 arg2) {
4650   return ((*obj).*F)(arg1, arg2);
4651 }
4652 
4653 template <class R, class C, class P1, class P2, class P3, R (C::*F)(P1, P2, P3)>
4654 R CallMethod3(C *obj, P1 arg1, P2 arg2, P3 arg3) {
4655   return ((*obj).*F)(arg1, arg2, arg3);
4656 }
4657 
4658 template <class R, class C, class P1, class P2, class P3, class P4,
4659           R (C::*F)(P1, P2, P3, P4)>
4660 R CallMethod4(C *obj, P1 arg1, P2 arg2, P3 arg3, P4 arg4) {
4661   return ((*obj).*F)(arg1, arg2, arg3, arg4);
4662 }
4663 
4664 /* MethodSig: like FuncSig, but for member functions.
4665  *
4666  * GetFunc() returns a normal FuncN object, so after calling GetFunc() no
4667  * more logic is required to special-case methods. */
4668 template <class R, class C>
4669 struct MethodSig0 {
4670   template <R (C::*F)()>
4671   Func1<R, C *, CallMethod0<R, C, F>, FuncInfo<C *, R> > GetFunc() {
4672     return Func1<R, C *, CallMethod0<R, C, F>, FuncInfo<C *, R> >();
4673   }
4674 };
4675 
4676 template <class R, class C, class P1>
4677 struct MethodSig1 {
4678   template <R (C::*F)(P1)>
4679   Func2<R, C *, P1, CallMethod1<R, C, P1, F>, FuncInfo<C *, R> > GetFunc() {
4680     return Func2<R, C *, P1, CallMethod1<R, C, P1, F>, FuncInfo<C *, R> >();
4681   }
4682 
4683   template <R (C::*F)(P1)>
4684   BoundFunc2<R, C *, P1, CallMethod1<R, C, P1, F>, FuncInfo<C *, R> > GetFunc(
4685       typename remove_constptr<P1>::type param1) {
4686     return BoundFunc2<R, C *, P1, CallMethod1<R, C, P1, F>, FuncInfo<C *, R> >(
4687         param1);
4688   }
4689 };
4690 
4691 template <class R, class C, class P1, class P2>
4692 struct MethodSig2 {
4693   template <R (C::*F)(P1, P2)>
4694   Func3<R, C *, P1, P2, CallMethod2<R, C, P1, P2, F>, FuncInfo<C *, R> >
4695   GetFunc() {
4696     return Func3<R, C *, P1, P2, CallMethod2<R, C, P1, P2, F>,
4697                  FuncInfo<C *, R> >();
4698   }
4699 
4700   template <R (C::*F)(P1, P2)>
4701   BoundFunc3<R, C *, P1, P2, CallMethod2<R, C, P1, P2, F>, FuncInfo<C *, R> >
4702   GetFunc(typename remove_constptr<P1>::type param1) {
4703     return BoundFunc3<R, C *, P1, P2, CallMethod2<R, C, P1, P2, F>,
4704                       FuncInfo<C *, R> >(param1);
4705   }
4706 };
4707 
4708 template <class R, class C, class P1, class P2, class P3>
4709 struct MethodSig3 {
4710   template <R (C::*F)(P1, P2, P3)>
4711   Func4<R, C *, P1, P2, P3, CallMethod3<R, C, P1, P2, P3, F>, FuncInfo<C *, R> >
4712   GetFunc() {
4713     return Func4<R, C *, P1, P2, P3, CallMethod3<R, C, P1, P2, P3, F>,
4714                  FuncInfo<C *, R> >();
4715   }
4716 
4717   template <R (C::*F)(P1, P2, P3)>
4718   BoundFunc4<R, C *, P1, P2, P3, CallMethod3<R, C, P1, P2, P3, F>,
4719              FuncInfo<C *, R> >
4720   GetFunc(typename remove_constptr<P1>::type param1) {
4721     return BoundFunc4<R, C *, P1, P2, P3, CallMethod3<R, C, P1, P2, P3, F>,
4722                       FuncInfo<C *, R> >(param1);
4723   }
4724 };
4725 
4726 template <class R, class C, class P1, class P2, class P3, class P4>
4727 struct MethodSig4 {
4728   template <R (C::*F)(P1, P2, P3, P4)>
4729   Func5<R, C *, P1, P2, P3, P4, CallMethod4<R, C, P1, P2, P3, P4, F>,
4730         FuncInfo<C *, R> >
4731   GetFunc() {
4732     return Func5<R, C *, P1, P2, P3, P4, CallMethod4<R, C, P1, P2, P3, P4, F>,
4733                  FuncInfo<C *, R> >();
4734   }
4735 
4736   template <R (C::*F)(P1, P2, P3, P4)>
4737   BoundFunc5<R, C *, P1, P2, P3, P4, CallMethod4<R, C, P1, P2, P3, P4, F>,
4738              FuncInfo<C *, R> >
4739   GetFunc(typename remove_constptr<P1>::type param1) {
4740     return BoundFunc5<R, C *, P1, P2, P3, P4,
4741                       CallMethod4<R, C, P1, P2, P3, P4, F>, FuncInfo<C *, R> >(
4742         param1);
4743   }
4744 };
4745 
4746 template <class R, class C>
4747 inline MethodSig0<R, C> MatchFunc(R (C::*f)()) {
4748   UPB_UNUSED(f);  /* Only used for template parameter deduction. */
4749   return MethodSig0<R, C>();
4750 }
4751 
4752 template <class R, class C, class P1>
4753 inline MethodSig1<R, C, P1> MatchFunc(R (C::*f)(P1)) {
4754   UPB_UNUSED(f);  /* Only used for template parameter deduction. */
4755   return MethodSig1<R, C, P1>();
4756 }
4757 
4758 template <class R, class C, class P1, class P2>
4759 inline MethodSig2<R, C, P1, P2> MatchFunc(R (C::*f)(P1, P2)) {
4760   UPB_UNUSED(f);  /* Only used for template parameter deduction. */
4761   return MethodSig2<R, C, P1, P2>();
4762 }
4763 
4764 template <class R, class C, class P1, class P2, class P3>
4765 inline MethodSig3<R, C, P1, P2, P3> MatchFunc(R (C::*f)(P1, P2, P3)) {
4766   UPB_UNUSED(f);  /* Only used for template parameter deduction. */
4767   return MethodSig3<R, C, P1, P2, P3>();
4768 }
4769 
4770 template <class R, class C, class P1, class P2, class P3, class P4>
4771 inline MethodSig4<R, C, P1, P2, P3, P4> MatchFunc(R (C::*f)(P1, P2, P3, P4)) {
4772   UPB_UNUSED(f);  /* Only used for template parameter deduction. */
4773   return MethodSig4<R, C, P1, P2, P3, P4>();
4774 }
4775 
4776 /* MaybeWrapReturn ************************************************************/
4777 
4778 /* Template class that attempts to wrap the return value of the function so it
4779  * matches the expected type.  There are two main adjustments it may make:
4780  *
4781  *   1. If the function returns void, make it return the expected type and with
4782  *      a value that always indicates success.
4783  *   2. If the function returns bool, make it return the expected type with a
4784  *      value that indicates success or failure.
4785  *
4786  * The "expected type" for return is:
4787  *   1. void* for start handlers.  If the closure parameter has a different type
4788  *      we will cast it to void* for the return in the success case.
4789  *   2. size_t for string buffer handlers.
4790  *   3. bool for everything else. */
4791 
4792 /* Template parameters are FuncN type and desired return type. */
4793 template <class F, class R, class Enable = void>
4794 struct MaybeWrapReturn;
4795 
4796 /* If the return type matches, return the given function unwrapped. */
4797 template <class F>
4798 struct MaybeWrapReturn<F, typename F::Return> {
4799   typedef F Func;
4800 };
4801 
4802 /* Function wrapper that munges the return value from void to (bool)true. */
4803 template <class P1, class P2, void F(P1, P2)>
4804 bool ReturnTrue2(P1 p1, P2 p2) {
4805   F(p1, p2);
4806   return true;
4807 }
4808 
4809 template <class P1, class P2, class P3, void F(P1, P2, P3)>
4810 bool ReturnTrue3(P1 p1, P2 p2, P3 p3) {
4811   F(p1, p2, p3);
4812   return true;
4813 }
4814 
4815 /* Function wrapper that munges the return value from void to (void*)arg1  */
4816 template <class P1, class P2, void F(P1, P2)>
4817 void *ReturnClosure2(P1 p1, P2 p2) {
4818   F(p1, p2);
4819   return p1;
4820 }
4821 
4822 template <class P1, class P2, class P3, void F(P1, P2, P3)>
4823 void *ReturnClosure3(P1 p1, P2 p2, P3 p3) {
4824   F(p1, p2, p3);
4825   return p1;
4826 }
4827 
4828 /* Function wrapper that munges the return value from R to void*. */
4829 template <class R, class P1, class P2, R F(P1, P2)>
4830 void *CastReturnToVoidPtr2(P1 p1, P2 p2) {
4831   return F(p1, p2);
4832 }
4833 
4834 template <class R, class P1, class P2, class P3, R F(P1, P2, P3)>
4835 void *CastReturnToVoidPtr3(P1 p1, P2 p2, P3 p3) {
4836   return F(p1, p2, p3);
4837 }
4838 
4839 /* Function wrapper that munges the return value from bool to void*. */
4840 template <class P1, class P2, bool F(P1, P2)>
4841 void *ReturnClosureOrBreak2(P1 p1, P2 p2) {
4842   return F(p1, p2) ? p1 : UPB_BREAK;
4843 }
4844 
4845 template <class P1, class P2, class P3, bool F(P1, P2, P3)>
4846 void *ReturnClosureOrBreak3(P1 p1, P2 p2, P3 p3) {
4847   return F(p1, p2, p3) ? p1 : UPB_BREAK;
4848 }
4849 
4850 /* For the string callback, which takes five params, returns the size param. */
4851 template <class P1, class P2,
4852           void F(P1, P2, const char *, size_t, const upb_bufhandle *)>
4853 size_t ReturnStringLen(P1 p1, P2 p2, const char *p3, size_t p4,
4854                        const upb_bufhandle *p5) {
4855   F(p1, p2, p3, p4, p5);
4856   return p4;
4857 }
4858 
4859 /* For the string callback, which takes five params, returns the size param or
4860  * zero. */
4861 template <class P1, class P2,
4862           bool F(P1, P2, const char *, size_t, const upb_bufhandle *)>
4863 size_t ReturnNOr0(P1 p1, P2 p2, const char *p3, size_t p4,
4864                   const upb_bufhandle *p5) {
4865   return F(p1, p2, p3, p4, p5) ? p4 : 0;
4866 }
4867 
4868 /* If we have a function returning void but want a function returning bool, wrap
4869  * it in a function that returns true. */
4870 template <class P1, class P2, void F(P1, P2), class I>
4871 struct MaybeWrapReturn<Func2<void, P1, P2, F, I>, bool> {
4872   typedef Func2<bool, P1, P2, ReturnTrue2<P1, P2, F>, I> Func;
4873 };
4874 
4875 template <class P1, class P2, class P3, void F(P1, P2, P3), class I>
4876 struct MaybeWrapReturn<Func3<void, P1, P2, P3, F, I>, bool> {
4877   typedef Func3<bool, P1, P2, P3, ReturnTrue3<P1, P2, P3, F>, I> Func;
4878 };
4879 
4880 /* If our function returns void but we want one returning void*, wrap it in a
4881  * function that returns the first argument. */
4882 template <class P1, class P2, void F(P1, P2), class I>
4883 struct MaybeWrapReturn<Func2<void, P1, P2, F, I>, void *> {
4884   typedef Func2<void *, P1, P2, ReturnClosure2<P1, P2, F>, I> Func;
4885 };
4886 
4887 template <class P1, class P2, class P3, void F(P1, P2, P3), class I>
4888 struct MaybeWrapReturn<Func3<void, P1, P2, P3, F, I>, void *> {
4889   typedef Func3<void *, P1, P2, P3, ReturnClosure3<P1, P2, P3, F>, I> Func;
4890 };
4891 
4892 /* If our function returns R* but we want one returning void*, wrap it in a
4893  * function that casts to void*. */
4894 template <class R, class P1, class P2, R *F(P1, P2), class I>
4895 struct MaybeWrapReturn<Func2<R *, P1, P2, F, I>, void *,
4896                        typename disable_if_same<R *, void *>::Type> {
4897   typedef Func2<void *, P1, P2, CastReturnToVoidPtr2<R *, P1, P2, F>, I> Func;
4898 };
4899 
4900 template <class R, class P1, class P2, class P3, R *F(P1, P2, P3), class I>
4901 struct MaybeWrapReturn<Func3<R *, P1, P2, P3, F, I>, void *,
4902                        typename disable_if_same<R *, void *>::Type> {
4903   typedef Func3<void *, P1, P2, P3, CastReturnToVoidPtr3<R *, P1, P2, P3, F>, I>
4904       Func;
4905 };
4906 
4907 /* If our function returns bool but we want one returning void*, wrap it in a
4908  * function that returns either the first param or UPB_BREAK. */
4909 template <class P1, class P2, bool F(P1, P2), class I>
4910 struct MaybeWrapReturn<Func2<bool, P1, P2, F, I>, void *> {
4911   typedef Func2<void *, P1, P2, ReturnClosureOrBreak2<P1, P2, F>, I> Func;
4912 };
4913 
4914 template <class P1, class P2, class P3, bool F(P1, P2, P3), class I>
4915 struct MaybeWrapReturn<Func3<bool, P1, P2, P3, F, I>, void *> {
4916   typedef Func3<void *, P1, P2, P3, ReturnClosureOrBreak3<P1, P2, P3, F>, I>
4917       Func;
4918 };
4919 
4920 /* If our function returns void but we want one returning size_t, wrap it in a
4921  * function that returns the size argument. */
4922 template <class P1, class P2,
4923           void F(P1, P2, const char *, size_t, const upb_bufhandle *), class I>
4924 struct MaybeWrapReturn<
4925     Func5<void, P1, P2, const char *, size_t, const upb_bufhandle *, F, I>,
4926           size_t> {
4927   typedef Func5<size_t, P1, P2, const char *, size_t, const upb_bufhandle *,
4928                 ReturnStringLen<P1, P2, F>, I> Func;
4929 };
4930 
4931 /* If our function returns bool but we want one returning size_t, wrap it in a
4932  * function that returns either 0 or the buf size. */
4933 template <class P1, class P2,
4934           bool F(P1, P2, const char *, size_t, const upb_bufhandle *), class I>
4935 struct MaybeWrapReturn<
4936     Func5<bool, P1, P2, const char *, size_t, const upb_bufhandle *, F, I>,
4937     size_t> {
4938   typedef Func5<size_t, P1, P2, const char *, size_t, const upb_bufhandle *,
4939                 ReturnNOr0<P1, P2, F>, I> Func;
4940 };
4941 
4942 /* ConvertParams **************************************************************/
4943 
4944 /* Template class that converts the function parameters if necessary, and
4945  * ignores the HandlerData parameter if appropriate.
4946  *
4947  * Template parameter is the are FuncN function type. */
4948 template <class F, class T>
4949 struct ConvertParams;
4950 
4951 /* Function that discards the handler data parameter. */
4952 template <class R, class P1, R F(P1)>
4953 R IgnoreHandlerData2(void *p1, const void *hd) {
4954   UPB_UNUSED(hd);
4955   return F(static_cast<P1>(p1));
4956 }
4957 
4958 template <class R, class P1, class P2Wrapper, class P2Wrapped,
4959           R F(P1, P2Wrapped)>
4960 R IgnoreHandlerData3(void *p1, const void *hd, P2Wrapper p2) {
4961   UPB_UNUSED(hd);
4962   return F(static_cast<P1>(p1), p2);
4963 }
4964 
4965 template <class R, class P1, class P2, class P3, R F(P1, P2, P3)>
4966 R IgnoreHandlerData4(void *p1, const void *hd, P2 p2, P3 p3) {
4967   UPB_UNUSED(hd);
4968   return F(static_cast<P1>(p1), p2, p3);
4969 }
4970 
4971 template <class R, class P1, class P2, class P3, class P4, R F(P1, P2, P3, P4)>
4972 R IgnoreHandlerData5(void *p1, const void *hd, P2 p2, P3 p3, P4 p4) {
4973   UPB_UNUSED(hd);
4974   return F(static_cast<P1>(p1), p2, p3, p4);
4975 }
4976 
4977 template <class R, class P1, R F(P1, const char*, size_t)>
4978 R IgnoreHandlerDataIgnoreHandle(void *p1, const void *hd, const char *p2,
4979                                 size_t p3, const upb_bufhandle *handle) {
4980   UPB_UNUSED(hd);
4981   UPB_UNUSED(handle);
4982   return F(static_cast<P1>(p1), p2, p3);
4983 }
4984 
4985 /* Function that casts the handler data parameter. */
4986 template <class R, class P1, class P2, R F(P1, P2)>
4987 R CastHandlerData2(void *c, const void *hd) {
4988   return F(static_cast<P1>(c), static_cast<P2>(hd));
4989 }
4990 
4991 template <class R, class P1, class P2, class P3Wrapper, class P3Wrapped,
4992           R F(P1, P2, P3Wrapped)>
4993 R CastHandlerData3(void *c, const void *hd, P3Wrapper p3) {
4994   return F(static_cast<P1>(c), static_cast<P2>(hd), p3);
4995 }
4996 
4997 template <class R, class P1, class P2, class P3, class P4, class P5,
4998           R F(P1, P2, P3, P4, P5)>
4999 R CastHandlerData5(void *c, const void *hd, P3 p3, P4 p4, P5 p5) {
5000   return F(static_cast<P1>(c), static_cast<P2>(hd), p3, p4, p5);
5001 }
5002 
5003 template <class R, class P1, class P2, R F(P1, P2, const char *, size_t)>
5004 R CastHandlerDataIgnoreHandle(void *c, const void *hd, const char *p3,
5005                               size_t p4, const upb_bufhandle *handle) {
5006   UPB_UNUSED(handle);
5007   return F(static_cast<P1>(c), static_cast<P2>(hd), p3, p4);
5008 }
5009 
5010 /* For unbound functions, ignore the handler data. */
5011 template <class R, class P1, R F(P1), class I, class T>
5012 struct ConvertParams<Func1<R, P1, F, I>, T> {
5013   typedef Func2<R, void *, const void *, IgnoreHandlerData2<R, P1, F>, I> Func;
5014 };
5015 
5016 template <class R, class P1, class P2, R F(P1, P2), class I,
5017           class R2, class P1_2, class P2_2, class P3_2>
5018 struct ConvertParams<Func2<R, P1, P2, F, I>,
5019                      R2 (*)(P1_2, P2_2, P3_2)> {
5020   typedef Func3<R, void *, const void *, P3_2,
5021                 IgnoreHandlerData3<R, P1, P3_2, P2, F>, I> Func;
5022 };
5023 
5024 /* For StringBuffer only; this ignores both the handler data and the
5025  * upb_bufhandle. */
5026 template <class R, class P1, R F(P1, const char *, size_t), class I, class T>
5027 struct ConvertParams<Func3<R, P1, const char *, size_t, F, I>, T> {
5028   typedef Func5<R, void *, const void *, const char *, size_t,
5029                 const upb_bufhandle *, IgnoreHandlerDataIgnoreHandle<R, P1, F>,
5030                 I> Func;
5031 };
5032 
5033 template <class R, class P1, class P2, class P3, class P4, R F(P1, P2, P3, P4),
5034           class I, class T>
5035 struct ConvertParams<Func4<R, P1, P2, P3, P4, F, I>, T> {
5036   typedef Func5<R, void *, const void *, P2, P3, P4,
5037                 IgnoreHandlerData5<R, P1, P2, P3, P4, F>, I> Func;
5038 };
5039 
5040 /* For bound functions, cast the handler data. */
5041 template <class R, class P1, class P2, R F(P1, P2), class I, class T>
5042 struct ConvertParams<BoundFunc2<R, P1, P2, F, I>, T> {
5043   typedef Func2<R, void *, const void *, CastHandlerData2<R, P1, P2, F>, I>
5044       Func;
5045 };
5046 
5047 template <class R, class P1, class P2, class P3, R F(P1, P2, P3), class I,
5048           class R2, class P1_2, class P2_2, class P3_2>
5049 struct ConvertParams<BoundFunc3<R, P1, P2, P3, F, I>,
5050                      R2 (*)(P1_2, P2_2, P3_2)> {
5051   typedef Func3<R, void *, const void *, P3_2,
5052                 CastHandlerData3<R, P1, P2, P3_2, P3, F>, I> Func;
5053 };
5054 
5055 /* For StringBuffer only; this ignores the upb_bufhandle. */
5056 template <class R, class P1, class P2, R F(P1, P2, const char *, size_t),
5057           class I, class T>
5058 struct ConvertParams<BoundFunc4<R, P1, P2, const char *, size_t, F, I>, T> {
5059   typedef Func5<R, void *, const void *, const char *, size_t,
5060                 const upb_bufhandle *,
5061                 CastHandlerDataIgnoreHandle<R, P1, P2, F>, I>
5062       Func;
5063 };
5064 
5065 template <class R, class P1, class P2, class P3, class P4, class P5,
5066           R F(P1, P2, P3, P4, P5), class I, class T>
5067 struct ConvertParams<BoundFunc5<R, P1, P2, P3, P4, P5, F, I>, T> {
5068   typedef Func5<R, void *, const void *, P3, P4, P5,
5069                 CastHandlerData5<R, P1, P2, P3, P4, P5, F>, I> Func;
5070 };
5071 
5072 /* utype/ltype are upper/lower-case, ctype is canonical C type, vtype is
5073  * variant C type. */
5074 #define TYPE_METHODS(utype, ltype, ctype, vtype)                      \
5075   template <>                                                         \
5076   struct CanonicalType<vtype> {                                       \
5077     typedef ctype Type;                                               \
5078   };                                                                  \
5079   template <>                                                         \
5080   inline bool HandlersPtr::SetValueHandler<vtype>(                    \
5081       FieldDefPtr f, const HandlersPtr::utype##Handler &handler) {    \
5082     handler.AddCleanup(ptr());                                        \
5083     return upb_handlers_set##ltype(ptr(), f.ptr(), handler.handler(), \
5084                                    &handler.attr());                  \
5085   }
5086 
5087 TYPE_METHODS(Double, double, double,   double)
5088 TYPE_METHODS(Float,  float,  float,    float)
5089 TYPE_METHODS(UInt64, uint64, uint64_t, UPB_UINT64_T)
5090 TYPE_METHODS(UInt32, uint32, uint32_t, UPB_UINT32_T)
5091 TYPE_METHODS(Int64,  int64,  int64_t,  UPB_INT64_T)
5092 TYPE_METHODS(Int32,  int32,  int32_t,  UPB_INT32_T)
5093 TYPE_METHODS(Bool,   bool,   bool,     bool)
5094 
5095 #ifdef UPB_TWO_32BIT_TYPES
5096 TYPE_METHODS(Int32,  int32,  int32_t,  UPB_INT32ALT_T)
5097 TYPE_METHODS(UInt32, uint32, uint32_t, UPB_UINT32ALT_T)
5098 #endif
5099 
5100 #ifdef UPB_TWO_64BIT_TYPES
5101 TYPE_METHODS(Int64,  int64,  int64_t,  UPB_INT64ALT_T)
5102 TYPE_METHODS(UInt64, uint64, uint64_t, UPB_UINT64ALT_T)
5103 #endif
5104 #undef TYPE_METHODS
5105 
5106 template <> struct CanonicalType<Status*> {
5107   typedef Status* Type;
5108 };
5109 
5110 template <class F> struct ReturnOf;
5111 
5112 template <class R, class P1, class P2>
5113 struct ReturnOf<R (*)(P1, P2)> {
5114   typedef R Return;
5115 };
5116 
5117 template <class R, class P1, class P2, class P3>
5118 struct ReturnOf<R (*)(P1, P2, P3)> {
5119   typedef R Return;
5120 };
5121 
5122 template <class R, class P1, class P2, class P3, class P4>
5123 struct ReturnOf<R (*)(P1, P2, P3, P4)> {
5124   typedef R Return;
5125 };
5126 
5127 template <class R, class P1, class P2, class P3, class P4, class P5>
5128 struct ReturnOf<R (*)(P1, P2, P3, P4, P5)> {
5129   typedef R Return;
5130 };
5131 
5132 
5133 template <class T>
5134 template <class F>
5135 inline Handler<T>::Handler(F func)
5136     : registered_(false),
5137       cleanup_data_(func.GetData()),
5138       cleanup_func_(func.GetCleanup()) {
5139   attr_.handler_data = func.GetData();
5140   typedef typename ReturnOf<T>::Return Return;
5141   typedef typename ConvertParams<F, T>::Func ConvertedParamsFunc;
5142   typedef typename MaybeWrapReturn<ConvertedParamsFunc, Return>::Func
5143       ReturnWrappedFunc;
5144   handler_ = ReturnWrappedFunc().Call;
5145 
5146   /* Set attributes based on what templates can statically tell us about the
5147    * user's function. */
5148 
5149   /* If the original function returns void, then we know that we wrapped it to
5150    * always return ok. */
5151   bool always_ok = is_same<typename F::FuncInfo::Return, void>::value;
5152   attr_.alwaysok = always_ok;
5153 
5154   /* Closure parameter and return type. */
5155   attr_.closure_type = UniquePtrForType<typename F::FuncInfo::Closure>();
5156 
5157   /* We use the closure type (from the first parameter) if the return type is
5158    * void or bool, since these are the two cases we wrap to return the closure's
5159    * type anyway.
5160    *
5161    * This is all nonsense for non START* handlers, but it doesn't matter because
5162    * in that case the value will be ignored. */
5163   typedef typename FirstUnlessVoidOrBool<typename F::FuncInfo::Return,
5164                                          typename F::FuncInfo::Closure>::value
5165       EffectiveReturn;
5166   attr_.return_closure_type = UniquePtrForType<EffectiveReturn>();
5167 }
5168 
5169 template <class T>
5170 inline void Handler<T>::AddCleanup(upb_handlers* h) const {
5171   UPB_ASSERT(!registered_);
5172   registered_ = true;
5173   if (cleanup_func_) {
5174     bool ok = upb_handlers_addcleanup(h, cleanup_data_, cleanup_func_);
5175     UPB_ASSERT(ok);
5176   }
5177 }
5178 
5179 }  /* namespace upb */
5180 
5181 #endif  /* __cplusplus */
5182 
5183 
5184 #undef UPB_TWO_32BIT_TYPES
5185 #undef UPB_TWO_64BIT_TYPES
5186 #undef UPB_INT32_T
5187 #undef UPB_UINT32_T
5188 #undef UPB_INT32ALT_T
5189 #undef UPB_UINT32ALT_T
5190 #undef UPB_INT64_T
5191 #undef UPB_UINT64_T
5192 #undef UPB_INT64ALT_T
5193 #undef UPB_UINT64ALT_T
5194 
5195 
5196 #endif  /* UPB_HANDLERS_INL_H_ */
5197 
5198 #endif  /* UPB_HANDLERS_H */
5199 /*
5200 ** upb::Sink (upb_sink)
5201 ** upb::BytesSink (upb_bytessink)
5202 **
5203 ** A upb_sink is an object that binds a upb_handlers object to some runtime
5204 ** state.  It is the object that can actually receive data via the upb_handlers
5205 ** interface.
5206 **
5207 ** Unlike upb_def and upb_handlers, upb_sink is never frozen, immutable, or
5208 ** thread-safe.  You can create as many of them as you want, but each one may
5209 ** only be used in a single thread at a time.
5210 **
5211 ** If we compare with class-based OOP, a you can think of a upb_def as an
5212 ** abstract base class, a upb_handlers as a concrete derived class, and a
5213 ** upb_sink as an object (class instance).
5214 */
5215 
5216 #ifndef UPB_SINK_H
5217 #define UPB_SINK_H
5218 
5219 
5220 
5221 #ifdef __cplusplus
5222 namespace upb {
5223 class BytesSink;
5224 class Sink;
5225 }
5226 #endif
5227 
5228 /* upb_sink *******************************************************************/
5229 
5230 #ifdef __cplusplus
5231 extern "C" {
5232 #endif
5233 
5234 typedef struct {
5235   const upb_handlers *handlers;
5236   void *closure;
5237 } upb_sink;
5238 
5239 #define PUTVAL(type, ctype)                                           \
5240   UPB_INLINE bool upb_sink_put##type(upb_sink s, upb_selector_t sel,  \
5241                                      ctype val) {                     \
5242     typedef upb_##type##_handlerfunc functype;                        \
5243     functype *func;                                                   \
5244     const void *hd;                                                   \
5245     if (!s.handlers) return true;                                     \
5246     func = (functype *)upb_handlers_gethandler(s.handlers, sel, &hd); \
5247     if (!func) return true;                                           \
5248     return func(s.closure, hd, val);                                  \
5249   }
5250 
5251 PUTVAL(int32,  int32_t)
5252 PUTVAL(int64,  int64_t)
5253 PUTVAL(uint32, uint32_t)
5254 PUTVAL(uint64, uint64_t)
5255 PUTVAL(float,  float)
5256 PUTVAL(double, double)
5257 PUTVAL(bool,   bool)
5258 #undef PUTVAL
5259 
5260 UPB_INLINE void upb_sink_reset(upb_sink *s, const upb_handlers *h, void *c) {
5261   s->handlers = h;
5262   s->closure = c;
5263 }
5264 
5265 UPB_INLINE size_t upb_sink_putstring(upb_sink s, upb_selector_t sel,
5266                                      const char *buf, size_t n,
5267                                      const upb_bufhandle *handle) {
5268   typedef upb_string_handlerfunc func;
5269   func *handler;
5270   const void *hd;
5271   if (!s.handlers) return n;
5272   handler = (func *)upb_handlers_gethandler(s.handlers, sel, &hd);
5273 
5274   if (!handler) return n;
5275   return handler(s.closure, hd, buf, n, handle);
5276 }
5277 
5278 UPB_INLINE bool upb_sink_putunknown(upb_sink s, const char *buf, size_t n) {
5279   typedef upb_unknown_handlerfunc func;
5280   func *handler;
5281   const void *hd;
5282   if (!s.handlers) return true;
5283   handler =
5284       (func *)upb_handlers_gethandler(s.handlers, UPB_UNKNOWN_SELECTOR, &hd);
5285 
5286   if (!handler) return n;
5287   return handler(s.closure, hd, buf, n);
5288 }
5289 
5290 UPB_INLINE bool upb_sink_startmsg(upb_sink s) {
5291   typedef upb_startmsg_handlerfunc func;
5292   func *startmsg;
5293   const void *hd;
5294   if (!s.handlers) return true;
5295   startmsg =
5296       (func *)upb_handlers_gethandler(s.handlers, UPB_STARTMSG_SELECTOR, &hd);
5297 
5298   if (!startmsg) return true;
5299   return startmsg(s.closure, hd);
5300 }
5301 
5302 UPB_INLINE bool upb_sink_endmsg(upb_sink s, upb_status *status) {
5303   typedef upb_endmsg_handlerfunc func;
5304   func *endmsg;
5305   const void *hd;
5306   if (!s.handlers) return true;
5307   endmsg =
5308       (func *)upb_handlers_gethandler(s.handlers, UPB_ENDMSG_SELECTOR, &hd);
5309 
5310   if (!endmsg) return true;
5311   return endmsg(s.closure, hd, status);
5312 }
5313 
5314 UPB_INLINE bool upb_sink_startseq(upb_sink s, upb_selector_t sel,
5315                                   upb_sink *sub) {
5316   typedef upb_startfield_handlerfunc func;
5317   func *startseq;
5318   const void *hd;
5319   sub->closure = s.closure;
5320   sub->handlers = s.handlers;
5321   if (!s.handlers) return true;
5322   startseq = (func*)upb_handlers_gethandler(s.handlers, sel, &hd);
5323 
5324   if (!startseq) return true;
5325   sub->closure = startseq(s.closure, hd);
5326   return sub->closure ? true : false;
5327 }
5328 
5329 UPB_INLINE bool upb_sink_endseq(upb_sink s, upb_selector_t sel) {
5330   typedef upb_endfield_handlerfunc func;
5331   func *endseq;
5332   const void *hd;
5333   if (!s.handlers) return true;
5334   endseq = (func*)upb_handlers_gethandler(s.handlers, sel, &hd);
5335 
5336   if (!endseq) return true;
5337   return endseq(s.closure, hd);
5338 }
5339 
5340 UPB_INLINE bool upb_sink_startstr(upb_sink s, upb_selector_t sel,
5341                                   size_t size_hint, upb_sink *sub) {
5342   typedef upb_startstr_handlerfunc func;
5343   func *startstr;
5344   const void *hd;
5345   sub->closure = s.closure;
5346   sub->handlers = s.handlers;
5347   if (!s.handlers) return true;
5348   startstr = (func*)upb_handlers_gethandler(s.handlers, sel, &hd);
5349 
5350   if (!startstr) return true;
5351   sub->closure = startstr(s.closure, hd, size_hint);
5352   return sub->closure ? true : false;
5353 }
5354 
5355 UPB_INLINE bool upb_sink_endstr(upb_sink s, upb_selector_t sel) {
5356   typedef upb_endfield_handlerfunc func;
5357   func *endstr;
5358   const void *hd;
5359   if (!s.handlers) return true;
5360   endstr = (func*)upb_handlers_gethandler(s.handlers, sel, &hd);
5361 
5362   if (!endstr) return true;
5363   return endstr(s.closure, hd);
5364 }
5365 
5366 UPB_INLINE bool upb_sink_startsubmsg(upb_sink s, upb_selector_t sel,
5367                                      upb_sink *sub) {
5368   typedef upb_startfield_handlerfunc func;
5369   func *startsubmsg;
5370   const void *hd;
5371   sub->closure = s.closure;
5372   if (!s.handlers) {
5373     sub->handlers = NULL;
5374     return true;
5375   }
5376   sub->handlers = upb_handlers_getsubhandlers_sel(s.handlers, sel);
5377   startsubmsg = (func*)upb_handlers_gethandler(s.handlers, sel, &hd);
5378 
5379   if (!startsubmsg) return true;
5380   sub->closure = startsubmsg(s.closure, hd);
5381   return sub->closure ? true : false;
5382 }
5383 
5384 UPB_INLINE bool upb_sink_endsubmsg(upb_sink s, upb_sink sub,
5385                                    upb_selector_t sel) {
5386   typedef upb_endfield_handlerfunc func;
5387   func *endsubmsg;
5388   const void *hd;
5389   if (!s.handlers) return true;
5390   endsubmsg = (func*)upb_handlers_gethandler(s.handlers, sel, &hd);
5391 
5392   if (!endsubmsg) return true;
5393   return endsubmsg(sub.closure, hd);
5394 }
5395 
5396 #ifdef __cplusplus
5397 }  /* extern "C" */
5398 
5399 /* A upb::Sink is an object that binds a upb::Handlers object to some runtime
5400  * state.  It represents an endpoint to which data can be sent.
5401  *
5402  * TODO(haberman): right now all of these functions take selectors.  Should they
5403  * take selectorbase instead?
5404  *
5405  * ie. instead of calling:
5406  *   sink->StartString(FOO_FIELD_START_STRING, ...)
5407  * a selector base would let you say:
5408  *   sink->StartString(FOO_FIELD, ...)
5409  *
5410  * This would make call sites a little nicer and require emitting fewer selector
5411  * definitions in .h files.
5412  *
5413  * But the current scheme has the benefit that you can retrieve a function
5414  * pointer for any handler with handlers->GetHandler(selector), without having
5415  * to have a separate GetHandler() function for each handler type.  The JIT
5416  * compiler uses this.  To accommodate we'd have to expose a separate
5417  * GetHandler() for every handler type.
5418  *
5419  * Also to ponder: selectors right now are independent of a specific Handlers
5420  * instance.  In other words, they allocate a number to every possible handler
5421  * that *could* be registered, without knowing anything about what handlers
5422  * *are* registered.  That means that using selectors as table offsets prohibits
5423  * us from compacting the handler table at Freeze() time.  If the table is very
5424  * sparse, this could be wasteful.
5425  *
5426  * Having another selector-like thing that is specific to a Handlers instance
5427  * would allow this compacting, but then it would be impossible to write code
5428  * ahead-of-time that can be bound to any Handlers instance at runtime.  For
5429  * example, a .proto file parser written as straight C will not know what
5430  * Handlers it will be bound to, so when it calls sink->StartString() what
5431  * selector will it pass?  It needs a selector like we have today, that is
5432  * independent of any particular upb::Handlers.
5433  *
5434  * Is there a way then to allow Handlers table compaction? */
5435 class upb::Sink {
5436  public:
5437   /* Constructor with no initialization; must be Reset() before use. */
5438   Sink() {}
5439 
5440   Sink(const Sink&) = default;
5441   Sink& operator=(const Sink&) = default;
5442 
5443   Sink(const upb_sink& sink) : sink_(sink) {}
5444   Sink &operator=(const upb_sink &sink) {
5445     sink_ = sink;
5446     return *this;
5447   }
5448 
5449   upb_sink sink() { return sink_; }
5450 
5451   /* Constructs a new sink for the given frozen handlers and closure.
5452    *
5453    * TODO: once the Handlers know the expected closure type, verify that T
5454    * matches it. */
5455   template <class T> Sink(const upb_handlers* handlers, T* closure) {
5456     Reset(handlers, closure);
5457   }
5458 
5459   upb_sink* ptr() { return &sink_; }
5460 
5461   /* Resets the value of the sink. */
5462   template <class T> void Reset(const upb_handlers* handlers, T* closure) {
5463     upb_sink_reset(&sink_, handlers, closure);
5464   }
5465 
5466   /* Returns the top-level object that is bound to this sink.
5467    *
5468    * TODO: once the Handlers know the expected closure type, verify that T
5469    * matches it. */
5470   template <class T> T* GetObject() const {
5471     return static_cast<T*>(sink_.closure);
5472   }
5473 
5474   /* Functions for pushing data into the sink.
5475    *
5476    * These return false if processing should stop (either due to error or just
5477    * to suspend).
5478    *
5479    * These may not be called from within one of the same sink's handlers (in
5480    * other words, handlers are not re-entrant). */
5481 
5482   /* Should be called at the start and end of every message; both the top-level
5483    * message and submessages.  This means that submessages should use the
5484    * following sequence:
5485    *   sink->StartSubMessage(startsubmsg_selector);
5486    *   sink->StartMessage();
5487    *   // ...
5488    *   sink->EndMessage(&status);
5489    *   sink->EndSubMessage(endsubmsg_selector); */
5490   bool StartMessage() { return upb_sink_startmsg(sink_); }
5491   bool EndMessage(upb_status *status) {
5492     return upb_sink_endmsg(sink_, status);
5493   }
5494 
5495   /* Putting of individual values.  These work for both repeated and
5496    * non-repeated fields, but for repeated fields you must wrap them in
5497    * calls to StartSequence()/EndSequence(). */
5498   bool PutInt32(HandlersPtr::Selector s, int32_t val) {
5499     return upb_sink_putint32(sink_, s, val);
5500   }
5501 
5502   bool PutInt64(HandlersPtr::Selector s, int64_t val) {
5503     return upb_sink_putint64(sink_, s, val);
5504   }
5505 
5506   bool PutUInt32(HandlersPtr::Selector s, uint32_t val) {
5507     return upb_sink_putuint32(sink_, s, val);
5508   }
5509 
5510   bool PutUInt64(HandlersPtr::Selector s, uint64_t val) {
5511     return upb_sink_putuint64(sink_, s, val);
5512   }
5513 
5514   bool PutFloat(HandlersPtr::Selector s, float val) {
5515     return upb_sink_putfloat(sink_, s, val);
5516   }
5517 
5518   bool PutDouble(HandlersPtr::Selector s, double val) {
5519     return upb_sink_putdouble(sink_, s, val);
5520   }
5521 
5522   bool PutBool(HandlersPtr::Selector s, bool val) {
5523     return upb_sink_putbool(sink_, s, val);
5524   }
5525 
5526   /* Putting of string/bytes values.  Each string can consist of zero or more
5527    * non-contiguous buffers of data.
5528    *
5529    * For StartString(), the function will write a sink for the string to "sub."
5530    * The sub-sink must be used for any/all PutStringBuffer() calls. */
5531   bool StartString(HandlersPtr::Selector s, size_t size_hint, Sink* sub) {
5532     upb_sink sub_c;
5533     bool ret = upb_sink_startstr(sink_, s, size_hint, &sub_c);
5534     *sub = sub_c;
5535     return ret;
5536   }
5537 
5538   size_t PutStringBuffer(HandlersPtr::Selector s, const char *buf, size_t len,
5539                          const upb_bufhandle *handle) {
5540     return upb_sink_putstring(sink_, s, buf, len, handle);
5541   }
5542 
5543   bool EndString(HandlersPtr::Selector s) {
5544     return upb_sink_endstr(sink_, s);
5545   }
5546 
5547   /* For submessage fields.
5548    *
5549    * For StartSubMessage(), the function will write a sink for the string to
5550    * "sub." The sub-sink must be used for any/all handlers called within the
5551    * submessage. */
5552   bool StartSubMessage(HandlersPtr::Selector s, Sink* sub) {
5553     upb_sink sub_c;
5554     bool ret = upb_sink_startsubmsg(sink_, s, &sub_c);
5555     *sub = sub_c;
5556     return ret;
5557   }
5558 
5559   bool EndSubMessage(HandlersPtr::Selector s, Sink sub) {
5560     return upb_sink_endsubmsg(sink_, sub.sink_, s);
5561   }
5562 
5563   /* For repeated fields of any type, the sequence of values must be wrapped in
5564    * these calls.
5565    *
5566    * For StartSequence(), the function will write a sink for the string to
5567    * "sub." The sub-sink must be used for any/all handlers called within the
5568    * sequence. */
5569   bool StartSequence(HandlersPtr::Selector s, Sink* sub) {
5570     upb_sink sub_c;
5571     bool ret = upb_sink_startseq(sink_, s, &sub_c);
5572     *sub = sub_c;
5573     return ret;
5574   }
5575 
5576   bool EndSequence(HandlersPtr::Selector s) {
5577     return upb_sink_endseq(sink_, s);
5578   }
5579 
5580   /* Copy and assign specifically allowed.
5581    * We don't even bother making these members private because so many
5582    * functions need them and this is mainly just a dumb data container anyway.
5583    */
5584 
5585  private:
5586   upb_sink sink_;
5587 };
5588 
5589 #endif  /* __cplusplus */
5590 
5591 /* upb_bytessink **************************************************************/
5592 
5593 typedef struct {
5594   const upb_byteshandler *handler;
5595   void *closure;
5596 } upb_bytessink ;
5597 
5598 UPB_INLINE void upb_bytessink_reset(upb_bytessink* s, const upb_byteshandler *h,
5599                                     void *closure) {
5600   s->handler = h;
5601   s->closure = closure;
5602 }
5603 
5604 UPB_INLINE bool upb_bytessink_start(upb_bytessink s, size_t size_hint,
5605                                     void **subc) {
5606   typedef upb_startstr_handlerfunc func;
5607   func *start;
5608   *subc = s.closure;
5609   if (!s.handler) return true;
5610   start = (func *)s.handler->table[UPB_STARTSTR_SELECTOR].func;
5611 
5612   if (!start) return true;
5613   *subc = start(s.closure,
5614                 s.handler->table[UPB_STARTSTR_SELECTOR].attr.handler_data,
5615                 size_hint);
5616   return *subc != NULL;
5617 }
5618 
5619 UPB_INLINE size_t upb_bytessink_putbuf(upb_bytessink s, void *subc,
5620                                        const char *buf, size_t size,
5621                                        const upb_bufhandle* handle) {
5622   typedef upb_string_handlerfunc func;
5623   func *putbuf;
5624   if (!s.handler) return true;
5625   putbuf = (func *)s.handler->table[UPB_STRING_SELECTOR].func;
5626 
5627   if (!putbuf) return true;
5628   return putbuf(subc, s.handler->table[UPB_STRING_SELECTOR].attr.handler_data,
5629                 buf, size, handle);
5630 }
5631 
5632 UPB_INLINE bool upb_bytessink_end(upb_bytessink s) {
5633   typedef upb_endfield_handlerfunc func;
5634   func *end;
5635   if (!s.handler) return true;
5636   end = (func *)s.handler->table[UPB_ENDSTR_SELECTOR].func;
5637 
5638   if (!end) return true;
5639   return end(s.closure,
5640              s.handler->table[UPB_ENDSTR_SELECTOR].attr.handler_data);
5641 }
5642 
5643 #ifdef __cplusplus
5644 
5645 class upb::BytesSink {
5646  public:
5647   BytesSink() {}
5648 
5649   BytesSink(const BytesSink&) = default;
5650   BytesSink& operator=(const BytesSink&) = default;
5651 
5652   BytesSink(const upb_bytessink& sink) : sink_(sink) {}
5653   BytesSink &operator=(const upb_bytessink &sink) {
5654     sink_ = sink;
5655     return *this;
5656   }
5657 
5658   upb_bytessink sink() { return sink_; }
5659 
5660   /* Constructs a new sink for the given frozen handlers and closure.
5661    *
5662    * TODO(haberman): once the Handlers know the expected closure type, verify
5663    * that T matches it. */
5664   template <class T> BytesSink(const upb_byteshandler* handler, T* closure) {
5665     upb_bytessink_reset(sink_, handler, closure);
5666   }
5667 
5668   /* Resets the value of the sink. */
5669   template <class T> void Reset(const upb_byteshandler* handler, T* closure) {
5670     upb_bytessink_reset(&sink_, handler, closure);
5671   }
5672 
5673   bool Start(size_t size_hint, void **subc) {
5674     return upb_bytessink_start(sink_, size_hint, subc);
5675   }
5676 
5677   size_t PutBuffer(void *subc, const char *buf, size_t len,
5678                    const upb_bufhandle *handle) {
5679     return upb_bytessink_putbuf(sink_, subc, buf, len, handle);
5680   }
5681 
5682   bool End() {
5683     return upb_bytessink_end(sink_);
5684   }
5685 
5686  private:
5687   upb_bytessink sink_;
5688 };
5689 
5690 #endif  /* __cplusplus */
5691 
5692 /* upb_bufsrc *****************************************************************/
5693 
5694 #ifdef __cplusplus
5695 extern "C" {
5696 #endif
5697 
5698 bool upb_bufsrc_putbuf(const char *buf, size_t len, upb_bytessink sink);
5699 
5700 #ifdef __cplusplus
5701 }  /* extern "C" */
5702 
5703 namespace upb {
5704 template <class T> bool PutBuffer(const T& str, BytesSink sink) {
5705   return upb_bufsrc_putbuf(str.data(), str.size(), sink.sink());
5706 }
5707 }
5708 
5709 #endif  /* __cplusplus */
5710 
5711 
5712 #endif
5713 /*
5714 ** Internal-only definitions for the decoder.
5715 */
5716 
5717 #ifndef UPB_DECODER_INT_H_
5718 #define UPB_DECODER_INT_H_
5719 
5720 /*
5721 ** upb::pb::Decoder
5722 **
5723 ** A high performance, streaming, resumable decoder for the binary protobuf
5724 ** format.
5725 **
5726 ** This interface works the same regardless of what decoder backend is being
5727 ** used.  A client of this class does not need to know whether decoding is using
5728 ** a JITted decoder (DynASM, LLVM, etc) or an interpreted decoder.  By default,
5729 ** it will always use the fastest available decoder.  However, you can call
5730 ** set_allow_jit(false) to disable any JIT decoder that might be available.
5731 ** This is primarily useful for testing purposes.
5732 */
5733 
5734 #ifndef UPB_DECODER_H_
5735 #define UPB_DECODER_H_
5736 
5737 
5738 #ifdef __cplusplus
5739 namespace upb {
5740 namespace pb {
5741 class CodeCache;
5742 class DecoderPtr;
5743 class DecoderMethodPtr;
5744 class DecoderMethodOptions;
5745 }  /* namespace pb */
5746 }  /* namespace upb */
5747 #endif
5748 
5749 /* The maximum number of bytes we are required to buffer internally between
5750  * calls to the decoder.  The value is 14: a 5 byte unknown tag plus ten-byte
5751  * varint, less one because we are buffering an incomplete value.
5752  *
5753  * Should only be used by unit tests. */
5754 #define UPB_DECODER_MAX_RESIDUAL_BYTES 14
5755 
5756 /* upb_pbdecodermethod ********************************************************/
5757 
5758 struct upb_pbdecodermethod;
5759 typedef struct upb_pbdecodermethod upb_pbdecodermethod;
5760 
5761 #ifdef __cplusplus
5762 extern "C" {
5763 #endif
5764 
5765 const upb_handlers *upb_pbdecodermethod_desthandlers(
5766     const upb_pbdecodermethod *m);
5767 const upb_byteshandler *upb_pbdecodermethod_inputhandler(
5768     const upb_pbdecodermethod *m);
5769 bool upb_pbdecodermethod_isnative(const upb_pbdecodermethod *m);
5770 
5771 #ifdef __cplusplus
5772 }  /* extern "C" */
5773 
5774 /* Represents the code to parse a protobuf according to a destination
5775  * Handlers. */
5776 class upb::pb::DecoderMethodPtr {
5777  public:
5778   DecoderMethodPtr() : ptr_(nullptr) {}
5779   DecoderMethodPtr(const upb_pbdecodermethod* ptr) : ptr_(ptr) {}
5780 
5781   const upb_pbdecodermethod* ptr() { return ptr_; }
5782 
5783   /* The destination handlers that are statically bound to this method.
5784    * This method is only capable of outputting to a sink that uses these
5785    * handlers. */
5786   const Handlers *dest_handlers() const {
5787     return upb_pbdecodermethod_desthandlers(ptr_);
5788   }
5789 
5790   /* The input handlers for this decoder method. */
5791   const BytesHandler* input_handler() const {
5792     return upb_pbdecodermethod_inputhandler(ptr_);
5793   }
5794 
5795   /* Whether this method is native. */
5796   bool is_native() const {
5797     return upb_pbdecodermethod_isnative(ptr_);
5798   }
5799 
5800  private:
5801   const upb_pbdecodermethod* ptr_;
5802 };
5803 
5804 #endif
5805 
5806 /* upb_pbdecoder **************************************************************/
5807 
5808 /* Preallocation hint: decoder won't allocate more bytes than this when first
5809  * constructed.  This hint may be an overestimate for some build configurations.
5810  * But if the decoder library is upgraded without recompiling the application,
5811  * it may be an underestimate. */
5812 #define UPB_PB_DECODER_SIZE 4416
5813 
5814 struct upb_pbdecoder;
5815 typedef struct upb_pbdecoder upb_pbdecoder;
5816 
5817 #ifdef __cplusplus
5818 extern "C" {
5819 #endif
5820 
5821 upb_pbdecoder *upb_pbdecoder_create(upb_arena *arena,
5822                                     const upb_pbdecodermethod *method,
5823                                     upb_sink output, upb_status *status);
5824 const upb_pbdecodermethod *upb_pbdecoder_method(const upb_pbdecoder *d);
5825 upb_bytessink upb_pbdecoder_input(upb_pbdecoder *d);
5826 uint64_t upb_pbdecoder_bytesparsed(const upb_pbdecoder *d);
5827 size_t upb_pbdecoder_maxnesting(const upb_pbdecoder *d);
5828 bool upb_pbdecoder_setmaxnesting(upb_pbdecoder *d, size_t max);
5829 void upb_pbdecoder_reset(upb_pbdecoder *d);
5830 
5831 #ifdef __cplusplus
5832 }  /* extern "C" */
5833 
5834 /* A Decoder receives binary protobuf data on its input sink and pushes the
5835  * decoded data to its output sink. */
5836 class upb::pb::DecoderPtr {
5837  public:
5838   DecoderPtr() : ptr_(nullptr) {}
5839   DecoderPtr(upb_pbdecoder* ptr) : ptr_(ptr) {}
5840 
5841   upb_pbdecoder* ptr() { return ptr_; }
5842 
5843   /* Constructs a decoder instance for the given method, which must outlive this
5844    * decoder.  Any errors during parsing will be set on the given status, which
5845    * must also outlive this decoder.
5846    *
5847    * The sink must match the given method. */
5848   static DecoderPtr Create(Arena *arena, DecoderMethodPtr method,
5849                            upb::Sink output, Status *status) {
5850     return DecoderPtr(upb_pbdecoder_create(arena->ptr(), method.ptr(),
5851                                            output.sink(), status->ptr()));
5852   }
5853 
5854   /* Returns the DecoderMethod this decoder is parsing from. */
5855   const DecoderMethodPtr method() const {
5856     return DecoderMethodPtr(upb_pbdecoder_method(ptr_));
5857   }
5858 
5859   /* The sink on which this decoder receives input. */
5860   BytesSink input() { return BytesSink(upb_pbdecoder_input(ptr())); }
5861 
5862   /* Returns number of bytes successfully parsed.
5863    *
5864    * This can be useful for determining the stream position where an error
5865    * occurred.
5866    *
5867    * This value may not be up-to-date when called from inside a parsing
5868    * callback. */
5869   uint64_t BytesParsed() { return upb_pbdecoder_bytesparsed(ptr()); }
5870 
5871   /* Gets/sets the parsing nexting limit.  If the total number of nested
5872    * submessages and repeated fields hits this limit, parsing will fail.  This
5873    * is a resource limit that controls the amount of memory used by the parsing
5874    * stack.
5875    *
5876    * Setting the limit will fail if the parser is currently suspended at a depth
5877    * greater than this, or if memory allocation of the stack fails. */
5878   size_t max_nesting() { return upb_pbdecoder_maxnesting(ptr()); }
5879   bool set_max_nesting(size_t max) { return upb_pbdecoder_maxnesting(ptr()); }
5880 
5881   void Reset() { upb_pbdecoder_reset(ptr()); }
5882 
5883   static const size_t kSize = UPB_PB_DECODER_SIZE;
5884 
5885  private:
5886   upb_pbdecoder *ptr_;
5887 };
5888 
5889 #endif  /* __cplusplus */
5890 
5891 /* upb_pbcodecache ************************************************************/
5892 
5893 /* Lazily builds and caches decoder methods that will push data to the given
5894  * handlers.  The destination handlercache must outlive this object. */
5895 
5896 struct upb_pbcodecache;
5897 typedef struct upb_pbcodecache upb_pbcodecache;
5898 
5899 #ifdef __cplusplus
5900 extern "C" {
5901 #endif
5902 
5903 upb_pbcodecache *upb_pbcodecache_new(upb_handlercache *dest);
5904 void upb_pbcodecache_free(upb_pbcodecache *c);
5905 bool upb_pbcodecache_allowjit(const upb_pbcodecache *c);
5906 void upb_pbcodecache_setallowjit(upb_pbcodecache *c, bool allow);
5907 void upb_pbcodecache_setlazy(upb_pbcodecache *c, bool lazy);
5908 const upb_pbdecodermethod *upb_pbcodecache_get(upb_pbcodecache *c,
5909                                                const upb_msgdef *md);
5910 
5911 #ifdef __cplusplus
5912 }  /* extern "C" */
5913 
5914 /* A class for caching protobuf processing code, whether bytecode for the
5915  * interpreted decoder or machine code for the JIT.
5916  *
5917  * This class is not thread-safe. */
5918 class upb::pb::CodeCache {
5919  public:
5920   CodeCache(upb::HandlerCache *dest)
5921       : ptr_(upb_pbcodecache_new(dest->ptr()), upb_pbcodecache_free) {}
5922   CodeCache(CodeCache&&) = default;
5923   CodeCache& operator=(CodeCache&&) = default;
5924 
5925   upb_pbcodecache* ptr() { return ptr_.get(); }
5926   const upb_pbcodecache* ptr() const { return ptr_.get(); }
5927 
5928   /* Whether the cache is allowed to generate machine code.  Defaults to true.
5929    * There is no real reason to turn it off except for testing or if you are
5930    * having a specific problem with the JIT.
5931    *
5932    * Note that allow_jit = true does not *guarantee* that the code will be JIT
5933    * compiled.  If this platform is not supported or the JIT was not compiled
5934    * in, the code may still be interpreted. */
5935   bool allow_jit() const { return upb_pbcodecache_allowjit(ptr()); }
5936 
5937   /* This may only be called when the object is first constructed, and prior to
5938    * any code generation. */
5939   void set_allow_jit(bool allow) { upb_pbcodecache_setallowjit(ptr(), allow); }
5940 
5941   /* Should the decoder push submessages to lazy handlers for fields that have
5942    * them?  The caller should set this iff the lazy handlers expect data that is
5943    * in protobuf binary format and the caller wishes to lazy parse it. */
5944   void set_lazy(bool lazy) { upb_pbcodecache_setlazy(ptr(), lazy); }
5945 
5946   /* Returns a DecoderMethod that can push data to the given handlers.
5947    * If a suitable method already exists, it will be returned from the cache. */
5948   const DecoderMethodPtr Get(MessageDefPtr md) {
5949     return DecoderMethodPtr(upb_pbcodecache_get(ptr(), md.ptr()));
5950   }
5951 
5952  private:
5953   std::unique_ptr<upb_pbcodecache, decltype(&upb_pbcodecache_free)> ptr_;
5954 };
5955 
5956 #endif  /* __cplusplus */
5957 
5958 #endif  /* UPB_DECODER_H_ */
5959 
5960 
5961 /* Opcode definitions.  The canonical meaning of each opcode is its
5962  * implementation in the interpreter (the JIT is written to match this).
5963  *
5964  * All instructions have the opcode in the low byte.
5965  * Instruction format for most instructions is:
5966  *
5967  * +-------------------+--------+
5968  * |     arg (24)      | op (8) |
5969  * +-------------------+--------+
5970  *
5971  * Exceptions are indicated below.  A few opcodes are multi-word. */
5972 typedef enum {
5973   /* Opcodes 1-8, 13, 15-18 parse their respective descriptor types.
5974    * Arg for all of these is the upb selector for this field. */
5975 #define T(type) OP_PARSE_ ## type = UPB_DESCRIPTOR_TYPE_ ## type
5976   T(DOUBLE), T(FLOAT), T(INT64), T(UINT64), T(INT32), T(FIXED64), T(FIXED32),
5977   T(BOOL), T(UINT32), T(SFIXED32), T(SFIXED64), T(SINT32), T(SINT64),
5978 #undef T
5979   OP_STARTMSG       = 9,   /* No arg. */
5980   OP_ENDMSG         = 10,  /* No arg. */
5981   OP_STARTSEQ       = 11,
5982   OP_ENDSEQ         = 12,
5983   OP_STARTSUBMSG    = 14,
5984   OP_ENDSUBMSG      = 19,
5985   OP_STARTSTR       = 20,
5986   OP_STRING         = 21,
5987   OP_ENDSTR         = 22,
5988 
5989   OP_PUSHTAGDELIM   = 23,  /* No arg. */
5990   OP_PUSHLENDELIM   = 24,  /* No arg. */
5991   OP_POP            = 25,  /* No arg. */
5992   OP_SETDELIM       = 26,  /* No arg. */
5993   OP_SETBIGGROUPNUM = 27,  /* two words:
5994                             *   | unused (24)     | opc (8) |
5995                             *   |        groupnum (32)      | */
5996   OP_CHECKDELIM     = 28,
5997   OP_CALL           = 29,
5998   OP_RET            = 30,
5999   OP_BRANCH         = 31,
6000 
6001   /* Different opcodes depending on how many bytes expected. */
6002   OP_TAG1           = 32,  /* | match tag (16) | jump target (8) | opc (8) | */
6003   OP_TAG2           = 33,  /* | match tag (16) | jump target (8) | opc (8) | */
6004   OP_TAGN           = 34,  /* three words: */
6005                            /*   | unused (16) | jump target(8) | opc (8) | */
6006                            /*   |           match tag 1 (32)             | */
6007                            /*   |           match tag 2 (32)             | */
6008 
6009   OP_SETDISPATCH    = 35,  /* N words: */
6010                            /*   | unused (24)         | opc | */
6011                            /*   | upb_inttable* (32 or 64)  | */
6012 
6013   OP_DISPATCH       = 36,  /* No arg. */
6014 
6015   OP_HALT           = 37   /* No arg. */
6016 } opcode;
6017 
6018 #define OP_MAX OP_HALT
6019 
6020 UPB_INLINE opcode getop(uint32_t instr) { return (opcode)(instr & 0xff); }
6021 
6022 struct upb_pbcodecache {
6023   upb_arena *arena;
6024   upb_handlercache *dest;
6025   bool allow_jit;
6026   bool lazy;
6027 
6028   /* Map of upb_msgdef -> mgroup. */
6029   upb_inttable groups;
6030 };
6031 
6032 /* Method group; represents a set of decoder methods that had their code
6033  * emitted together.  Immutable once created.  */
6034 typedef struct {
6035   /* Maps upb_msgdef/upb_handlers -> upb_pbdecodermethod.  Owned by us.
6036    *
6037    * Ideally this would be on pbcodecache (if we were actually caching code).
6038    * Right now we don't actually cache anything, which is wasteful. */
6039   upb_inttable methods;
6040 
6041   /* The bytecode for our methods, if any exists.  Owned by us. */
6042   uint32_t *bytecode;
6043   uint32_t *bytecode_end;
6044 } mgroup;
6045 
6046 /* The maximum that any submessages can be nested.  Matches proto2's limit.
6047  * This specifies the size of the decoder's statically-sized array and therefore
6048  * setting it high will cause the upb::pb::Decoder object to be larger.
6049  *
6050  * If necessary we can add a runtime-settable property to Decoder that allow
6051  * this to be larger than the compile-time setting, but this would add
6052  * complexity, particularly since we would have to decide how/if to give users
6053  * the ability to set a custom memory allocation function. */
6054 #define UPB_DECODER_MAX_NESTING 64
6055 
6056 /* Internal-only struct used by the decoder. */
6057 typedef struct {
6058   /* Space optimization note: we store two pointers here that the JIT
6059    * doesn't need at all; the upb_handlers* inside the sink and
6060    * the dispatch table pointer.  We can optimze so that the JIT uses
6061    * smaller stack frames than the interpreter.  The only thing we need
6062    * to guarantee is that the fallback routines can find end_ofs. */
6063   upb_sink sink;
6064 
6065   /* The absolute stream offset of the end-of-frame delimiter.
6066    * Non-delimited frames (groups and non-packed repeated fields) reuse the
6067    * delimiter of their parent, even though the frame may not end there.
6068    *
6069    * NOTE: the JIT stores a slightly different value here for non-top frames.
6070    * It stores the value relative to the end of the enclosed message.  But the
6071    * top frame is still stored the same way, which is important for ensuring
6072    * that calls from the JIT into C work correctly. */
6073   uint64_t end_ofs;
6074   const uint32_t *base;
6075 
6076   /* 0 indicates a length-delimited field.
6077    * A positive number indicates a known group.
6078    * A negative number indicates an unknown group. */
6079   int32_t groupnum;
6080   upb_inttable *dispatch;  /* Not used by the JIT. */
6081 } upb_pbdecoder_frame;
6082 
6083 struct upb_pbdecodermethod {
6084   /* While compiling, the base is relative in "ofs", after compiling it is
6085    * absolute in "ptr". */
6086   union {
6087     uint32_t ofs;     /* PC offset of method. */
6088     void *ptr;        /* Pointer to bytecode or machine code for this method. */
6089   } code_base;
6090 
6091   /* The decoder method group to which this method belongs. */
6092   const mgroup *group;
6093 
6094   /* Whether this method is native code or bytecode. */
6095   bool is_native_;
6096 
6097   /* The handler one calls to invoke this method. */
6098   upb_byteshandler input_handler_;
6099 
6100   /* The destination handlers this method is bound to.  We own a ref. */
6101   const upb_handlers *dest_handlers_;
6102 
6103   /* Dispatch table -- used by both bytecode decoder and JIT when encountering a
6104    * field number that wasn't the one we were expecting to see.  See
6105    * decoder.int.h for the layout of this table. */
6106   upb_inttable dispatch;
6107 };
6108 
6109 struct upb_pbdecoder {
6110   upb_arena *arena;
6111 
6112   /* Our input sink. */
6113   upb_bytessink input_;
6114 
6115   /* The decoder method we are parsing with (owned). */
6116   const upb_pbdecodermethod *method_;
6117 
6118   size_t call_len;
6119   const uint32_t *pc, *last;
6120 
6121   /* Current input buffer and its stream offset. */
6122   const char *buf, *ptr, *end, *checkpoint;
6123 
6124   /* End of the delimited region, relative to ptr, NULL if not in this buf. */
6125   const char *delim_end;
6126 
6127   /* End of the delimited region, relative to ptr, end if not in this buf. */
6128   const char *data_end;
6129 
6130   /* Overall stream offset of "buf." */
6131   uint64_t bufstart_ofs;
6132 
6133   /* Buffer for residual bytes not parsed from the previous buffer. */
6134   char residual[UPB_DECODER_MAX_RESIDUAL_BYTES];
6135   char *residual_end;
6136 
6137   /* Bytes of data that should be discarded from the input beore we start
6138    * parsing again.  We set this when we internally determine that we can
6139    * safely skip the next N bytes, but this region extends past the current
6140    * user buffer. */
6141   size_t skip;
6142 
6143   /* Stores the user buffer passed to our decode function. */
6144   const char *buf_param;
6145   size_t size_param;
6146   const upb_bufhandle *handle;
6147 
6148   /* Our internal stack. */
6149   upb_pbdecoder_frame *stack, *top, *limit;
6150   const uint32_t **callstack;
6151   size_t stack_size;
6152 
6153   upb_status *status;
6154 };
6155 
6156 /* Decoder entry points; used as handlers. */
6157 void *upb_pbdecoder_startbc(void *closure, const void *pc, size_t size_hint);
6158 size_t upb_pbdecoder_decode(void *closure, const void *hd, const char *buf,
6159                             size_t size, const upb_bufhandle *handle);
6160 bool upb_pbdecoder_end(void *closure, const void *handler_data);
6161 
6162 /* Decoder-internal functions that the JIT calls to handle fallback paths. */
6163 int32_t upb_pbdecoder_resume(upb_pbdecoder *d, void *p, const char *buf,
6164                              size_t size, const upb_bufhandle *handle);
6165 size_t upb_pbdecoder_suspend(upb_pbdecoder *d);
6166 int32_t upb_pbdecoder_skipunknown(upb_pbdecoder *d, int32_t fieldnum,
6167                                   uint8_t wire_type);
6168 int32_t upb_pbdecoder_checktag_slow(upb_pbdecoder *d, uint64_t expected);
6169 int32_t upb_pbdecoder_decode_varint_slow(upb_pbdecoder *d, uint64_t *u64);
6170 int32_t upb_pbdecoder_decode_f32(upb_pbdecoder *d, uint32_t *u32);
6171 int32_t upb_pbdecoder_decode_f64(upb_pbdecoder *d, uint64_t *u64);
6172 void upb_pbdecoder_seterr(upb_pbdecoder *d, const char *msg);
6173 
6174 /* Error messages that are shared between the bytecode and JIT decoders. */
6175 extern const char *kPbDecoderStackOverflow;
6176 extern const char *kPbDecoderSubmessageTooLong;
6177 
6178 /* Access to decoderplan members needed by the decoder. */
6179 const char *upb_pbdecoder_getopname(unsigned int op);
6180 
6181 /* A special label that means "do field dispatch for this message and branch to
6182  * wherever that takes you." */
6183 #define LABEL_DISPATCH 0
6184 
6185 /* A special slot in the dispatch table that stores the epilogue (ENDMSG and/or
6186  * RET) for branching to when we find an appropriate ENDGROUP tag. */
6187 #define DISPATCH_ENDMSG 0
6188 
6189 /* It's important to use this invalid wire type instead of 0 (which is a valid
6190  * wire type). */
6191 #define NO_WIRE_TYPE 0xff
6192 
6193 /* The dispatch table layout is:
6194  *   [field number] -> [ 48-bit offset ][ 8-bit wt2 ][ 8-bit wt1 ]
6195  *
6196  * If wt1 matches, jump to the 48-bit offset.  If wt2 matches, lookup
6197  * (UPB_MAX_FIELDNUMBER + fieldnum) and jump there.
6198  *
6199  * We need two wire types because of packed/non-packed compatibility.  A
6200  * primitive repeated field can use either wire type and be valid.  While we
6201  * could key the table on fieldnum+wiretype, the table would be 8x sparser.
6202  *
6203  * Storing two wire types in the primary value allows us to quickly rule out
6204  * the second wire type without needing to do a separate lookup (this case is
6205  * less common than an unknown field). */
6206 UPB_INLINE uint64_t upb_pbdecoder_packdispatch(uint64_t ofs, uint8_t wt1,
6207                                                uint8_t wt2) {
6208   return (ofs << 16) | (wt2 << 8) | wt1;
6209 }
6210 
6211 UPB_INLINE void upb_pbdecoder_unpackdispatch(uint64_t dispatch, uint64_t *ofs,
6212                                              uint8_t *wt1, uint8_t *wt2) {
6213   *wt1 = (uint8_t)dispatch;
6214   *wt2 = (uint8_t)(dispatch >> 8);
6215   *ofs = dispatch >> 16;
6216 }
6217 
6218 /* All of the functions in decoder.c that return int32_t return values according
6219  * to the following scheme:
6220  *   1. negative values indicate a return code from the following list.
6221  *   2. positive values indicate that error or end of buffer was hit, and
6222  *      that the decode function should immediately return the given value
6223  *      (the decoder state has already been suspended and is ready to be
6224  *      resumed). */
6225 #define DECODE_OK -1
6226 #define DECODE_MISMATCH -2  /* Used only from checktag_slow(). */
6227 #define DECODE_ENDGROUP -3  /* Used only from checkunknown(). */
6228 
6229 #define CHECK_RETURN(x) { int32_t ret = x; if (ret >= 0) return ret; }
6230 
6231 
6232 #endif  /* UPB_DECODER_INT_H_ */
6233 /*
6234 ** A number of routines for varint manipulation (we keep them all around to
6235 ** have multiple approaches available for benchmarking).
6236 */
6237 
6238 #ifndef UPB_VARINT_DECODER_H_
6239 #define UPB_VARINT_DECODER_H_
6240 
6241 #include <assert.h>
6242 #include <stdint.h>
6243 #include <string.h>
6244 
6245 
6246 #ifdef __cplusplus
6247 extern "C" {
6248 #endif
6249 
6250 #define UPB_MAX_WIRE_TYPE 5
6251 
6252 /* The maximum number of bytes that it takes to encode a 64-bit varint. */
6253 #define UPB_PB_VARINT_MAX_LEN 10
6254 
6255 /* Array of the "native" (ie. non-packed-repeated) wire type for the given a
6256  * descriptor type (upb_descriptortype_t). */
6257 extern const uint8_t upb_pb_native_wire_types[];
6258 
6259 UPB_INLINE uint64_t byteswap64(uint64_t val) {
6260   uint64_t byte = 0xff;
6261   return (val & (byte << 56) >> 56)
6262     | (val & (byte << 48) >> 40)
6263     | (val & (byte << 40) >> 24)
6264     | (val & (byte << 32) >> 8)
6265     | (val & (byte << 24) << 8)
6266     | (val & (byte << 16) << 24)
6267     | (val & (byte <<  8) << 40)
6268     | (val & (byte <<  0) << 56);
6269 }
6270 
6271 /* Zig-zag encoding/decoding **************************************************/
6272 
6273 UPB_INLINE int32_t upb_zzdec_32(uint64_t _n) {
6274   uint32_t n = (uint32_t)_n;
6275   return (n >> 1) ^ -(int32_t)(n & 1);
6276 }
6277 UPB_INLINE int64_t upb_zzdec_64(uint64_t n) {
6278   return (n >> 1) ^ -(int64_t)(n & 1);
6279 }
6280 UPB_INLINE uint32_t upb_zzenc_32(int32_t n) {
6281   return ((uint32_t)n << 1) ^ (n >> 31);
6282 }
6283 UPB_INLINE uint64_t upb_zzenc_64(int64_t n) {
6284   return ((uint64_t)n << 1) ^ (n >> 63);
6285 }
6286 
6287 /* Decoding *******************************************************************/
6288 
6289 /* All decoding functions return this struct by value. */
6290 typedef struct {
6291   const char *p;  /* NULL if the varint was unterminated. */
6292   uint64_t val;
6293 } upb_decoderet;
6294 
6295 UPB_INLINE upb_decoderet upb_decoderet_make(const char *p, uint64_t val) {
6296   upb_decoderet ret;
6297   ret.p = p;
6298   ret.val = val;
6299   return ret;
6300 }
6301 
6302 upb_decoderet upb_vdecode_max8_branch32(upb_decoderet r);
6303 upb_decoderet upb_vdecode_max8_branch64(upb_decoderet r);
6304 
6305 /* Template for a function that checks the first two bytes with branching
6306  * and dispatches 2-10 bytes with a separate function.  Note that this may read
6307  * up to 10 bytes, so it must not be used unless there are at least ten bytes
6308  * left in the buffer! */
6309 #define UPB_VARINT_DECODER_CHECK2(name, decode_max8_function)                  \
6310 UPB_INLINE upb_decoderet upb_vdecode_check2_ ## name(const char *_p) {         \
6311   uint8_t *p = (uint8_t*)_p;                                                   \
6312   upb_decoderet r;                                                             \
6313   if ((*p & 0x80) == 0) {                                                      \
6314   /* Common case: one-byte varint. */                                          \
6315     return upb_decoderet_make(_p + 1, *p & 0x7fU);                             \
6316   }                                                                            \
6317   r = upb_decoderet_make(_p + 2, (*p & 0x7fU) | ((*(p + 1) & 0x7fU) << 7));    \
6318   if ((*(p + 1) & 0x80) == 0) {                                                \
6319     /* Two-byte varint. */                                                     \
6320     return r;                                                                  \
6321   }                                                                            \
6322   /* Longer varint, fallback to out-of-line function. */                       \
6323   return decode_max8_function(r);                                              \
6324 }
6325 
6326 UPB_VARINT_DECODER_CHECK2(branch32, upb_vdecode_max8_branch32)
6327 UPB_VARINT_DECODER_CHECK2(branch64, upb_vdecode_max8_branch64)
6328 #undef UPB_VARINT_DECODER_CHECK2
6329 
6330 /* Our canonical functions for decoding varints, based on the currently
6331  * favored best-performing implementations. */
6332 UPB_INLINE upb_decoderet upb_vdecode_fast(const char *p) {
6333   if (sizeof(long) == 8)
6334     return upb_vdecode_check2_branch64(p);
6335   else
6336     return upb_vdecode_check2_branch32(p);
6337 }
6338 
6339 
6340 /* Encoding *******************************************************************/
6341 
6342 UPB_INLINE int upb_value_size(uint64_t val) {
6343 #ifdef __GNUC__
6344   int high_bit = 63 - __builtin_clzll(val);  /* 0-based, undef if val == 0. */
6345 #else
6346   int high_bit = 0;
6347   uint64_t tmp = val;
6348   while(tmp >>= 1) high_bit++;
6349 #endif
6350   return val == 0 ? 1 : high_bit / 8 + 1;
6351 }
6352 
6353 /* Encodes a 64-bit varint into buf (which must be >=UPB_PB_VARINT_MAX_LEN
6354  * bytes long), returning how many bytes were used.
6355  *
6356  * TODO: benchmark and optimize if necessary. */
6357 UPB_INLINE size_t upb_vencode64(uint64_t val, char *buf) {
6358   size_t i;
6359   if (val == 0) { buf[0] = 0; return 1; }
6360   i = 0;
6361   while (val) {
6362     uint8_t byte = val & 0x7fU;
6363     val >>= 7;
6364     if (val) byte |= 0x80U;
6365     buf[i++] = byte;
6366   }
6367   return i;
6368 }
6369 
6370 UPB_INLINE size_t upb_varint_size(uint64_t val) {
6371   char buf[UPB_PB_VARINT_MAX_LEN];
6372   return upb_vencode64(val, buf);
6373 }
6374 
6375 /* Encodes a 32-bit varint, *not* sign-extended. */
6376 UPB_INLINE uint64_t upb_vencode32(uint32_t val) {
6377   char buf[UPB_PB_VARINT_MAX_LEN];
6378   size_t bytes = upb_vencode64(val, buf);
6379   uint64_t ret = 0;
6380   UPB_ASSERT(bytes <= 5);
6381   memcpy(&ret, buf, bytes);
6382 #ifdef UPB_BIG_ENDIAN
6383   ret = byteswap64(ret);
6384 #endif
6385   UPB_ASSERT(ret <= 0xffffffffffU);
6386   return ret;
6387 }
6388 
6389 #ifdef __cplusplus
6390 }  /* extern "C" */
6391 #endif
6392 
6393 
6394 #endif  /* UPB_VARINT_DECODER_H_ */
6395 /*
6396 ** upb::pb::Encoder (upb_pb_encoder)
6397 **
6398 ** Implements a set of upb_handlers that write protobuf data to the binary wire
6399 ** format.
6400 **
6401 ** This encoder implementation does not have any access to any out-of-band or
6402 ** precomputed lengths for submessages, so it must buffer submessages internally
6403 ** before it can emit the first byte.
6404 */
6405 
6406 #ifndef UPB_ENCODER_H_
6407 #define UPB_ENCODER_H_
6408 
6409 
6410 #ifdef __cplusplus
6411 namespace upb {
6412 namespace pb {
6413 class EncoderPtr;
6414 }  /* namespace pb */
6415 }  /* namespace upb */
6416 #endif
6417 
6418 #define UPB_PBENCODER_MAX_NESTING 100
6419 
6420 /* upb_pb_encoder *************************************************************/
6421 
6422 /* Preallocation hint: decoder won't allocate more bytes than this when first
6423  * constructed.  This hint may be an overestimate for some build configurations.
6424  * But if the decoder library is upgraded without recompiling the application,
6425  * it may be an underestimate. */
6426 #define UPB_PB_ENCODER_SIZE 784
6427 
6428 struct upb_pb_encoder;
6429 typedef struct upb_pb_encoder upb_pb_encoder;
6430 
6431 #ifdef __cplusplus
6432 extern "C" {
6433 #endif
6434 
6435 upb_sink upb_pb_encoder_input(upb_pb_encoder *p);
6436 upb_pb_encoder* upb_pb_encoder_create(upb_arena* a, const upb_handlers* h,
6437                                       upb_bytessink output);
6438 
6439 /* Lazily builds and caches handlers that will push encoded data to a bytessink.
6440  * Any msgdef objects used with this object must outlive it. */
6441 upb_handlercache *upb_pb_encoder_newcache(void);
6442 
6443 #ifdef __cplusplus
6444 }  /* extern "C" { */
6445 
6446 class upb::pb::EncoderPtr {
6447  public:
6448   EncoderPtr(upb_pb_encoder* ptr) : ptr_(ptr) {}
6449 
6450   upb_pb_encoder* ptr() { return ptr_; }
6451 
6452   /* Creates a new encoder in the given environment.  The Handlers must have
6453    * come from NewHandlers() below. */
6454   static EncoderPtr Create(Arena* arena, const Handlers* handlers,
6455                            BytesSink output) {
6456     return EncoderPtr(
6457         upb_pb_encoder_create(arena->ptr(), handlers, output.sink()));
6458   }
6459 
6460   /* The input to the encoder. */
6461   upb::Sink input() { return upb_pb_encoder_input(ptr()); }
6462 
6463   /* Creates a new set of handlers for this MessageDef. */
6464   static HandlerCache NewCache() {
6465     return HandlerCache(upb_pb_encoder_newcache());
6466   }
6467 
6468   static const size_t kSize = UPB_PB_ENCODER_SIZE;
6469 
6470  private:
6471   upb_pb_encoder* ptr_;
6472 };
6473 
6474 #endif  /* __cplusplus */
6475 
6476 #endif  /* UPB_ENCODER_H_ */
6477 /*
6478 ** upb::pb::TextPrinter (upb_textprinter)
6479 **
6480 ** Handlers for writing to protobuf text format.
6481 */
6482 
6483 #ifndef UPB_TEXT_H_
6484 #define UPB_TEXT_H_
6485 
6486 
6487 #ifdef __cplusplus
6488 namespace upb {
6489 namespace pb {
6490 class TextPrinterPtr;
6491 }  /* namespace pb */
6492 }  /* namespace upb */
6493 #endif
6494 
6495 /* upb_textprinter ************************************************************/
6496 
6497 struct upb_textprinter;
6498 typedef struct upb_textprinter upb_textprinter;
6499 
6500 #ifdef __cplusplus
6501 extern "C" {
6502 #endif
6503 
6504 /* C API. */
6505 upb_textprinter *upb_textprinter_create(upb_arena *arena, const upb_handlers *h,
6506                                         upb_bytessink output);
6507 void upb_textprinter_setsingleline(upb_textprinter *p, bool single_line);
6508 upb_sink upb_textprinter_input(upb_textprinter *p);
6509 upb_handlercache *upb_textprinter_newcache(void);
6510 
6511 #ifdef __cplusplus
6512 }  /* extern "C" */
6513 
6514 class upb::pb::TextPrinterPtr {
6515  public:
6516   TextPrinterPtr(upb_textprinter* ptr) : ptr_(ptr) {}
6517 
6518   /* The given handlers must have come from NewHandlers().  It must outlive the
6519    * TextPrinter. */
6520   static TextPrinterPtr Create(Arena *arena, upb::HandlersPtr *handlers,
6521                                BytesSink output) {
6522     return TextPrinterPtr(
6523         upb_textprinter_create(arena->ptr(), handlers->ptr(), output.sink()));
6524   }
6525 
6526   void SetSingleLineMode(bool single_line) {
6527     upb_textprinter_setsingleline(ptr_, single_line);
6528   }
6529 
6530   Sink input() { return upb_textprinter_input(ptr_); }
6531 
6532   /* If handler caching becomes a requirement we can add a code cache as in
6533    * decoder.h */
6534   static HandlerCache NewCache() {
6535     return HandlerCache(upb_textprinter_newcache());
6536   }
6537 
6538  private:
6539   upb_textprinter* ptr_;
6540 };
6541 
6542 #endif
6543 
6544 #endif  /* UPB_TEXT_H_ */
6545 /*
6546 ** upb::json::Parser (upb_json_parser)
6547 **
6548 ** Parses JSON according to a specific schema.
6549 ** Support for parsing arbitrary JSON (schema-less) will be added later.
6550 */
6551 
6552 #ifndef UPB_JSON_PARSER_H_
6553 #define UPB_JSON_PARSER_H_
6554 
6555 
6556 #ifdef __cplusplus
6557 namespace upb {
6558 namespace json {
6559 class CodeCache;
6560 class ParserPtr;
6561 class ParserMethodPtr;
6562 }  /* namespace json */
6563 }  /* namespace upb */
6564 #endif
6565 
6566 /* upb_json_parsermethod ******************************************************/
6567 
6568 struct upb_json_parsermethod;
6569 typedef struct upb_json_parsermethod upb_json_parsermethod;
6570 
6571 #ifdef __cplusplus
6572 extern "C" {
6573 #endif
6574 
6575 const upb_byteshandler* upb_json_parsermethod_inputhandler(
6576     const upb_json_parsermethod* m);
6577 
6578 #ifdef __cplusplus
6579 }  /* extern "C" */
6580 
6581 class upb::json::ParserMethodPtr {
6582  public:
6583   ParserMethodPtr() : ptr_(nullptr) {}
6584   ParserMethodPtr(const upb_json_parsermethod* ptr) : ptr_(ptr) {}
6585 
6586   const upb_json_parsermethod* ptr() const { return ptr_; }
6587 
6588   const BytesHandler* input_handler() const {
6589     return upb_json_parsermethod_inputhandler(ptr());
6590   }
6591 
6592  private:
6593   const upb_json_parsermethod* ptr_;
6594 };
6595 
6596 #endif  /* __cplusplus */
6597 
6598 /* upb_json_parser ************************************************************/
6599 
6600 /* Preallocation hint: parser won't allocate more bytes than this when first
6601  * constructed.  This hint may be an overestimate for some build configurations.
6602  * But if the parser library is upgraded without recompiling the application,
6603  * it may be an underestimate. */
6604 #define UPB_JSON_PARSER_SIZE 5712
6605 
6606 struct upb_json_parser;
6607 typedef struct upb_json_parser upb_json_parser;
6608 
6609 #ifdef __cplusplus
6610 extern "C" {
6611 #endif
6612 
6613 upb_json_parser* upb_json_parser_create(upb_arena* a,
6614                                         const upb_json_parsermethod* m,
6615                                         const upb_symtab* symtab,
6616                                         upb_sink output,
6617                                         upb_status *status,
6618                                         bool ignore_json_unknown);
6619 upb_bytessink upb_json_parser_input(upb_json_parser* p);
6620 
6621 #ifdef __cplusplus
6622 }  /* extern "C" */
6623 
6624 /* Parses an incoming BytesStream, pushing the results to the destination
6625  * sink. */
6626 class upb::json::ParserPtr {
6627  public:
6628   ParserPtr(upb_json_parser* ptr) : ptr_(ptr) {}
6629 
6630   static ParserPtr Create(Arena* arena, ParserMethodPtr method,
6631                           SymbolTable* symtab, Sink output, Status* status,
6632                           bool ignore_json_unknown) {
6633     upb_symtab* symtab_ptr = symtab ? symtab->ptr() : nullptr;
6634     return ParserPtr(upb_json_parser_create(
6635         arena->ptr(), method.ptr(), symtab_ptr, output.sink(), status->ptr(),
6636         ignore_json_unknown));
6637   }
6638 
6639   BytesSink input() { return upb_json_parser_input(ptr_); }
6640 
6641  private:
6642   upb_json_parser* ptr_;
6643 };
6644 
6645 #endif  /* __cplusplus */
6646 
6647 /* upb_json_codecache *********************************************************/
6648 
6649 /* Lazily builds and caches decoder methods that will push data to the given
6650  * handlers.  The upb_symtab object(s) must outlive this object. */
6651 
6652 struct upb_json_codecache;
6653 typedef struct upb_json_codecache upb_json_codecache;
6654 
6655 #ifdef __cplusplus
6656 extern "C" {
6657 #endif
6658 
6659 upb_json_codecache *upb_json_codecache_new(void);
6660 void upb_json_codecache_free(upb_json_codecache *cache);
6661 const upb_json_parsermethod* upb_json_codecache_get(upb_json_codecache* cache,
6662                                                     const upb_msgdef* md);
6663 
6664 #ifdef __cplusplus
6665 }  /* extern "C" */
6666 
6667 class upb::json::CodeCache {
6668  public:
6669   CodeCache() : ptr_(upb_json_codecache_new(), upb_json_codecache_free) {}
6670 
6671   /* Returns a DecoderMethod that can push data to the given handlers.
6672    * If a suitable method already exists, it will be returned from the cache. */
6673   ParserMethodPtr Get(MessageDefPtr md) {
6674     return upb_json_codecache_get(ptr_.get(), md.ptr());
6675   }
6676 
6677  private:
6678   std::unique_ptr<upb_json_codecache, decltype(&upb_json_codecache_free)> ptr_;
6679 };
6680 
6681 #endif
6682 
6683 #endif  /* UPB_JSON_PARSER_H_ */
6684 /*
6685 ** upb::json::Printer
6686 **
6687 ** Handlers that emit JSON according to a specific protobuf schema.
6688 */
6689 
6690 #ifndef UPB_JSON_TYPED_PRINTER_H_
6691 #define UPB_JSON_TYPED_PRINTER_H_
6692 
6693 
6694 #ifdef __cplusplus
6695 namespace upb {
6696 namespace json {
6697 class PrinterPtr;
6698 }  /* namespace json */
6699 }  /* namespace upb */
6700 #endif
6701 
6702 /* upb_json_printer ***********************************************************/
6703 
6704 #define UPB_JSON_PRINTER_SIZE 192
6705 
6706 struct upb_json_printer;
6707 typedef struct upb_json_printer upb_json_printer;
6708 
6709 #ifdef __cplusplus
6710 extern "C" {
6711 #endif
6712 
6713 /* Native C API. */
6714 upb_json_printer *upb_json_printer_create(upb_arena *a, const upb_handlers *h,
6715                                           upb_bytessink output);
6716 upb_sink upb_json_printer_input(upb_json_printer *p);
6717 const upb_handlers *upb_json_printer_newhandlers(const upb_msgdef *md,
6718                                                  bool preserve_fieldnames,
6719                                                  const void *owner);
6720 
6721 /* Lazily builds and caches handlers that will push encoded data to a bytessink.
6722  * Any msgdef objects used with this object must outlive it. */
6723 upb_handlercache *upb_json_printer_newcache(bool preserve_proto_fieldnames);
6724 
6725 #ifdef __cplusplus
6726 }  /* extern "C" */
6727 
6728 /* Prints an incoming stream of data to a BytesSink in JSON format. */
6729 class upb::json::PrinterPtr {
6730  public:
6731   PrinterPtr(upb_json_printer* ptr) : ptr_(ptr) {}
6732 
6733   static PrinterPtr Create(Arena *arena, const upb::Handlers *handlers,
6734                            BytesSink output) {
6735     return PrinterPtr(
6736         upb_json_printer_create(arena->ptr(), handlers, output.sink()));
6737   }
6738 
6739   /* The input to the printer. */
6740   Sink input() { return upb_json_printer_input(ptr_); }
6741 
6742   static const size_t kSize = UPB_JSON_PRINTER_SIZE;
6743 
6744   static HandlerCache NewCache(bool preserve_proto_fieldnames) {
6745     return upb_json_printer_newcache(preserve_proto_fieldnames);
6746   }
6747 
6748  private:
6749   upb_json_printer* ptr_;
6750 };
6751 
6752 #endif  /* __cplusplus */
6753 
6754 #endif  /* UPB_JSON_TYPED_PRINTER_H_ */
6755 /* See port_def.inc.  This should #undef all macros #defined there. */
6756 
6757 #undef UPB_MAPTYPE_STRING
6758 #undef UPB_SIZE
6759 #undef UPB_PTR_AT
6760 #undef UPB_READ_ONEOF
6761 #undef UPB_WRITE_ONEOF
6762 #undef UPB_INLINE
6763 #undef UPB_FORCEINLINE
6764 #undef UPB_NOINLINE
6765 #undef UPB_NORETURN
6766 #undef UPB_MAX
6767 #undef UPB_MIN
6768 #undef UPB_UNUSED
6769 #undef UPB_ASSUME
6770 #undef UPB_ASSERT
6771 #undef UPB_ASSERT_DEBUGVAR
6772 #undef UPB_UNREACHABLE
6773 #undef UPB_INFINITY
6774 #undef UPB_MSVC_VSNPRINTF
6775 #undef _upb_snprintf
6776 #undef _upb_vsnprintf
6777 #undef _upb_va_copy
6778