1 /* Amalgamated source file */
2 /*
3 * Copyright (c) 2009-2021, Google LLC
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Google LLC nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 /*
30 * This is where we define macros used across upb.
31 *
32 * All of these macros are undef'd in port_undef.inc to avoid leaking them to
33 * users.
34 *
35 * The correct usage is:
36 *
37 * #include "upb/foobar.h"
38 * #include "upb/baz.h"
39 *
40 * // MUST be last included header.
41 * #include "upb/port_def.inc"
42 *
43 * // Code for this file.
44 * // <...>
45 *
46 * // Can be omitted for .c files, required for .h.
47 * #include "upb/port_undef.inc"
48 *
49 * This file is private and must not be included by users!
50 */
51
52 #if !((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
53 (defined(__cplusplus) && __cplusplus >= 201103L) || \
54 (defined(_MSC_VER) && _MSC_VER >= 1900))
55 #error upb requires C99 or C++11 or MSVC >= 2015.
56 #endif
57
58 #include <stdint.h>
59 #include <stddef.h>
60
61 #if UINTPTR_MAX == 0xffffffff
62 #define UPB_SIZE(size32, size64) size32
63 #else
64 #define UPB_SIZE(size32, size64) size64
65 #endif
66
67 /* If we always read/write as a consistent type to each address, this shouldn't
68 * violate aliasing.
69 */
70 #define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs)))
71
72 #define UPB_READ_ONEOF(msg, fieldtype, offset, case_offset, case_val, default) \
73 *UPB_PTR_AT(msg, case_offset, int) == case_val \
74 ? *UPB_PTR_AT(msg, offset, fieldtype) \
75 : default
76
77 #define UPB_WRITE_ONEOF(msg, fieldtype, offset, value, case_offset, case_val) \
78 *UPB_PTR_AT(msg, case_offset, int) = case_val; \
79 *UPB_PTR_AT(msg, offset, fieldtype) = value;
80
81 #define UPB_MAPTYPE_STRING 0
82
83 /* UPB_INLINE: inline if possible, emit standalone code if required. */
84 #ifdef __cplusplus
85 #define UPB_INLINE inline
86 #elif defined (__GNUC__) || defined(__clang__)
87 #define UPB_INLINE static __inline__
88 #else
89 #define UPB_INLINE static
90 #endif
91
92 #define UPB_MALLOC_ALIGN 8
93 #define UPB_ALIGN_UP(size, align) (((size) + (align) - 1) / (align) * (align))
94 #define UPB_ALIGN_DOWN(size, align) ((size) / (align) * (align))
95 #define UPB_ALIGN_MALLOC(size) UPB_ALIGN_UP(size, UPB_MALLOC_ALIGN)
96 #define UPB_ALIGN_OF(type) offsetof (struct { char c; type member; }, member)
97
98 // Hints to the compiler about likely/unlikely branches.
99 #if defined (__GNUC__) || defined(__clang__)
100 #define UPB_LIKELY(x) __builtin_expect((bool)(x), 1)
101 #define UPB_UNLIKELY(x) __builtin_expect((bool)(x), 0)
102 #else
103 #define UPB_LIKELY(x) (x)
104 #define UPB_UNLIKELY(x) (x)
105 #endif
106
107 // Macros for function attributes on compilers that support them.
108 #ifdef __GNUC__
109 #define UPB_FORCEINLINE __inline__ __attribute__((always_inline))
110 #define UPB_NOINLINE __attribute__((noinline))
111 #define UPB_NORETURN __attribute__((__noreturn__))
112 #define UPB_PRINTF(str, first_vararg) __attribute__((format (printf, str, first_vararg)))
113 #elif defined(_MSC_VER)
114 #define UPB_NOINLINE
115 #define UPB_FORCEINLINE
116 #define UPB_NORETURN __declspec(noreturn)
117 #define UPB_PRINTF(str, first_vararg)
118 #else /* !defined(__GNUC__) */
119 #define UPB_FORCEINLINE
120 #define UPB_NOINLINE
121 #define UPB_NORETURN
122 #define UPB_PRINTF(str, first_vararg)
123 #endif
124
125 #define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
126 #define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
127
128 #define UPB_UNUSED(var) (void)var
129
130 // UPB_ASSUME(): in release mode, we tell the compiler to assume this is true.
131 #ifdef NDEBUG
132 #ifdef __GNUC__
133 #define UPB_ASSUME(expr) if (!(expr)) __builtin_unreachable()
134 #elif defined _MSC_VER
135 #define UPB_ASSUME(expr) if (!(expr)) __assume(0)
136 #else
137 #define UPB_ASSUME(expr) do {} while (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 #if defined(__GNUC__) || defined(__clang__)
152 #define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0)
153 #else
154 #define UPB_UNREACHABLE() do { assert(0); } while(0)
155 #endif
156
157 /* UPB_SETJMP() / UPB_LONGJMP(): avoid setting/restoring signal mask. */
158 #ifdef __APPLE__
159 #define UPB_SETJMP(buf) _setjmp(buf)
160 #define UPB_LONGJMP(buf, val) _longjmp(buf, val)
161 #else
162 #define UPB_SETJMP(buf) setjmp(buf)
163 #define UPB_LONGJMP(buf, val) longjmp(buf, val)
164 #endif
165
166 /* UPB_PTRADD(ptr, ofs): add pointer while avoiding "NULL + 0" UB */
167 #define UPB_PTRADD(ptr, ofs) ((ofs) ? (ptr) + (ofs) : (ptr))
168
169 /* Configure whether fasttable is switched on or not. *************************/
170
171 #ifdef __has_attribute
172 #define UPB_HAS_ATTRIBUTE(x) __has_attribute(x)
173 #else
174 #define UPB_HAS_ATTRIBUTE(x) 0
175 #endif
176
177 #if UPB_HAS_ATTRIBUTE(musttail)
178 #define UPB_MUSTTAIL __attribute__((musttail))
179 #else
180 #define UPB_MUSTTAIL
181 #endif
182
183 #undef UPB_HAS_ATTRIBUTE
184
185 /* This check is not fully robust: it does not require that we have "musttail"
186 * support available. We need tail calls to avoid consuming arbitrary amounts
187 * of stack space.
188 *
189 * GCC/Clang can mostly be trusted to generate tail calls as long as
190 * optimization is enabled, but, debug builds will not generate tail calls
191 * unless "musttail" is available.
192 *
193 * We should probably either:
194 * 1. require that the compiler supports musttail.
195 * 2. add some fallback code for when musttail isn't available (ie. return
196 * instead of tail calling). This is safe and portable, but this comes at
197 * a CPU cost.
198 */
199 #if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__)
200 #define UPB_FASTTABLE_SUPPORTED 1
201 #else
202 #define UPB_FASTTABLE_SUPPORTED 0
203 #endif
204
205 /* define UPB_ENABLE_FASTTABLE to force fast table support.
206 * This is useful when we want to ensure we are really getting fasttable,
207 * for example for testing or benchmarking. */
208 #if defined(UPB_ENABLE_FASTTABLE)
209 #if !UPB_FASTTABLE_SUPPORTED
210 #error fasttable is x86-64/ARM64 only and requires GCC or Clang.
211 #endif
212 #define UPB_FASTTABLE 1
213 /* Define UPB_TRY_ENABLE_FASTTABLE to use fasttable if possible.
214 * This is useful for releasing code that might be used on multiple platforms,
215 * for example the PHP or Ruby C extensions. */
216 #elif defined(UPB_TRY_ENABLE_FASTTABLE)
217 #define UPB_FASTTABLE UPB_FASTTABLE_SUPPORTED
218 #else
219 #define UPB_FASTTABLE 0
220 #endif
221
222 /* UPB_FASTTABLE_INIT() allows protos compiled for fasttable to gracefully
223 * degrade to non-fasttable if we are using UPB_TRY_ENABLE_FASTTABLE. */
224 #if !UPB_FASTTABLE && defined(UPB_TRY_ENABLE_FASTTABLE)
225 #define UPB_FASTTABLE_INIT(...)
226 #else
227 #define UPB_FASTTABLE_INIT(...) __VA_ARGS__
228 #endif
229
230 #undef UPB_FASTTABLE_SUPPORTED
231
232 /* ASAN poisoning (for arena) *************************************************/
233
234 #if defined(__SANITIZE_ADDRESS__)
235 #define UPB_ASAN 1
236 #ifdef __cplusplus
237 extern "C" {
238 #endif
239 void __asan_poison_memory_region(void const volatile *addr, size_t size);
240 void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
241 #ifdef __cplusplus
242 } /* extern "C" */
243 #endif
244 #define UPB_POISON_MEMORY_REGION(addr, size) \
245 __asan_poison_memory_region((addr), (size))
246 #define UPB_UNPOISON_MEMORY_REGION(addr, size) \
247 __asan_unpoison_memory_region((addr), (size))
248 #else
249 #define UPB_ASAN 0
250 #define UPB_POISON_MEMORY_REGION(addr, size) \
251 ((void)(addr), (void)(size))
252 #define UPB_UNPOISON_MEMORY_REGION(addr, size) \
253 ((void)(addr), (void)(size))
254 #endif
255
256 /* Disable proto2 arena behavior (TEMPORARY) **********************************/
257
258 #ifdef UPB_DISABLE_PROTO2_ENUM_CHECKING
259 #define UPB_TREAT_PROTO2_ENUMS_LIKE_PROTO3 1
260 #else
261 #define UPB_TREAT_PROTO2_ENUMS_LIKE_PROTO3 0
262 #endif
263
264 /** upb/collections.h ************************************************************/
265 #ifndef UPB_COLLECTIONS_H_
266 #define UPB_COLLECTIONS_H_
267
268
269 /** google/protobuf/descriptor.upb.h ************************************************************//* This file was generated by upbc (the upb compiler) from the input
270 * file:
271 *
272 * google/protobuf/descriptor.proto
273 *
274 * Do not edit -- your changes will be discarded when the file is
275 * regenerated. */
276
277 #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_
278 #define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_
279
280
281 /** upb/msg_internal.h ************************************************************/
282 /*
283 ** Our memory representation for parsing tables and messages themselves.
284 ** Functions in this file are used by generated code and possibly reflection.
285 **
286 ** The definitions in this file are internal to upb.
287 **/
288
289 #ifndef UPB_MSG_INT_H_
290 #define UPB_MSG_INT_H_
291
292 #include <stdint.h>
293 #include <stdlib.h>
294 #include <string.h>
295
296
297 /** upb/msg.h ************************************************************/
298 /*
299 * Public APIs for message operations that do not require descriptors.
300 * These functions can be used even in build that does not want to depend on
301 * reflection or descriptors.
302 *
303 * Descriptor-based reflection functionality lives in reflection.h.
304 */
305
306 #ifndef UPB_MSG_H_
307 #define UPB_MSG_H_
308
309 #include <stddef.h>
310
311
312 /** upb/upb.h ************************************************************/
313 /*
314 * This file contains shared definitions that are widely used across upb.
315 */
316
317 #ifndef UPB_H_
318 #define UPB_H_
319
320 #include <assert.h>
321 #include <stdarg.h>
322 #include <stdbool.h>
323 #include <stddef.h>
324 #include <stdint.h>
325 #include <string.h>
326
327
328 #ifdef __cplusplus
329 extern "C" {
330 #endif
331
332 /* upb_Status *****************************************************************/
333
334 #define _kUpb_Status_MaxMessage 127
335
336 typedef struct {
337 bool ok;
338 char msg[_kUpb_Status_MaxMessage]; /* Error message; NULL-terminated. */
339 } upb_Status;
340
341 const char* upb_Status_ErrorMessage(const upb_Status* status);
342 bool upb_Status_IsOk(const upb_Status* status);
343
344 /* These are no-op if |status| is NULL. */
345 void upb_Status_Clear(upb_Status* status);
346 void upb_Status_SetErrorMessage(upb_Status* status, const char* msg);
347 void upb_Status_SetErrorFormat(upb_Status* status, const char* fmt, ...)
348 UPB_PRINTF(2, 3);
349 void upb_Status_VSetErrorFormat(upb_Status* status, const char* fmt,
350 va_list args) UPB_PRINTF(2, 0);
351 void upb_Status_VAppendErrorFormat(upb_Status* status, const char* fmt,
352 va_list args) UPB_PRINTF(2, 0);
353
354 /** upb_StringView ************************************************************/
355
356 typedef struct {
357 const char* data;
358 size_t size;
359 } upb_StringView;
360
upb_StringView_FromDataAndSize(const char * data,size_t size)361 UPB_INLINE upb_StringView upb_StringView_FromDataAndSize(const char* data,
362 size_t size) {
363 upb_StringView ret;
364 ret.data = data;
365 ret.size = size;
366 return ret;
367 }
368
upb_StringView_FromString(const char * data)369 UPB_INLINE upb_StringView upb_StringView_FromString(const char* data) {
370 return upb_StringView_FromDataAndSize(data, strlen(data));
371 }
372
upb_StringView_IsEqual(upb_StringView a,upb_StringView b)373 UPB_INLINE bool upb_StringView_IsEqual(upb_StringView a, upb_StringView b) {
374 return a.size == b.size && memcmp(a.data, b.data, a.size) == 0;
375 }
376
377 #define UPB_STRINGVIEW_INIT(ptr, len) \
378 { ptr, len }
379
380 #define UPB_STRINGVIEW_FORMAT "%.*s"
381 #define UPB_STRINGVIEW_ARGS(view) (int)(view).size, (view).data
382
383 /** upb_alloc *****************************************************************/
384
385 /* A upb_alloc is a possibly-stateful allocator object.
386 *
387 * It could either be an arena allocator (which doesn't require individual
388 * free() calls) or a regular malloc() (which does). The client must therefore
389 * free memory unless it knows that the allocator is an arena allocator. */
390
391 struct upb_alloc;
392 typedef struct upb_alloc upb_alloc;
393
394 /* A malloc()/free() function.
395 * If "size" is 0 then the function acts like free(), otherwise it acts like
396 * realloc(). Only "oldsize" bytes from a previous allocation are preserved. */
397 typedef void* upb_alloc_func(upb_alloc* alloc, void* ptr, size_t oldsize,
398 size_t size);
399
400 struct upb_alloc {
401 upb_alloc_func* func;
402 };
403
upb_malloc(upb_alloc * alloc,size_t size)404 UPB_INLINE void* upb_malloc(upb_alloc* alloc, size_t size) {
405 UPB_ASSERT(alloc);
406 return alloc->func(alloc, NULL, 0, size);
407 }
408
upb_realloc(upb_alloc * alloc,void * ptr,size_t oldsize,size_t size)409 UPB_INLINE void* upb_realloc(upb_alloc* alloc, void* ptr, size_t oldsize,
410 size_t size) {
411 UPB_ASSERT(alloc);
412 return alloc->func(alloc, ptr, oldsize, size);
413 }
414
upb_free(upb_alloc * alloc,void * ptr)415 UPB_INLINE void upb_free(upb_alloc* alloc, void* ptr) {
416 assert(alloc);
417 alloc->func(alloc, ptr, 0, 0);
418 }
419
420 /* The global allocator used by upb. Uses the standard malloc()/free(). */
421
422 extern upb_alloc upb_alloc_global;
423
424 /* Functions that hard-code the global malloc.
425 *
426 * We still get benefit because we can put custom logic into our global
427 * allocator, like injecting out-of-memory faults in debug/testing builds. */
428
upb_gmalloc(size_t size)429 UPB_INLINE void* upb_gmalloc(size_t size) {
430 return upb_malloc(&upb_alloc_global, size);
431 }
432
upb_grealloc(void * ptr,size_t oldsize,size_t size)433 UPB_INLINE void* upb_grealloc(void* ptr, size_t oldsize, size_t size) {
434 return upb_realloc(&upb_alloc_global, ptr, oldsize, size);
435 }
436
upb_gfree(void * ptr)437 UPB_INLINE void upb_gfree(void* ptr) { upb_free(&upb_alloc_global, ptr); }
438
439 /* upb_Arena ******************************************************************/
440
441 /* upb_Arena is a specific allocator implementation that uses arena allocation.
442 * The user provides an allocator that will be used to allocate the underlying
443 * arena blocks. Arenas by nature do not require the individual allocations
444 * to be freed. However the Arena does allow users to register cleanup
445 * functions that will run when the arena is destroyed.
446 *
447 * A upb_Arena is *not* thread-safe.
448 *
449 * You could write a thread-safe arena allocator that satisfies the
450 * upb_alloc interface, but it would not be as efficient for the
451 * single-threaded case. */
452
453 typedef void upb_CleanupFunc(void* ud);
454
455 struct upb_Arena;
456 typedef struct upb_Arena upb_Arena;
457
458 typedef struct {
459 /* We implement the allocator interface.
460 * This must be the first member of upb_Arena!
461 * TODO(haberman): remove once handlers are gone. */
462 upb_alloc alloc;
463
464 char *ptr, *end;
465 } _upb_ArenaHead;
466
467 /* Creates an arena from the given initial block (if any -- n may be 0).
468 * Additional blocks will be allocated from |alloc|. If |alloc| is NULL, this
469 * is a fixed-size arena and cannot grow. */
470 upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc);
471 void upb_Arena_Free(upb_Arena* a);
472 bool upb_Arena_AddCleanup(upb_Arena* a, void* ud, upb_CleanupFunc* func);
473 bool upb_Arena_Fuse(upb_Arena* a, upb_Arena* b);
474 void* _upb_Arena_SlowMalloc(upb_Arena* a, size_t size);
475
upb_Arena_Alloc(upb_Arena * a)476 UPB_INLINE upb_alloc* upb_Arena_Alloc(upb_Arena* a) { return (upb_alloc*)a; }
477
_upb_ArenaHas(upb_Arena * a)478 UPB_INLINE size_t _upb_ArenaHas(upb_Arena* a) {
479 _upb_ArenaHead* h = (_upb_ArenaHead*)a;
480 return (size_t)(h->end - h->ptr);
481 }
482
_upb_Arena_FastMalloc(upb_Arena * a,size_t size)483 UPB_INLINE void* _upb_Arena_FastMalloc(upb_Arena* a, size_t size) {
484 _upb_ArenaHead* h = (_upb_ArenaHead*)a;
485 void* ret = h->ptr;
486 UPB_ASSERT(UPB_ALIGN_MALLOC((uintptr_t)ret) == (uintptr_t)ret);
487 UPB_ASSERT(UPB_ALIGN_MALLOC(size) == size);
488 UPB_UNPOISON_MEMORY_REGION(ret, size);
489
490 h->ptr += size;
491
492 #if UPB_ASAN
493 {
494 size_t guard_size = 32;
495 if (_upb_ArenaHas(a) >= guard_size) {
496 h->ptr += guard_size;
497 } else {
498 h->ptr = h->end;
499 }
500 }
501 #endif
502
503 return ret;
504 }
505
upb_Arena_Malloc(upb_Arena * a,size_t size)506 UPB_INLINE void* upb_Arena_Malloc(upb_Arena* a, size_t size) {
507 size = UPB_ALIGN_MALLOC(size);
508
509 if (UPB_UNLIKELY(_upb_ArenaHas(a) < size)) {
510 return _upb_Arena_SlowMalloc(a, size);
511 }
512
513 return _upb_Arena_FastMalloc(a, size);
514 }
515
516 // Shrinks the last alloc from arena.
517 // REQUIRES: (ptr, oldsize) was the last malloc/realloc from this arena.
518 // We could also add a upb_Arena_TryShrinkLast() which is simply a no-op if
519 // this was not the last alloc.
upb_Arena_ShrinkLast(upb_Arena * a,void * ptr,size_t oldsize,size_t size)520 UPB_INLINE void upb_Arena_ShrinkLast(upb_Arena* a, void* ptr, size_t oldsize,
521 size_t size) {
522 _upb_ArenaHead* h = (_upb_ArenaHead*)a;
523 oldsize = UPB_ALIGN_MALLOC(oldsize);
524 size = UPB_ALIGN_MALLOC(size);
525 UPB_ASSERT((char*)ptr + oldsize == h->ptr); // Must be the last alloc.
526 UPB_ASSERT(size <= oldsize);
527 h->ptr = (char*)ptr + size;
528 }
529
upb_Arena_Realloc(upb_Arena * a,void * ptr,size_t oldsize,size_t size)530 UPB_INLINE void* upb_Arena_Realloc(upb_Arena* a, void* ptr, size_t oldsize,
531 size_t size) {
532 _upb_ArenaHead* h = (_upb_ArenaHead*)a;
533 oldsize = UPB_ALIGN_MALLOC(oldsize);
534 size = UPB_ALIGN_MALLOC(size);
535 bool is_most_recent_alloc = (uintptr_t)ptr + oldsize == (uintptr_t)h->ptr;
536
537 if (is_most_recent_alloc) {
538 ptrdiff_t diff = size - oldsize;
539 if ((ptrdiff_t)_upb_ArenaHas(a) >= diff) {
540 h->ptr += diff;
541 return ptr;
542 }
543 } else if (size <= oldsize) {
544 return ptr;
545 }
546
547 void* ret = upb_Arena_Malloc(a, size);
548
549 if (ret && oldsize > 0) {
550 memcpy(ret, ptr, UPB_MIN(oldsize, size));
551 }
552
553 return ret;
554 }
555
upb_Arena_New(void)556 UPB_INLINE upb_Arena* upb_Arena_New(void) {
557 return upb_Arena_Init(NULL, 0, &upb_alloc_global);
558 }
559
560 /* Constants ******************************************************************/
561
562 /* A list of types as they are encoded on-the-wire. */
563 typedef enum {
564 kUpb_WireType_Varint = 0,
565 kUpb_WireType_64Bit = 1,
566 kUpb_WireType_Delimited = 2,
567 kUpb_WireType_StartGroup = 3,
568 kUpb_WireType_EndGroup = 4,
569 kUpb_WireType_32Bit = 5
570 } upb_WireType;
571
572 /* The types a field can have. Note that this list is not identical to the
573 * types defined in descriptor.proto, which gives INT32 and SINT32 separate
574 * types (we distinguish the two with the "integer encoding" enum below). */
575 typedef enum {
576 kUpb_CType_Bool = 1,
577 kUpb_CType_Float = 2,
578 kUpb_CType_Int32 = 3,
579 kUpb_CType_UInt32 = 4,
580 kUpb_CType_Enum = 5, /* Enum values are int32. */
581 kUpb_CType_Message = 6,
582 kUpb_CType_Double = 7,
583 kUpb_CType_Int64 = 8,
584 kUpb_CType_UInt64 = 9,
585 kUpb_CType_String = 10,
586 kUpb_CType_Bytes = 11
587 } upb_CType;
588
589 /* The repeated-ness of each field; this matches descriptor.proto. */
590 typedef enum {
591 kUpb_Label_Optional = 1,
592 kUpb_Label_Required = 2,
593 kUpb_Label_Repeated = 3
594 } upb_Label;
595
596 /* Descriptor types, as defined in descriptor.proto. */
597 typedef enum {
598 kUpb_FieldType_Double = 1,
599 kUpb_FieldType_Float = 2,
600 kUpb_FieldType_Int64 = 3,
601 kUpb_FieldType_UInt64 = 4,
602 kUpb_FieldType_Int32 = 5,
603 kUpb_FieldType_Fixed64 = 6,
604 kUpb_FieldType_Fixed32 = 7,
605 kUpb_FieldType_Bool = 8,
606 kUpb_FieldType_String = 9,
607 kUpb_FieldType_Group = 10,
608 kUpb_FieldType_Message = 11,
609 kUpb_FieldType_Bytes = 12,
610 kUpb_FieldType_UInt32 = 13,
611 kUpb_FieldType_Enum = 14,
612 kUpb_FieldType_SFixed32 = 15,
613 kUpb_FieldType_SFixed64 = 16,
614 kUpb_FieldType_SInt32 = 17,
615 kUpb_FieldType_SInt64 = 18
616 } upb_FieldType;
617
618 #define kUpb_Map_Begin ((size_t)-1)
619
_upb_IsLittleEndian(void)620 UPB_INLINE bool _upb_IsLittleEndian(void) {
621 int x = 1;
622 return *(char*)&x == 1;
623 }
624
_upb_BigEndian_Swap32(uint32_t val)625 UPB_INLINE uint32_t _upb_BigEndian_Swap32(uint32_t val) {
626 if (_upb_IsLittleEndian()) {
627 return val;
628 } else {
629 return ((val & 0xff) << 24) | ((val & 0xff00) << 8) |
630 ((val & 0xff0000) >> 8) | ((val & 0xff000000) >> 24);
631 }
632 }
633
_upb_BigEndian_Swap64(uint64_t val)634 UPB_INLINE uint64_t _upb_BigEndian_Swap64(uint64_t val) {
635 if (_upb_IsLittleEndian()) {
636 return val;
637 } else {
638 return ((uint64_t)_upb_BigEndian_Swap32((uint32_t)val) << 32) |
639 _upb_BigEndian_Swap32((uint32_t)(val >> 32));
640 }
641 }
642
_upb_Log2Ceiling(int x)643 UPB_INLINE int _upb_Log2Ceiling(int x) {
644 if (x <= 1) return 0;
645 #ifdef __GNUC__
646 return 32 - __builtin_clz(x - 1);
647 #else
648 int lg2 = 0;
649 while (1 << lg2 < x) lg2++;
650 return lg2;
651 #endif
652 }
653
_upb_Log2CeilingSize(int x)654 UPB_INLINE int _upb_Log2CeilingSize(int x) { return 1 << _upb_Log2Ceiling(x); }
655
656
657 #ifdef __cplusplus
658 } /* extern "C" */
659 #endif
660
661 #endif /* UPB_H_ */
662
663 #ifdef __cplusplus
664 extern "C" {
665 #endif
666
667 /** upb_Message ***************************************************************/
668
669 typedef void upb_Message;
670
671 /* For users these are opaque. They can be obtained from
672 * upb_MessageDef_MiniTable() but users cannot access any of the members. */
673 struct upb_MiniTable;
674 typedef struct upb_MiniTable upb_MiniTable;
675
676 /* Adds unknown data (serialized protobuf data) to the given message. The data
677 * is copied into the message instance. */
678 void upb_Message_AddUnknown(upb_Message* msg, const char* data, size_t len,
679 upb_Arena* arena);
680
681 /* Returns a reference to the message's unknown data. */
682 const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len);
683
684 /* Returns the number of extensions present in this message. */
685 size_t upb_Message_ExtensionCount(const upb_Message* msg);
686
687 /** upb_ExtensionRegistry *****************************************************/
688
689 /* Extension registry: a dynamic data structure that stores a map of:
690 * (upb_MiniTable, number) -> extension info
691 *
692 * upb_decode() uses upb_ExtensionRegistry to look up extensions while parsing
693 * binary format.
694 *
695 * upb_ExtensionRegistry is part of the mini-table (msglayout) family of
696 * objects. Like all mini-table objects, it is suitable for reflection-less
697 * builds that do not want to expose names into the binary.
698 *
699 * Unlike most mini-table types, upb_ExtensionRegistry requires dynamic memory
700 * allocation and dynamic initialization:
701 * * If reflection is being used, then upb_DefPool will construct an appropriate
702 * upb_ExtensionRegistry automatically.
703 * * For a mini-table only build, the user must manually construct the
704 * upb_ExtensionRegistry and populate it with all of the extensions the user
705 * cares about.
706 * * A third alternative is to manually unpack relevant extensions after the
707 * main parse is complete, similar to how Any works. This is perhaps the
708 * nicest solution from the perspective of reducing dependencies, avoiding
709 * dynamic memory allocation, and avoiding the need to parse uninteresting
710 * extensions. The downsides are:
711 * (1) parse errors are not caught during the main parse
712 * (2) the CPU hit of parsing comes during access, which could cause an
713 * undesirable stutter in application performance.
714 *
715 * Users cannot directly get or put into this map. Users can only add the
716 * extensions from a generated module and pass the extension registry to the
717 * binary decoder.
718 *
719 * A upb_DefPool provides a upb_ExtensionRegistry, so any users who use
720 * reflection do not need to populate a upb_ExtensionRegistry directly.
721 */
722
723 struct upb_ExtensionRegistry;
724 typedef struct upb_ExtensionRegistry upb_ExtensionRegistry;
725
726 /* Creates a upb_ExtensionRegistry in the given arena. The arena must outlive
727 * any use of the extreg. */
728 upb_ExtensionRegistry* upb_ExtensionRegistry_New(upb_Arena* arena);
729
730 #ifdef __cplusplus
731 } /* extern "C" */
732 #endif
733
734 #endif /* UPB_MSG_INT_H_ */
735
736 /** upb/table_internal.h ************************************************************/
737 /*
738 * upb_table
739 *
740 * This header is INTERNAL-ONLY! Its interfaces are not public or stable!
741 * This file defines very fast int->upb_value (inttable) and string->upb_value
742 * (strtable) hash tables.
743 *
744 * The table uses chained scatter with Brent's variation (inspired by the Lua
745 * implementation of hash tables). The hash function for strings is Austin
746 * Appleby's "MurmurHash."
747 *
748 * The inttable uses uintptr_t as its key, which guarantees it can be used to
749 * store pointers or integers of at least 32 bits (upb isn't really useful on
750 * systems where sizeof(void*) < 4).
751 *
752 * The table must be homogeneous (all values of the same type). In debug
753 * mode, we check this on insert and lookup.
754 */
755
756 #ifndef UPB_TABLE_H_
757 #define UPB_TABLE_H_
758
759 #include <stdint.h>
760 #include <string.h>
761
762
763 // Must be last.
764
765 #ifdef __cplusplus
766 extern "C" {
767 #endif
768
769 /* upb_value ******************************************************************/
770
771 typedef struct {
772 uint64_t val;
773 } upb_value;
774
775 /* Variant that works with a length-delimited rather than NULL-delimited string,
776 * as supported by strtable. */
777 char* upb_strdup2(const char* s, size_t len, upb_Arena* a);
778
_upb_value_setval(upb_value * v,uint64_t val)779 UPB_INLINE void _upb_value_setval(upb_value* v, uint64_t val) { v->val = val; }
780
781 /* For each value ctype, define the following set of functions:
782 *
783 * // Get/set an int32 from a upb_value.
784 * int32_t upb_value_getint32(upb_value val);
785 * void upb_value_setint32(upb_value *val, int32_t cval);
786 *
787 * // Construct a new upb_value from an int32.
788 * upb_value upb_value_int32(int32_t val); */
789 #define FUNCS(name, membername, type_t, converter, proto_type) \
790 UPB_INLINE void upb_value_set##name(upb_value* val, type_t cval) { \
791 val->val = (converter)cval; \
792 } \
793 UPB_INLINE upb_value upb_value_##name(type_t val) { \
794 upb_value ret; \
795 upb_value_set##name(&ret, val); \
796 return ret; \
797 } \
798 UPB_INLINE type_t upb_value_get##name(upb_value val) { \
799 return (type_t)(converter)val.val; \
800 }
801
FUNCS(int32,int32,int32_t,int32_t,UPB_CTYPE_INT32)802 FUNCS(int32, int32, int32_t, int32_t, UPB_CTYPE_INT32)
803 FUNCS(int64, int64, int64_t, int64_t, UPB_CTYPE_INT64)
804 FUNCS(uint32, uint32, uint32_t, uint32_t, UPB_CTYPE_UINT32)
805 FUNCS(uint64, uint64, uint64_t, uint64_t, UPB_CTYPE_UINT64)
806 FUNCS(bool, _bool, bool, bool, UPB_CTYPE_BOOL)
807 FUNCS(cstr, cstr, char*, uintptr_t, UPB_CTYPE_CSTR)
808 FUNCS(ptr, ptr, void*, uintptr_t, UPB_CTYPE_PTR)
809 FUNCS(constptr, constptr, const void*, uintptr_t, UPB_CTYPE_CONSTPTR)
810
811 #undef FUNCS
812
813 UPB_INLINE void upb_value_setfloat(upb_value* val, float cval) {
814 memcpy(&val->val, &cval, sizeof(cval));
815 }
816
upb_value_setdouble(upb_value * val,double cval)817 UPB_INLINE void upb_value_setdouble(upb_value* val, double cval) {
818 memcpy(&val->val, &cval, sizeof(cval));
819 }
820
upb_value_float(float cval)821 UPB_INLINE upb_value upb_value_float(float cval) {
822 upb_value ret;
823 upb_value_setfloat(&ret, cval);
824 return ret;
825 }
826
upb_value_double(double cval)827 UPB_INLINE upb_value upb_value_double(double cval) {
828 upb_value ret;
829 upb_value_setdouble(&ret, cval);
830 return ret;
831 }
832
833 #undef SET_TYPE
834
835 /* upb_tabkey *****************************************************************/
836
837 /* Either:
838 * 1. an actual integer key, or
839 * 2. a pointer to a string prefixed by its uint32_t length, owned by us.
840 *
841 * ...depending on whether this is a string table or an int table. We would
842 * make this a union of those two types, but C89 doesn't support statically
843 * initializing a non-first union member. */
844 typedef uintptr_t upb_tabkey;
845
upb_tabstr(upb_tabkey key,uint32_t * len)846 UPB_INLINE char* upb_tabstr(upb_tabkey key, uint32_t* len) {
847 char* mem = (char*)key;
848 if (len) memcpy(len, mem, sizeof(*len));
849 return mem + sizeof(*len);
850 }
851
upb_tabstrview(upb_tabkey key)852 UPB_INLINE upb_StringView upb_tabstrview(upb_tabkey key) {
853 upb_StringView ret;
854 uint32_t len;
855 ret.data = upb_tabstr(key, &len);
856 ret.size = len;
857 return ret;
858 }
859
860 /* upb_tabval *****************************************************************/
861
862 typedef struct upb_tabval {
863 uint64_t val;
864 } upb_tabval;
865
866 #define UPB_TABVALUE_EMPTY_INIT \
867 { -1 }
868
869 /* upb_table ******************************************************************/
870
871 typedef struct _upb_tabent {
872 upb_tabkey key;
873 upb_tabval val;
874
875 /* Internal chaining. This is const so we can create static initializers for
876 * tables. We cast away const sometimes, but *only* when the containing
877 * upb_table is known to be non-const. This requires a bit of care, but
878 * the subtlety is confined to table.c. */
879 const struct _upb_tabent* next;
880 } upb_tabent;
881
882 typedef struct {
883 size_t count; /* Number of entries in the hash part. */
884 uint32_t mask; /* Mask to turn hash value -> bucket. */
885 uint32_t max_count; /* Max count before we hit our load limit. */
886 uint8_t size_lg2; /* Size of the hashtable part is 2^size_lg2 entries. */
887 upb_tabent* entries;
888 } upb_table;
889
890 typedef struct {
891 upb_table t;
892 } upb_strtable;
893
894 typedef struct {
895 upb_table t; /* For entries that don't fit in the array part. */
896 const upb_tabval* array; /* Array part of the table. See const note above. */
897 size_t array_size; /* Array part size. */
898 size_t array_count; /* Array part number of elements. */
899 } upb_inttable;
900
upb_table_size(const upb_table * t)901 UPB_INLINE size_t upb_table_size(const upb_table* t) {
902 if (t->size_lg2 == 0)
903 return 0;
904 else
905 return 1 << t->size_lg2;
906 }
907
908 /* Internal-only functions, in .h file only out of necessity. */
upb_tabent_isempty(const upb_tabent * e)909 UPB_INLINE bool upb_tabent_isempty(const upb_tabent* e) { return e->key == 0; }
910
911 /* Initialize and uninitialize a table, respectively. If memory allocation
912 * failed, false is returned that the table is uninitialized. */
913 bool upb_inttable_init(upb_inttable* table, upb_Arena* a);
914 bool upb_strtable_init(upb_strtable* table, size_t expected_size, upb_Arena* a);
915
916 /* Returns the number of values in the table. */
917 size_t upb_inttable_count(const upb_inttable* t);
upb_strtable_count(const upb_strtable * t)918 UPB_INLINE size_t upb_strtable_count(const upb_strtable* t) {
919 return t->t.count;
920 }
921
922 void upb_strtable_clear(upb_strtable* t);
923
924 /* Inserts the given key into the hashtable with the given value. The key must
925 * not already exist in the hash table. For string tables, the key must be
926 * NULL-terminated, and the table will make an internal copy of the key.
927 * Inttables must not insert a value of UINTPTR_MAX.
928 *
929 * If a table resize was required but memory allocation failed, false is
930 * returned and the table is unchanged. */
931 bool upb_inttable_insert(upb_inttable* t, uintptr_t key, upb_value val,
932 upb_Arena* a);
933 bool upb_strtable_insert(upb_strtable* t, const char* key, size_t len,
934 upb_value val, upb_Arena* a);
935
936 /* Looks up key in this table, returning "true" if the key was found.
937 * If v is non-NULL, copies the value for this key into *v. */
938 bool upb_inttable_lookup(const upb_inttable* t, uintptr_t key, upb_value* v);
939 bool upb_strtable_lookup2(const upb_strtable* t, const char* key, size_t len,
940 upb_value* v);
941
942 /* For NULL-terminated strings. */
upb_strtable_lookup(const upb_strtable * t,const char * key,upb_value * v)943 UPB_INLINE bool upb_strtable_lookup(const upb_strtable* t, const char* key,
944 upb_value* v) {
945 return upb_strtable_lookup2(t, key, strlen(key), v);
946 }
947
948 /* Removes an item from the table. Returns true if the remove was successful,
949 * and stores the removed item in *val if non-NULL. */
950 bool upb_inttable_remove(upb_inttable* t, uintptr_t key, upb_value* val);
951 bool upb_strtable_remove2(upb_strtable* t, const char* key, size_t len,
952 upb_value* val);
953
upb_strtable_remove(upb_strtable * t,const char * key,upb_value * v)954 UPB_INLINE bool upb_strtable_remove(upb_strtable* t, const char* key,
955 upb_value* v) {
956 return upb_strtable_remove2(t, key, strlen(key), v);
957 }
958
959 /* Updates an existing entry in an inttable. If the entry does not exist,
960 * returns false and does nothing. Unlike insert/remove, this does not
961 * invalidate iterators. */
962 bool upb_inttable_replace(upb_inttable* t, uintptr_t key, upb_value val);
963
964 /* Optimizes the table for the current set of entries, for both memory use and
965 * lookup time. Client should call this after all entries have been inserted;
966 * inserting more entries is legal, but will likely require a table resize. */
967 void upb_inttable_compact(upb_inttable* t, upb_Arena* a);
968
969 /* Exposed for testing only. */
970 bool upb_strtable_resize(upb_strtable* t, size_t size_lg2, upb_Arena* a);
971
972 /* Iterators ******************************************************************/
973
974 /* Iteration over inttable.
975 *
976 * intptr_t iter = UPB_INTTABLE_BEGIN;
977 * uintptr_t key;
978 * upb_value val;
979 * while (upb_inttable_next2(t, &key, &val, &iter)) {
980 * // ...
981 * }
982 */
983
984 #define UPB_INTTABLE_BEGIN -1
985
986 bool upb_inttable_next2(const upb_inttable* t, uintptr_t* key, upb_value* val,
987 intptr_t* iter);
988 void upb_inttable_removeiter(upb_inttable* t, intptr_t* iter);
989
990 /* Iteration over strtable.
991 *
992 * intptr_t iter = UPB_INTTABLE_BEGIN;
993 * upb_StringView key;
994 * upb_value val;
995 * while (upb_strtable_next2(t, &key, &val, &iter)) {
996 * // ...
997 * }
998 */
999
1000 #define UPB_STRTABLE_BEGIN -1
1001
1002 bool upb_strtable_next2(const upb_strtable* t, upb_StringView* key,
1003 upb_value* val, intptr_t* iter);
1004 void upb_strtable_removeiter(upb_strtable* t, intptr_t* iter);
1005
1006 /* DEPRECATED iterators, slated for removal.
1007 *
1008 * Iterators for int and string tables. We are subject to some kind of unusual
1009 * design constraints:
1010 *
1011 * For high-level languages:
1012 * - we must be able to guarantee that we don't crash or corrupt memory even if
1013 * the program accesses an invalidated iterator.
1014 *
1015 * For C++11 range-based for:
1016 * - iterators must be copyable
1017 * - iterators must be comparable
1018 * - it must be possible to construct an "end" value.
1019 *
1020 * Iteration order is undefined.
1021 *
1022 * Modifying the table invalidates iterators. upb_{str,int}table_done() is
1023 * guaranteed to work even on an invalidated iterator, as long as the table it
1024 * is iterating over has not been freed. Calling next() or accessing data from
1025 * an invalidated iterator yields unspecified elements from the table, but it is
1026 * guaranteed not to crash and to return real table elements (except when done()
1027 * is true). */
1028
1029 /* upb_strtable_iter **********************************************************/
1030
1031 /* upb_strtable_iter i;
1032 * upb_strtable_begin(&i, t);
1033 * for(; !upb_strtable_done(&i); upb_strtable_next(&i)) {
1034 * const char *key = upb_strtable_iter_key(&i);
1035 * const upb_value val = upb_strtable_iter_value(&i);
1036 * // ...
1037 * }
1038 */
1039
1040 typedef struct {
1041 const upb_strtable* t;
1042 size_t index;
1043 } upb_strtable_iter;
1044
1045 void upb_strtable_begin(upb_strtable_iter* i, const upb_strtable* t);
1046 void upb_strtable_next(upb_strtable_iter* i);
1047 bool upb_strtable_done(const upb_strtable_iter* i);
1048 upb_StringView upb_strtable_iter_key(const upb_strtable_iter* i);
1049 upb_value upb_strtable_iter_value(const upb_strtable_iter* i);
1050 void upb_strtable_iter_setdone(upb_strtable_iter* i);
1051 bool upb_strtable_iter_isequal(const upb_strtable_iter* i1,
1052 const upb_strtable_iter* i2);
1053
1054 /* upb_inttable_iter **********************************************************/
1055
1056 /* upb_inttable_iter i;
1057 * upb_inttable_begin(&i, t);
1058 * for(; !upb_inttable_done(&i); upb_inttable_next(&i)) {
1059 * uintptr_t key = upb_inttable_iter_key(&i);
1060 * upb_value val = upb_inttable_iter_value(&i);
1061 * // ...
1062 * }
1063 */
1064
1065 typedef struct {
1066 const upb_inttable* t;
1067 size_t index;
1068 bool array_part;
1069 } upb_inttable_iter;
1070
str_tabent(const upb_strtable_iter * i)1071 UPB_INLINE const upb_tabent* str_tabent(const upb_strtable_iter* i) {
1072 return &i->t->t.entries[i->index];
1073 }
1074
1075 void upb_inttable_begin(upb_inttable_iter* i, const upb_inttable* t);
1076 void upb_inttable_next(upb_inttable_iter* i);
1077 bool upb_inttable_done(const upb_inttable_iter* i);
1078 uintptr_t upb_inttable_iter_key(const upb_inttable_iter* i);
1079 upb_value upb_inttable_iter_value(const upb_inttable_iter* i);
1080 void upb_inttable_iter_setdone(upb_inttable_iter* i);
1081 bool upb_inttable_iter_isequal(const upb_inttable_iter* i1,
1082 const upb_inttable_iter* i2);
1083
1084 uint32_t _upb_Hash(const void* p, size_t n, uint64_t seed);
1085
1086 #ifdef __cplusplus
1087 } /* extern "C" */
1088 #endif
1089
1090
1091 #endif /* UPB_TABLE_H_ */
1092
1093 /* Must be last. */
1094
1095 #ifdef __cplusplus
1096 extern "C" {
1097 #endif
1098
1099 /** upb_*Int* conversion routines ********************************************/
1100
_upb_Int32_FromI(int v)1101 UPB_INLINE int32_t _upb_Int32_FromI(int v) { return (int32_t)v; }
1102
_upb_Int64_FromLL(long long v)1103 UPB_INLINE int64_t _upb_Int64_FromLL(long long v) { return (int64_t)v; }
1104
_upb_UInt32_FromU(unsigned v)1105 UPB_INLINE uint32_t _upb_UInt32_FromU(unsigned v) { return (uint32_t)v; }
1106
_upb_UInt64_FromULL(unsigned long long v)1107 UPB_INLINE uint64_t _upb_UInt64_FromULL(unsigned long long v) {
1108 return (uint64_t)v;
1109 }
1110
1111 /** upb_MiniTable *************************************************************/
1112
1113 /* upb_MiniTable represents the memory layout of a given upb_MessageDef. The
1114 * members are public so generated code can initialize them, but users MUST NOT
1115 * read or write any of its members. */
1116
1117 typedef struct {
1118 uint32_t number;
1119 uint16_t offset;
1120 int16_t presence; // If >0, hasbit_index. If <0, ~oneof_index
1121 uint16_t submsg_index; // kUpb_NoSub if descriptortype != MESSAGE/GROUP/ENUM
1122 uint8_t descriptortype;
1123 uint8_t mode; /* upb_FieldMode | upb_LabelFlags |
1124 (upb_FieldRep << kUpb_FieldRep_Shift) */
1125 } upb_MiniTable_Field;
1126
1127 #define kUpb_NoSub ((uint16_t)-1)
1128
1129 typedef enum {
1130 kUpb_FieldMode_Map = 0,
1131 kUpb_FieldMode_Array = 1,
1132 kUpb_FieldMode_Scalar = 2,
1133 } upb_FieldMode;
1134
1135 // Mask to isolate the upb_FieldMode from field.mode.
1136 #define kUpb_FieldMode_Mask 3
1137
1138 /* Extra flags on the mode field. */
1139 typedef enum {
1140 kUpb_LabelFlags_IsPacked = 4,
1141 kUpb_LabelFlags_IsExtension = 8,
1142 } upb_LabelFlags;
1143
1144 // Note: we sort by this number when calculating layout order.
1145 typedef enum {
1146 kUpb_FieldRep_1Byte = 0,
1147 kUpb_FieldRep_4Byte = 1,
1148 kUpb_FieldRep_StringView = 2,
1149 kUpb_FieldRep_Pointer = 3,
1150 kUpb_FieldRep_8Byte = 4,
1151
1152 kUpb_FieldRep_Shift = 5, // Bit offset of the rep in upb_MiniTable_Field.mode
1153 kUpb_FieldRep_Max = kUpb_FieldRep_8Byte,
1154 } upb_FieldRep;
1155
upb_FieldMode_Get(const upb_MiniTable_Field * field)1156 UPB_INLINE upb_FieldMode upb_FieldMode_Get(const upb_MiniTable_Field* field) {
1157 return (upb_FieldMode)(field->mode & 3);
1158 }
1159
upb_IsRepeatedOrMap(const upb_MiniTable_Field * field)1160 UPB_INLINE bool upb_IsRepeatedOrMap(const upb_MiniTable_Field* field) {
1161 /* This works because upb_FieldMode has no value 3. */
1162 return !(field->mode & kUpb_FieldMode_Scalar);
1163 }
1164
upb_IsSubMessage(const upb_MiniTable_Field * field)1165 UPB_INLINE bool upb_IsSubMessage(const upb_MiniTable_Field* field) {
1166 return field->descriptortype == kUpb_FieldType_Message ||
1167 field->descriptortype == kUpb_FieldType_Group;
1168 }
1169
1170 struct upb_Decoder;
1171 struct upb_MiniTable;
1172
1173 typedef const char* _upb_FieldParser(struct upb_Decoder* d, const char* ptr,
1174 upb_Message* msg, intptr_t table,
1175 uint64_t hasbits, uint64_t data);
1176
1177 typedef struct {
1178 uint64_t field_data;
1179 _upb_FieldParser* field_parser;
1180 } _upb_FastTable_Entry;
1181
1182 typedef struct {
1183 const int32_t* values; // List of values <0 or >63
1184 uint64_t mask; // Bits are set for acceptable value 0 <= x < 64
1185 int value_count;
1186 } upb_MiniTable_Enum;
1187
1188 typedef union {
1189 const struct upb_MiniTable* submsg;
1190 const upb_MiniTable_Enum* subenum;
1191 } upb_MiniTable_Sub;
1192
1193 typedef enum {
1194 kUpb_ExtMode_NonExtendable = 0, // Non-extendable message.
1195 kUpb_ExtMode_Extendable = 1, // Normal extendable message.
1196 kUpb_ExtMode_IsMessageSet = 2, // MessageSet message.
1197 kUpb_ExtMode_IsMessageSet_ITEM =
1198 3, // MessageSet item (temporary only, see decode.c)
1199
1200 // During table building we steal a bit to indicate that the message is a map
1201 // entry. *Only* used during table building!
1202 kUpb_ExtMode_IsMapEntry = 4,
1203 } upb_ExtMode;
1204
1205 /* MessageSet wire format is:
1206 * message MessageSet {
1207 * repeated group Item = 1 {
1208 * required int32 type_id = 2;
1209 * required bytes message = 3;
1210 * }
1211 * }
1212 */
1213 typedef enum {
1214 _UPB_MSGSET_ITEM = 1,
1215 _UPB_MSGSET_TYPEID = 2,
1216 _UPB_MSGSET_MESSAGE = 3,
1217 } upb_msgext_fieldnum;
1218
1219 struct upb_MiniTable {
1220 const upb_MiniTable_Sub* subs;
1221 const upb_MiniTable_Field* fields;
1222 /* Must be aligned to sizeof(void*). Doesn't include internal members like
1223 * unknown fields, extension dict, pointer to msglayout, etc. */
1224 uint16_t size;
1225 uint16_t field_count;
1226 uint8_t ext; // upb_ExtMode, declared as uint8_t so sizeof(ext) == 1
1227 uint8_t dense_below;
1228 uint8_t table_mask;
1229 uint8_t required_count; // Required fields have the lowest hasbits.
1230 /* To statically initialize the tables of variable length, we need a flexible
1231 * array member, and we need to compile in gnu99 mode (constant initialization
1232 * of flexible array members is a GNU extension, not in C99 unfortunately. */
1233 _upb_FastTable_Entry fasttable[];
1234 };
1235
1236 typedef struct {
1237 upb_MiniTable_Field field;
1238 const upb_MiniTable* extendee;
1239 upb_MiniTable_Sub sub; /* NULL unless submessage or proto2 enum */
1240 } upb_MiniTable_Extension;
1241
1242 typedef struct {
1243 const upb_MiniTable** msgs;
1244 const upb_MiniTable_Enum** enums;
1245 const upb_MiniTable_Extension** exts;
1246 int msg_count;
1247 int enum_count;
1248 int ext_count;
1249 } upb_MiniTable_File;
1250
1251 // Computes a bitmask in which the |l->required_count| lowest bits are set,
1252 // except that we skip the lowest bit (because upb never uses hasbit 0).
1253 //
1254 // Sample output:
1255 // requiredmask(1) => 0b10 (0x2)
1256 // requiredmask(5) => 0b111110 (0x3e)
upb_MiniTable_requiredmask(const upb_MiniTable * l)1257 UPB_INLINE uint64_t upb_MiniTable_requiredmask(const upb_MiniTable* l) {
1258 int n = l->required_count;
1259 assert(0 < n && n <= 63);
1260 return ((1ULL << n) - 1) << 1;
1261 }
1262
1263 /** upb_ExtensionRegistry *****************************************************/
1264
1265 /* Adds the given extension info for message type |l| and field number |num|
1266 * into the registry. Returns false if this message type and field number were
1267 * already in the map, or if memory allocation fails. */
1268 bool _upb_extreg_add(upb_ExtensionRegistry* r,
1269 const upb_MiniTable_Extension** e, size_t count);
1270
1271 /* Looks up the extension (if any) defined for message type |l| and field
1272 * number |num|. If an extension was found, copies the field info into |*ext|
1273 * and returns true. Otherwise returns false. */
1274 const upb_MiniTable_Extension* _upb_extreg_get(const upb_ExtensionRegistry* r,
1275 const upb_MiniTable* l,
1276 uint32_t num);
1277
1278 /** upb_Message ***************************************************************/
1279
1280 /* Internal members of a upb_Message that track unknown fields and/or
1281 * extensions. We can change this without breaking binary compatibility. We put
1282 * these before the user's data. The user's upb_Message* points after the
1283 * upb_Message_Internal. */
1284
1285 typedef struct {
1286 /* Total size of this structure, including the data that follows.
1287 * Must be aligned to 8, which is alignof(upb_Message_Extension) */
1288 uint32_t size;
1289
1290 /* Offsets relative to the beginning of this structure.
1291 *
1292 * Unknown data grows forward from the beginning to unknown_end.
1293 * Extension data grows backward from size to ext_begin.
1294 * When the two meet, we're out of data and have to realloc.
1295 *
1296 * If we imagine that the final member of this struct is:
1297 * char data[size - overhead]; // overhead =
1298 * sizeof(upb_Message_InternalData)
1299 *
1300 * Then we have:
1301 * unknown data: data[0 .. (unknown_end - overhead)]
1302 * extensions data: data[(ext_begin - overhead) .. (size - overhead)] */
1303 uint32_t unknown_end;
1304 uint32_t ext_begin;
1305 /* Data follows, as if there were an array:
1306 * char data[size - sizeof(upb_Message_InternalData)]; */
1307 } upb_Message_InternalData;
1308
1309 typedef struct {
1310 upb_Message_InternalData* internal;
1311 /* Message data follows. */
1312 } upb_Message_Internal;
1313
1314 /* Maps upb_CType -> memory size. */
1315 extern char _upb_CTypeo_size[12];
1316
upb_msg_sizeof(const upb_MiniTable * l)1317 UPB_INLINE size_t upb_msg_sizeof(const upb_MiniTable* l) {
1318 return l->size + sizeof(upb_Message_Internal);
1319 }
1320
_upb_Message_New_inl(const upb_MiniTable * l,upb_Arena * a)1321 UPB_INLINE upb_Message* _upb_Message_New_inl(const upb_MiniTable* l,
1322 upb_Arena* a) {
1323 size_t size = upb_msg_sizeof(l);
1324 void* mem = upb_Arena_Malloc(a, size + sizeof(upb_Message_Internal));
1325 upb_Message* msg;
1326 if (UPB_UNLIKELY(!mem)) return NULL;
1327 msg = UPB_PTR_AT(mem, sizeof(upb_Message_Internal), upb_Message);
1328 memset(mem, 0, size);
1329 return msg;
1330 }
1331
1332 /* Creates a new messages with the given layout on the given arena. */
1333 upb_Message* _upb_Message_New(const upb_MiniTable* l, upb_Arena* a);
1334
upb_Message_Getinternal(upb_Message * msg)1335 UPB_INLINE upb_Message_Internal* upb_Message_Getinternal(upb_Message* msg) {
1336 ptrdiff_t size = sizeof(upb_Message_Internal);
1337 return (upb_Message_Internal*)((char*)msg - size);
1338 }
1339
1340 /* Clears the given message. */
1341 void _upb_Message_Clear(upb_Message* msg, const upb_MiniTable* l);
1342
1343 /* Discards the unknown fields for this message only. */
1344 void _upb_Message_DiscardUnknown_shallow(upb_Message* msg);
1345
1346 /* Adds unknown data (serialized protobuf data) to the given message. The data
1347 * is copied into the message instance. */
1348 bool _upb_Message_AddUnknown(upb_Message* msg, const char* data, size_t len,
1349 upb_Arena* arena);
1350
1351 /** upb_Message_Extension *****************************************************/
1352
1353 /* The internal representation of an extension is self-describing: it contains
1354 * enough information that we can serialize it to binary format without needing
1355 * to look it up in a upb_ExtensionRegistry.
1356 *
1357 * This representation allocates 16 bytes to data on 64-bit platforms. This is
1358 * rather wasteful for scalars (in the extreme case of bool, it wastes 15
1359 * bytes). We accept this because we expect messages to be the most common
1360 * extension type. */
1361 typedef struct {
1362 const upb_MiniTable_Extension* ext;
1363 union {
1364 upb_StringView str;
1365 void* ptr;
1366 char scalar_data[8];
1367 } data;
1368 } upb_Message_Extension;
1369
1370 /* Adds the given extension data to the given message. |ext| is copied into the
1371 * message instance. This logically replaces any previously-added extension with
1372 * this number */
1373 upb_Message_Extension* _upb_Message_GetOrCreateExtension(
1374 upb_Message* msg, const upb_MiniTable_Extension* ext, upb_Arena* arena);
1375
1376 /* Returns an array of extensions for this message. Note: the array is
1377 * ordered in reverse relative to the order of creation. */
1378 const upb_Message_Extension* _upb_Message_Getexts(const upb_Message* msg,
1379 size_t* count);
1380
1381 /* Returns an extension for the given field number, or NULL if no extension
1382 * exists for this field number. */
1383 const upb_Message_Extension* _upb_Message_Getext(
1384 const upb_Message* msg, const upb_MiniTable_Extension* ext);
1385
1386 void _upb_Message_Clearext(upb_Message* msg,
1387 const upb_MiniTable_Extension* ext);
1388
1389 void _upb_Message_Clearext(upb_Message* msg,
1390 const upb_MiniTable_Extension* ext);
1391
1392 /** Hasbit access *************************************************************/
1393
_upb_hasbit(const upb_Message * msg,size_t idx)1394 UPB_INLINE bool _upb_hasbit(const upb_Message* msg, size_t idx) {
1395 return (*UPB_PTR_AT(msg, idx / 8, const char) & (1 << (idx % 8))) != 0;
1396 }
1397
_upb_sethas(const upb_Message * msg,size_t idx)1398 UPB_INLINE void _upb_sethas(const upb_Message* msg, size_t idx) {
1399 (*UPB_PTR_AT(msg, idx / 8, char)) |= (char)(1 << (idx % 8));
1400 }
1401
_upb_clearhas(const upb_Message * msg,size_t idx)1402 UPB_INLINE void _upb_clearhas(const upb_Message* msg, size_t idx) {
1403 (*UPB_PTR_AT(msg, idx / 8, char)) &= (char)(~(1 << (idx % 8)));
1404 }
1405
_upb_Message_Hasidx(const upb_MiniTable_Field * f)1406 UPB_INLINE size_t _upb_Message_Hasidx(const upb_MiniTable_Field* f) {
1407 UPB_ASSERT(f->presence > 0);
1408 return f->presence;
1409 }
1410
_upb_hasbit_field(const upb_Message * msg,const upb_MiniTable_Field * f)1411 UPB_INLINE bool _upb_hasbit_field(const upb_Message* msg,
1412 const upb_MiniTable_Field* f) {
1413 return _upb_hasbit(msg, _upb_Message_Hasidx(f));
1414 }
1415
_upb_sethas_field(const upb_Message * msg,const upb_MiniTable_Field * f)1416 UPB_INLINE void _upb_sethas_field(const upb_Message* msg,
1417 const upb_MiniTable_Field* f) {
1418 _upb_sethas(msg, _upb_Message_Hasidx(f));
1419 }
1420
_upb_clearhas_field(const upb_Message * msg,const upb_MiniTable_Field * f)1421 UPB_INLINE void _upb_clearhas_field(const upb_Message* msg,
1422 const upb_MiniTable_Field* f) {
1423 _upb_clearhas(msg, _upb_Message_Hasidx(f));
1424 }
1425
1426 /** Oneof case access *********************************************************/
1427
_upb_oneofcase(upb_Message * msg,size_t case_ofs)1428 UPB_INLINE uint32_t* _upb_oneofcase(upb_Message* msg, size_t case_ofs) {
1429 return UPB_PTR_AT(msg, case_ofs, uint32_t);
1430 }
1431
_upb_getoneofcase(const void * msg,size_t case_ofs)1432 UPB_INLINE uint32_t _upb_getoneofcase(const void* msg, size_t case_ofs) {
1433 return *UPB_PTR_AT(msg, case_ofs, uint32_t);
1434 }
1435
_upb_oneofcase_ofs(const upb_MiniTable_Field * f)1436 UPB_INLINE size_t _upb_oneofcase_ofs(const upb_MiniTable_Field* f) {
1437 UPB_ASSERT(f->presence < 0);
1438 return ~(ptrdiff_t)f->presence;
1439 }
1440
_upb_oneofcase_field(upb_Message * msg,const upb_MiniTable_Field * f)1441 UPB_INLINE uint32_t* _upb_oneofcase_field(upb_Message* msg,
1442 const upb_MiniTable_Field* f) {
1443 return _upb_oneofcase(msg, _upb_oneofcase_ofs(f));
1444 }
1445
_upb_getoneofcase_field(const upb_Message * msg,const upb_MiniTable_Field * f)1446 UPB_INLINE uint32_t _upb_getoneofcase_field(const upb_Message* msg,
1447 const upb_MiniTable_Field* f) {
1448 return _upb_getoneofcase(msg, _upb_oneofcase_ofs(f));
1449 }
1450
_upb_has_submsg_nohasbit(const upb_Message * msg,size_t ofs)1451 UPB_INLINE bool _upb_has_submsg_nohasbit(const upb_Message* msg, size_t ofs) {
1452 return *UPB_PTR_AT(msg, ofs, const upb_Message*) != NULL;
1453 }
1454
1455 /** upb_Array *****************************************************************/
1456
1457 /* Our internal representation for repeated fields. */
1458 typedef struct {
1459 uintptr_t data; /* Tagged ptr: low 3 bits of ptr are lg2(elem size). */
1460 size_t len; /* Measured in elements. */
1461 size_t size; /* Measured in elements. */
1462 uint64_t junk;
1463 } upb_Array;
1464
_upb_array_constptr(const upb_Array * arr)1465 UPB_INLINE const void* _upb_array_constptr(const upb_Array* arr) {
1466 UPB_ASSERT((arr->data & 7) <= 4);
1467 return (void*)(arr->data & ~(uintptr_t)7);
1468 }
1469
_upb_array_tagptr(void * ptr,int elem_size_lg2)1470 UPB_INLINE uintptr_t _upb_array_tagptr(void* ptr, int elem_size_lg2) {
1471 UPB_ASSERT(elem_size_lg2 <= 4);
1472 return (uintptr_t)ptr | elem_size_lg2;
1473 }
1474
_upb_array_ptr(upb_Array * arr)1475 UPB_INLINE void* _upb_array_ptr(upb_Array* arr) {
1476 return (void*)_upb_array_constptr(arr);
1477 }
1478
_upb_tag_arrptr(void * ptr,int elem_size_lg2)1479 UPB_INLINE uintptr_t _upb_tag_arrptr(void* ptr, int elem_size_lg2) {
1480 UPB_ASSERT(elem_size_lg2 <= 4);
1481 UPB_ASSERT(((uintptr_t)ptr & 7) == 0);
1482 return (uintptr_t)ptr | (unsigned)elem_size_lg2;
1483 }
1484
_upb_Array_New(upb_Arena * a,size_t init_size,int elem_size_lg2)1485 UPB_INLINE upb_Array* _upb_Array_New(upb_Arena* a, size_t init_size,
1486 int elem_size_lg2) {
1487 const size_t arr_size = UPB_ALIGN_UP(sizeof(upb_Array), UPB_MALLOC_ALIGN);
1488 const size_t bytes = arr_size + (init_size << elem_size_lg2);
1489 upb_Array* arr = (upb_Array*)upb_Arena_Malloc(a, bytes);
1490 if (!arr) return NULL;
1491 arr->data = _upb_tag_arrptr(UPB_PTR_AT(arr, arr_size, void), elem_size_lg2);
1492 arr->len = 0;
1493 arr->size = init_size;
1494 return arr;
1495 }
1496
1497 /* Resizes the capacity of the array to be at least min_size. */
1498 bool _upb_array_realloc(upb_Array* arr, size_t min_size, upb_Arena* arena);
1499
1500 /* Fallback functions for when the accessors require a resize. */
1501 void* _upb_Array_Resize_fallback(upb_Array** arr_ptr, size_t size,
1502 int elem_size_lg2, upb_Arena* arena);
1503 bool _upb_Array_Append_fallback(upb_Array** arr_ptr, const void* value,
1504 int elem_size_lg2, upb_Arena* arena);
1505
_upb_array_reserve(upb_Array * arr,size_t size,upb_Arena * arena)1506 UPB_INLINE bool _upb_array_reserve(upb_Array* arr, size_t size,
1507 upb_Arena* arena) {
1508 if (arr->size < size) return _upb_array_realloc(arr, size, arena);
1509 return true;
1510 }
1511
_upb_Array_Resize(upb_Array * arr,size_t size,upb_Arena * arena)1512 UPB_INLINE bool _upb_Array_Resize(upb_Array* arr, size_t size,
1513 upb_Arena* arena) {
1514 if (!_upb_array_reserve(arr, size, arena)) return false;
1515 arr->len = size;
1516 return true;
1517 }
1518
_upb_array_detach(const void * msg,size_t ofs)1519 UPB_INLINE void _upb_array_detach(const void* msg, size_t ofs) {
1520 *UPB_PTR_AT(msg, ofs, upb_Array*) = NULL;
1521 }
1522
_upb_array_accessor(const void * msg,size_t ofs,size_t * size)1523 UPB_INLINE const void* _upb_array_accessor(const void* msg, size_t ofs,
1524 size_t* size) {
1525 const upb_Array* arr = *UPB_PTR_AT(msg, ofs, const upb_Array*);
1526 if (arr) {
1527 if (size) *size = arr->len;
1528 return _upb_array_constptr(arr);
1529 } else {
1530 if (size) *size = 0;
1531 return NULL;
1532 }
1533 }
1534
_upb_array_mutable_accessor(void * msg,size_t ofs,size_t * size)1535 UPB_INLINE void* _upb_array_mutable_accessor(void* msg, size_t ofs,
1536 size_t* size) {
1537 upb_Array* arr = *UPB_PTR_AT(msg, ofs, upb_Array*);
1538 if (arr) {
1539 if (size) *size = arr->len;
1540 return _upb_array_ptr(arr);
1541 } else {
1542 if (size) *size = 0;
1543 return NULL;
1544 }
1545 }
1546
_upb_Array_Resize_accessor2(void * msg,size_t ofs,size_t size,int elem_size_lg2,upb_Arena * arena)1547 UPB_INLINE void* _upb_Array_Resize_accessor2(void* msg, size_t ofs, size_t size,
1548 int elem_size_lg2,
1549 upb_Arena* arena) {
1550 upb_Array** arr_ptr = UPB_PTR_AT(msg, ofs, upb_Array*);
1551 upb_Array* arr = *arr_ptr;
1552 if (!arr || arr->size < size) {
1553 return _upb_Array_Resize_fallback(arr_ptr, size, elem_size_lg2, arena);
1554 }
1555 arr->len = size;
1556 return _upb_array_ptr(arr);
1557 }
1558
_upb_Array_Append_accessor2(void * msg,size_t ofs,int elem_size_lg2,const void * value,upb_Arena * arena)1559 UPB_INLINE bool _upb_Array_Append_accessor2(void* msg, size_t ofs,
1560 int elem_size_lg2,
1561 const void* value,
1562 upb_Arena* arena) {
1563 upb_Array** arr_ptr = UPB_PTR_AT(msg, ofs, upb_Array*);
1564 size_t elem_size = 1 << elem_size_lg2;
1565 upb_Array* arr = *arr_ptr;
1566 void* ptr;
1567 if (!arr || arr->len == arr->size) {
1568 return _upb_Array_Append_fallback(arr_ptr, value, elem_size_lg2, arena);
1569 }
1570 ptr = _upb_array_ptr(arr);
1571 memcpy(UPB_PTR_AT(ptr, arr->len * elem_size, char), value, elem_size);
1572 arr->len++;
1573 return true;
1574 }
1575
1576 /* Used by old generated code, remove once all code has been regenerated. */
_upb_sizelg2(upb_CType type)1577 UPB_INLINE int _upb_sizelg2(upb_CType type) {
1578 switch (type) {
1579 case kUpb_CType_Bool:
1580 return 0;
1581 case kUpb_CType_Float:
1582 case kUpb_CType_Int32:
1583 case kUpb_CType_UInt32:
1584 case kUpb_CType_Enum:
1585 return 2;
1586 case kUpb_CType_Message:
1587 return UPB_SIZE(2, 3);
1588 case kUpb_CType_Double:
1589 case kUpb_CType_Int64:
1590 case kUpb_CType_UInt64:
1591 return 3;
1592 case kUpb_CType_String:
1593 case kUpb_CType_Bytes:
1594 return UPB_SIZE(3, 4);
1595 }
1596 UPB_UNREACHABLE();
1597 }
_upb_Array_Resize_accessor(void * msg,size_t ofs,size_t size,upb_CType type,upb_Arena * arena)1598 UPB_INLINE void* _upb_Array_Resize_accessor(void* msg, size_t ofs, size_t size,
1599 upb_CType type, upb_Arena* arena) {
1600 return _upb_Array_Resize_accessor2(msg, ofs, size, _upb_sizelg2(type), arena);
1601 }
_upb_Array_Append_accessor(void * msg,size_t ofs,size_t elem_size,upb_CType type,const void * value,upb_Arena * arena)1602 UPB_INLINE bool _upb_Array_Append_accessor(void* msg, size_t ofs,
1603 size_t elem_size, upb_CType type,
1604 const void* value,
1605 upb_Arena* arena) {
1606 (void)elem_size;
1607 return _upb_Array_Append_accessor2(msg, ofs, _upb_sizelg2(type), value,
1608 arena);
1609 }
1610
1611 /** upb_Map *******************************************************************/
1612
1613 /* Right now we use strmaps for everything. We'll likely want to use
1614 * integer-specific maps for integer-keyed maps.*/
1615 typedef struct {
1616 /* Size of key and val, based on the map type. Strings are represented as '0'
1617 * because they must be handled specially. */
1618 char key_size;
1619 char val_size;
1620
1621 upb_strtable table;
1622 } upb_Map;
1623
1624 /* Map entries aren't actually stored, they are only used during parsing. For
1625 * parsing, it helps a lot if all map entry messages have the same layout.
1626 * The compiler and def.c must ensure that all map entries have this layout. */
1627 typedef struct {
1628 upb_Message_Internal internal;
1629 union {
1630 upb_StringView str; /* For str/bytes. */
1631 upb_value val; /* For all other types. */
1632 } k;
1633 union {
1634 upb_StringView str; /* For str/bytes. */
1635 upb_value val; /* For all other types. */
1636 } v;
1637 } upb_MapEntry;
1638
1639 /* Creates a new map on the given arena with this key/value type. */
1640 upb_Map* _upb_Map_New(upb_Arena* a, size_t key_size, size_t value_size);
1641
1642 /* Converting between internal table representation and user values.
1643 *
1644 * _upb_map_tokey() and _upb_map_fromkey() are inverses.
1645 * _upb_map_tovalue() and _upb_map_fromvalue() are inverses.
1646 *
1647 * These functions account for the fact that strings are treated differently
1648 * from other types when stored in a map.
1649 */
1650
_upb_map_tokey(const void * key,size_t size)1651 UPB_INLINE upb_StringView _upb_map_tokey(const void* key, size_t size) {
1652 if (size == UPB_MAPTYPE_STRING) {
1653 return *(upb_StringView*)key;
1654 } else {
1655 return upb_StringView_FromDataAndSize((const char*)key, size);
1656 }
1657 }
1658
_upb_map_fromkey(upb_StringView key,void * out,size_t size)1659 UPB_INLINE void _upb_map_fromkey(upb_StringView key, void* out, size_t size) {
1660 if (size == UPB_MAPTYPE_STRING) {
1661 memcpy(out, &key, sizeof(key));
1662 } else {
1663 memcpy(out, key.data, size);
1664 }
1665 }
1666
_upb_map_tovalue(const void * val,size_t size,upb_value * msgval,upb_Arena * a)1667 UPB_INLINE bool _upb_map_tovalue(const void* val, size_t size,
1668 upb_value* msgval, upb_Arena* a) {
1669 if (size == UPB_MAPTYPE_STRING) {
1670 upb_StringView* strp = (upb_StringView*)upb_Arena_Malloc(a, sizeof(*strp));
1671 if (!strp) return false;
1672 *strp = *(upb_StringView*)val;
1673 *msgval = upb_value_ptr(strp);
1674 } else {
1675 memcpy(msgval, val, size);
1676 }
1677 return true;
1678 }
1679
_upb_map_fromvalue(upb_value val,void * out,size_t size)1680 UPB_INLINE void _upb_map_fromvalue(upb_value val, void* out, size_t size) {
1681 if (size == UPB_MAPTYPE_STRING) {
1682 const upb_StringView* strp = (const upb_StringView*)upb_value_getptr(val);
1683 memcpy(out, strp, sizeof(upb_StringView));
1684 } else {
1685 memcpy(out, &val, size);
1686 }
1687 }
1688
1689 /* Map operations, shared by reflection and generated code. */
1690
_upb_Map_Size(const upb_Map * map)1691 UPB_INLINE size_t _upb_Map_Size(const upb_Map* map) {
1692 return map->table.t.count;
1693 }
1694
_upb_Map_Get(const upb_Map * map,const void * key,size_t key_size,void * val,size_t val_size)1695 UPB_INLINE bool _upb_Map_Get(const upb_Map* map, const void* key,
1696 size_t key_size, void* val, size_t val_size) {
1697 upb_value tabval;
1698 upb_StringView k = _upb_map_tokey(key, key_size);
1699 bool ret = upb_strtable_lookup2(&map->table, k.data, k.size, &tabval);
1700 if (ret && val) {
1701 _upb_map_fromvalue(tabval, val, val_size);
1702 }
1703 return ret;
1704 }
1705
_upb_map_next(const upb_Map * map,size_t * iter)1706 UPB_INLINE void* _upb_map_next(const upb_Map* map, size_t* iter) {
1707 upb_strtable_iter it;
1708 it.t = &map->table;
1709 it.index = *iter;
1710 upb_strtable_next(&it);
1711 *iter = it.index;
1712 if (upb_strtable_done(&it)) return NULL;
1713 return (void*)str_tabent(&it);
1714 }
1715
1716 typedef enum {
1717 // LINT.IfChange
1718 _kUpb_MapInsertStatus_Inserted = 0,
1719 _kUpb_MapInsertStatus_Replaced = 1,
1720 _kUpb_MapInsertStatus_OutOfMemory = 2,
1721 // LINT.ThenChange(//depot/google3/third_party/upb/upb/collections.h)
1722 } _upb_MapInsertStatus;
1723
_upb_Map_Insert(upb_Map * map,const void * key,size_t key_size,void * val,size_t val_size,upb_Arena * a)1724 UPB_INLINE _upb_MapInsertStatus _upb_Map_Insert(upb_Map* map, const void* key,
1725 size_t key_size, void* val,
1726 size_t val_size, upb_Arena* a) {
1727 upb_StringView strkey = _upb_map_tokey(key, key_size);
1728 upb_value tabval = {0};
1729 if (!_upb_map_tovalue(val, val_size, &tabval, a)) {
1730 return _kUpb_MapInsertStatus_OutOfMemory;
1731 }
1732
1733 /* TODO(haberman): add overwrite operation to minimize number of lookups. */
1734 bool removed =
1735 upb_strtable_remove2(&map->table, strkey.data, strkey.size, NULL);
1736 if (!upb_strtable_insert(&map->table, strkey.data, strkey.size, tabval, a)) {
1737 return _kUpb_MapInsertStatus_OutOfMemory;
1738 }
1739 return removed ? _kUpb_MapInsertStatus_Replaced
1740 : _kUpb_MapInsertStatus_Inserted;
1741 }
1742
_upb_Map_Delete(upb_Map * map,const void * key,size_t key_size)1743 UPB_INLINE bool _upb_Map_Delete(upb_Map* map, const void* key,
1744 size_t key_size) {
1745 upb_StringView k = _upb_map_tokey(key, key_size);
1746 return upb_strtable_remove2(&map->table, k.data, k.size, NULL);
1747 }
1748
_upb_Map_Clear(upb_Map * map)1749 UPB_INLINE void _upb_Map_Clear(upb_Map* map) {
1750 upb_strtable_clear(&map->table);
1751 }
1752
1753 /* Message map operations, these get the map from the message first. */
1754
_upb_msg_map_size(const upb_Message * msg,size_t ofs)1755 UPB_INLINE size_t _upb_msg_map_size(const upb_Message* msg, size_t ofs) {
1756 upb_Map* map = *UPB_PTR_AT(msg, ofs, upb_Map*);
1757 return map ? _upb_Map_Size(map) : 0;
1758 }
1759
_upb_msg_map_get(const upb_Message * msg,size_t ofs,const void * key,size_t key_size,void * val,size_t val_size)1760 UPB_INLINE bool _upb_msg_map_get(const upb_Message* msg, size_t ofs,
1761 const void* key, size_t key_size, void* val,
1762 size_t val_size) {
1763 upb_Map* map = *UPB_PTR_AT(msg, ofs, upb_Map*);
1764 if (!map) return false;
1765 return _upb_Map_Get(map, key, key_size, val, val_size);
1766 }
1767
_upb_msg_map_next(const upb_Message * msg,size_t ofs,size_t * iter)1768 UPB_INLINE void* _upb_msg_map_next(const upb_Message* msg, size_t ofs,
1769 size_t* iter) {
1770 upb_Map* map = *UPB_PTR_AT(msg, ofs, upb_Map*);
1771 if (!map) return NULL;
1772 return _upb_map_next(map, iter);
1773 }
1774
_upb_msg_map_set(upb_Message * msg,size_t ofs,const void * key,size_t key_size,void * val,size_t val_size,upb_Arena * arena)1775 UPB_INLINE bool _upb_msg_map_set(upb_Message* msg, size_t ofs, const void* key,
1776 size_t key_size, void* val, size_t val_size,
1777 upb_Arena* arena) {
1778 upb_Map** map = UPB_PTR_AT(msg, ofs, upb_Map*);
1779 if (!*map) {
1780 *map = _upb_Map_New(arena, key_size, val_size);
1781 }
1782 return _upb_Map_Insert(*map, key, key_size, val, val_size, arena) !=
1783 _kUpb_MapInsertStatus_OutOfMemory;
1784 }
1785
_upb_msg_map_delete(upb_Message * msg,size_t ofs,const void * key,size_t key_size)1786 UPB_INLINE bool _upb_msg_map_delete(upb_Message* msg, size_t ofs,
1787 const void* key, size_t key_size) {
1788 upb_Map* map = *UPB_PTR_AT(msg, ofs, upb_Map*);
1789 if (!map) return false;
1790 return _upb_Map_Delete(map, key, key_size);
1791 }
1792
_upb_msg_map_clear(upb_Message * msg,size_t ofs)1793 UPB_INLINE void _upb_msg_map_clear(upb_Message* msg, size_t ofs) {
1794 upb_Map* map = *UPB_PTR_AT(msg, ofs, upb_Map*);
1795 if (!map) return;
1796 _upb_Map_Clear(map);
1797 }
1798
1799 /* Accessing map key/value from a pointer, used by generated code only. */
1800
_upb_msg_map_key(const void * msg,void * key,size_t size)1801 UPB_INLINE void _upb_msg_map_key(const void* msg, void* key, size_t size) {
1802 const upb_tabent* ent = (const upb_tabent*)msg;
1803 uint32_t u32len;
1804 upb_StringView k;
1805 k.data = upb_tabstr(ent->key, &u32len);
1806 k.size = u32len;
1807 _upb_map_fromkey(k, key, size);
1808 }
1809
_upb_msg_map_value(const void * msg,void * val,size_t size)1810 UPB_INLINE void _upb_msg_map_value(const void* msg, void* val, size_t size) {
1811 const upb_tabent* ent = (const upb_tabent*)msg;
1812 upb_value v = {ent->val.val};
1813 _upb_map_fromvalue(v, val, size);
1814 }
1815
_upb_msg_map_set_value(void * msg,const void * val,size_t size)1816 UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val,
1817 size_t size) {
1818 upb_tabent* ent = (upb_tabent*)msg;
1819 /* This is like _upb_map_tovalue() except the entry already exists so we can
1820 * reuse the allocated upb_StringView for string fields. */
1821 if (size == UPB_MAPTYPE_STRING) {
1822 upb_StringView* strp = (upb_StringView*)(uintptr_t)ent->val.val;
1823 memcpy(strp, val, sizeof(*strp));
1824 } else {
1825 memcpy(&ent->val.val, val, size);
1826 }
1827 }
1828
1829 /** _upb_mapsorter ************************************************************/
1830
1831 /* _upb_mapsorter sorts maps and provides ordered iteration over the entries.
1832 * Since maps can be recursive (map values can be messages which contain other
1833 * maps). _upb_mapsorter can contain a stack of maps. */
1834
1835 typedef struct {
1836 upb_tabent const** entries;
1837 int size;
1838 int cap;
1839 } _upb_mapsorter;
1840
1841 typedef struct {
1842 int start;
1843 int pos;
1844 int end;
1845 } _upb_sortedmap;
1846
_upb_mapsorter_init(_upb_mapsorter * s)1847 UPB_INLINE void _upb_mapsorter_init(_upb_mapsorter* s) {
1848 s->entries = NULL;
1849 s->size = 0;
1850 s->cap = 0;
1851 }
1852
_upb_mapsorter_destroy(_upb_mapsorter * s)1853 UPB_INLINE void _upb_mapsorter_destroy(_upb_mapsorter* s) {
1854 if (s->entries) free(s->entries);
1855 }
1856
1857 bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
1858 const upb_Map* map, _upb_sortedmap* sorted);
1859
_upb_mapsorter_popmap(_upb_mapsorter * s,_upb_sortedmap * sorted)1860 UPB_INLINE void _upb_mapsorter_popmap(_upb_mapsorter* s,
1861 _upb_sortedmap* sorted) {
1862 s->size = sorted->start;
1863 }
1864
_upb_sortedmap_next(_upb_mapsorter * s,const upb_Map * map,_upb_sortedmap * sorted,upb_MapEntry * ent)1865 UPB_INLINE bool _upb_sortedmap_next(_upb_mapsorter* s, const upb_Map* map,
1866 _upb_sortedmap* sorted, upb_MapEntry* ent) {
1867 if (sorted->pos == sorted->end) return false;
1868 const upb_tabent* tabent = s->entries[sorted->pos++];
1869 upb_StringView key = upb_tabstrview(tabent->key);
1870 _upb_map_fromkey(key, &ent->k, map->key_size);
1871 upb_value val = {tabent->val.val};
1872 _upb_map_fromvalue(val, &ent->v, map->val_size);
1873 return true;
1874 }
1875
1876 #ifdef __cplusplus
1877 } /* extern "C" */
1878 #endif
1879
1880
1881 #endif /* UPB_MSG_INT_H_ */
1882
1883 /** upb/decode.h ************************************************************/
1884 /*
1885 * upb_decode: parsing into a upb_Message using a upb_MiniTable.
1886 */
1887
1888 #ifndef UPB_DECODE_H_
1889 #define UPB_DECODE_H_
1890
1891
1892 /* Must be last. */
1893
1894 #ifdef __cplusplus
1895 extern "C" {
1896 #endif
1897
1898 enum {
1899 /* If set, strings will alias the input buffer instead of copying into the
1900 * arena. */
1901 kUpb_DecodeOption_AliasString = 1,
1902
1903 /* If set, the parse will return failure if any message is missing any
1904 * required fields when the message data ends. The parse will still continue,
1905 * and the failure will only be reported at the end.
1906 *
1907 * IMPORTANT CAVEATS:
1908 *
1909 * 1. This can throw a false positive failure if an incomplete message is seen
1910 * on the wire but is later completed when the sub-message occurs again.
1911 * For this reason, a second pass is required to verify a failure, to be
1912 * truly robust.
1913 *
1914 * 2. This can return a false success if you are decoding into a message that
1915 * already has some sub-message fields present. If the sub-message does
1916 * not occur in the binary payload, we will never visit it and discover the
1917 * incomplete sub-message. For this reason, this check is only useful for
1918 * implemting ParseFromString() semantics. For MergeFromString(), a
1919 * post-parse validation step will always be necessary. */
1920 kUpb_DecodeOption_CheckRequired = 2,
1921 };
1922
1923 #define UPB_DECODE_MAXDEPTH(depth) ((depth) << 16)
1924
1925 typedef enum {
1926 kUpb_DecodeStatus_Ok = 0,
1927 kUpb_DecodeStatus_Malformed = 1, // Wire format was corrupt
1928 kUpb_DecodeStatus_OutOfMemory = 2, // Arena alloc failed
1929 kUpb_DecodeStatus_BadUtf8 = 3, // String field had bad UTF-8
1930 kUpb_DecodeStatus_MaxDepthExceeded = 4, // Exceeded UPB_DECODE_MAXDEPTH
1931
1932 // kUpb_DecodeOption_CheckRequired failed (see above), but the parse otherwise
1933 // succeeded.
1934 kUpb_DecodeStatus_MissingRequired = 5,
1935 } upb_DecodeStatus;
1936
1937 upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg,
1938 const upb_MiniTable* l,
1939 const upb_ExtensionRegistry* extreg, int options,
1940 upb_Arena* arena);
1941
1942 #ifdef __cplusplus
1943 } /* extern "C" */
1944 #endif
1945
1946
1947 #endif /* UPB_DECODE_H_ */
1948
1949 /** upb/decode_fast.h ************************************************************/
1950 // These are the specialized field parser functions for the fast parser.
1951 // Generated tables will refer to these by name.
1952 //
1953 // The function names are encoded with names like:
1954 //
1955 // // 123 4
1956 // upb_pss_1bt(); // Parse singular string, 1 byte tag.
1957 //
1958 // In position 1:
1959 // - 'p' for parse, most function use this
1960 // - 'c' for copy, for when we are copying strings instead of aliasing
1961 //
1962 // In position 2 (cardinality):
1963 // - 's' for singular, with or without hasbit
1964 // - 'o' for oneof
1965 // - 'r' for non-packed repeated
1966 // - 'p' for packed repeated
1967 //
1968 // In position 3 (type):
1969 // - 'b1' for bool
1970 // - 'v4' for 4-byte varint
1971 // - 'v8' for 8-byte varint
1972 // - 'z4' for zig-zag-encoded 4-byte varint
1973 // - 'z8' for zig-zag-encoded 8-byte varint
1974 // - 'f4' for 4-byte fixed
1975 // - 'f8' for 8-byte fixed
1976 // - 'm' for sub-message
1977 // - 's' for string (validate UTF-8)
1978 // - 'b' for bytes
1979 //
1980 // In position 4 (tag length):
1981 // - '1' for one-byte tags (field numbers 1-15)
1982 // - '2' for two-byte tags (field numbers 16-2048)
1983
1984 #ifndef UPB_DECODE_FAST_H_
1985 #define UPB_DECODE_FAST_H_
1986
1987
1988 struct upb_Decoder;
1989
1990 // The fallback, generic parsing function that can handle any field type.
1991 // This just uses the regular (non-fast) parser to parse a single field.
1992 const char* fastdecode_generic(struct upb_Decoder* d, const char* ptr,
1993 upb_Message* msg, intptr_t table,
1994 uint64_t hasbits, uint64_t data);
1995
1996 #define UPB_PARSE_PARAMS \
1997 struct upb_Decoder *d, const char *ptr, upb_Message *msg, intptr_t table, \
1998 uint64_t hasbits, uint64_t data
1999
2000 /* primitive fields ***********************************************************/
2001
2002 #define F(card, type, valbytes, tagbytes) \
2003 const char* upb_p##card##type##valbytes##_##tagbytes##bt(UPB_PARSE_PARAMS);
2004
2005 #define TYPES(card, tagbytes) \
2006 F(card, b, 1, tagbytes) \
2007 F(card, v, 4, tagbytes) \
2008 F(card, v, 8, tagbytes) \
2009 F(card, z, 4, tagbytes) \
2010 F(card, z, 8, tagbytes) \
2011 F(card, f, 4, tagbytes) \
2012 F(card, f, 8, tagbytes)
2013
2014 #define TAGBYTES(card) \
2015 TYPES(card, 1) \
2016 TYPES(card, 2)
2017
2018 TAGBYTES(s)
TAGBYTES(o)2019 TAGBYTES(o)
2020 TAGBYTES(r)
2021 TAGBYTES(p)
2022
2023 #undef F
2024 #undef TYPES
2025 #undef TAGBYTES
2026
2027 /* string fields **************************************************************/
2028
2029 #define F(card, tagbytes, type) \
2030 const char* upb_p##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS); \
2031 const char* upb_c##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS);
2032
2033 #define UTF8(card, tagbytes) \
2034 F(card, tagbytes, s) \
2035 F(card, tagbytes, b)
2036
2037 #define TAGBYTES(card) \
2038 UTF8(card, 1) \
2039 UTF8(card, 2)
2040
2041 TAGBYTES(s)
2042 TAGBYTES(o)
2043 TAGBYTES(r)
2044
2045 #undef F
2046 #undef TAGBYTES
2047
2048 /* sub-message fields *********************************************************/
2049
2050 #define F(card, tagbytes, size_ceil, ceil_arg) \
2051 const char* upb_p##card##m_##tagbytes##bt_max##size_ceil##b(UPB_PARSE_PARAMS);
2052
2053 #define SIZES(card, tagbytes) \
2054 F(card, tagbytes, 64, 64) \
2055 F(card, tagbytes, 128, 128) \
2056 F(card, tagbytes, 192, 192) \
2057 F(card, tagbytes, 256, 256) \
2058 F(card, tagbytes, max, -1)
2059
2060 #define TAGBYTES(card) \
2061 SIZES(card, 1) \
2062 SIZES(card, 2)
2063
2064 TAGBYTES(s)
2065 TAGBYTES(o)
2066 TAGBYTES(r)
2067
2068 #undef TAGBYTES
2069 #undef SIZES
2070 #undef F
2071
2072 #undef UPB_PARSE_PARAMS
2073
2074 #endif /* UPB_DECODE_FAST_H_ */
2075
2076 /** upb/encode.h ************************************************************/
2077 /*
2078 * upb_Encode: parsing into a upb_Message using a upb_MiniTable.
2079 */
2080
2081 #ifndef UPB_ENCODE_H_
2082 #define UPB_ENCODE_H_
2083
2084
2085 /* Must be last. */
2086
2087 #ifdef __cplusplus
2088 extern "C" {
2089 #endif
2090
2091 enum {
2092 /* If set, the results of serializing will be deterministic across all
2093 * instances of this binary. There are no guarantees across different
2094 * binary builds.
2095 *
2096 * If your proto contains maps, the encoder will need to malloc()/free()
2097 * memory during encode. */
2098 kUpb_Encode_Deterministic = 1,
2099
2100 /* When set, unknown fields are not printed. */
2101 kUpb_Encode_SkipUnknown = 2,
2102
2103 /* When set, the encode will fail if any required fields are missing. */
2104 kUpb_Encode_CheckRequired = 4,
2105 };
2106
2107 #define UPB_ENCODE_MAXDEPTH(depth) ((depth) << 16)
2108
2109 char* upb_Encode(const void* msg, const upb_MiniTable* l, int options,
2110 upb_Arena* arena, size_t* size);
2111
2112
2113 #ifdef __cplusplus
2114 } /* extern "C" */
2115 #endif
2116
2117 #endif /* UPB_ENCODE_H_ */
2118
2119
2120 #ifdef __cplusplus
2121 extern "C" {
2122 #endif
2123
2124 struct google_protobuf_FileDescriptorSet;
2125 struct google_protobuf_FileDescriptorProto;
2126 struct google_protobuf_DescriptorProto;
2127 struct google_protobuf_DescriptorProto_ExtensionRange;
2128 struct google_protobuf_DescriptorProto_ReservedRange;
2129 struct google_protobuf_ExtensionRangeOptions;
2130 struct google_protobuf_FieldDescriptorProto;
2131 struct google_protobuf_OneofDescriptorProto;
2132 struct google_protobuf_EnumDescriptorProto;
2133 struct google_protobuf_EnumDescriptorProto_EnumReservedRange;
2134 struct google_protobuf_EnumValueDescriptorProto;
2135 struct google_protobuf_ServiceDescriptorProto;
2136 struct google_protobuf_MethodDescriptorProto;
2137 struct google_protobuf_FileOptions;
2138 struct google_protobuf_MessageOptions;
2139 struct google_protobuf_FieldOptions;
2140 struct google_protobuf_OneofOptions;
2141 struct google_protobuf_EnumOptions;
2142 struct google_protobuf_EnumValueOptions;
2143 struct google_protobuf_ServiceOptions;
2144 struct google_protobuf_MethodOptions;
2145 struct google_protobuf_UninterpretedOption;
2146 struct google_protobuf_UninterpretedOption_NamePart;
2147 struct google_protobuf_SourceCodeInfo;
2148 struct google_protobuf_SourceCodeInfo_Location;
2149 struct google_protobuf_GeneratedCodeInfo;
2150 struct google_protobuf_GeneratedCodeInfo_Annotation;
2151 typedef struct google_protobuf_FileDescriptorSet google_protobuf_FileDescriptorSet;
2152 typedef struct google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto;
2153 typedef struct google_protobuf_DescriptorProto google_protobuf_DescriptorProto;
2154 typedef struct google_protobuf_DescriptorProto_ExtensionRange google_protobuf_DescriptorProto_ExtensionRange;
2155 typedef struct google_protobuf_DescriptorProto_ReservedRange google_protobuf_DescriptorProto_ReservedRange;
2156 typedef struct google_protobuf_ExtensionRangeOptions google_protobuf_ExtensionRangeOptions;
2157 typedef struct google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto;
2158 typedef struct google_protobuf_OneofDescriptorProto google_protobuf_OneofDescriptorProto;
2159 typedef struct google_protobuf_EnumDescriptorProto google_protobuf_EnumDescriptorProto;
2160 typedef struct google_protobuf_EnumDescriptorProto_EnumReservedRange google_protobuf_EnumDescriptorProto_EnumReservedRange;
2161 typedef struct google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescriptorProto;
2162 typedef struct google_protobuf_ServiceDescriptorProto google_protobuf_ServiceDescriptorProto;
2163 typedef struct google_protobuf_MethodDescriptorProto google_protobuf_MethodDescriptorProto;
2164 typedef struct google_protobuf_FileOptions google_protobuf_FileOptions;
2165 typedef struct google_protobuf_MessageOptions google_protobuf_MessageOptions;
2166 typedef struct google_protobuf_FieldOptions google_protobuf_FieldOptions;
2167 typedef struct google_protobuf_OneofOptions google_protobuf_OneofOptions;
2168 typedef struct google_protobuf_EnumOptions google_protobuf_EnumOptions;
2169 typedef struct google_protobuf_EnumValueOptions google_protobuf_EnumValueOptions;
2170 typedef struct google_protobuf_ServiceOptions google_protobuf_ServiceOptions;
2171 typedef struct google_protobuf_MethodOptions google_protobuf_MethodOptions;
2172 typedef struct google_protobuf_UninterpretedOption google_protobuf_UninterpretedOption;
2173 typedef struct google_protobuf_UninterpretedOption_NamePart google_protobuf_UninterpretedOption_NamePart;
2174 typedef struct google_protobuf_SourceCodeInfo google_protobuf_SourceCodeInfo;
2175 typedef struct google_protobuf_SourceCodeInfo_Location google_protobuf_SourceCodeInfo_Location;
2176 typedef struct google_protobuf_GeneratedCodeInfo google_protobuf_GeneratedCodeInfo;
2177 typedef struct google_protobuf_GeneratedCodeInfo_Annotation google_protobuf_GeneratedCodeInfo_Annotation;
2178 extern const upb_MiniTable google_protobuf_FileDescriptorSet_msginit;
2179 extern const upb_MiniTable google_protobuf_FileDescriptorProto_msginit;
2180 extern const upb_MiniTable google_protobuf_DescriptorProto_msginit;
2181 extern const upb_MiniTable google_protobuf_DescriptorProto_ExtensionRange_msginit;
2182 extern const upb_MiniTable google_protobuf_DescriptorProto_ReservedRange_msginit;
2183 extern const upb_MiniTable google_protobuf_ExtensionRangeOptions_msginit;
2184 extern const upb_MiniTable google_protobuf_FieldDescriptorProto_msginit;
2185 extern const upb_MiniTable google_protobuf_OneofDescriptorProto_msginit;
2186 extern const upb_MiniTable google_protobuf_EnumDescriptorProto_msginit;
2187 extern const upb_MiniTable google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit;
2188 extern const upb_MiniTable google_protobuf_EnumValueDescriptorProto_msginit;
2189 extern const upb_MiniTable google_protobuf_ServiceDescriptorProto_msginit;
2190 extern const upb_MiniTable google_protobuf_MethodDescriptorProto_msginit;
2191 extern const upb_MiniTable google_protobuf_FileOptions_msginit;
2192 extern const upb_MiniTable google_protobuf_MessageOptions_msginit;
2193 extern const upb_MiniTable google_protobuf_FieldOptions_msginit;
2194 extern const upb_MiniTable google_protobuf_OneofOptions_msginit;
2195 extern const upb_MiniTable google_protobuf_EnumOptions_msginit;
2196 extern const upb_MiniTable google_protobuf_EnumValueOptions_msginit;
2197 extern const upb_MiniTable google_protobuf_ServiceOptions_msginit;
2198 extern const upb_MiniTable google_protobuf_MethodOptions_msginit;
2199 extern const upb_MiniTable google_protobuf_UninterpretedOption_msginit;
2200 extern const upb_MiniTable google_protobuf_UninterpretedOption_NamePart_msginit;
2201 extern const upb_MiniTable google_protobuf_SourceCodeInfo_msginit;
2202 extern const upb_MiniTable google_protobuf_SourceCodeInfo_Location_msginit;
2203 extern const upb_MiniTable google_protobuf_GeneratedCodeInfo_msginit;
2204 extern const upb_MiniTable google_protobuf_GeneratedCodeInfo_Annotation_msginit;
2205
2206 typedef enum {
2207 google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1,
2208 google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2,
2209 google_protobuf_FieldDescriptorProto_LABEL_REPEATED = 3
2210 } google_protobuf_FieldDescriptorProto_Label;
2211
2212 typedef enum {
2213 google_protobuf_FieldDescriptorProto_TYPE_DOUBLE = 1,
2214 google_protobuf_FieldDescriptorProto_TYPE_FLOAT = 2,
2215 google_protobuf_FieldDescriptorProto_TYPE_INT64 = 3,
2216 google_protobuf_FieldDescriptorProto_TYPE_UINT64 = 4,
2217 google_protobuf_FieldDescriptorProto_TYPE_INT32 = 5,
2218 google_protobuf_FieldDescriptorProto_TYPE_FIXED64 = 6,
2219 google_protobuf_FieldDescriptorProto_TYPE_FIXED32 = 7,
2220 google_protobuf_FieldDescriptorProto_TYPE_BOOL = 8,
2221 google_protobuf_FieldDescriptorProto_TYPE_STRING = 9,
2222 google_protobuf_FieldDescriptorProto_TYPE_GROUP = 10,
2223 google_protobuf_FieldDescriptorProto_TYPE_MESSAGE = 11,
2224 google_protobuf_FieldDescriptorProto_TYPE_BYTES = 12,
2225 google_protobuf_FieldDescriptorProto_TYPE_UINT32 = 13,
2226 google_protobuf_FieldDescriptorProto_TYPE_ENUM = 14,
2227 google_protobuf_FieldDescriptorProto_TYPE_SFIXED32 = 15,
2228 google_protobuf_FieldDescriptorProto_TYPE_SFIXED64 = 16,
2229 google_protobuf_FieldDescriptorProto_TYPE_SINT32 = 17,
2230 google_protobuf_FieldDescriptorProto_TYPE_SINT64 = 18
2231 } google_protobuf_FieldDescriptorProto_Type;
2232
2233 typedef enum {
2234 google_protobuf_FieldOptions_STRING = 0,
2235 google_protobuf_FieldOptions_CORD = 1,
2236 google_protobuf_FieldOptions_STRING_PIECE = 2
2237 } google_protobuf_FieldOptions_CType;
2238
2239 typedef enum {
2240 google_protobuf_FieldOptions_JS_NORMAL = 0,
2241 google_protobuf_FieldOptions_JS_STRING = 1,
2242 google_protobuf_FieldOptions_JS_NUMBER = 2
2243 } google_protobuf_FieldOptions_JSType;
2244
2245 typedef enum {
2246 google_protobuf_FileOptions_SPEED = 1,
2247 google_protobuf_FileOptions_CODE_SIZE = 2,
2248 google_protobuf_FileOptions_LITE_RUNTIME = 3
2249 } google_protobuf_FileOptions_OptimizeMode;
2250
2251 typedef enum {
2252 google_protobuf_MethodOptions_IDEMPOTENCY_UNKNOWN = 0,
2253 google_protobuf_MethodOptions_NO_SIDE_EFFECTS = 1,
2254 google_protobuf_MethodOptions_IDEMPOTENT = 2
2255 } google_protobuf_MethodOptions_IdempotencyLevel;
2256
2257
2258 extern const upb_MiniTable_Enum google_protobuf_FieldDescriptorProto_Label_enuminit;
2259 extern const upb_MiniTable_Enum google_protobuf_FieldDescriptorProto_Type_enuminit;
2260 extern const upb_MiniTable_Enum google_protobuf_FieldOptions_CType_enuminit;
2261 extern const upb_MiniTable_Enum google_protobuf_FieldOptions_JSType_enuminit;
2262 extern const upb_MiniTable_Enum google_protobuf_FileOptions_OptimizeMode_enuminit;
2263 extern const upb_MiniTable_Enum google_protobuf_MethodOptions_IdempotencyLevel_enuminit;
2264
2265 /* google.protobuf.FileDescriptorSet */
2266
google_protobuf_FileDescriptorSet_new(upb_Arena * arena)2267 UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_new(upb_Arena* arena) {
2268 return (google_protobuf_FileDescriptorSet*)_upb_Message_New(&google_protobuf_FileDescriptorSet_msginit, arena);
2269 }
google_protobuf_FileDescriptorSet_parse(const char * buf,size_t size,upb_Arena * arena)2270 UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_parse(const char* buf, size_t size, upb_Arena* arena) {
2271 google_protobuf_FileDescriptorSet* ret = google_protobuf_FileDescriptorSet_new(arena);
2272 if (!ret) return NULL;
2273 if (upb_Decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
2274 return NULL;
2275 }
2276 return ret;
2277 }
google_protobuf_FileDescriptorSet_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)2278 UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_parse_ex(const char* buf, size_t size,
2279 const upb_ExtensionRegistry* extreg,
2280 int options, upb_Arena* arena) {
2281 google_protobuf_FileDescriptorSet* ret = google_protobuf_FileDescriptorSet_new(arena);
2282 if (!ret) return NULL;
2283 if (upb_Decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, extreg, options, arena) !=
2284 kUpb_DecodeStatus_Ok) {
2285 return NULL;
2286 }
2287 return ret;
2288 }
google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet * msg,upb_Arena * arena,size_t * len)2289 UPB_INLINE char* google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet* msg, upb_Arena* arena, size_t* len) {
2290 return upb_Encode(msg, &google_protobuf_FileDescriptorSet_msginit, 0, arena, len);
2291 }
google_protobuf_FileDescriptorSet_serialize_ex(const google_protobuf_FileDescriptorSet * msg,int options,upb_Arena * arena,size_t * len)2292 UPB_INLINE char* google_protobuf_FileDescriptorSet_serialize_ex(const google_protobuf_FileDescriptorSet* msg, int options,
2293 upb_Arena* arena, size_t* len) {
2294 return upb_Encode(msg, &google_protobuf_FileDescriptorSet_msginit, options, arena, len);
2295 }
google_protobuf_FileDescriptorSet_has_file(const google_protobuf_FileDescriptorSet * msg)2296 UPB_INLINE bool google_protobuf_FileDescriptorSet_has_file(const google_protobuf_FileDescriptorSet* msg) {
2297 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0));
2298 }
google_protobuf_FileDescriptorSet_clear_file(const google_protobuf_FileDescriptorSet * msg)2299 UPB_INLINE void google_protobuf_FileDescriptorSet_clear_file(const google_protobuf_FileDescriptorSet* msg) {
2300 _upb_array_detach(msg, UPB_SIZE(0, 0));
2301 }
google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet * msg,size_t * len)2302 UPB_INLINE const google_protobuf_FileDescriptorProto* const* google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet* msg, size_t* len) {
2303 return (const google_protobuf_FileDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len);
2304 }
2305
google_protobuf_FileDescriptorSet_mutable_file(google_protobuf_FileDescriptorSet * msg,size_t * len)2306 UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_mutable_file(google_protobuf_FileDescriptorSet* msg, size_t* len) {
2307 return (google_protobuf_FileDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len);
2308 }
google_protobuf_FileDescriptorSet_resize_file(google_protobuf_FileDescriptorSet * msg,size_t len,upb_Arena * arena)2309 UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_resize_file(google_protobuf_FileDescriptorSet* msg, size_t len, upb_Arena* arena) {
2310 return (google_protobuf_FileDescriptorProto**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(0, 0), len, UPB_SIZE(2, 3), arena);
2311 }
google_protobuf_FileDescriptorSet_add_file(google_protobuf_FileDescriptorSet * msg,upb_Arena * arena)2312 UPB_INLINE struct google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorSet_add_file(google_protobuf_FileDescriptorSet* msg, upb_Arena* arena) {
2313 struct google_protobuf_FileDescriptorProto* sub = (struct google_protobuf_FileDescriptorProto*)_upb_Message_New(&google_protobuf_FileDescriptorProto_msginit, arena);
2314 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(0, 0), UPB_SIZE(2, 3), &sub, arena);
2315 if (!ok) return NULL;
2316 return sub;
2317 }
2318
2319 /* google.protobuf.FileDescriptorProto */
2320
google_protobuf_FileDescriptorProto_new(upb_Arena * arena)2321 UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_new(upb_Arena* arena) {
2322 return (google_protobuf_FileDescriptorProto*)_upb_Message_New(&google_protobuf_FileDescriptorProto_msginit, arena);
2323 }
google_protobuf_FileDescriptorProto_parse(const char * buf,size_t size,upb_Arena * arena)2324 UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
2325 google_protobuf_FileDescriptorProto* ret = google_protobuf_FileDescriptorProto_new(arena);
2326 if (!ret) return NULL;
2327 if (upb_Decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
2328 return NULL;
2329 }
2330 return ret;
2331 }
google_protobuf_FileDescriptorProto_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)2332 UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_parse_ex(const char* buf, size_t size,
2333 const upb_ExtensionRegistry* extreg,
2334 int options, upb_Arena* arena) {
2335 google_protobuf_FileDescriptorProto* ret = google_protobuf_FileDescriptorProto_new(arena);
2336 if (!ret) return NULL;
2337 if (upb_Decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, extreg, options, arena) !=
2338 kUpb_DecodeStatus_Ok) {
2339 return NULL;
2340 }
2341 return ret;
2342 }
google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto * msg,upb_Arena * arena,size_t * len)2343 UPB_INLINE char* google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto* msg, upb_Arena* arena, size_t* len) {
2344 return upb_Encode(msg, &google_protobuf_FileDescriptorProto_msginit, 0, arena, len);
2345 }
google_protobuf_FileDescriptorProto_serialize_ex(const google_protobuf_FileDescriptorProto * msg,int options,upb_Arena * arena,size_t * len)2346 UPB_INLINE char* google_protobuf_FileDescriptorProto_serialize_ex(const google_protobuf_FileDescriptorProto* msg, int options,
2347 upb_Arena* arena, size_t* len) {
2348 return upb_Encode(msg, &google_protobuf_FileDescriptorProto_msginit, options, arena, len);
2349 }
google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto * msg)2350 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto* msg) {
2351 return _upb_hasbit(msg, 1);
2352 }
google_protobuf_FileDescriptorProto_clear_name(const google_protobuf_FileDescriptorProto * msg)2353 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_name(const google_protobuf_FileDescriptorProto* msg) {
2354 *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
2355 _upb_clearhas(msg, 1);
2356 }
google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto * msg)2357 UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto* msg) {
2358 return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView);
2359 }
google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto * msg)2360 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto* msg) {
2361 return _upb_hasbit(msg, 2);
2362 }
google_protobuf_FileDescriptorProto_clear_package(const google_protobuf_FileDescriptorProto * msg)2363 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_package(const google_protobuf_FileDescriptorProto* msg) {
2364 *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
2365 _upb_clearhas(msg, 2);
2366 }
google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto * msg)2367 UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto* msg) {
2368 return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_StringView);
2369 }
google_protobuf_FileDescriptorProto_clear_dependency(const google_protobuf_FileDescriptorProto * msg)2370 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_dependency(const google_protobuf_FileDescriptorProto* msg) {
2371 _upb_array_detach(msg, UPB_SIZE(20, 40));
2372 }
google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto * msg,size_t * len)2373 UPB_INLINE upb_StringView const* google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* len) {
2374 return (upb_StringView const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len);
2375 }
google_protobuf_FileDescriptorProto_has_message_type(const google_protobuf_FileDescriptorProto * msg)2376 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_message_type(const google_protobuf_FileDescriptorProto* msg) {
2377 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(24, 48));
2378 }
google_protobuf_FileDescriptorProto_clear_message_type(const google_protobuf_FileDescriptorProto * msg)2379 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_message_type(const google_protobuf_FileDescriptorProto* msg) {
2380 _upb_array_detach(msg, UPB_SIZE(24, 48));
2381 }
google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto * msg,size_t * len)2382 UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto* msg, size_t* len) {
2383 return (const google_protobuf_DescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len);
2384 }
google_protobuf_FileDescriptorProto_has_enum_type(const google_protobuf_FileDescriptorProto * msg)2385 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_enum_type(const google_protobuf_FileDescriptorProto* msg) {
2386 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(28, 56));
2387 }
google_protobuf_FileDescriptorProto_clear_enum_type(const google_protobuf_FileDescriptorProto * msg)2388 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_enum_type(const google_protobuf_FileDescriptorProto* msg) {
2389 _upb_array_detach(msg, UPB_SIZE(28, 56));
2390 }
google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto * msg,size_t * len)2391 UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto* msg, size_t* len) {
2392 return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len);
2393 }
google_protobuf_FileDescriptorProto_has_service(const google_protobuf_FileDescriptorProto * msg)2394 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_service(const google_protobuf_FileDescriptorProto* msg) {
2395 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(32, 64));
2396 }
google_protobuf_FileDescriptorProto_clear_service(const google_protobuf_FileDescriptorProto * msg)2397 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_service(const google_protobuf_FileDescriptorProto* msg) {
2398 _upb_array_detach(msg, UPB_SIZE(32, 64));
2399 }
google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto * msg,size_t * len)2400 UPB_INLINE const google_protobuf_ServiceDescriptorProto* const* google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto* msg, size_t* len) {
2401 return (const google_protobuf_ServiceDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(32, 64), len);
2402 }
google_protobuf_FileDescriptorProto_has_extension(const google_protobuf_FileDescriptorProto * msg)2403 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_extension(const google_protobuf_FileDescriptorProto* msg) {
2404 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(36, 72));
2405 }
google_protobuf_FileDescriptorProto_clear_extension(const google_protobuf_FileDescriptorProto * msg)2406 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_extension(const google_protobuf_FileDescriptorProto* msg) {
2407 _upb_array_detach(msg, UPB_SIZE(36, 72));
2408 }
google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto * msg,size_t * len)2409 UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto* msg, size_t* len) {
2410 return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len);
2411 }
google_protobuf_FileDescriptorProto_has_options(const google_protobuf_FileDescriptorProto * msg)2412 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_options(const google_protobuf_FileDescriptorProto* msg) {
2413 return _upb_hasbit(msg, 3);
2414 }
google_protobuf_FileDescriptorProto_clear_options(const google_protobuf_FileDescriptorProto * msg)2415 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_options(const google_protobuf_FileDescriptorProto* msg) {
2416 *UPB_PTR_AT(msg, UPB_SIZE(40, 80), const upb_Message*) = NULL;
2417 }
google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto * msg)2418 UPB_INLINE const google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto* msg) {
2419 return *UPB_PTR_AT(msg, UPB_SIZE(40, 80), const google_protobuf_FileOptions*);
2420 }
google_protobuf_FileDescriptorProto_has_source_code_info(const google_protobuf_FileDescriptorProto * msg)2421 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_source_code_info(const google_protobuf_FileDescriptorProto* msg) {
2422 return _upb_hasbit(msg, 4);
2423 }
google_protobuf_FileDescriptorProto_clear_source_code_info(const google_protobuf_FileDescriptorProto * msg)2424 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_source_code_info(const google_protobuf_FileDescriptorProto* msg) {
2425 *UPB_PTR_AT(msg, UPB_SIZE(44, 88), const upb_Message*) = NULL;
2426 }
google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto * msg)2427 UPB_INLINE const google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto* msg) {
2428 return *UPB_PTR_AT(msg, UPB_SIZE(44, 88), const google_protobuf_SourceCodeInfo*);
2429 }
google_protobuf_FileDescriptorProto_clear_public_dependency(const google_protobuf_FileDescriptorProto * msg)2430 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_public_dependency(const google_protobuf_FileDescriptorProto* msg) {
2431 _upb_array_detach(msg, UPB_SIZE(48, 96));
2432 }
google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto * msg,size_t * len)2433 UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* len) {
2434 return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(48, 96), len);
2435 }
google_protobuf_FileDescriptorProto_clear_weak_dependency(const google_protobuf_FileDescriptorProto * msg)2436 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_weak_dependency(const google_protobuf_FileDescriptorProto* msg) {
2437 _upb_array_detach(msg, UPB_SIZE(52, 104));
2438 }
google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto * msg,size_t * len)2439 UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* len) {
2440 return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(52, 104), len);
2441 }
google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto * msg)2442 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto* msg) {
2443 return _upb_hasbit(msg, 5);
2444 }
google_protobuf_FileDescriptorProto_clear_syntax(const google_protobuf_FileDescriptorProto * msg)2445 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_syntax(const google_protobuf_FileDescriptorProto* msg) {
2446 *UPB_PTR_AT(msg, UPB_SIZE(56, 112), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
2447 _upb_clearhas(msg, 5);
2448 }
google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto * msg)2449 UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto* msg) {
2450 return *UPB_PTR_AT(msg, UPB_SIZE(56, 112), upb_StringView);
2451 }
2452
google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto * msg,upb_StringView value)2453 UPB_INLINE void google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto *msg, upb_StringView value) {
2454 _upb_sethas(msg, 1);
2455 *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView) = value;
2456 }
google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto * msg,upb_StringView value)2457 UPB_INLINE void google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto *msg, upb_StringView value) {
2458 _upb_sethas(msg, 2);
2459 *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_StringView) = value;
2460 }
google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto * msg,size_t * len)2461 UPB_INLINE upb_StringView* google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto* msg, size_t* len) {
2462 return (upb_StringView*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len);
2463 }
google_protobuf_FileDescriptorProto_resize_dependency(google_protobuf_FileDescriptorProto * msg,size_t len,upb_Arena * arena)2464 UPB_INLINE upb_StringView* google_protobuf_FileDescriptorProto_resize_dependency(google_protobuf_FileDescriptorProto* msg, size_t len, upb_Arena* arena) {
2465 return (upb_StringView*)_upb_Array_Resize_accessor2(msg, UPB_SIZE(20, 40), len, UPB_SIZE(3, 4), arena);
2466 }
google_protobuf_FileDescriptorProto_add_dependency(google_protobuf_FileDescriptorProto * msg,upb_StringView val,upb_Arena * arena)2467 UPB_INLINE bool google_protobuf_FileDescriptorProto_add_dependency(google_protobuf_FileDescriptorProto* msg, upb_StringView val, upb_Arena* arena) {
2468 return _upb_Array_Append_accessor2(msg, UPB_SIZE(20, 40), UPB_SIZE(3, 4), &val, arena);
2469 }
google_protobuf_FileDescriptorProto_mutable_message_type(google_protobuf_FileDescriptorProto * msg,size_t * len)2470 UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_mutable_message_type(google_protobuf_FileDescriptorProto* msg, size_t* len) {
2471 return (google_protobuf_DescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len);
2472 }
google_protobuf_FileDescriptorProto_resize_message_type(google_protobuf_FileDescriptorProto * msg,size_t len,upb_Arena * arena)2473 UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_resize_message_type(google_protobuf_FileDescriptorProto* msg, size_t len, upb_Arena* arena) {
2474 return (google_protobuf_DescriptorProto**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(24, 48), len, UPB_SIZE(2, 3), arena);
2475 }
google_protobuf_FileDescriptorProto_add_message_type(google_protobuf_FileDescriptorProto * msg,upb_Arena * arena)2476 UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_FileDescriptorProto_add_message_type(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) {
2477 struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)_upb_Message_New(&google_protobuf_DescriptorProto_msginit, arena);
2478 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(24, 48), UPB_SIZE(2, 3), &sub, arena);
2479 if (!ok) return NULL;
2480 return sub;
2481 }
google_protobuf_FileDescriptorProto_mutable_enum_type(google_protobuf_FileDescriptorProto * msg,size_t * len)2482 UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_mutable_enum_type(google_protobuf_FileDescriptorProto* msg, size_t* len) {
2483 return (google_protobuf_EnumDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len);
2484 }
google_protobuf_FileDescriptorProto_resize_enum_type(google_protobuf_FileDescriptorProto * msg,size_t len,upb_Arena * arena)2485 UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_resize_enum_type(google_protobuf_FileDescriptorProto* msg, size_t len, upb_Arena* arena) {
2486 return (google_protobuf_EnumDescriptorProto**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(28, 56), len, UPB_SIZE(2, 3), arena);
2487 }
google_protobuf_FileDescriptorProto_add_enum_type(google_protobuf_FileDescriptorProto * msg,upb_Arena * arena)2488 UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_FileDescriptorProto_add_enum_type(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) {
2489 struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)_upb_Message_New(&google_protobuf_EnumDescriptorProto_msginit, arena);
2490 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(28, 56), UPB_SIZE(2, 3), &sub, arena);
2491 if (!ok) return NULL;
2492 return sub;
2493 }
google_protobuf_FileDescriptorProto_mutable_service(google_protobuf_FileDescriptorProto * msg,size_t * len)2494 UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_mutable_service(google_protobuf_FileDescriptorProto* msg, size_t* len) {
2495 return (google_protobuf_ServiceDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 64), len);
2496 }
google_protobuf_FileDescriptorProto_resize_service(google_protobuf_FileDescriptorProto * msg,size_t len,upb_Arena * arena)2497 UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_resize_service(google_protobuf_FileDescriptorProto* msg, size_t len, upb_Arena* arena) {
2498 return (google_protobuf_ServiceDescriptorProto**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(32, 64), len, UPB_SIZE(2, 3), arena);
2499 }
google_protobuf_FileDescriptorProto_add_service(google_protobuf_FileDescriptorProto * msg,upb_Arena * arena)2500 UPB_INLINE struct google_protobuf_ServiceDescriptorProto* google_protobuf_FileDescriptorProto_add_service(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) {
2501 struct google_protobuf_ServiceDescriptorProto* sub = (struct google_protobuf_ServiceDescriptorProto*)_upb_Message_New(&google_protobuf_ServiceDescriptorProto_msginit, arena);
2502 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(32, 64), UPB_SIZE(2, 3), &sub, arena);
2503 if (!ok) return NULL;
2504 return sub;
2505 }
google_protobuf_FileDescriptorProto_mutable_extension(google_protobuf_FileDescriptorProto * msg,size_t * len)2506 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_mutable_extension(google_protobuf_FileDescriptorProto* msg, size_t* len) {
2507 return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 72), len);
2508 }
google_protobuf_FileDescriptorProto_resize_extension(google_protobuf_FileDescriptorProto * msg,size_t len,upb_Arena * arena)2509 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_resize_extension(google_protobuf_FileDescriptorProto* msg, size_t len, upb_Arena* arena) {
2510 return (google_protobuf_FieldDescriptorProto**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(36, 72), len, UPB_SIZE(2, 3), arena);
2511 }
google_protobuf_FileDescriptorProto_add_extension(google_protobuf_FileDescriptorProto * msg,upb_Arena * arena)2512 UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_FileDescriptorProto_add_extension(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) {
2513 struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_Message_New(&google_protobuf_FieldDescriptorProto_msginit, arena);
2514 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(36, 72), UPB_SIZE(2, 3), &sub, arena);
2515 if (!ok) return NULL;
2516 return sub;
2517 }
google_protobuf_FileDescriptorProto_set_options(google_protobuf_FileDescriptorProto * msg,google_protobuf_FileOptions * value)2518 UPB_INLINE void google_protobuf_FileDescriptorProto_set_options(google_protobuf_FileDescriptorProto *msg, google_protobuf_FileOptions* value) {
2519 _upb_sethas(msg, 3);
2520 *UPB_PTR_AT(msg, UPB_SIZE(40, 80), google_protobuf_FileOptions*) = value;
2521 }
google_protobuf_FileDescriptorProto_mutable_options(google_protobuf_FileDescriptorProto * msg,upb_Arena * arena)2522 UPB_INLINE struct google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_mutable_options(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) {
2523 struct google_protobuf_FileOptions* sub = (struct google_protobuf_FileOptions*)google_protobuf_FileDescriptorProto_options(msg);
2524 if (sub == NULL) {
2525 sub = (struct google_protobuf_FileOptions*)_upb_Message_New(&google_protobuf_FileOptions_msginit, arena);
2526 if (!sub) return NULL;
2527 google_protobuf_FileDescriptorProto_set_options(msg, sub);
2528 }
2529 return sub;
2530 }
google_protobuf_FileDescriptorProto_set_source_code_info(google_protobuf_FileDescriptorProto * msg,google_protobuf_SourceCodeInfo * value)2531 UPB_INLINE void google_protobuf_FileDescriptorProto_set_source_code_info(google_protobuf_FileDescriptorProto *msg, google_protobuf_SourceCodeInfo* value) {
2532 _upb_sethas(msg, 4);
2533 *UPB_PTR_AT(msg, UPB_SIZE(44, 88), google_protobuf_SourceCodeInfo*) = value;
2534 }
google_protobuf_FileDescriptorProto_mutable_source_code_info(google_protobuf_FileDescriptorProto * msg,upb_Arena * arena)2535 UPB_INLINE struct google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_mutable_source_code_info(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) {
2536 struct google_protobuf_SourceCodeInfo* sub = (struct google_protobuf_SourceCodeInfo*)google_protobuf_FileDescriptorProto_source_code_info(msg);
2537 if (sub == NULL) {
2538 sub = (struct google_protobuf_SourceCodeInfo*)_upb_Message_New(&google_protobuf_SourceCodeInfo_msginit, arena);
2539 if (!sub) return NULL;
2540 google_protobuf_FileDescriptorProto_set_source_code_info(msg, sub);
2541 }
2542 return sub;
2543 }
google_protobuf_FileDescriptorProto_mutable_public_dependency(google_protobuf_FileDescriptorProto * msg,size_t * len)2544 UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_public_dependency(google_protobuf_FileDescriptorProto* msg, size_t* len) {
2545 return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(48, 96), len);
2546 }
google_protobuf_FileDescriptorProto_resize_public_dependency(google_protobuf_FileDescriptorProto * msg,size_t len,upb_Arena * arena)2547 UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_public_dependency(google_protobuf_FileDescriptorProto* msg, size_t len, upb_Arena* arena) {
2548 return (int32_t*)_upb_Array_Resize_accessor2(msg, UPB_SIZE(48, 96), len, 2, arena);
2549 }
google_protobuf_FileDescriptorProto_add_public_dependency(google_protobuf_FileDescriptorProto * msg,int32_t val,upb_Arena * arena)2550 UPB_INLINE bool google_protobuf_FileDescriptorProto_add_public_dependency(google_protobuf_FileDescriptorProto* msg, int32_t val, upb_Arena* arena) {
2551 return _upb_Array_Append_accessor2(msg, UPB_SIZE(48, 96), 2, &val, arena);
2552 }
google_protobuf_FileDescriptorProto_mutable_weak_dependency(google_protobuf_FileDescriptorProto * msg,size_t * len)2553 UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_weak_dependency(google_protobuf_FileDescriptorProto* msg, size_t* len) {
2554 return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(52, 104), len);
2555 }
google_protobuf_FileDescriptorProto_resize_weak_dependency(google_protobuf_FileDescriptorProto * msg,size_t len,upb_Arena * arena)2556 UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_weak_dependency(google_protobuf_FileDescriptorProto* msg, size_t len, upb_Arena* arena) {
2557 return (int32_t*)_upb_Array_Resize_accessor2(msg, UPB_SIZE(52, 104), len, 2, arena);
2558 }
google_protobuf_FileDescriptorProto_add_weak_dependency(google_protobuf_FileDescriptorProto * msg,int32_t val,upb_Arena * arena)2559 UPB_INLINE bool google_protobuf_FileDescriptorProto_add_weak_dependency(google_protobuf_FileDescriptorProto* msg, int32_t val, upb_Arena* arena) {
2560 return _upb_Array_Append_accessor2(msg, UPB_SIZE(52, 104), 2, &val, arena);
2561 }
google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto * msg,upb_StringView value)2562 UPB_INLINE void google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto *msg, upb_StringView value) {
2563 _upb_sethas(msg, 5);
2564 *UPB_PTR_AT(msg, UPB_SIZE(56, 112), upb_StringView) = value;
2565 }
2566
2567 /* google.protobuf.DescriptorProto */
2568
google_protobuf_DescriptorProto_new(upb_Arena * arena)2569 UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_new(upb_Arena* arena) {
2570 return (google_protobuf_DescriptorProto*)_upb_Message_New(&google_protobuf_DescriptorProto_msginit, arena);
2571 }
google_protobuf_DescriptorProto_parse(const char * buf,size_t size,upb_Arena * arena)2572 UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
2573 google_protobuf_DescriptorProto* ret = google_protobuf_DescriptorProto_new(arena);
2574 if (!ret) return NULL;
2575 if (upb_Decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
2576 return NULL;
2577 }
2578 return ret;
2579 }
google_protobuf_DescriptorProto_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)2580 UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_parse_ex(const char* buf, size_t size,
2581 const upb_ExtensionRegistry* extreg,
2582 int options, upb_Arena* arena) {
2583 google_protobuf_DescriptorProto* ret = google_protobuf_DescriptorProto_new(arena);
2584 if (!ret) return NULL;
2585 if (upb_Decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, extreg, options, arena) !=
2586 kUpb_DecodeStatus_Ok) {
2587 return NULL;
2588 }
2589 return ret;
2590 }
google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto * msg,upb_Arena * arena,size_t * len)2591 UPB_INLINE char* google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto* msg, upb_Arena* arena, size_t* len) {
2592 return upb_Encode(msg, &google_protobuf_DescriptorProto_msginit, 0, arena, len);
2593 }
google_protobuf_DescriptorProto_serialize_ex(const google_protobuf_DescriptorProto * msg,int options,upb_Arena * arena,size_t * len)2594 UPB_INLINE char* google_protobuf_DescriptorProto_serialize_ex(const google_protobuf_DescriptorProto* msg, int options,
2595 upb_Arena* arena, size_t* len) {
2596 return upb_Encode(msg, &google_protobuf_DescriptorProto_msginit, options, arena, len);
2597 }
google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto * msg)2598 UPB_INLINE bool google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto* msg) {
2599 return _upb_hasbit(msg, 1);
2600 }
google_protobuf_DescriptorProto_clear_name(const google_protobuf_DescriptorProto * msg)2601 UPB_INLINE void google_protobuf_DescriptorProto_clear_name(const google_protobuf_DescriptorProto* msg) {
2602 *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
2603 _upb_clearhas(msg, 1);
2604 }
google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto * msg)2605 UPB_INLINE upb_StringView google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto* msg) {
2606 return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView);
2607 }
google_protobuf_DescriptorProto_has_field(const google_protobuf_DescriptorProto * msg)2608 UPB_INLINE bool google_protobuf_DescriptorProto_has_field(const google_protobuf_DescriptorProto* msg) {
2609 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(12, 24));
2610 }
google_protobuf_DescriptorProto_clear_field(const google_protobuf_DescriptorProto * msg)2611 UPB_INLINE void google_protobuf_DescriptorProto_clear_field(const google_protobuf_DescriptorProto* msg) {
2612 _upb_array_detach(msg, UPB_SIZE(12, 24));
2613 }
google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto * msg,size_t * len)2614 UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto* msg, size_t* len) {
2615 return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(12, 24), len);
2616 }
google_protobuf_DescriptorProto_has_nested_type(const google_protobuf_DescriptorProto * msg)2617 UPB_INLINE bool google_protobuf_DescriptorProto_has_nested_type(const google_protobuf_DescriptorProto* msg) {
2618 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(16, 32));
2619 }
google_protobuf_DescriptorProto_clear_nested_type(const google_protobuf_DescriptorProto * msg)2620 UPB_INLINE void google_protobuf_DescriptorProto_clear_nested_type(const google_protobuf_DescriptorProto* msg) {
2621 _upb_array_detach(msg, UPB_SIZE(16, 32));
2622 }
google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto * msg,size_t * len)2623 UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto* msg, size_t* len) {
2624 return (const google_protobuf_DescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len);
2625 }
google_protobuf_DescriptorProto_has_enum_type(const google_protobuf_DescriptorProto * msg)2626 UPB_INLINE bool google_protobuf_DescriptorProto_has_enum_type(const google_protobuf_DescriptorProto* msg) {
2627 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(20, 40));
2628 }
google_protobuf_DescriptorProto_clear_enum_type(const google_protobuf_DescriptorProto * msg)2629 UPB_INLINE void google_protobuf_DescriptorProto_clear_enum_type(const google_protobuf_DescriptorProto* msg) {
2630 _upb_array_detach(msg, UPB_SIZE(20, 40));
2631 }
google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto * msg,size_t * len)2632 UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto* msg, size_t* len) {
2633 return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len);
2634 }
google_protobuf_DescriptorProto_has_extension_range(const google_protobuf_DescriptorProto * msg)2635 UPB_INLINE bool google_protobuf_DescriptorProto_has_extension_range(const google_protobuf_DescriptorProto* msg) {
2636 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(24, 48));
2637 }
google_protobuf_DescriptorProto_clear_extension_range(const google_protobuf_DescriptorProto * msg)2638 UPB_INLINE void google_protobuf_DescriptorProto_clear_extension_range(const google_protobuf_DescriptorProto* msg) {
2639 _upb_array_detach(msg, UPB_SIZE(24, 48));
2640 }
google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto * msg,size_t * len)2641 UPB_INLINE const google_protobuf_DescriptorProto_ExtensionRange* const* google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto* msg, size_t* len) {
2642 return (const google_protobuf_DescriptorProto_ExtensionRange* const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len);
2643 }
google_protobuf_DescriptorProto_has_extension(const google_protobuf_DescriptorProto * msg)2644 UPB_INLINE bool google_protobuf_DescriptorProto_has_extension(const google_protobuf_DescriptorProto* msg) {
2645 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(28, 56));
2646 }
google_protobuf_DescriptorProto_clear_extension(const google_protobuf_DescriptorProto * msg)2647 UPB_INLINE void google_protobuf_DescriptorProto_clear_extension(const google_protobuf_DescriptorProto* msg) {
2648 _upb_array_detach(msg, UPB_SIZE(28, 56));
2649 }
google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto * msg,size_t * len)2650 UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto* msg, size_t* len) {
2651 return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len);
2652 }
google_protobuf_DescriptorProto_has_options(const google_protobuf_DescriptorProto * msg)2653 UPB_INLINE bool google_protobuf_DescriptorProto_has_options(const google_protobuf_DescriptorProto* msg) {
2654 return _upb_hasbit(msg, 2);
2655 }
google_protobuf_DescriptorProto_clear_options(const google_protobuf_DescriptorProto * msg)2656 UPB_INLINE void google_protobuf_DescriptorProto_clear_options(const google_protobuf_DescriptorProto* msg) {
2657 *UPB_PTR_AT(msg, UPB_SIZE(32, 64), const upb_Message*) = NULL;
2658 }
google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto * msg)2659 UPB_INLINE const google_protobuf_MessageOptions* google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto* msg) {
2660 return *UPB_PTR_AT(msg, UPB_SIZE(32, 64), const google_protobuf_MessageOptions*);
2661 }
google_protobuf_DescriptorProto_has_oneof_decl(const google_protobuf_DescriptorProto * msg)2662 UPB_INLINE bool google_protobuf_DescriptorProto_has_oneof_decl(const google_protobuf_DescriptorProto* msg) {
2663 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(36, 72));
2664 }
google_protobuf_DescriptorProto_clear_oneof_decl(const google_protobuf_DescriptorProto * msg)2665 UPB_INLINE void google_protobuf_DescriptorProto_clear_oneof_decl(const google_protobuf_DescriptorProto* msg) {
2666 _upb_array_detach(msg, UPB_SIZE(36, 72));
2667 }
google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto * msg,size_t * len)2668 UPB_INLINE const google_protobuf_OneofDescriptorProto* const* google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto* msg, size_t* len) {
2669 return (const google_protobuf_OneofDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len);
2670 }
google_protobuf_DescriptorProto_has_reserved_range(const google_protobuf_DescriptorProto * msg)2671 UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_range(const google_protobuf_DescriptorProto* msg) {
2672 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(40, 80));
2673 }
google_protobuf_DescriptorProto_clear_reserved_range(const google_protobuf_DescriptorProto * msg)2674 UPB_INLINE void google_protobuf_DescriptorProto_clear_reserved_range(const google_protobuf_DescriptorProto* msg) {
2675 _upb_array_detach(msg, UPB_SIZE(40, 80));
2676 }
google_protobuf_DescriptorProto_reserved_range(const google_protobuf_DescriptorProto * msg,size_t * len)2677 UPB_INLINE const google_protobuf_DescriptorProto_ReservedRange* const* google_protobuf_DescriptorProto_reserved_range(const google_protobuf_DescriptorProto* msg, size_t* len) {
2678 return (const google_protobuf_DescriptorProto_ReservedRange* const*)_upb_array_accessor(msg, UPB_SIZE(40, 80), len);
2679 }
google_protobuf_DescriptorProto_clear_reserved_name(const google_protobuf_DescriptorProto * msg)2680 UPB_INLINE void google_protobuf_DescriptorProto_clear_reserved_name(const google_protobuf_DescriptorProto* msg) {
2681 _upb_array_detach(msg, UPB_SIZE(44, 88));
2682 }
google_protobuf_DescriptorProto_reserved_name(const google_protobuf_DescriptorProto * msg,size_t * len)2683 UPB_INLINE upb_StringView const* google_protobuf_DescriptorProto_reserved_name(const google_protobuf_DescriptorProto* msg, size_t* len) {
2684 return (upb_StringView const*)_upb_array_accessor(msg, UPB_SIZE(44, 88), len);
2685 }
2686
google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto * msg,upb_StringView value)2687 UPB_INLINE void google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto *msg, upb_StringView value) {
2688 _upb_sethas(msg, 1);
2689 *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView) = value;
2690 }
google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto * msg,size_t * len)2691 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto* msg, size_t* len) {
2692 return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(12, 24), len);
2693 }
google_protobuf_DescriptorProto_resize_field(google_protobuf_DescriptorProto * msg,size_t len,upb_Arena * arena)2694 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_field(google_protobuf_DescriptorProto* msg, size_t len, upb_Arena* arena) {
2695 return (google_protobuf_FieldDescriptorProto**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(12, 24), len, UPB_SIZE(2, 3), arena);
2696 }
google_protobuf_DescriptorProto_add_field(google_protobuf_DescriptorProto * msg,upb_Arena * arena)2697 UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_field(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
2698 struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_Message_New(&google_protobuf_FieldDescriptorProto_msginit, arena);
2699 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(12, 24), UPB_SIZE(2, 3), &sub, arena);
2700 if (!ok) return NULL;
2701 return sub;
2702 }
google_protobuf_DescriptorProto_mutable_nested_type(google_protobuf_DescriptorProto * msg,size_t * len)2703 UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_mutable_nested_type(google_protobuf_DescriptorProto* msg, size_t* len) {
2704 return (google_protobuf_DescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len);
2705 }
google_protobuf_DescriptorProto_resize_nested_type(google_protobuf_DescriptorProto * msg,size_t len,upb_Arena * arena)2706 UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_resize_nested_type(google_protobuf_DescriptorProto* msg, size_t len, upb_Arena* arena) {
2707 return (google_protobuf_DescriptorProto**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(16, 32), len, UPB_SIZE(2, 3), arena);
2708 }
google_protobuf_DescriptorProto_add_nested_type(google_protobuf_DescriptorProto * msg,upb_Arena * arena)2709 UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_add_nested_type(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
2710 struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)_upb_Message_New(&google_protobuf_DescriptorProto_msginit, arena);
2711 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(16, 32), UPB_SIZE(2, 3), &sub, arena);
2712 if (!ok) return NULL;
2713 return sub;
2714 }
google_protobuf_DescriptorProto_mutable_enum_type(google_protobuf_DescriptorProto * msg,size_t * len)2715 UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_mutable_enum_type(google_protobuf_DescriptorProto* msg, size_t* len) {
2716 return (google_protobuf_EnumDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len);
2717 }
google_protobuf_DescriptorProto_resize_enum_type(google_protobuf_DescriptorProto * msg,size_t len,upb_Arena * arena)2718 UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_resize_enum_type(google_protobuf_DescriptorProto* msg, size_t len, upb_Arena* arena) {
2719 return (google_protobuf_EnumDescriptorProto**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(20, 40), len, UPB_SIZE(2, 3), arena);
2720 }
google_protobuf_DescriptorProto_add_enum_type(google_protobuf_DescriptorProto * msg,upb_Arena * arena)2721 UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_DescriptorProto_add_enum_type(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
2722 struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)_upb_Message_New(&google_protobuf_EnumDescriptorProto_msginit, arena);
2723 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(20, 40), UPB_SIZE(2, 3), &sub, arena);
2724 if (!ok) return NULL;
2725 return sub;
2726 }
google_protobuf_DescriptorProto_mutable_extension_range(google_protobuf_DescriptorProto * msg,size_t * len)2727 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_mutable_extension_range(google_protobuf_DescriptorProto* msg, size_t* len) {
2728 return (google_protobuf_DescriptorProto_ExtensionRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len);
2729 }
google_protobuf_DescriptorProto_resize_extension_range(google_protobuf_DescriptorProto * msg,size_t len,upb_Arena * arena)2730 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_resize_extension_range(google_protobuf_DescriptorProto* msg, size_t len, upb_Arena* arena) {
2731 return (google_protobuf_DescriptorProto_ExtensionRange**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(24, 48), len, UPB_SIZE(2, 3), arena);
2732 }
google_protobuf_DescriptorProto_add_extension_range(google_protobuf_DescriptorProto * msg,upb_Arena * arena)2733 UPB_INLINE struct google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_add_extension_range(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
2734 struct google_protobuf_DescriptorProto_ExtensionRange* sub = (struct google_protobuf_DescriptorProto_ExtensionRange*)_upb_Message_New(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena);
2735 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(24, 48), UPB_SIZE(2, 3), &sub, arena);
2736 if (!ok) return NULL;
2737 return sub;
2738 }
google_protobuf_DescriptorProto_mutable_extension(google_protobuf_DescriptorProto * msg,size_t * len)2739 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_extension(google_protobuf_DescriptorProto* msg, size_t* len) {
2740 return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len);
2741 }
google_protobuf_DescriptorProto_resize_extension(google_protobuf_DescriptorProto * msg,size_t len,upb_Arena * arena)2742 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_extension(google_protobuf_DescriptorProto* msg, size_t len, upb_Arena* arena) {
2743 return (google_protobuf_FieldDescriptorProto**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(28, 56), len, UPB_SIZE(2, 3), arena);
2744 }
google_protobuf_DescriptorProto_add_extension(google_protobuf_DescriptorProto * msg,upb_Arena * arena)2745 UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_extension(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
2746 struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_Message_New(&google_protobuf_FieldDescriptorProto_msginit, arena);
2747 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(28, 56), UPB_SIZE(2, 3), &sub, arena);
2748 if (!ok) return NULL;
2749 return sub;
2750 }
google_protobuf_DescriptorProto_set_options(google_protobuf_DescriptorProto * msg,google_protobuf_MessageOptions * value)2751 UPB_INLINE void google_protobuf_DescriptorProto_set_options(google_protobuf_DescriptorProto *msg, google_protobuf_MessageOptions* value) {
2752 _upb_sethas(msg, 2);
2753 *UPB_PTR_AT(msg, UPB_SIZE(32, 64), google_protobuf_MessageOptions*) = value;
2754 }
google_protobuf_DescriptorProto_mutable_options(google_protobuf_DescriptorProto * msg,upb_Arena * arena)2755 UPB_INLINE struct google_protobuf_MessageOptions* google_protobuf_DescriptorProto_mutable_options(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
2756 struct google_protobuf_MessageOptions* sub = (struct google_protobuf_MessageOptions*)google_protobuf_DescriptorProto_options(msg);
2757 if (sub == NULL) {
2758 sub = (struct google_protobuf_MessageOptions*)_upb_Message_New(&google_protobuf_MessageOptions_msginit, arena);
2759 if (!sub) return NULL;
2760 google_protobuf_DescriptorProto_set_options(msg, sub);
2761 }
2762 return sub;
2763 }
google_protobuf_DescriptorProto_mutable_oneof_decl(google_protobuf_DescriptorProto * msg,size_t * len)2764 UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_mutable_oneof_decl(google_protobuf_DescriptorProto* msg, size_t* len) {
2765 return (google_protobuf_OneofDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 72), len);
2766 }
google_protobuf_DescriptorProto_resize_oneof_decl(google_protobuf_DescriptorProto * msg,size_t len,upb_Arena * arena)2767 UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_resize_oneof_decl(google_protobuf_DescriptorProto* msg, size_t len, upb_Arena* arena) {
2768 return (google_protobuf_OneofDescriptorProto**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(36, 72), len, UPB_SIZE(2, 3), arena);
2769 }
google_protobuf_DescriptorProto_add_oneof_decl(google_protobuf_DescriptorProto * msg,upb_Arena * arena)2770 UPB_INLINE struct google_protobuf_OneofDescriptorProto* google_protobuf_DescriptorProto_add_oneof_decl(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
2771 struct google_protobuf_OneofDescriptorProto* sub = (struct google_protobuf_OneofDescriptorProto*)_upb_Message_New(&google_protobuf_OneofDescriptorProto_msginit, arena);
2772 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(36, 72), UPB_SIZE(2, 3), &sub, arena);
2773 if (!ok) return NULL;
2774 return sub;
2775 }
google_protobuf_DescriptorProto_mutable_reserved_range(google_protobuf_DescriptorProto * msg,size_t * len)2776 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_mutable_reserved_range(google_protobuf_DescriptorProto* msg, size_t* len) {
2777 return (google_protobuf_DescriptorProto_ReservedRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(40, 80), len);
2778 }
google_protobuf_DescriptorProto_resize_reserved_range(google_protobuf_DescriptorProto * msg,size_t len,upb_Arena * arena)2779 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_resize_reserved_range(google_protobuf_DescriptorProto* msg, size_t len, upb_Arena* arena) {
2780 return (google_protobuf_DescriptorProto_ReservedRange**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(40, 80), len, UPB_SIZE(2, 3), arena);
2781 }
google_protobuf_DescriptorProto_add_reserved_range(google_protobuf_DescriptorProto * msg,upb_Arena * arena)2782 UPB_INLINE struct google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_add_reserved_range(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
2783 struct google_protobuf_DescriptorProto_ReservedRange* sub = (struct google_protobuf_DescriptorProto_ReservedRange*)_upb_Message_New(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena);
2784 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(40, 80), UPB_SIZE(2, 3), &sub, arena);
2785 if (!ok) return NULL;
2786 return sub;
2787 }
google_protobuf_DescriptorProto_mutable_reserved_name(google_protobuf_DescriptorProto * msg,size_t * len)2788 UPB_INLINE upb_StringView* google_protobuf_DescriptorProto_mutable_reserved_name(google_protobuf_DescriptorProto* msg, size_t* len) {
2789 return (upb_StringView*)_upb_array_mutable_accessor(msg, UPB_SIZE(44, 88), len);
2790 }
google_protobuf_DescriptorProto_resize_reserved_name(google_protobuf_DescriptorProto * msg,size_t len,upb_Arena * arena)2791 UPB_INLINE upb_StringView* google_protobuf_DescriptorProto_resize_reserved_name(google_protobuf_DescriptorProto* msg, size_t len, upb_Arena* arena) {
2792 return (upb_StringView*)_upb_Array_Resize_accessor2(msg, UPB_SIZE(44, 88), len, UPB_SIZE(3, 4), arena);
2793 }
google_protobuf_DescriptorProto_add_reserved_name(google_protobuf_DescriptorProto * msg,upb_StringView val,upb_Arena * arena)2794 UPB_INLINE bool google_protobuf_DescriptorProto_add_reserved_name(google_protobuf_DescriptorProto* msg, upb_StringView val, upb_Arena* arena) {
2795 return _upb_Array_Append_accessor2(msg, UPB_SIZE(44, 88), UPB_SIZE(3, 4), &val, arena);
2796 }
2797
2798 /* google.protobuf.DescriptorProto.ExtensionRange */
2799
google_protobuf_DescriptorProto_ExtensionRange_new(upb_Arena * arena)2800 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_new(upb_Arena* arena) {
2801 return (google_protobuf_DescriptorProto_ExtensionRange*)_upb_Message_New(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena);
2802 }
google_protobuf_DescriptorProto_ExtensionRange_parse(const char * buf,size_t size,upb_Arena * arena)2803 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_parse(const char* buf, size_t size, upb_Arena* arena) {
2804 google_protobuf_DescriptorProto_ExtensionRange* ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena);
2805 if (!ret) return NULL;
2806 if (upb_Decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
2807 return NULL;
2808 }
2809 return ret;
2810 }
google_protobuf_DescriptorProto_ExtensionRange_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)2811 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_parse_ex(const char* buf, size_t size,
2812 const upb_ExtensionRegistry* extreg,
2813 int options, upb_Arena* arena) {
2814 google_protobuf_DescriptorProto_ExtensionRange* ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena);
2815 if (!ret) return NULL;
2816 if (upb_Decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, extreg, options, arena) !=
2817 kUpb_DecodeStatus_Ok) {
2818 return NULL;
2819 }
2820 return ret;
2821 }
google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange * msg,upb_Arena * arena,size_t * len)2822 UPB_INLINE char* google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange* msg, upb_Arena* arena, size_t* len) {
2823 return upb_Encode(msg, &google_protobuf_DescriptorProto_ExtensionRange_msginit, 0, arena, len);
2824 }
google_protobuf_DescriptorProto_ExtensionRange_serialize_ex(const google_protobuf_DescriptorProto_ExtensionRange * msg,int options,upb_Arena * arena,size_t * len)2825 UPB_INLINE char* google_protobuf_DescriptorProto_ExtensionRange_serialize_ex(const google_protobuf_DescriptorProto_ExtensionRange* msg, int options,
2826 upb_Arena* arena, size_t* len) {
2827 return upb_Encode(msg, &google_protobuf_DescriptorProto_ExtensionRange_msginit, options, arena, len);
2828 }
google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange * msg)2829 UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
2830 return _upb_hasbit(msg, 1);
2831 }
google_protobuf_DescriptorProto_ExtensionRange_clear_start(const google_protobuf_DescriptorProto_ExtensionRange * msg)2832 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_start(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
2833 *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = 0;
2834 _upb_clearhas(msg, 1);
2835 }
google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange * msg)2836 UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
2837 return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t);
2838 }
google_protobuf_DescriptorProto_ExtensionRange_has_end(const google_protobuf_DescriptorProto_ExtensionRange * msg)2839 UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_end(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
2840 return _upb_hasbit(msg, 2);
2841 }
google_protobuf_DescriptorProto_ExtensionRange_clear_end(const google_protobuf_DescriptorProto_ExtensionRange * msg)2842 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_end(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
2843 *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = 0;
2844 _upb_clearhas(msg, 2);
2845 }
google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange * msg)2846 UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
2847 return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t);
2848 }
google_protobuf_DescriptorProto_ExtensionRange_has_options(const google_protobuf_DescriptorProto_ExtensionRange * msg)2849 UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_options(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
2850 return _upb_hasbit(msg, 3);
2851 }
google_protobuf_DescriptorProto_ExtensionRange_clear_options(const google_protobuf_DescriptorProto_ExtensionRange * msg)2852 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_options(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
2853 *UPB_PTR_AT(msg, UPB_SIZE(12, 16), const upb_Message*) = NULL;
2854 }
google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange * msg)2855 UPB_INLINE const google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
2856 return *UPB_PTR_AT(msg, UPB_SIZE(12, 16), const google_protobuf_ExtensionRangeOptions*);
2857 }
2858
google_protobuf_DescriptorProto_ExtensionRange_set_start(google_protobuf_DescriptorProto_ExtensionRange * msg,int32_t value)2859 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_start(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) {
2860 _upb_sethas(msg, 1);
2861 *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
2862 }
google_protobuf_DescriptorProto_ExtensionRange_set_end(google_protobuf_DescriptorProto_ExtensionRange * msg,int32_t value)2863 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_end(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) {
2864 _upb_sethas(msg, 2);
2865 *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
2866 }
google_protobuf_DescriptorProto_ExtensionRange_set_options(google_protobuf_DescriptorProto_ExtensionRange * msg,google_protobuf_ExtensionRangeOptions * value)2867 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_options(google_protobuf_DescriptorProto_ExtensionRange *msg, google_protobuf_ExtensionRangeOptions* value) {
2868 _upb_sethas(msg, 3);
2869 *UPB_PTR_AT(msg, UPB_SIZE(12, 16), google_protobuf_ExtensionRangeOptions*) = value;
2870 }
google_protobuf_DescriptorProto_ExtensionRange_mutable_options(google_protobuf_DescriptorProto_ExtensionRange * msg,upb_Arena * arena)2871 UPB_INLINE struct google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_mutable_options(google_protobuf_DescriptorProto_ExtensionRange* msg, upb_Arena* arena) {
2872 struct google_protobuf_ExtensionRangeOptions* sub = (struct google_protobuf_ExtensionRangeOptions*)google_protobuf_DescriptorProto_ExtensionRange_options(msg);
2873 if (sub == NULL) {
2874 sub = (struct google_protobuf_ExtensionRangeOptions*)_upb_Message_New(&google_protobuf_ExtensionRangeOptions_msginit, arena);
2875 if (!sub) return NULL;
2876 google_protobuf_DescriptorProto_ExtensionRange_set_options(msg, sub);
2877 }
2878 return sub;
2879 }
2880
2881 /* google.protobuf.DescriptorProto.ReservedRange */
2882
google_protobuf_DescriptorProto_ReservedRange_new(upb_Arena * arena)2883 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_new(upb_Arena* arena) {
2884 return (google_protobuf_DescriptorProto_ReservedRange*)_upb_Message_New(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena);
2885 }
google_protobuf_DescriptorProto_ReservedRange_parse(const char * buf,size_t size,upb_Arena * arena)2886 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_parse(const char* buf, size_t size, upb_Arena* arena) {
2887 google_protobuf_DescriptorProto_ReservedRange* ret = google_protobuf_DescriptorProto_ReservedRange_new(arena);
2888 if (!ret) return NULL;
2889 if (upb_Decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
2890 return NULL;
2891 }
2892 return ret;
2893 }
google_protobuf_DescriptorProto_ReservedRange_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)2894 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_parse_ex(const char* buf, size_t size,
2895 const upb_ExtensionRegistry* extreg,
2896 int options, upb_Arena* arena) {
2897 google_protobuf_DescriptorProto_ReservedRange* ret = google_protobuf_DescriptorProto_ReservedRange_new(arena);
2898 if (!ret) return NULL;
2899 if (upb_Decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, extreg, options, arena) !=
2900 kUpb_DecodeStatus_Ok) {
2901 return NULL;
2902 }
2903 return ret;
2904 }
google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange * msg,upb_Arena * arena,size_t * len)2905 UPB_INLINE char* google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange* msg, upb_Arena* arena, size_t* len) {
2906 return upb_Encode(msg, &google_protobuf_DescriptorProto_ReservedRange_msginit, 0, arena, len);
2907 }
google_protobuf_DescriptorProto_ReservedRange_serialize_ex(const google_protobuf_DescriptorProto_ReservedRange * msg,int options,upb_Arena * arena,size_t * len)2908 UPB_INLINE char* google_protobuf_DescriptorProto_ReservedRange_serialize_ex(const google_protobuf_DescriptorProto_ReservedRange* msg, int options,
2909 upb_Arena* arena, size_t* len) {
2910 return upb_Encode(msg, &google_protobuf_DescriptorProto_ReservedRange_msginit, options, arena, len);
2911 }
google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange * msg)2912 UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange* msg) {
2913 return _upb_hasbit(msg, 1);
2914 }
google_protobuf_DescriptorProto_ReservedRange_clear_start(const google_protobuf_DescriptorProto_ReservedRange * msg)2915 UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_clear_start(const google_protobuf_DescriptorProto_ReservedRange* msg) {
2916 *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = 0;
2917 _upb_clearhas(msg, 1);
2918 }
google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange * msg)2919 UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange* msg) {
2920 return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t);
2921 }
google_protobuf_DescriptorProto_ReservedRange_has_end(const google_protobuf_DescriptorProto_ReservedRange * msg)2922 UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_end(const google_protobuf_DescriptorProto_ReservedRange* msg) {
2923 return _upb_hasbit(msg, 2);
2924 }
google_protobuf_DescriptorProto_ReservedRange_clear_end(const google_protobuf_DescriptorProto_ReservedRange * msg)2925 UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_clear_end(const google_protobuf_DescriptorProto_ReservedRange* msg) {
2926 *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = 0;
2927 _upb_clearhas(msg, 2);
2928 }
google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange * msg)2929 UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange* msg) {
2930 return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t);
2931 }
2932
google_protobuf_DescriptorProto_ReservedRange_set_start(google_protobuf_DescriptorProto_ReservedRange * msg,int32_t value)2933 UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_start(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) {
2934 _upb_sethas(msg, 1);
2935 *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
2936 }
google_protobuf_DescriptorProto_ReservedRange_set_end(google_protobuf_DescriptorProto_ReservedRange * msg,int32_t value)2937 UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_end(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) {
2938 _upb_sethas(msg, 2);
2939 *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
2940 }
2941
2942 /* google.protobuf.ExtensionRangeOptions */
2943
google_protobuf_ExtensionRangeOptions_new(upb_Arena * arena)2944 UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_new(upb_Arena* arena) {
2945 return (google_protobuf_ExtensionRangeOptions*)_upb_Message_New(&google_protobuf_ExtensionRangeOptions_msginit, arena);
2946 }
google_protobuf_ExtensionRangeOptions_parse(const char * buf,size_t size,upb_Arena * arena)2947 UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_parse(const char* buf, size_t size, upb_Arena* arena) {
2948 google_protobuf_ExtensionRangeOptions* ret = google_protobuf_ExtensionRangeOptions_new(arena);
2949 if (!ret) return NULL;
2950 if (upb_Decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
2951 return NULL;
2952 }
2953 return ret;
2954 }
google_protobuf_ExtensionRangeOptions_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)2955 UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_parse_ex(const char* buf, size_t size,
2956 const upb_ExtensionRegistry* extreg,
2957 int options, upb_Arena* arena) {
2958 google_protobuf_ExtensionRangeOptions* ret = google_protobuf_ExtensionRangeOptions_new(arena);
2959 if (!ret) return NULL;
2960 if (upb_Decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, extreg, options, arena) !=
2961 kUpb_DecodeStatus_Ok) {
2962 return NULL;
2963 }
2964 return ret;
2965 }
google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions * msg,upb_Arena * arena,size_t * len)2966 UPB_INLINE char* google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena, size_t* len) {
2967 return upb_Encode(msg, &google_protobuf_ExtensionRangeOptions_msginit, 0, arena, len);
2968 }
google_protobuf_ExtensionRangeOptions_serialize_ex(const google_protobuf_ExtensionRangeOptions * msg,int options,upb_Arena * arena,size_t * len)2969 UPB_INLINE char* google_protobuf_ExtensionRangeOptions_serialize_ex(const google_protobuf_ExtensionRangeOptions* msg, int options,
2970 upb_Arena* arena, size_t* len) {
2971 return upb_Encode(msg, &google_protobuf_ExtensionRangeOptions_msginit, options, arena, len);
2972 }
google_protobuf_ExtensionRangeOptions_has_uninterpreted_option(const google_protobuf_ExtensionRangeOptions * msg)2973 UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_uninterpreted_option(const google_protobuf_ExtensionRangeOptions* msg) {
2974 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0));
2975 }
google_protobuf_ExtensionRangeOptions_clear_uninterpreted_option(const google_protobuf_ExtensionRangeOptions * msg)2976 UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_uninterpreted_option(const google_protobuf_ExtensionRangeOptions* msg) {
2977 _upb_array_detach(msg, UPB_SIZE(0, 0));
2978 }
google_protobuf_ExtensionRangeOptions_uninterpreted_option(const google_protobuf_ExtensionRangeOptions * msg,size_t * len)2979 UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ExtensionRangeOptions_uninterpreted_option(const google_protobuf_ExtensionRangeOptions* msg, size_t* len) {
2980 return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len);
2981 }
2982
google_protobuf_ExtensionRangeOptions_mutable_uninterpreted_option(google_protobuf_ExtensionRangeOptions * msg,size_t * len)2983 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_mutable_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, size_t* len) {
2984 return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len);
2985 }
google_protobuf_ExtensionRangeOptions_resize_uninterpreted_option(google_protobuf_ExtensionRangeOptions * msg,size_t len,upb_Arena * arena)2986 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_resize_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, size_t len, upb_Arena* arena) {
2987 return (google_protobuf_UninterpretedOption**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(0, 0), len, UPB_SIZE(2, 3), arena);
2988 }
google_protobuf_ExtensionRangeOptions_add_uninterpreted_option(google_protobuf_ExtensionRangeOptions * msg,upb_Arena * arena)2989 UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ExtensionRangeOptions_add_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena) {
2990 struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(&google_protobuf_UninterpretedOption_msginit, arena);
2991 bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(0, 0), UPB_SIZE(2, 3), &sub, arena);
2992 if (!ok) return NULL;
2993 return sub;
2994 }
2995
2996 /* google.protobuf.FieldDescriptorProto */
2997
google_protobuf_FieldDescriptorProto_new(upb_Arena * arena)2998 UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_new(upb_Arena* arena) {
2999 return (google_protobuf_FieldDescriptorProto*)_upb_Message_New(&google_protobuf_FieldDescriptorProto_msginit, arena);
3000 }
google_protobuf_FieldDescriptorProto_parse(const char * buf,size_t size,upb_Arena * arena)3001 UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
3002 google_protobuf_FieldDescriptorProto* ret = google_protobuf_FieldDescriptorProto_new(arena);
3003 if (!ret) return NULL;
3004 if (upb_Decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
3005 return NULL;
3006 }
3007 return ret;
3008 }
google_protobuf_FieldDescriptorProto_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)3009 UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_parse_ex(const char* buf, size_t size,
3010 const upb_ExtensionRegistry* extreg,
3011 int options, upb_Arena* arena) {
3012 google_protobuf_FieldDescriptorProto* ret = google_protobuf_FieldDescriptorProto_new(arena);
3013 if (!ret) return NULL;
3014 if (upb_Decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, extreg, options, arena) !=
3015 kUpb_DecodeStatus_Ok) {
3016 return NULL;
3017 }
3018 return ret;
3019 }
google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto * msg,upb_Arena * arena,size_t * len)3020 UPB_INLINE char* google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto* msg, upb_Arena* arena, size_t* len) {
3021 return upb_Encode(msg, &google_protobuf_FieldDescriptorProto_msginit, 0, arena, len);
3022 }
google_protobuf_FieldDescriptorProto_serialize_ex(const google_protobuf_FieldDescriptorProto * msg,int options,upb_Arena * arena,size_t * len)3023 UPB_INLINE char* google_protobuf_FieldDescriptorProto_serialize_ex(const google_protobuf_FieldDescriptorProto* msg, int options,
3024 upb_Arena* arena, size_t* len) {
3025 return upb_Encode(msg, &google_protobuf_FieldDescriptorProto_msginit, options, arena, len);
3026 }
google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto * msg)3027 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto* msg) {
3028 return _upb_hasbit(msg, 1);
3029 }
google_protobuf_FieldDescriptorProto_clear_name(const google_protobuf_FieldDescriptorProto * msg)3030 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_name(const google_protobuf_FieldDescriptorProto* msg) {
3031 *UPB_PTR_AT(msg, UPB_SIZE(24, 24), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
3032 _upb_clearhas(msg, 1);
3033 }
google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto * msg)3034 UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto* msg) {
3035 return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), upb_StringView);
3036 }
google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto * msg)3037 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto* msg) {
3038 return _upb_hasbit(msg, 2);
3039 }
google_protobuf_FieldDescriptorProto_clear_extendee(const google_protobuf_FieldDescriptorProto * msg)3040 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_extendee(const google_protobuf_FieldDescriptorProto* msg) {
3041 *UPB_PTR_AT(msg, UPB_SIZE(32, 40), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
3042 _upb_clearhas(msg, 2);
3043 }
google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto * msg)3044 UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto* msg) {
3045 return *UPB_PTR_AT(msg, UPB_SIZE(32, 40), upb_StringView);
3046 }
google_protobuf_FieldDescriptorProto_has_number(const google_protobuf_FieldDescriptorProto * msg)3047 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_number(const google_protobuf_FieldDescriptorProto* msg) {
3048 return _upb_hasbit(msg, 3);
3049 }
google_protobuf_FieldDescriptorProto_clear_number(const google_protobuf_FieldDescriptorProto * msg)3050 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_number(const google_protobuf_FieldDescriptorProto* msg) {
3051 *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = 0;
3052 _upb_clearhas(msg, 3);
3053 }
google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto * msg)3054 UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto* msg) {
3055 return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t);
3056 }
google_protobuf_FieldDescriptorProto_has_label(const google_protobuf_FieldDescriptorProto * msg)3057 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_label(const google_protobuf_FieldDescriptorProto* msg) {
3058 return _upb_hasbit(msg, 4);
3059 }
google_protobuf_FieldDescriptorProto_clear_label(const google_protobuf_FieldDescriptorProto * msg)3060 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_label(const google_protobuf_FieldDescriptorProto* msg) {
3061 *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = 0;
3062 _upb_clearhas(msg, 4);
3063 }
google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto * msg)3064 UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto* msg) {
3065 return google_protobuf_FieldDescriptorProto_has_label(msg) ? *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) : 1;
3066 }
google_protobuf_FieldDescriptorProto_has_type(const google_protobuf_FieldDescriptorProto * msg)3067 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type(const google_protobuf_FieldDescriptorProto* msg) {
3068 return _upb_hasbit(msg, 5);
3069 }
google_protobuf_FieldDescriptorProto_clear_type(const google_protobuf_FieldDescriptorProto * msg)3070 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_type(const google_protobuf_FieldDescriptorProto* msg) {
3071 *UPB_PTR_AT(msg, UPB_SIZE(12, 12), int32_t) = 0;
3072 _upb_clearhas(msg, 5);
3073 }
google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto * msg)3074 UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto* msg) {
3075 return google_protobuf_FieldDescriptorProto_has_type(msg) ? *UPB_PTR_AT(msg, UPB_SIZE(12, 12), int32_t) : 1;
3076 }
google_protobuf_FieldDescriptorProto_has_type_name(const google_protobuf_FieldDescriptorProto * msg)3077 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type_name(const google_protobuf_FieldDescriptorProto* msg) {
3078 return _upb_hasbit(msg, 6);
3079 }
google_protobuf_FieldDescriptorProto_clear_type_name(const google_protobuf_FieldDescriptorProto * msg)3080 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_type_name(const google_protobuf_FieldDescriptorProto* msg) {
3081 *UPB_PTR_AT(msg, UPB_SIZE(40, 56), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
3082 _upb_clearhas(msg, 6);
3083 }
google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto * msg)3084 UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto* msg) {
3085 return *UPB_PTR_AT(msg, UPB_SIZE(40, 56), upb_StringView);
3086 }
google_protobuf_FieldDescriptorProto_has_default_value(const google_protobuf_FieldDescriptorProto * msg)3087 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_default_value(const google_protobuf_FieldDescriptorProto* msg) {
3088 return _upb_hasbit(msg, 7);
3089 }
google_protobuf_FieldDescriptorProto_clear_default_value(const google_protobuf_FieldDescriptorProto * msg)3090 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_default_value(const google_protobuf_FieldDescriptorProto* msg) {
3091 *UPB_PTR_AT(msg, UPB_SIZE(48, 72), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
3092 _upb_clearhas(msg, 7);
3093 }
google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto * msg)3094 UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto* msg) {
3095 return *UPB_PTR_AT(msg, UPB_SIZE(48, 72), upb_StringView);
3096 }
google_protobuf_FieldDescriptorProto_has_options(const google_protobuf_FieldDescriptorProto * msg)3097 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_options(const google_protobuf_FieldDescriptorProto* msg) {
3098 return _upb_hasbit(msg, 8);
3099 }
google_protobuf_FieldDescriptorProto_clear_options(const google_protobuf_FieldDescriptorProto * msg)3100 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_options(const google_protobuf_FieldDescriptorProto* msg) {
3101 *UPB_PTR_AT(msg, UPB_SIZE(56, 88), const upb_Message*) = NULL;
3102 }
google_protobuf_FieldDescriptorProto_options(const google_protobuf_FieldDescriptorProto * msg)3103 UPB_INLINE const google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_options(const google_protobuf_FieldDescriptorProto* msg) {
3104 return *UPB_PTR_AT(msg, UPB_SIZE(56, 88), const google_protobuf_FieldOptions*);
3105 }
google_protobuf_FieldDescriptorProto_has_oneof_index(const google_protobuf_FieldDescriptorProto * msg)3106 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_oneof_index(const google_protobuf_FieldDescriptorProto* msg) {
3107 return _upb_hasbit(msg, 9);
3108 }
google_protobuf_FieldDescriptorProto_clear_oneof_index(const google_protobuf_FieldDescriptorProto * msg)3109 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_oneof_index(const google_protobuf_FieldDescriptorProto* msg) {
3110 *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t) = 0;
3111 _upb_clearhas(msg, 9);
3112 }
google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto * msg)3113 UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto* msg) {
3114 return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t);
3115 }
google_protobuf_FieldDescriptorProto_has_json_name(const google_protobuf_FieldDescriptorProto * msg)3116 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_json_name(const google_protobuf_FieldDescriptorProto* msg) {
3117 return _upb_hasbit(msg, 10);
3118 }
google_protobuf_FieldDescriptorProto_clear_json_name(const google_protobuf_FieldDescriptorProto * msg)3119 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_json_name(const google_protobuf_FieldDescriptorProto* msg) {
3120 *UPB_PTR_AT(msg, UPB_SIZE(60, 96), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
3121 _upb_clearhas(msg, 10);
3122 }
google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto * msg)3123 UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto* msg) {
3124 return *UPB_PTR_AT(msg, UPB_SIZE(60, 96), upb_StringView);
3125 }
google_protobuf_FieldDescriptorProto_has_proto3_optional(const google_protobuf_FieldDescriptorProto * msg)3126 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_proto3_optional(const google_protobuf_FieldDescriptorProto* msg) {
3127 return _upb_hasbit(msg, 11);
3128 }
google_protobuf_FieldDescriptorProto_clear_proto3_optional(const google_protobuf_FieldDescriptorProto * msg)3129 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_proto3_optional(const google_protobuf_FieldDescriptorProto* msg) {
3130 *UPB_PTR_AT(msg, UPB_SIZE(20, 20), bool) = 0;
3131 _upb_clearhas(msg, 11);
3132 }
google_protobuf_FieldDescriptorProto_proto3_optional(const google_protobuf_FieldDescriptorProto * msg)3133 UPB_INLINE bool google_protobuf_FieldDescriptorProto_proto3_optional(const google_protobuf_FieldDescriptorProto* msg) {
3134 return *UPB_PTR_AT(msg, UPB_SIZE(20, 20), bool);
3135 }
3136
google_protobuf_FieldDescriptorProto_set_name(google_protobuf_FieldDescriptorProto * msg,upb_StringView value)3137 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_name(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) {
3138 _upb_sethas(msg, 1);
3139 *UPB_PTR_AT(msg, UPB_SIZE(24, 24), upb_StringView) = value;
3140 }
google_protobuf_FieldDescriptorProto_set_extendee(google_protobuf_FieldDescriptorProto * msg,upb_StringView value)3141 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_extendee(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) {
3142 _upb_sethas(msg, 2);
3143 *UPB_PTR_AT(msg, UPB_SIZE(32, 40), upb_StringView) = value;
3144 }
google_protobuf_FieldDescriptorProto_set_number(google_protobuf_FieldDescriptorProto * msg,int32_t value)3145 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_number(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
3146 _upb_sethas(msg, 3);
3147 *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
3148 }
google_protobuf_FieldDescriptorProto_set_label(google_protobuf_FieldDescriptorProto * msg,int32_t value)3149 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_label(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
3150 _upb_sethas(msg, 4);
3151 *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
3152 }
google_protobuf_FieldDescriptorProto_set_type(google_protobuf_FieldDescriptorProto * msg,int32_t value)3153 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
3154 _upb_sethas(msg, 5);
3155 *UPB_PTR_AT(msg, UPB_SIZE(12, 12), int32_t) = value;
3156 }
google_protobuf_FieldDescriptorProto_set_type_name(google_protobuf_FieldDescriptorProto * msg,upb_StringView value)3157 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type_name(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) {
3158 _upb_sethas(msg, 6);
3159 *UPB_PTR_AT(msg, UPB_SIZE(40, 56), upb_StringView) = value;
3160 }
google_protobuf_FieldDescriptorProto_set_default_value(google_protobuf_FieldDescriptorProto * msg,upb_StringView value)3161 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_default_value(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) {
3162 _upb_sethas(msg, 7);
3163 *UPB_PTR_AT(msg, UPB_SIZE(48, 72), upb_StringView) = value;
3164 }
google_protobuf_FieldDescriptorProto_set_options(google_protobuf_FieldDescriptorProto * msg,google_protobuf_FieldOptions * value)3165 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_options(google_protobuf_FieldDescriptorProto *msg, google_protobuf_FieldOptions* value) {
3166 _upb_sethas(msg, 8);
3167 *UPB_PTR_AT(msg, UPB_SIZE(56, 88), google_protobuf_FieldOptions*) = value;
3168 }
google_protobuf_FieldDescriptorProto_mutable_options(google_protobuf_FieldDescriptorProto * msg,upb_Arena * arena)3169 UPB_INLINE struct google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_mutable_options(google_protobuf_FieldDescriptorProto* msg, upb_Arena* arena) {
3170 struct google_protobuf_FieldOptions* sub = (struct google_protobuf_FieldOptions*)google_protobuf_FieldDescriptorProto_options(msg);
3171 if (sub == NULL) {
3172 sub = (struct google_protobuf_FieldOptions*)_upb_Message_New(&google_protobuf_FieldOptions_msginit, arena);
3173 if (!sub) return NULL;
3174 google_protobuf_FieldDescriptorProto_set_options(msg, sub);
3175 }
3176 return sub;
3177 }
google_protobuf_FieldDescriptorProto_set_oneof_index(google_protobuf_FieldDescriptorProto * msg,int32_t value)3178 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_oneof_index(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
3179 _upb_sethas(msg, 9);
3180 *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t) = value;
3181 }
google_protobuf_FieldDescriptorProto_set_json_name(google_protobuf_FieldDescriptorProto * msg,upb_StringView value)3182 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_json_name(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) {
3183 _upb_sethas(msg, 10);
3184 *UPB_PTR_AT(msg, UPB_SIZE(60, 96), upb_StringView) = value;
3185 }
google_protobuf_FieldDescriptorProto_set_proto3_optional(google_protobuf_FieldDescriptorProto * msg,bool value)3186 UPB_INLINE void google_protobuf_FieldDescriptorProto_set_proto3_optional(google_protobuf_FieldDescriptorProto *msg, bool value) {
3187 _upb_sethas(msg, 11);
3188 *UPB_PTR_AT(msg, UPB_SIZE(20, 20), bool) = value;
3189 }
3190
3191 /* google.protobuf.OneofDescriptorProto */
3192
google_protobuf_OneofDescriptorProto_new(upb_Arena * arena)3193 UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptorProto_new(upb_Arena* arena) {
3194 return (google_protobuf_OneofDescriptorProto*)_upb_Message_New(&google_protobuf_OneofDescriptorProto_msginit, arena);
3195 }
google_protobuf_OneofDescriptorProto_parse(const char * buf,size_t size,upb_Arena * arena)3196 UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
3197 google_protobuf_OneofDescriptorProto* ret = google_protobuf_OneofDescriptorProto_new(arena);
3198 if (!ret) return NULL;
3199 if (upb_Decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
3200 return NULL;
3201 }
3202 return ret;
3203 }
google_protobuf_OneofDescriptorProto_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)3204 UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptorProto_parse_ex(const char* buf, size_t size,
3205 const upb_ExtensionRegistry* extreg,
3206 int options, upb_Arena* arena) {
3207 google_protobuf_OneofDescriptorProto* ret = google_protobuf_OneofDescriptorProto_new(arena);
3208 if (!ret) return NULL;
3209 if (upb_Decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, extreg, options, arena) !=
3210 kUpb_DecodeStatus_Ok) {
3211 return NULL;
3212 }
3213 return ret;
3214 }
google_protobuf_OneofDescriptorProto_serialize(const google_protobuf_OneofDescriptorProto * msg,upb_Arena * arena,size_t * len)3215 UPB_INLINE char* google_protobuf_OneofDescriptorProto_serialize(const google_protobuf_OneofDescriptorProto* msg, upb_Arena* arena, size_t* len) {
3216 return upb_Encode(msg, &google_protobuf_OneofDescriptorProto_msginit, 0, arena, len);
3217 }
google_protobuf_OneofDescriptorProto_serialize_ex(const google_protobuf_OneofDescriptorProto * msg,int options,upb_Arena * arena,size_t * len)3218 UPB_INLINE char* google_protobuf_OneofDescriptorProto_serialize_ex(const google_protobuf_OneofDescriptorProto* msg, int options,
3219 upb_Arena* arena, size_t* len) {
3220 return upb_Encode(msg, &google_protobuf_OneofDescriptorProto_msginit, options, arena, len);
3221 }
google_protobuf_OneofDescriptorProto_has_name(const google_protobuf_OneofDescriptorProto * msg)3222 UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_name(const google_protobuf_OneofDescriptorProto* msg) {
3223 return _upb_hasbit(msg, 1);
3224 }
google_protobuf_OneofDescriptorProto_clear_name(const google_protobuf_OneofDescriptorProto * msg)3225 UPB_INLINE void google_protobuf_OneofDescriptorProto_clear_name(const google_protobuf_OneofDescriptorProto* msg) {
3226 *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
3227 _upb_clearhas(msg, 1);
3228 }
google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto * msg)3229 UPB_INLINE upb_StringView google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto* msg) {
3230 return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView);
3231 }
google_protobuf_OneofDescriptorProto_has_options(const google_protobuf_OneofDescriptorProto * msg)3232 UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_options(const google_protobuf_OneofDescriptorProto* msg) {
3233 return _upb_hasbit(msg, 2);
3234 }
google_protobuf_OneofDescriptorProto_clear_options(const google_protobuf_OneofDescriptorProto * msg)3235 UPB_INLINE void google_protobuf_OneofDescriptorProto_clear_options(const google_protobuf_OneofDescriptorProto* msg) {
3236 *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const upb_Message*) = NULL;
3237 }
google_protobuf_OneofDescriptorProto_options(const google_protobuf_OneofDescriptorProto * msg)3238 UPB_INLINE const google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_options(const google_protobuf_OneofDescriptorProto* msg) {
3239 return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_OneofOptions*);
3240 }
3241
google_protobuf_OneofDescriptorProto_set_name(google_protobuf_OneofDescriptorProto * msg,upb_StringView value)3242 UPB_INLINE void google_protobuf_OneofDescriptorProto_set_name(google_protobuf_OneofDescriptorProto *msg, upb_StringView value) {
3243 _upb_sethas(msg, 1);
3244 *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView) = value;
3245 }
google_protobuf_OneofDescriptorProto_set_options(google_protobuf_OneofDescriptorProto * msg,google_protobuf_OneofOptions * value)3246 UPB_INLINE void google_protobuf_OneofDescriptorProto_set_options(google_protobuf_OneofDescriptorProto *msg, google_protobuf_OneofOptions* value) {
3247 _upb_sethas(msg, 2);
3248 *UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_OneofOptions*) = value;
3249 }
google_protobuf_OneofDescriptorProto_mutable_options(google_protobuf_OneofDescriptorProto * msg,upb_Arena * arena)3250 UPB_INLINE struct google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_mutable_options(google_protobuf_OneofDescriptorProto* msg, upb_Arena* arena) {
3251 struct google_protobuf_OneofOptions* sub = (struct google_protobuf_OneofOptions*)google_protobuf_OneofDescriptorProto_options(msg);
3252 if (sub == NULL) {
3253 sub = (struct google_protobuf_OneofOptions*)_upb_Message_New(&google_protobuf_OneofOptions_msginit, arena);
3254 if (!sub) return NULL;
3255 google_protobuf_OneofDescriptorProto_set_options(msg, sub);
3256 }
3257 return sub;
3258 }
3259
3260 /* google.protobuf.EnumDescriptorProto */
3261
google_protobuf_EnumDescriptorProto_new(upb_Arena * arena)3262 UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorProto_new(upb_Arena* arena) {
3263 return (google_protobuf_EnumDescriptorProto*)_upb_Message_New(&google_protobuf_EnumDescriptorProto_msginit, arena);
3264 }
google_protobuf_EnumDescriptorProto_parse(const char * buf,size_t size,upb_Arena * arena)3265 UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
3266 google_protobuf_EnumDescriptorProto* ret = google_protobuf_EnumDescriptorProto_new(arena);
3267 if (!ret) return NULL;
3268 if (upb_Decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
3269 return NULL;
3270 }
3271 return ret;
3272 }
google_protobuf_EnumDescriptorProto_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)3273 UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorProto_parse_ex(const char* buf, size_t size,
3274 const upb_ExtensionRegistry* extreg,
3275 int options, upb_Arena* arena) {
3276 google_protobuf_EnumDescriptorProto* ret = google_protobuf_EnumDescriptorProto_new(arena);
3277 if (!ret) return NULL;
3278 if (upb_Decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, extreg, options, arena) !=
3279 kUpb_DecodeStatus_Ok) {
3280 return NULL;
3281 }
3282 return ret;
3283 }
google_protobuf_EnumDescriptorProto_serialize(const google_protobuf_EnumDescriptorProto * msg,upb_Arena * arena,size_t * len)3284 UPB_INLINE char* google_protobuf_EnumDescriptorProto_serialize(const google_protobuf_EnumDescriptorProto* msg, upb_Arena* arena, size_t* len) {
3285 return upb_Encode(msg, &google_protobuf_EnumDescriptorProto_msginit, 0, arena, len);
3286 }
google_protobuf_EnumDescriptorProto_serialize_ex(const google_protobuf_EnumDescriptorProto * msg,int options,upb_Arena * arena,size_t * len)3287 UPB_INLINE char* google_protobuf_EnumDescriptorProto_serialize_ex(const google_protobuf_EnumDescriptorProto* msg, int options,
3288 upb_Arena* arena, size_t* len) {
3289 return upb_Encode(msg, &google_protobuf_EnumDescriptorProto_msginit, options, arena, len);
3290 }
google_protobuf_EnumDescriptorProto_has_name(const google_protobuf_EnumDescriptorProto * msg)3291 UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_name(const google_protobuf_EnumDescriptorProto* msg) {
3292 return _upb_hasbit(msg, 1);
3293 }
google_protobuf_EnumDescriptorProto_clear_name(const google_protobuf_EnumDescriptorProto * msg)3294 UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_name(const google_protobuf_EnumDescriptorProto* msg) {
3295 *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
3296 _upb_clearhas(msg, 1);
3297 }
google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto * msg)3298 UPB_INLINE upb_StringView google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto* msg) {
3299 return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView);
3300 }
google_protobuf_EnumDescriptorProto_has_value(const google_protobuf_EnumDescriptorProto * msg)3301 UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_value(const google_protobuf_EnumDescriptorProto* msg) {
3302 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(12, 24));
3303 }
google_protobuf_EnumDescriptorProto_clear_value(const google_protobuf_EnumDescriptorProto * msg)3304 UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_value(const google_protobuf_EnumDescriptorProto* msg) {
3305 _upb_array_detach(msg, UPB_SIZE(12, 24));
3306 }
google_protobuf_EnumDescriptorProto_value(const google_protobuf_EnumDescriptorProto * msg,size_t * len)3307 UPB_INLINE const google_protobuf_EnumValueDescriptorProto* const* google_protobuf_EnumDescriptorProto_value(const google_protobuf_EnumDescriptorProto* msg, size_t* len) {
3308 return (const google_protobuf_EnumValueDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(12, 24), len);
3309 }
google_protobuf_EnumDescriptorProto_has_options(const google_protobuf_EnumDescriptorProto * msg)3310 UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_options(const google_protobuf_EnumDescriptorProto* msg) {
3311 return _upb_hasbit(msg, 2);
3312 }
google_protobuf_EnumDescriptorProto_clear_options(const google_protobuf_EnumDescriptorProto * msg)3313 UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_options(const google_protobuf_EnumDescriptorProto* msg) {
3314 *UPB_PTR_AT(msg, UPB_SIZE(16, 32), const upb_Message*) = NULL;
3315 }
google_protobuf_EnumDescriptorProto_options(const google_protobuf_EnumDescriptorProto * msg)3316 UPB_INLINE const google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_options(const google_protobuf_EnumDescriptorProto* msg) {
3317 return *UPB_PTR_AT(msg, UPB_SIZE(16, 32), const google_protobuf_EnumOptions*);
3318 }
google_protobuf_EnumDescriptorProto_has_reserved_range(const google_protobuf_EnumDescriptorProto * msg)3319 UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_range(const google_protobuf_EnumDescriptorProto* msg) {
3320 return _upb_has_submsg_nohasbit(msg, UPB_SIZE(20, 40));
3321 }
google_protobuf_EnumDescriptorProto_clear_reserved_range(const google_protobuf_EnumDescriptorProto * msg)3322 UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_reserved_range(const google_protobuf_EnumDescriptorProto* msg) {
3323 _upb_array_detach(msg, UPB_SIZE(20, 40));
3324 }
google_protobuf_EnumDescriptorProto_reserved_range(const google_protobuf_EnumDescriptorProto * msg,size_t * len)3325 UPB_INLINE const google_protobuf_EnumDescriptorProto_EnumReservedRange* const* google_protobuf_EnumDescriptorProto_reserved_range(const google_protobuf_EnumDescriptorProto* msg, size_t* len) {
3326 return (const google_protobuf_EnumDescriptorProto_EnumReservedRange* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len);
3327 }
google_protobuf_EnumDescriptorProto_clear_reserved_name(const google_protobuf_EnumDescriptorProto * msg)3328 UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_reserved_name(const google_protobuf_EnumDescriptorProto* msg) {
3329 _upb_array_detach(msg, UPB_SIZE(24, 48));
3330 }
google_protobuf_EnumDescriptorProto_reserved_name(const google_protobuf_EnumDescriptorProto * msg,size_t * len)3331 UPB_INLINE upb_StringView const* google_protobuf_EnumDescriptorProto_reserved_name(const google_protobuf_EnumDescriptorProto* msg, size_t* len) {
3332 return (upb_StringView const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len);
3333 }
3334
google_protobuf_EnumDescriptorProto_set_name(google_protobuf_EnumDescriptorProto * msg,upb_StringView value)3335 UPB_INLINE void google_protobuf_EnumDescriptorProto_set_name(google_protobuf_EnumDescriptorProto *msg, upb_StringView value) {
3336 _upb_sethas(msg, 1);
3337 *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView) = value;
3338 }
google_protobuf_EnumDescriptorProto_mutable_value(google_protobuf_EnumDescriptorProto * msg,size_t * len)3339