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