1 // Ruby is still using proto3 enum semantics for proto2
2 #define UPB_DISABLE_CLOSED_ENUM_CHECKING
3 /* Amalgamated source file */
4
5 /*
6 * This is where we define internal portability macros used across upb.
7 *
8 * All of these macros are undef'd in undef.inc to avoid leaking them to users.
9 *
10 * The correct usage is:
11 *
12 * #include "upb/foobar.h"
13 * #include "upb/baz.h"
14 *
15 * // MUST be last included header.
16 * #include "upb/port/def.inc"
17 *
18 * // Code for this file.
19 * // <...>
20 *
21 * // Can be omitted for .c files, required for .h.
22 * #include "upb/port/undef.inc"
23 *
24 * This file is private and must not be included by users!
25 */
26
27 #if !((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
28 (defined(__cplusplus) && __cplusplus >= 201402L) || \
29 (defined(_MSC_VER) && _MSC_VER >= 1900))
30 #error upb requires C99 or C++14 or MSVC >= 2015.
31 #endif
32
33 // Portable check for GCC minimum version:
34 // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
35 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
36 #define UPB_GNUC_MIN(x, y) \
37 (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
38 #else
39 #define UPB_GNUC_MIN(x, y) 0
40 #endif
41
42 #include <assert.h>
43 #include <setjmp.h>
44 #include <stdbool.h>
45 #include <stdint.h>
46 #include <stdio.h>
47 #include <stdlib.h>
48
49 #ifndef UINTPTR_MAX
50 Error, UINTPTR_MAX is undefined
51 #endif
52
53 #if UINTPTR_MAX == 0xffffffff
54 #define UPB_SIZE(size32, size64) size32
55 #else
56 #define UPB_SIZE(size32, size64) size64
57 #endif
58
59 /* If we always read/write as a consistent type to each address, this shouldn't
60 * violate aliasing.
61 */
62 #define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs)))
63
64 #define UPB_MAPTYPE_STRING 0
65
66 // UPB_EXPORT: always generate a public symbol.
67 #if defined(__GNUC__) || defined(__clang__)
68 #define UPB_EXPORT __attribute__((visibility("default"))) __attribute__((used))
69 #else
70 #define UPB_EXPORT
71 #endif
72
73 // UPB_INLINE: inline if possible, emit standalone code if required.
74 #ifdef __cplusplus
75 #define UPB_INLINE inline
76 #elif defined (__GNUC__) || defined(__clang__)
77 #define UPB_INLINE static __inline__
78 #else
79 #define UPB_INLINE static
80 #endif
81
82 #ifdef UPB_BUILD_API
83 #define UPB_API UPB_EXPORT
84 #define UPB_API_INLINE UPB_EXPORT
85 #else
86 #define UPB_API
87 #define UPB_API_INLINE UPB_INLINE
88 #endif
89
90 #ifdef EXPORT_UPBC
91 #define UPBC_API UPB_EXPORT
92 #else
93 #define UPBC_API
94 #endif
95
96 #define UPB_MALLOC_ALIGN 8
97 #define UPB_ALIGN_UP(size, align) (((size) + (align) - 1) / (align) * (align))
98 #define UPB_ALIGN_DOWN(size, align) ((size) / (align) * (align))
99 #define UPB_ALIGN_MALLOC(size) UPB_ALIGN_UP(size, UPB_MALLOC_ALIGN)
100 #ifdef __clang__
101 #define UPB_ALIGN_OF(type) _Alignof(type)
102 #else
103 #define UPB_ALIGN_OF(type) offsetof (struct { char c; type member; }, member)
104 #endif
105
106 #ifdef _MSC_VER
107 // Some versions of our Windows compiler don't support the C11 syntax.
108 #define UPB_ALIGN_AS(x) __declspec(align(x))
109 #else
110 #define UPB_ALIGN_AS(x) _Alignas(x)
111 #endif
112
113 // Hints to the compiler about likely/unlikely branches.
114 #if defined (__GNUC__) || defined(__clang__)
115 #define UPB_LIKELY(x) __builtin_expect((bool)(x), 1)
116 #define UPB_UNLIKELY(x) __builtin_expect((bool)(x), 0)
117 #else
118 #define UPB_LIKELY(x) (x)
119 #define UPB_UNLIKELY(x) (x)
120 #endif
121
122 // Macros for function attributes on compilers that support them.
123 #ifdef __GNUC__
124 #define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static
125 #define UPB_NOINLINE __attribute__((noinline))
126 #define UPB_NORETURN __attribute__((__noreturn__))
127 #define UPB_PRINTF(str, first_vararg) __attribute__((format (printf, str, first_vararg)))
128 #elif defined(_MSC_VER)
129 #define UPB_NOINLINE
130 #define UPB_FORCEINLINE static
131 #define UPB_NORETURN __declspec(noreturn)
132 #define UPB_PRINTF(str, first_vararg)
133 #else /* !defined(__GNUC__) */
134 #define UPB_FORCEINLINE static
135 #define UPB_NOINLINE
136 #define UPB_NORETURN
137 #define UPB_PRINTF(str, first_vararg)
138 #endif
139
140 #define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
141 #define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
142
143 #define UPB_UNUSED(var) (void)var
144
145 // UPB_ASSUME(): in release mode, we tell the compiler to assume this is true.
146 #ifdef NDEBUG
147 #ifdef __GNUC__
148 #define UPB_ASSUME(expr) if (!(expr)) __builtin_unreachable()
149 #elif defined _MSC_VER
150 #define UPB_ASSUME(expr) if (!(expr)) __assume(0)
151 #else
152 #define UPB_ASSUME(expr) do {} while (false && (expr))
153 #endif
154 #else
155 #define UPB_ASSUME(expr) assert(expr)
156 #endif
157
158 /* UPB_ASSERT(): in release mode, we use the expression without letting it be
159 * evaluated. This prevents "unused variable" warnings. */
160 #ifdef NDEBUG
161 #define UPB_ASSERT(expr) do {} while (false && (expr))
162 #else
163 #define UPB_ASSERT(expr) assert(expr)
164 #endif
165
166 #if defined(__GNUC__) || defined(__clang__)
167 #define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0)
168 #elif defined(_MSC_VER)
169 #define UPB_UNREACHABLE() \
170 do { \
171 assert(0); \
172 __assume(0); \
173 } while (0)
174 #else
175 #define UPB_UNREACHABLE() do { assert(0); } while(0)
176 #endif
177
178 /* UPB_SETJMP() / UPB_LONGJMP(): avoid setting/restoring signal mask. */
179 #ifdef __APPLE__
180 #define UPB_SETJMP(buf) _setjmp(buf)
181 #define UPB_LONGJMP(buf, val) _longjmp(buf, val)
182 #elif defined(WASM_WAMR)
183 #define UPB_SETJMP(buf) 0
184 #define UPB_LONGJMP(buf, val) abort()
185 #else
186 #define UPB_SETJMP(buf) setjmp(buf)
187 #define UPB_LONGJMP(buf, val) longjmp(buf, val)
188 #endif
189
190 #ifdef __GNUC__
191 #define UPB_USE_C11_ATOMICS
192 #define UPB_ATOMIC(T) _Atomic(T)
193 #else
194 #define UPB_ATOMIC(T) T
195 #endif
196
197 /* UPB_PTRADD(ptr, ofs): add pointer while avoiding "NULL + 0" UB */
198 #define UPB_PTRADD(ptr, ofs) ((ofs) ? (ptr) + (ofs) : (ptr))
199
200 #define UPB_PRIVATE(x) x##_dont_copy_me__upb_internal_use_only
201
202 #ifdef UPB_ALLOW_PRIVATE_ACCESS__FOR_BITS_ONLY
203 #define UPB_ONLYBITS(x) x
204 #else
205 #define UPB_ONLYBITS(x) UPB_PRIVATE(x)
206 #endif
207
208 /* Configure whether fasttable is switched on or not. *************************/
209
210 #ifdef __has_attribute
211 #define UPB_HAS_ATTRIBUTE(x) __has_attribute(x)
212 #else
213 #define UPB_HAS_ATTRIBUTE(x) 0
214 #endif
215
216 #if UPB_HAS_ATTRIBUTE(musttail)
217 #define UPB_MUSTTAIL __attribute__((musttail))
218 #else
219 #define UPB_MUSTTAIL
220 #endif
221
222 #undef UPB_HAS_ATTRIBUTE
223
224 /* This check is not fully robust: it does not require that we have "musttail"
225 * support available. We need tail calls to avoid consuming arbitrary amounts
226 * of stack space.
227 *
228 * GCC/Clang can mostly be trusted to generate tail calls as long as
229 * optimization is enabled, but, debug builds will not generate tail calls
230 * unless "musttail" is available.
231 *
232 * We should probably either:
233 * 1. require that the compiler supports musttail.
234 * 2. add some fallback code for when musttail isn't available (ie. return
235 * instead of tail calling). This is safe and portable, but this comes at
236 * a CPU cost.
237 */
238 #if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__)
239 #define UPB_FASTTABLE_SUPPORTED 1
240 #else
241 #define UPB_FASTTABLE_SUPPORTED 0
242 #endif
243
244 /* define UPB_ENABLE_FASTTABLE to force fast table support.
245 * This is useful when we want to ensure we are really getting fasttable,
246 * for example for testing or benchmarking. */
247 #if defined(UPB_ENABLE_FASTTABLE)
248 #if !UPB_FASTTABLE_SUPPORTED
249 #error fasttable is x86-64/ARM64 only and requires GCC or Clang.
250 #endif
251 #define UPB_FASTTABLE 1
252 /* Define UPB_TRY_ENABLE_FASTTABLE to use fasttable if possible.
253 * This is useful for releasing code that might be used on multiple platforms,
254 * for example the PHP or Ruby C extensions. */
255 #elif defined(UPB_TRY_ENABLE_FASTTABLE)
256 #define UPB_FASTTABLE UPB_FASTTABLE_SUPPORTED
257 #else
258 #define UPB_FASTTABLE 0
259 #endif
260
261 /* UPB_FASTTABLE_INIT() allows protos compiled for fasttable to gracefully
262 * degrade to non-fasttable if the runtime or platform do not support it. */
263 #if !UPB_FASTTABLE
264 #define UPB_FASTTABLE_INIT(...)
265 #define UPB_FASTTABLE_MASK(mask) -1
266 #else
267 #define UPB_FASTTABLE_INIT(...) __VA_ARGS__
268 #define UPB_FASTTABLE_MASK(mask) mask
269 #endif
270
271 #undef UPB_FASTTABLE_SUPPORTED
272
273 /* ASAN poisoning (for arena).
274 * If using UPB from an interpreted language like Ruby, a build of the
275 * interpreter compiled with ASAN enabled must be used in order to get sane and
276 * expected behavior.
277 */
278
279 /* Due to preprocessor limitations, the conditional logic for setting
280 * UPN_CLANG_ASAN below cannot be consolidated into a portable one-liner.
281 * See https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html.
282 */
283 #if defined(__has_feature)
284 #if __has_feature(address_sanitizer)
285 #define UPB_CLANG_ASAN 1
286 #else
287 #define UPB_CLANG_ASAN 0
288 #endif
289 #else
290 #define UPB_CLANG_ASAN 0
291 #endif
292
293 #if defined(__SANITIZE_ADDRESS__) || UPB_CLANG_ASAN
294 #define UPB_ASAN 1
295 #define UPB_ASAN_GUARD_SIZE 32
296 #ifdef __cplusplus
297 extern "C" {
298 #endif
299 void __asan_poison_memory_region(void const volatile *addr, size_t size);
300 void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
301 #ifdef __cplusplus
302 } /* extern "C" */
303 #endif
304 #define UPB_POISON_MEMORY_REGION(addr, size) \
305 __asan_poison_memory_region((addr), (size))
306 #define UPB_UNPOISON_MEMORY_REGION(addr, size) \
307 __asan_unpoison_memory_region((addr), (size))
308 #else
309 #define UPB_ASAN 0
310 #define UPB_ASAN_GUARD_SIZE 0
311 #define UPB_POISON_MEMORY_REGION(addr, size) \
312 ((void)(addr), (void)(size))
313 #define UPB_UNPOISON_MEMORY_REGION(addr, size) \
314 ((void)(addr), (void)(size))
315 #endif
316
317 /* Disable proto2 arena behavior (TEMPORARY) **********************************/
318
319 #ifdef UPB_DISABLE_CLOSED_ENUM_CHECKING
320 #define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 1
321 #else
322 #define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 0
323 #endif
324
325 #if defined(__cplusplus)
326 #if defined(__clang__) || UPB_GNUC_MIN(6, 0)
327 // https://gcc.gnu.org/gcc-6/changes.html
328 #if __cplusplus >= 201402L
329 #define UPB_DEPRECATED [[deprecated]]
330 #else
331 #define UPB_DEPRECATED __attribute__((deprecated))
332 #endif
333 #else
334 #define UPB_DEPRECATED
335 #endif
336 #else
337 #define UPB_DEPRECATED
338 #endif
339
340 #if defined(UPB_IS_GOOGLE3) && \
341 (!defined(UPB_BOOTSTRAP_STAGE) || UPB_BOOTSTRAP_STAGE != 0)
342 #define UPB_DESC(sym) proto2_##sym
343 #define UPB_DESC_MINITABLE(sym) &proto2__##sym##_msg_init
344 #elif defined(UPB_BOOTSTRAP_STAGE) && UPB_BOOTSTRAP_STAGE == 0
345 #define UPB_DESC(sym) google_protobuf_##sym
346 #define UPB_DESC_MINITABLE(sym) google__protobuf__##sym##_msg_init()
347 #else
348 #define UPB_DESC(sym) google_protobuf_##sym
349 #define UPB_DESC_MINITABLE(sym) &google__protobuf__##sym##_msg_init
350 #endif
351
352 #undef UPB_IS_GOOGLE3
353
354 // Linker arrays combine elements from multiple translation units into a single
355 // array that can be iterated over at runtime.
356 //
357 // It is an alternative to pre-main "registration" functions.
358 //
359 // Usage:
360 //
361 // // In N translation units.
362 // UPB_LINKARR_APPEND(foo_array) static int elems[3] = {1, 2, 3};
363 //
364 // // At runtime:
365 // UPB_LINKARR_DECLARE(foo_array, int);
366 //
367 // void f() {
368 // const int* start = UPB_LINKARR_START(foo_array);
369 // const int* stop = UPB_LINKARR_STOP(foo_array);
370 // for (const int* p = start; p < stop; p++) {
371 // // Windows can introduce zero padding, so we have to skip zeroes.
372 // if (*p != 0) {
373 // vec.push_back(*p);
374 // }
375 // }
376 // }
377
378 #if defined(__ELF__) || defined(__wasm__)
379
380 #define UPB_LINKARR_APPEND(name) \
381 __attribute__((retain, used, section("linkarr_" #name)))
382 #define UPB_LINKARR_DECLARE(name, type) \
383 extern type const __start_linkarr_##name; \
384 extern type const __stop_linkarr_##name; \
385 UPB_LINKARR_APPEND(name) type UPB_linkarr_internal_empty_##name[1]
386 #define UPB_LINKARR_START(name) (&__start_linkarr_##name)
387 #define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
388
389 #elif defined(__MACH__)
390
391 /* As described in: https://stackoverflow.com/a/22366882 */
392 #define UPB_LINKARR_APPEND(name) \
393 __attribute__((retain, used, section("__DATA,__la_" #name)))
394 #define UPB_LINKARR_DECLARE(name, type) \
395 extern type const __start_linkarr_##name __asm( \
396 "section$start$__DATA$__la_" #name); \
397 extern type const __stop_linkarr_##name __asm( \
398 "section$end$__DATA$" \
399 "__la_" #name); \
400 UPB_LINKARR_APPEND(name) type UPB_linkarr_internal_empty_##name[1]
401 #define UPB_LINKARR_START(name) (&__start_linkarr_##name)
402 #define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
403
404 #elif defined(_MSC_VER) && defined(__clang__)
405
406 /* See:
407 * https://devblogs.microsoft.com/oldnewthing/20181107-00/?p=100155
408 * https://devblogs.microsoft.com/oldnewthing/20181108-00/?p=100165
409 * https://devblogs.microsoft.com/oldnewthing/20181109-00/?p=100175 */
410
411 // Usage of __attribute__ here probably means this is Clang-specific, and would
412 // not work on MSVC.
413 #define UPB_LINKARR_APPEND(name) \
414 __declspec(allocate("la_" #name "$j")) __attribute__((retain, used))
415 #define UPB_LINKARR_DECLARE(name, type) \
416 __declspec(allocate("la_" #name "$a")) type __start_linkarr_##name; \
417 __declspec(allocate("la_" #name "$z")) type __stop_linkarr_##name; \
418 UPB_LINKARR_APPEND(name) type UPB_linkarr_internal_empty_##name[1] = {0}
419 #define UPB_LINKARR_START(name) (&__start_linkarr_##name)
420 #define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
421
422 #else
423
424 // Linker arrays are not supported on this platform. Make appends a no-op but
425 // don't define the other macros.
426 #define UPB_LINKARR_APPEND(name)
427
428 #endif
429
430 // Future versions of upb will include breaking changes to some APIs.
431 // This macro can be set to enable these API changes ahead of time, so that
432 // user code can be updated before upgrading versions of protobuf.
433 #ifdef UPB_FUTURE_BREAKING_CHANGES
434
435 // Properly enforce closed enums in python.
436 // Owner: mkruskal@
437 #define UPB_FUTURE_PYTHON_CLOSED_ENUM_ENFORCEMENT 1
438
439 #endif
440
441 #ifndef UPB_BASE_STATUS_H_
442 #define UPB_BASE_STATUS_H_
443
444 #include <stdarg.h>
445
446 // Must be last.
447
448 #define _kUpb_Status_MaxMessage 511
449
450 typedef struct {
451 bool ok;
452 char msg[_kUpb_Status_MaxMessage]; // Error message; NULL-terminated.
453 } upb_Status;
454
455 #ifdef __cplusplus
456 extern "C" {
457 #endif
458
459 UPB_API const char* upb_Status_ErrorMessage(const upb_Status* status);
460 UPB_API bool upb_Status_IsOk(const upb_Status* status);
461
462 // These are no-op if |status| is NULL.
463 UPB_API void upb_Status_Clear(upb_Status* status);
464 void upb_Status_SetErrorMessage(upb_Status* status, const char* msg);
465 void upb_Status_SetErrorFormat(upb_Status* status, const char* fmt, ...)
466 UPB_PRINTF(2, 3);
467 void upb_Status_VSetErrorFormat(upb_Status* status, const char* fmt,
468 va_list args) UPB_PRINTF(2, 0);
469 void upb_Status_VAppendErrorFormat(upb_Status* status, const char* fmt,
470 va_list args) UPB_PRINTF(2, 0);
471
472 #ifdef __cplusplus
473 } /* extern "C" */
474 #endif
475
476
477 #endif /* UPB_BASE_STATUS_H_ */
478
479 #ifndef UPB_WIRE_EPS_COPY_INPUT_STREAM_H_
480 #define UPB_WIRE_EPS_COPY_INPUT_STREAM_H_
481
482 #include <string.h>
483
484
485 /* upb_Arena is a specific allocator implementation that uses arena allocation.
486 * The user provides an allocator that will be used to allocate the underlying
487 * arena blocks. Arenas by nature do not require the individual allocations
488 * to be freed. However the Arena does allow users to register cleanup
489 * functions that will run when the arena is destroyed.
490 *
491 * A upb_Arena is *not* thread-safe.
492 *
493 * You could write a thread-safe arena allocator that satisfies the
494 * upb_alloc interface, but it would not be as efficient for the
495 * single-threaded case. */
496
497 #ifndef UPB_MEM_ARENA_H_
498 #define UPB_MEM_ARENA_H_
499
500 #include <stddef.h>
501 #include <stdint.h>
502
503
504 #ifndef UPB_MEM_ALLOC_H_
505 #define UPB_MEM_ALLOC_H_
506
507 // Must be last.
508
509 #ifdef __cplusplus
510 extern "C" {
511 #endif
512
513 typedef struct upb_alloc upb_alloc;
514
515 /* A combined `malloc()`/`free()` function.
516 * If `size` is 0 then the function acts like `free()`, otherwise it acts like
517 * `realloc()`. Only `oldsize` bytes from a previous allocation are
518 * preserved. */
519 typedef void* upb_alloc_func(upb_alloc* alloc, void* ptr, size_t oldsize,
520 size_t size);
521
522 /* A upb_alloc is a possibly-stateful allocator object.
523 *
524 * It could either be an arena allocator (which doesn't require individual
525 * `free()` calls) or a regular `malloc()` (which does). The client must
526 * therefore free memory unless it knows that the allocator is an arena
527 * allocator. */
528 struct upb_alloc {
529 upb_alloc_func* func;
530 };
531
upb_malloc(upb_alloc * alloc,size_t size)532 UPB_INLINE void* upb_malloc(upb_alloc* alloc, size_t size) {
533 UPB_ASSERT(alloc);
534 return alloc->func(alloc, NULL, 0, size);
535 }
536
upb_realloc(upb_alloc * alloc,void * ptr,size_t oldsize,size_t size)537 UPB_INLINE void* upb_realloc(upb_alloc* alloc, void* ptr, size_t oldsize,
538 size_t size) {
539 UPB_ASSERT(alloc);
540 return alloc->func(alloc, ptr, oldsize, size);
541 }
542
upb_free(upb_alloc * alloc,void * ptr)543 UPB_INLINE void upb_free(upb_alloc* alloc, void* ptr) {
544 UPB_ASSERT(alloc);
545 alloc->func(alloc, ptr, 0, 0);
546 }
547
548 // The global allocator used by upb. Uses the standard malloc()/free().
549
550 extern upb_alloc upb_alloc_global;
551
552 /* Functions that hard-code the global malloc.
553 *
554 * We still get benefit because we can put custom logic into our global
555 * allocator, like injecting out-of-memory faults in debug/testing builds. */
556
upb_gmalloc(size_t size)557 UPB_INLINE void* upb_gmalloc(size_t size) {
558 return upb_malloc(&upb_alloc_global, size);
559 }
560
upb_grealloc(void * ptr,size_t oldsize,size_t size)561 UPB_INLINE void* upb_grealloc(void* ptr, size_t oldsize, size_t size) {
562 return upb_realloc(&upb_alloc_global, ptr, oldsize, size);
563 }
564
upb_gfree(void * ptr)565 UPB_INLINE void upb_gfree(void* ptr) { upb_free(&upb_alloc_global, ptr); }
566
567 #ifdef __cplusplus
568 } /* extern "C" */
569 #endif
570
571
572 #endif /* UPB_MEM_ALLOC_H_ */
573
574 #ifndef UPB_MEM_INTERNAL_ARENA_H_
575 #define UPB_MEM_INTERNAL_ARENA_H_
576
577 #include <stddef.h>
578 #include <stdint.h>
579 #include <string.h>
580
581 // Must be last.
582
583 // This is QUITE an ugly hack, which specifies the number of pointers needed
584 // to equal (or exceed) the storage required for one upb_Arena.
585 //
586 // We need this because the decoder inlines a upb_Arena for performance but
587 // the full struct is not visible outside of arena.c. Yes, I know, it's awful.
588 #define UPB_ARENA_SIZE_HACK 7
589
590 // LINT.IfChange(upb_Arena)
591
592 struct upb_Arena {
593 char* UPB_ONLYBITS(ptr);
594 char* UPB_ONLYBITS(end);
595 };
596
597 // LINT.ThenChange(//depot/google3/third_party/upb/bits/typescript/arena.ts:upb_Arena)
598
599 #ifdef __cplusplus
600 extern "C" {
601 #endif
602
603 void UPB_PRIVATE(_upb_Arena_SwapIn)(struct upb_Arena* des,
604 const struct upb_Arena* src);
605 void UPB_PRIVATE(_upb_Arena_SwapOut)(struct upb_Arena* des,
606 const struct upb_Arena* src);
607
608 // Returns whether |ptr| was allocated directly by |a| (so care must be used
609 // with fused arenas).
610 UPB_API bool UPB_ONLYBITS(_upb_Arena_Contains)(const struct upb_Arena* a,
611 void* ptr);
612
UPB_PRIVATE(_upb_ArenaHas)613 UPB_INLINE size_t UPB_PRIVATE(_upb_ArenaHas)(const struct upb_Arena* a) {
614 return (size_t)(a->UPB_ONLYBITS(end) - a->UPB_ONLYBITS(ptr));
615 }
616
upb_Arena_Malloc(struct upb_Arena * a,size_t size)617 UPB_API_INLINE void* upb_Arena_Malloc(struct upb_Arena* a, size_t size) {
618 void* UPB_PRIVATE(_upb_Arena_SlowMalloc)(struct upb_Arena * a, size_t size);
619
620 size = UPB_ALIGN_MALLOC(size);
621 const size_t span = size + UPB_ASAN_GUARD_SIZE;
622 if (UPB_UNLIKELY(UPB_PRIVATE(_upb_ArenaHas)(a) < span)) {
623 return UPB_PRIVATE(_upb_Arena_SlowMalloc)(a, span);
624 }
625
626 // We have enough space to do a fast malloc.
627 void* ret = a->UPB_ONLYBITS(ptr);
628 UPB_ASSERT(UPB_ALIGN_MALLOC((uintptr_t)ret) == (uintptr_t)ret);
629 UPB_ASSERT(UPB_ALIGN_MALLOC(size) == size);
630 UPB_UNPOISON_MEMORY_REGION(ret, size);
631
632 a->UPB_ONLYBITS(ptr) += span;
633
634 return ret;
635 }
636
upb_Arena_Realloc(struct upb_Arena * a,void * ptr,size_t oldsize,size_t size)637 UPB_API_INLINE void* upb_Arena_Realloc(struct upb_Arena* a, void* ptr,
638 size_t oldsize, size_t size) {
639 oldsize = UPB_ALIGN_MALLOC(oldsize);
640 size = UPB_ALIGN_MALLOC(size);
641 bool is_most_recent_alloc =
642 (uintptr_t)ptr + oldsize == (uintptr_t)a->UPB_ONLYBITS(ptr);
643
644 if (is_most_recent_alloc) {
645 ptrdiff_t diff = size - oldsize;
646 if ((ptrdiff_t)UPB_PRIVATE(_upb_ArenaHas)(a) >= diff) {
647 a->UPB_ONLYBITS(ptr) += diff;
648 return ptr;
649 }
650 } else if (size <= oldsize) {
651 return ptr;
652 }
653
654 void* ret = upb_Arena_Malloc(a, size);
655
656 if (ret && oldsize > 0) {
657 memcpy(ret, ptr, UPB_MIN(oldsize, size));
658 }
659
660 return ret;
661 }
662
upb_Arena_ShrinkLast(struct upb_Arena * a,void * ptr,size_t oldsize,size_t size)663 UPB_API_INLINE void upb_Arena_ShrinkLast(struct upb_Arena* a, void* ptr,
664 size_t oldsize, size_t size) {
665 oldsize = UPB_ALIGN_MALLOC(oldsize);
666 size = UPB_ALIGN_MALLOC(size);
667 // Must be the last alloc.
668 UPB_ASSERT((char*)ptr + oldsize ==
669 a->UPB_ONLYBITS(ptr) - UPB_ASAN_GUARD_SIZE);
670 UPB_ASSERT(size <= oldsize);
671 a->UPB_ONLYBITS(ptr) = (char*)ptr + size;
672 }
673
674 #ifdef __cplusplus
675 } /* extern "C" */
676 #endif
677
678
679 #endif /* UPB_MEM_INTERNAL_ARENA_H_ */
680
681 // Must be last.
682
683 typedef struct upb_Arena upb_Arena;
684
685 #ifdef __cplusplus
686 extern "C" {
687 #endif
688
689 // Creates an arena from the given initial block (if any -- n may be 0).
690 // Additional blocks will be allocated from |alloc|. If |alloc| is NULL, this
691 // is a fixed-size arena and cannot grow.
692 UPB_API upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc);
693
694 UPB_API void upb_Arena_Free(upb_Arena* a);
695 UPB_API bool upb_Arena_Fuse(upb_Arena* a, upb_Arena* b);
696
697 bool upb_Arena_IncRefFor(upb_Arena* a, const void* owner);
698 void upb_Arena_DecRefFor(upb_Arena* a, const void* owner);
699
700 size_t upb_Arena_SpaceAllocated(upb_Arena* a, size_t* fused_count);
701 uint32_t upb_Arena_DebugRefCount(upb_Arena* a);
702
upb_Arena_New(void)703 UPB_API_INLINE upb_Arena* upb_Arena_New(void) {
704 return upb_Arena_Init(NULL, 0, &upb_alloc_global);
705 }
706
707 UPB_API_INLINE void* upb_Arena_Malloc(struct upb_Arena* a, size_t size);
708
709 UPB_API_INLINE void* upb_Arena_Realloc(upb_Arena* a, void* ptr, size_t oldsize,
710 size_t size);
711
712 // Sets the maximum block size for all arenas. This is a global configuration
713 // setting that will affect all existing and future arenas. If
714 // upb_Arena_Malloc() is called with a size larger than this, we will exceed
715 // this size and allocate a larger block.
716 //
717 // This API is meant for experimentation only. It will likely be removed in
718 // the future.
719 void upb_Arena_SetMaxBlockSize(size_t max);
720
721 // Shrinks the last alloc from arena.
722 // REQUIRES: (ptr, oldsize) was the last malloc/realloc from this arena.
723 // We could also add a upb_Arena_TryShrinkLast() which is simply a no-op if
724 // this was not the last alloc.
725 UPB_API_INLINE void upb_Arena_ShrinkLast(upb_Arena* a, void* ptr,
726 size_t oldsize, size_t size);
727
728 #ifdef UPB_TRACING_ENABLED
729 void upb_Arena_SetTraceHandler(void (*initArenaTraceHandler)(const upb_Arena*,
730 size_t size),
731 void (*fuseArenaTraceHandler)(const upb_Arena*,
732 const upb_Arena*),
733 void (*freeArenaTraceHandler)(const upb_Arena*));
734 #endif
735
736 #ifdef __cplusplus
737 } /* extern "C" */
738 #endif
739
740
741 #endif /* UPB_MEM_ARENA_H_ */
742
743 // Must be last.
744
745 #ifdef __cplusplus
746 extern "C" {
747 #endif
748
749 // The maximum number of bytes a single protobuf field can take up in the
750 // wire format. We only want to do one bounds check per field, so the input
751 // stream guarantees that after upb_EpsCopyInputStream_IsDone() is called,
752 // the decoder can read this many bytes without performing another bounds
753 // check. The stream will copy into a patch buffer as necessary to guarantee
754 // this invariant.
755 #define kUpb_EpsCopyInputStream_SlopBytes 16
756
757 enum {
758 kUpb_EpsCopyInputStream_NoAliasing = 0,
759 kUpb_EpsCopyInputStream_OnPatch = 1,
760 kUpb_EpsCopyInputStream_NoDelta = 2
761 };
762
763 typedef struct {
764 const char* end; // Can read up to SlopBytes bytes beyond this.
765 const char* limit_ptr; // For bounds checks, = end + UPB_MIN(limit, 0)
766 uintptr_t aliasing;
767 int limit; // Submessage limit relative to end
768 bool error; // To distinguish between EOF and error.
769 char patch[kUpb_EpsCopyInputStream_SlopBytes * 2];
770 } upb_EpsCopyInputStream;
771
772 // Returns true if the stream is in the error state. A stream enters the error
773 // state when the user reads past a limit (caught in IsDone()) or the
774 // ZeroCopyInputStream returns an error.
upb_EpsCopyInputStream_IsError(upb_EpsCopyInputStream * e)775 UPB_INLINE bool upb_EpsCopyInputStream_IsError(upb_EpsCopyInputStream* e) {
776 return e->error;
777 }
778
779 typedef const char* upb_EpsCopyInputStream_BufferFlipCallback(
780 upb_EpsCopyInputStream* e, const char* old_end, const char* new_start);
781
782 typedef const char* upb_EpsCopyInputStream_IsDoneFallbackFunc(
783 upb_EpsCopyInputStream* e, const char* ptr, int overrun);
784
785 // Initializes a upb_EpsCopyInputStream using the contents of the buffer
786 // [*ptr, size]. Updates `*ptr` as necessary to guarantee that at least
787 // kUpb_EpsCopyInputStream_SlopBytes are available to read.
upb_EpsCopyInputStream_Init(upb_EpsCopyInputStream * e,const char ** ptr,size_t size,bool enable_aliasing)788 UPB_INLINE void upb_EpsCopyInputStream_Init(upb_EpsCopyInputStream* e,
789 const char** ptr, size_t size,
790 bool enable_aliasing) {
791 if (size <= kUpb_EpsCopyInputStream_SlopBytes) {
792 memset(&e->patch, 0, 32);
793 if (size) memcpy(&e->patch, *ptr, size);
794 e->aliasing = enable_aliasing ? (uintptr_t)*ptr - (uintptr_t)e->patch
795 : kUpb_EpsCopyInputStream_NoAliasing;
796 *ptr = e->patch;
797 e->end = *ptr + size;
798 e->limit = 0;
799 } else {
800 e->end = *ptr + size - kUpb_EpsCopyInputStream_SlopBytes;
801 e->limit = kUpb_EpsCopyInputStream_SlopBytes;
802 e->aliasing = enable_aliasing ? kUpb_EpsCopyInputStream_NoDelta
803 : kUpb_EpsCopyInputStream_NoAliasing;
804 }
805 e->limit_ptr = e->end;
806 e->error = false;
807 }
808
809 typedef enum {
810 // The current stream position is at a limit.
811 kUpb_IsDoneStatus_Done,
812
813 // The current stream position is not at a limit.
814 kUpb_IsDoneStatus_NotDone,
815
816 // The current stream position is not at a limit, and the stream needs to
817 // be flipped to a new buffer before more data can be read.
818 kUpb_IsDoneStatus_NeedFallback,
819 } upb_IsDoneStatus;
820
821 // Returns the status of the current stream position. This is a low-level
822 // function, it is simpler to call upb_EpsCopyInputStream_IsDone() if possible.
upb_EpsCopyInputStream_IsDoneStatus(upb_EpsCopyInputStream * e,const char * ptr,int * overrun)823 UPB_INLINE upb_IsDoneStatus upb_EpsCopyInputStream_IsDoneStatus(
824 upb_EpsCopyInputStream* e, const char* ptr, int* overrun) {
825 *overrun = ptr - e->end;
826 if (UPB_LIKELY(ptr < e->limit_ptr)) {
827 return kUpb_IsDoneStatus_NotDone;
828 } else if (UPB_LIKELY(*overrun == e->limit)) {
829 return kUpb_IsDoneStatus_Done;
830 } else {
831 return kUpb_IsDoneStatus_NeedFallback;
832 }
833 }
834
835 // Returns true if the stream has hit a limit, either the current delimited
836 // limit or the overall end-of-stream. As a side effect, this function may flip
837 // the pointer to a new buffer if there are less than
838 // kUpb_EpsCopyInputStream_SlopBytes of data to be read in the current buffer.
839 //
840 // Postcondition: if the function returns false, there are at least
841 // kUpb_EpsCopyInputStream_SlopBytes of data available to read at *ptr.
upb_EpsCopyInputStream_IsDoneWithCallback(upb_EpsCopyInputStream * e,const char ** ptr,upb_EpsCopyInputStream_IsDoneFallbackFunc * func)842 UPB_INLINE bool upb_EpsCopyInputStream_IsDoneWithCallback(
843 upb_EpsCopyInputStream* e, const char** ptr,
844 upb_EpsCopyInputStream_IsDoneFallbackFunc* func) {
845 int overrun;
846 switch (upb_EpsCopyInputStream_IsDoneStatus(e, *ptr, &overrun)) {
847 case kUpb_IsDoneStatus_Done:
848 return true;
849 case kUpb_IsDoneStatus_NotDone:
850 return false;
851 case kUpb_IsDoneStatus_NeedFallback:
852 *ptr = func(e, *ptr, overrun);
853 return *ptr == NULL;
854 }
855 UPB_UNREACHABLE();
856 }
857
858 const char* _upb_EpsCopyInputStream_IsDoneFallbackNoCallback(
859 upb_EpsCopyInputStream* e, const char* ptr, int overrun);
860
861 // A simpler version of IsDoneWithCallback() that does not support a buffer flip
862 // callback. Useful in cases where we do not need to insert custom logic at
863 // every buffer flip.
864 //
865 // If this returns true, the user must call upb_EpsCopyInputStream_IsError()
866 // to distinguish between EOF and error.
upb_EpsCopyInputStream_IsDone(upb_EpsCopyInputStream * e,const char ** ptr)867 UPB_INLINE bool upb_EpsCopyInputStream_IsDone(upb_EpsCopyInputStream* e,
868 const char** ptr) {
869 return upb_EpsCopyInputStream_IsDoneWithCallback(
870 e, ptr, _upb_EpsCopyInputStream_IsDoneFallbackNoCallback);
871 }
872
873 // Returns the total number of bytes that are safe to read from the current
874 // buffer without reading uninitialized or unallocated memory.
875 //
876 // Note that this check does not respect any semantic limits on the stream,
877 // either limits from PushLimit() or the overall stream end, so some of these
878 // bytes may have unpredictable, nonsense values in them. The guarantee is only
879 // that the bytes are valid to read from the perspective of the C language
880 // (ie. you can read without triggering UBSAN or ASAN).
upb_EpsCopyInputStream_BytesAvailable(upb_EpsCopyInputStream * e,const char * ptr)881 UPB_INLINE size_t upb_EpsCopyInputStream_BytesAvailable(
882 upb_EpsCopyInputStream* e, const char* ptr) {
883 return (e->end - ptr) + kUpb_EpsCopyInputStream_SlopBytes;
884 }
885
886 // Returns true if the given delimited field size is valid (it does not extend
887 // beyond any previously-pushed limits). `ptr` should point to the beginning
888 // of the field data, after the delimited size.
889 //
890 // Note that this does *not* guarantee that all of the data for this field is in
891 // the current buffer.
upb_EpsCopyInputStream_CheckSize(const upb_EpsCopyInputStream * e,const char * ptr,int size)892 UPB_INLINE bool upb_EpsCopyInputStream_CheckSize(
893 const upb_EpsCopyInputStream* e, const char* ptr, int size) {
894 UPB_ASSERT(size >= 0);
895 return ptr - e->end + size <= e->limit;
896 }
897
_upb_EpsCopyInputStream_CheckSizeAvailable(upb_EpsCopyInputStream * e,const char * ptr,int size,bool submessage)898 UPB_INLINE bool _upb_EpsCopyInputStream_CheckSizeAvailable(
899 upb_EpsCopyInputStream* e, const char* ptr, int size, bool submessage) {
900 // This is one extra branch compared to the more normal:
901 // return (size_t)(end - ptr) < size;
902 // However it is one less computation if we are just about to use "ptr + len":
903 // https://godbolt.org/z/35YGPz
904 // In microbenchmarks this shows a small improvement.
905 uintptr_t uptr = (uintptr_t)ptr;
906 uintptr_t uend = (uintptr_t)e->limit_ptr;
907 uintptr_t res = uptr + (size_t)size;
908 if (!submessage) uend += kUpb_EpsCopyInputStream_SlopBytes;
909 // NOTE: this check depends on having a linear address space. This is not
910 // technically guaranteed by uintptr_t.
911 bool ret = res >= uptr && res <= uend;
912 if (size < 0) UPB_ASSERT(!ret);
913 return ret;
914 }
915
916 // Returns true if the given delimited field size is valid (it does not extend
917 // beyond any previously-pushed limited) *and* all of the data for this field is
918 // available to be read in the current buffer.
919 //
920 // If the size is negative, this function will always return false. This
921 // property can be useful in some cases.
upb_EpsCopyInputStream_CheckDataSizeAvailable(upb_EpsCopyInputStream * e,const char * ptr,int size)922 UPB_INLINE bool upb_EpsCopyInputStream_CheckDataSizeAvailable(
923 upb_EpsCopyInputStream* e, const char* ptr, int size) {
924 return _upb_EpsCopyInputStream_CheckSizeAvailable(e, ptr, size, false);
925 }
926
927 // Returns true if the given sub-message size is valid (it does not extend
928 // beyond any previously-pushed limited) *and* all of the data for this
929 // sub-message is available to be parsed in the current buffer.
930 //
931 // This implies that all fields from the sub-message can be parsed from the
932 // current buffer while maintaining the invariant that we always have at least
933 // kUpb_EpsCopyInputStream_SlopBytes of data available past the beginning of
934 // any individual field start.
935 //
936 // If the size is negative, this function will always return false. This
937 // property can be useful in some cases.
upb_EpsCopyInputStream_CheckSubMessageSizeAvailable(upb_EpsCopyInputStream * e,const char * ptr,int size)938 UPB_INLINE bool upb_EpsCopyInputStream_CheckSubMessageSizeAvailable(
939 upb_EpsCopyInputStream* e, const char* ptr, int size) {
940 return _upb_EpsCopyInputStream_CheckSizeAvailable(e, ptr, size, true);
941 }
942
943 // Returns true if aliasing_enabled=true was passed to
944 // upb_EpsCopyInputStream_Init() when this stream was initialized.
upb_EpsCopyInputStream_AliasingEnabled(upb_EpsCopyInputStream * e)945 UPB_INLINE bool upb_EpsCopyInputStream_AliasingEnabled(
946 upb_EpsCopyInputStream* e) {
947 return e->aliasing != kUpb_EpsCopyInputStream_NoAliasing;
948 }
949
950 // Returns true if aliasing_enabled=true was passed to
951 // upb_EpsCopyInputStream_Init() when this stream was initialized *and* we can
952 // alias into the region [ptr, size] in an input buffer.
upb_EpsCopyInputStream_AliasingAvailable(upb_EpsCopyInputStream * e,const char * ptr,size_t size)953 UPB_INLINE bool upb_EpsCopyInputStream_AliasingAvailable(
954 upb_EpsCopyInputStream* e, const char* ptr, size_t size) {
955 // When EpsCopyInputStream supports streaming, this will need to become a
956 // runtime check.
957 return upb_EpsCopyInputStream_CheckDataSizeAvailable(e, ptr, size) &&
958 e->aliasing >= kUpb_EpsCopyInputStream_NoDelta;
959 }
960
961 // Returns a pointer into an input buffer that corresponds to the parsing
962 // pointer `ptr`. The returned pointer may be the same as `ptr`, but also may
963 // be different if we are currently parsing out of the patch buffer.
964 //
965 // REQUIRES: Aliasing must be available for the given pointer. If the input is a
966 // flat buffer and aliasing is enabled, then aliasing will always be available.
upb_EpsCopyInputStream_GetAliasedPtr(upb_EpsCopyInputStream * e,const char * ptr)967 UPB_INLINE const char* upb_EpsCopyInputStream_GetAliasedPtr(
968 upb_EpsCopyInputStream* e, const char* ptr) {
969 UPB_ASSUME(upb_EpsCopyInputStream_AliasingAvailable(e, ptr, 0));
970 uintptr_t delta =
971 e->aliasing == kUpb_EpsCopyInputStream_NoDelta ? 0 : e->aliasing;
972 return (const char*)((uintptr_t)ptr + delta);
973 }
974
975 // Reads string data from the input, aliasing into the input buffer instead of
976 // copying. The parsing pointer is passed in `*ptr`, and will be updated if
977 // necessary to point to the actual input buffer. Returns the new parsing
978 // pointer, which will be advanced past the string data.
979 //
980 // REQUIRES: Aliasing must be available for this data region (test with
981 // upb_EpsCopyInputStream_AliasingAvailable().
upb_EpsCopyInputStream_ReadStringAliased(upb_EpsCopyInputStream * e,const char ** ptr,size_t size)982 UPB_INLINE const char* upb_EpsCopyInputStream_ReadStringAliased(
983 upb_EpsCopyInputStream* e, const char** ptr, size_t size) {
984 UPB_ASSUME(upb_EpsCopyInputStream_AliasingAvailable(e, *ptr, size));
985 const char* ret = *ptr + size;
986 *ptr = upb_EpsCopyInputStream_GetAliasedPtr(e, *ptr);
987 UPB_ASSUME(ret != NULL);
988 return ret;
989 }
990
991 // Skips `size` bytes of data from the input and returns a pointer past the end.
992 // Returns NULL on end of stream or error.
upb_EpsCopyInputStream_Skip(upb_EpsCopyInputStream * e,const char * ptr,int size)993 UPB_INLINE const char* upb_EpsCopyInputStream_Skip(upb_EpsCopyInputStream* e,
994 const char* ptr, int size) {
995 if (!upb_EpsCopyInputStream_CheckDataSizeAvailable(e, ptr, size)) return NULL;
996 return ptr + size;
997 }
998
999 // Copies `size` bytes of data from the input `ptr` into the buffer `to`, and
1000 // returns a pointer past the end. Returns NULL on end of stream or error.
upb_EpsCopyInputStream_Copy(upb_EpsCopyInputStream * e,const char * ptr,void * to,int size)1001 UPB_INLINE const char* upb_EpsCopyInputStream_Copy(upb_EpsCopyInputStream* e,
1002 const char* ptr, void* to,
1003 int size) {
1004 if (!upb_EpsCopyInputStream_CheckDataSizeAvailable(e, ptr, size)) return NULL;
1005 memcpy(to, ptr, size);
1006 return ptr + size;
1007 }
1008
1009 // Reads string data from the stream and advances the pointer accordingly.
1010 // If aliasing was enabled when the stream was initialized, then the returned
1011 // pointer will point into the input buffer if possible, otherwise new data
1012 // will be allocated from arena and copied into. We may be forced to copy even
1013 // if aliasing was enabled if the input data spans input buffers.
1014 //
1015 // Returns NULL if memory allocation failed, or we reached a premature EOF.
upb_EpsCopyInputStream_ReadString(upb_EpsCopyInputStream * e,const char ** ptr,size_t size,upb_Arena * arena)1016 UPB_INLINE const char* upb_EpsCopyInputStream_ReadString(
1017 upb_EpsCopyInputStream* e, const char** ptr, size_t size,
1018 upb_Arena* arena) {
1019 if (upb_EpsCopyInputStream_AliasingAvailable(e, *ptr, size)) {
1020 return upb_EpsCopyInputStream_ReadStringAliased(e, ptr, size);
1021 } else {
1022 // We need to allocate and copy.
1023 if (!upb_EpsCopyInputStream_CheckDataSizeAvailable(e, *ptr, size)) {
1024 return NULL;
1025 }
1026 UPB_ASSERT(arena);
1027 char* data = (char*)upb_Arena_Malloc(arena, size);
1028 if (!data) return NULL;
1029 const char* ret = upb_EpsCopyInputStream_Copy(e, *ptr, data, size);
1030 *ptr = data;
1031 return ret;
1032 }
1033 }
1034
_upb_EpsCopyInputStream_CheckLimit(upb_EpsCopyInputStream * e)1035 UPB_INLINE void _upb_EpsCopyInputStream_CheckLimit(upb_EpsCopyInputStream* e) {
1036 UPB_ASSERT(e->limit_ptr == e->end + UPB_MIN(0, e->limit));
1037 }
1038
1039 // Pushes a limit onto the stack of limits for the current stream. The limit
1040 // will extend for `size` bytes beyond the position in `ptr`. Future calls to
1041 // upb_EpsCopyInputStream_IsDone() will return `true` when the stream position
1042 // reaches this limit.
1043 //
1044 // Returns a delta that the caller must store and supply to PopLimit() below.
upb_EpsCopyInputStream_PushLimit(upb_EpsCopyInputStream * e,const char * ptr,int size)1045 UPB_INLINE int upb_EpsCopyInputStream_PushLimit(upb_EpsCopyInputStream* e,
1046 const char* ptr, int size) {
1047 int limit = size + (int)(ptr - e->end);
1048 int delta = e->limit - limit;
1049 _upb_EpsCopyInputStream_CheckLimit(e);
1050 UPB_ASSERT(limit <= e->limit);
1051 e->limit = limit;
1052 e->limit_ptr = e->end + UPB_MIN(0, limit);
1053 _upb_EpsCopyInputStream_CheckLimit(e);
1054 return delta;
1055 }
1056
1057 // Pops the last limit that was pushed on this stream. This may only be called
1058 // once IsDone() returns true. The user must pass the delta that was returned
1059 // from PushLimit().
upb_EpsCopyInputStream_PopLimit(upb_EpsCopyInputStream * e,const char * ptr,int saved_delta)1060 UPB_INLINE void upb_EpsCopyInputStream_PopLimit(upb_EpsCopyInputStream* e,
1061 const char* ptr,
1062 int saved_delta) {
1063 UPB_ASSERT(ptr - e->end == e->limit);
1064 _upb_EpsCopyInputStream_CheckLimit(e);
1065 e->limit += saved_delta;
1066 e->limit_ptr = e->end + UPB_MIN(0, e->limit);
1067 _upb_EpsCopyInputStream_CheckLimit(e);
1068 }
1069
_upb_EpsCopyInputStream_IsDoneFallbackInline(upb_EpsCopyInputStream * e,const char * ptr,int overrun,upb_EpsCopyInputStream_BufferFlipCallback * callback)1070 UPB_INLINE const char* _upb_EpsCopyInputStream_IsDoneFallbackInline(
1071 upb_EpsCopyInputStream* e, const char* ptr, int overrun,
1072 upb_EpsCopyInputStream_BufferFlipCallback* callback) {
1073 if (overrun < e->limit) {
1074 // Need to copy remaining data into patch buffer.
1075 UPB_ASSERT(overrun < kUpb_EpsCopyInputStream_SlopBytes);
1076 const char* old_end = ptr;
1077 const char* new_start = &e->patch[0] + overrun;
1078 memset(e->patch + kUpb_EpsCopyInputStream_SlopBytes, 0,
1079 kUpb_EpsCopyInputStream_SlopBytes);
1080 memcpy(e->patch, e->end, kUpb_EpsCopyInputStream_SlopBytes);
1081 ptr = new_start;
1082 e->end = &e->patch[kUpb_EpsCopyInputStream_SlopBytes];
1083 e->limit -= kUpb_EpsCopyInputStream_SlopBytes;
1084 e->limit_ptr = e->end + e->limit;
1085 UPB_ASSERT(ptr < e->limit_ptr);
1086 if (e->aliasing != kUpb_EpsCopyInputStream_NoAliasing) {
1087 e->aliasing = (uintptr_t)old_end - (uintptr_t)new_start;
1088 }
1089 return callback(e, old_end, new_start);
1090 } else {
1091 UPB_ASSERT(overrun > e->limit);
1092 e->error = true;
1093 return callback(e, NULL, NULL);
1094 }
1095 }
1096
1097 typedef const char* upb_EpsCopyInputStream_ParseDelimitedFunc(
1098 upb_EpsCopyInputStream* e, const char* ptr, void* ctx);
1099
1100 // Tries to perform a fast-path handling of the given delimited message data.
1101 // If the sub-message beginning at `*ptr` and extending for `len` is short and
1102 // fits within this buffer, calls `func` with `ctx` as a parameter, where the
1103 // pushing and popping of limits is handled automatically and with lower cost
1104 // than the normal PushLimit()/PopLimit() sequence.
upb_EpsCopyInputStream_TryParseDelimitedFast(upb_EpsCopyInputStream * e,const char ** ptr,int len,upb_EpsCopyInputStream_ParseDelimitedFunc * func,void * ctx)1105 UPB_FORCEINLINE bool upb_EpsCopyInputStream_TryParseDelimitedFast(
1106 upb_EpsCopyInputStream* e, const char** ptr, int len,
1107 upb_EpsCopyInputStream_ParseDelimitedFunc* func, void* ctx) {
1108 if (!upb_EpsCopyInputStream_CheckSubMessageSizeAvailable(e, *ptr, len)) {
1109 return false;
1110 }
1111
1112 // Fast case: Sub-message is <128 bytes and fits in the current buffer.
1113 // This means we can preserve limit/limit_ptr verbatim.
1114 const char* saved_limit_ptr = e->limit_ptr;
1115 int saved_limit = e->limit;
1116 e->limit_ptr = *ptr + len;
1117 e->limit = e->limit_ptr - e->end;
1118 UPB_ASSERT(e->limit_ptr == e->end + UPB_MIN(0, e->limit));
1119 *ptr = func(e, *ptr, ctx);
1120 e->limit_ptr = saved_limit_ptr;
1121 e->limit = saved_limit;
1122 UPB_ASSERT(e->limit_ptr == e->end + UPB_MIN(0, e->limit));
1123 return true;
1124 }
1125
1126 #ifdef __cplusplus
1127 } /* extern "C" */
1128 #endif
1129
1130
1131 #endif // UPB_WIRE_EPS_COPY_INPUT_STREAM_H_
1132
1133 #ifndef UPB_JSON_DECODE_H_
1134 #define UPB_JSON_DECODE_H_
1135
1136 #include <stddef.h>
1137
1138
1139 // Public APIs for message operations that do not depend on the schema.
1140 //
1141 // MiniTable-based accessors live in accessors.h.
1142
1143 #ifndef UPB_MESSAGE_MESSAGE_H_
1144 #define UPB_MESSAGE_MESSAGE_H_
1145
1146 #include <stddef.h>
1147
1148
1149 /*
1150 ** Our memory representation for parsing tables and messages themselves.
1151 ** Functions in this file are used by generated code and possibly reflection.
1152 **
1153 ** The definitions in this file are internal to upb.
1154 **/
1155
1156 #ifndef UPB_MESSAGE_INTERNAL_MESSAGE_H_
1157 #define UPB_MESSAGE_INTERNAL_MESSAGE_H_
1158
1159 #include <stdlib.h>
1160 #include <string.h>
1161
1162
1163 #ifndef UPB_MESSAGE_INTERNAL_EXTENSION_H_
1164 #define UPB_MESSAGE_INTERNAL_EXTENSION_H_
1165
1166 #include <stddef.h>
1167
1168
1169 // Users should include array.h or map.h instead.
1170 // IWYU pragma: private, include "upb/message/array.h"
1171
1172 #ifndef UPB_MESSAGE_VALUE_H_
1173 #define UPB_MESSAGE_VALUE_H_
1174
1175 #include <stdint.h>
1176 #include <string.h>
1177
1178 #ifndef UPB_BASE_STRING_VIEW_H_
1179 #define UPB_BASE_STRING_VIEW_H_
1180
1181 #include <string.h>
1182
1183 // Must be last.
1184
1185 #define UPB_STRINGVIEW_INIT(ptr, len) \
1186 { ptr, len }
1187
1188 #define UPB_STRINGVIEW_FORMAT "%.*s"
1189 #define UPB_STRINGVIEW_ARGS(view) (int)(view).size, (view).data
1190
1191 // LINT.IfChange(struct_definition)
1192 typedef struct {
1193 const char* data;
1194 size_t size;
1195 } upb_StringView;
1196
1197 #ifdef __cplusplus
1198 extern "C" {
1199 #endif
1200
upb_StringView_FromDataAndSize(const char * data,size_t size)1201 UPB_API_INLINE upb_StringView upb_StringView_FromDataAndSize(const char* data,
1202 size_t size) {
1203 upb_StringView ret;
1204 ret.data = data;
1205 ret.size = size;
1206 return ret;
1207 }
1208
upb_StringView_FromString(const char * data)1209 UPB_INLINE upb_StringView upb_StringView_FromString(const char* data) {
1210 return upb_StringView_FromDataAndSize(data, strlen(data));
1211 }
1212
upb_StringView_IsEqual(upb_StringView a,upb_StringView b)1213 UPB_INLINE bool upb_StringView_IsEqual(upb_StringView a, upb_StringView b) {
1214 return (a.size == b.size) && (!a.size || !memcmp(a.data, b.data, a.size));
1215 }
1216
1217 // LINT.ThenChange(
1218 // GoogleInternalName1,
1219 // //depot/google3/third_party/upb/bits/golang/accessor.go:map_go_string,
1220 // //depot/google3/third_party/upb/bits/typescript/string_view.ts
1221 // )
1222
1223 #ifdef __cplusplus
1224 } /* extern "C" */
1225 #endif
1226
1227
1228 #endif /* UPB_BASE_STRING_VIEW_H_ */
1229
1230 // Must be last.
1231
1232 #ifdef __cplusplus
1233 extern "C" {
1234 #endif
1235
1236 typedef union {
1237 bool bool_val;
1238 float float_val;
1239 double double_val;
1240 int32_t int32_val;
1241 int64_t int64_val;
1242 uint32_t uint32_val;
1243 uint64_t uint64_val;
1244 const struct upb_Array* array_val;
1245 const struct upb_Map* map_val;
1246 const struct upb_Message* msg_val;
1247 upb_StringView str_val;
1248
1249 // EXPERIMENTAL: A tagged upb_Message*. Users must use this instead of
1250 // msg_val if unlinked sub-messages may possibly be in use. See the
1251 // documentation in kUpb_DecodeOption_ExperimentalAllowUnlinked for more
1252 // information.
1253 uintptr_t tagged_msg_val; // upb_TaggedMessagePtr
1254 } upb_MessageValue;
1255
upb_MessageValue_Zero(void)1256 UPB_API_INLINE upb_MessageValue upb_MessageValue_Zero(void) {
1257 upb_MessageValue zero;
1258 memset(&zero, 0, sizeof(zero));
1259 return zero;
1260 }
1261
1262 typedef union {
1263 struct upb_Array* array;
1264 struct upb_Map* map;
1265 struct upb_Message* msg;
1266 } upb_MutableMessageValue;
1267
upb_MutableMessageValue_Zero(void)1268 UPB_API_INLINE upb_MutableMessageValue upb_MutableMessageValue_Zero(void) {
1269 upb_MutableMessageValue zero;
1270 memset(&zero, 0, sizeof(zero));
1271 return zero;
1272 }
1273
1274 #ifdef __cplusplus
1275 } /* extern "C" */
1276 #endif
1277
1278
1279 #endif /* UPB_MESSAGE_VALUE_H_ */
1280
1281 #ifndef UPB_MINI_TABLE_EXTENSION_H_
1282 #define UPB_MINI_TABLE_EXTENSION_H_
1283
1284 #include <stdint.h>
1285
1286
1287 #ifndef UPB_BASE_DESCRIPTOR_CONSTANTS_H_
1288 #define UPB_BASE_DESCRIPTOR_CONSTANTS_H_
1289
1290 // Must be last.
1291
1292 // The types a field can have. Note that this list is not identical to the
1293 // types defined in descriptor.proto, which gives INT32 and SINT32 separate
1294 // types (we distinguish the two with the "integer encoding" enum below).
1295 // This enum is an internal convenience only and has no meaning outside of upb.
1296 typedef enum {
1297 kUpb_CType_Bool = 1,
1298 kUpb_CType_Float = 2,
1299 kUpb_CType_Int32 = 3,
1300 kUpb_CType_UInt32 = 4,
1301 kUpb_CType_Enum = 5, // Enum values are int32. TODO: rename
1302 kUpb_CType_Message = 6,
1303 kUpb_CType_Double = 7,
1304 kUpb_CType_Int64 = 8,
1305 kUpb_CType_UInt64 = 9,
1306 kUpb_CType_String = 10,
1307 kUpb_CType_Bytes = 11
1308 } upb_CType;
1309
1310 // The repeated-ness of each field; this matches descriptor.proto.
1311 typedef enum {
1312 kUpb_Label_Optional = 1,
1313 kUpb_Label_Required = 2,
1314 kUpb_Label_Repeated = 3
1315 } upb_Label;
1316
1317 // Descriptor types, as defined in descriptor.proto.
1318 typedef enum {
1319 kUpb_FieldType_Double = 1,
1320 kUpb_FieldType_Float = 2,
1321 kUpb_FieldType_Int64 = 3,
1322 kUpb_FieldType_UInt64 = 4,
1323 kUpb_FieldType_Int32 = 5,
1324 kUpb_FieldType_Fixed64 = 6,
1325 kUpb_FieldType_Fixed32 = 7,
1326 kUpb_FieldType_Bool = 8,
1327 kUpb_FieldType_String = 9,
1328 kUpb_FieldType_Group = 10,
1329 kUpb_FieldType_Message = 11,
1330 kUpb_FieldType_Bytes = 12,
1331 kUpb_FieldType_UInt32 = 13,
1332 kUpb_FieldType_Enum = 14,
1333 kUpb_FieldType_SFixed32 = 15,
1334 kUpb_FieldType_SFixed64 = 16,
1335 kUpb_FieldType_SInt32 = 17,
1336 kUpb_FieldType_SInt64 = 18,
1337 } upb_FieldType;
1338
1339 #define kUpb_FieldType_SizeOf 19
1340
1341 #ifdef __cplusplus
1342 extern "C" {
1343 #endif
1344
1345 // Convert from upb_FieldType to upb_CType
upb_FieldType_CType(upb_FieldType field_type)1346 UPB_INLINE upb_CType upb_FieldType_CType(upb_FieldType field_type) {
1347 static const upb_CType c_type[] = {
1348 kUpb_CType_Double, // kUpb_FieldType_Double
1349 kUpb_CType_Float, // kUpb_FieldType_Float
1350 kUpb_CType_Int64, // kUpb_FieldType_Int64
1351 kUpb_CType_UInt64, // kUpb_FieldType_UInt64
1352 kUpb_CType_Int32, // kUpb_FieldType_Int32
1353 kUpb_CType_UInt64, // kUpb_FieldType_Fixed64
1354 kUpb_CType_UInt32, // kUpb_FieldType_Fixed32
1355 kUpb_CType_Bool, // kUpb_FieldType_Bool
1356 kUpb_CType_String, // kUpb_FieldType_String
1357 kUpb_CType_Message, // kUpb_FieldType_Group
1358 kUpb_CType_Message, // kUpb_FieldType_Message
1359 kUpb_CType_Bytes, // kUpb_FieldType_Bytes
1360 kUpb_CType_UInt32, // kUpb_FieldType_UInt32
1361 kUpb_CType_Enum, // kUpb_FieldType_Enum
1362 kUpb_CType_Int32, // kUpb_FieldType_SFixed32
1363 kUpb_CType_Int64, // kUpb_FieldType_SFixed64
1364 kUpb_CType_Int32, // kUpb_FieldType_SInt32
1365 kUpb_CType_Int64, // kUpb_FieldType_SInt64
1366 };
1367
1368 // -1 here because the enum is one-based but the table is zero-based.
1369 return c_type[field_type - 1];
1370 }
1371
upb_FieldType_IsPackable(upb_FieldType field_type)1372 UPB_INLINE bool upb_FieldType_IsPackable(upb_FieldType field_type) {
1373 // clang-format off
1374 const unsigned kUnpackableTypes =
1375 (1 << kUpb_FieldType_String) |
1376 (1 << kUpb_FieldType_Bytes) |
1377 (1 << kUpb_FieldType_Message) |
1378 (1 << kUpb_FieldType_Group);
1379 // clang-format on
1380 return (1 << field_type) & ~kUnpackableTypes;
1381 }
1382
1383 #ifdef __cplusplus
1384 } /* extern "C" */
1385 #endif
1386
1387
1388 #endif /* UPB_BASE_DESCRIPTOR_CONSTANTS_H_ */
1389
1390 #ifndef UPB_MINI_TABLE_INTERNAL_EXTENSION_H_
1391 #define UPB_MINI_TABLE_INTERNAL_EXTENSION_H_
1392
1393 #include <stddef.h>
1394 #include <stdint.h>
1395
1396
1397 #ifndef UPB_MINI_TABLE_INTERNAL_FIELD_H_
1398 #define UPB_MINI_TABLE_INTERNAL_FIELD_H_
1399
1400 #include <stddef.h>
1401 #include <stdint.h>
1402
1403
1404 #ifndef UPB_MINI_TABLE_INTERNAL_SIZE_LOG2_H_
1405 #define UPB_MINI_TABLE_INTERNAL_SIZE_LOG2_H_
1406
1407 #include <stddef.h>
1408 #include <stdint.h>
1409
1410
1411 // Must be last.
1412
1413 #ifdef __cplusplus
1414 extern "C" {
1415 #endif
1416
1417 // Return the log2 of the storage size in bytes for a upb_CType
UPB_PRIVATE(_upb_CType_SizeLg2)1418 UPB_INLINE int UPB_PRIVATE(_upb_CType_SizeLg2)(upb_CType c_type) {
1419 static const int8_t size[] = {
1420 0, // kUpb_CType_Bool
1421 2, // kUpb_CType_Float
1422 2, // kUpb_CType_Int32
1423 2, // kUpb_CType_UInt32
1424 2, // kUpb_CType_Enum
1425 UPB_SIZE(2, 3), // kUpb_CType_Message
1426 3, // kUpb_CType_Double
1427 3, // kUpb_CType_Int64
1428 3, // kUpb_CType_UInt64
1429 UPB_SIZE(3, 4), // kUpb_CType_String
1430 UPB_SIZE(3, 4), // kUpb_CType_Bytes
1431 };
1432
1433 // -1 here because the enum is one-based but the table is zero-based.
1434 return size[c_type - 1];
1435 }
1436
1437 // Return the log2 of the storage size in bytes for a upb_FieldType
UPB_PRIVATE(_upb_FieldType_SizeLg2)1438 UPB_INLINE int UPB_PRIVATE(_upb_FieldType_SizeLg2)(upb_FieldType field_type) {
1439 static const int8_t size[] = {
1440 3, // kUpb_FieldType_Double
1441 2, // kUpb_FieldType_Float
1442 3, // kUpb_FieldType_Int64
1443 3, // kUpb_FieldType_UInt64
1444 2, // kUpb_FieldType_Int32
1445 3, // kUpb_FieldType_Fixed64
1446 2, // kUpb_FieldType_Fixed32
1447 0, // kUpb_FieldType_Bool
1448 UPB_SIZE(3, 4), // kUpb_FieldType_String
1449 UPB_SIZE(2, 3), // kUpb_FieldType_Group
1450 UPB_SIZE(2, 3), // kUpb_FieldType_Message
1451 UPB_SIZE(3, 4), // kUpb_FieldType_Bytes
1452 2, // kUpb_FieldType_UInt32
1453 2, // kUpb_FieldType_Enum
1454 2, // kUpb_FieldType_SFixed32
1455 3, // kUpb_FieldType_SFixed64
1456 2, // kUpb_FieldType_SInt32
1457 3, // kUpb_FieldType_SInt64
1458 };
1459
1460 // -1 here because the enum is one-based but the table is zero-based.
1461 return size[field_type - 1];
1462 }
1463
1464 #ifdef __cplusplus
1465 } /* extern "C" */
1466 #endif
1467
1468
1469 #endif /* UPB_MINI_TABLE_INTERNAL_SIZE_LOG2_H_ */
1470
1471 // Must be last.
1472
1473 // LINT.IfChange(struct_definition)
1474 struct upb_MiniTableField {
1475 uint32_t UPB_ONLYBITS(number);
1476 uint16_t UPB_ONLYBITS(offset);
1477 int16_t presence; // If >0, hasbit_index. If <0, ~oneof_index
1478
1479 // Indexes into `upb_MiniTable.subs`
1480 // Will be set to `kUpb_NoSub` if `descriptortype` != MESSAGE/GROUP/ENUM
1481 uint16_t UPB_PRIVATE(submsg_index);
1482
1483 uint8_t UPB_PRIVATE(descriptortype);
1484
1485 // upb_FieldMode | upb_LabelFlags | (upb_FieldRep << kUpb_FieldRep_Shift)
1486 uint8_t UPB_ONLYBITS(mode);
1487 };
1488
1489 #define kUpb_NoSub ((uint16_t) - 1)
1490
1491 typedef enum {
1492 kUpb_FieldMode_Map = 0,
1493 kUpb_FieldMode_Array = 1,
1494 kUpb_FieldMode_Scalar = 2,
1495 } upb_FieldMode;
1496
1497 // Mask to isolate the upb_FieldMode from field.mode.
1498 #define kUpb_FieldMode_Mask 3
1499
1500 // Extra flags on the mode field.
1501 typedef enum {
1502 kUpb_LabelFlags_IsPacked = 4,
1503 kUpb_LabelFlags_IsExtension = 8,
1504 // Indicates that this descriptor type is an "alternate type":
1505 // - for Int32, this indicates that the actual type is Enum (but was
1506 // rewritten to Int32 because it is an open enum that requires no check).
1507 // - for Bytes, this indicates that the actual type is String (but does
1508 // not require any UTF-8 check).
1509 kUpb_LabelFlags_IsAlternate = 16,
1510 } upb_LabelFlags;
1511
1512 // Note: we sort by this number when calculating layout order.
1513 typedef enum {
1514 kUpb_FieldRep_1Byte = 0,
1515 kUpb_FieldRep_4Byte = 1,
1516 kUpb_FieldRep_StringView = 2,
1517 kUpb_FieldRep_8Byte = 3,
1518
1519 kUpb_FieldRep_NativePointer =
1520 UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte),
1521 kUpb_FieldRep_Max = kUpb_FieldRep_8Byte,
1522 } upb_FieldRep;
1523
1524 #define kUpb_FieldRep_Shift 6
1525
1526 #ifdef __cplusplus
1527 extern "C" {
1528 #endif
1529
1530 UPB_INLINE upb_FieldMode
UPB_PRIVATE(_upb_MiniTableField_Mode)1531 UPB_PRIVATE(_upb_MiniTableField_Mode)(const struct upb_MiniTableField* f) {
1532 return (upb_FieldMode)(f->UPB_ONLYBITS(mode) & kUpb_FieldMode_Mask);
1533 }
1534
1535 UPB_INLINE upb_FieldRep
UPB_PRIVATE(_upb_MiniTableField_GetRep)1536 UPB_PRIVATE(_upb_MiniTableField_GetRep)(const struct upb_MiniTableField* f) {
1537 return (upb_FieldRep)(f->UPB_ONLYBITS(mode) >> kUpb_FieldRep_Shift);
1538 }
1539
upb_MiniTableField_IsArray(const struct upb_MiniTableField * f)1540 UPB_API_INLINE bool upb_MiniTableField_IsArray(
1541 const struct upb_MiniTableField* f) {
1542 return UPB_PRIVATE(_upb_MiniTableField_Mode)(f) == kUpb_FieldMode_Array;
1543 }
1544
upb_MiniTableField_IsMap(const struct upb_MiniTableField * f)1545 UPB_API_INLINE bool upb_MiniTableField_IsMap(
1546 const struct upb_MiniTableField* f) {
1547 return UPB_PRIVATE(_upb_MiniTableField_Mode)(f) == kUpb_FieldMode_Map;
1548 }
1549
upb_MiniTableField_IsScalar(const struct upb_MiniTableField * f)1550 UPB_API_INLINE bool upb_MiniTableField_IsScalar(
1551 const struct upb_MiniTableField* f) {
1552 return UPB_PRIVATE(_upb_MiniTableField_Mode)(f) == kUpb_FieldMode_Scalar;
1553 }
1554
UPB_PRIVATE(_upb_MiniTableField_IsAlternate)1555 UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_IsAlternate)(
1556 const struct upb_MiniTableField* f) {
1557 return (f->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsAlternate) != 0;
1558 }
1559
upb_MiniTableField_IsExtension(const struct upb_MiniTableField * f)1560 UPB_API_INLINE bool upb_MiniTableField_IsExtension(
1561 const struct upb_MiniTableField* f) {
1562 return (f->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsExtension) != 0;
1563 }
1564
upb_MiniTableField_IsPacked(const struct upb_MiniTableField * f)1565 UPB_API_INLINE bool upb_MiniTableField_IsPacked(
1566 const struct upb_MiniTableField* f) {
1567 return (f->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsPacked) != 0;
1568 }
1569
1570 UPB_API_INLINE upb_FieldType
upb_MiniTableField_Type(const struct upb_MiniTableField * f)1571 upb_MiniTableField_Type(const struct upb_MiniTableField* f) {
1572 const upb_FieldType type = (upb_FieldType)f->UPB_PRIVATE(descriptortype);
1573 if (UPB_PRIVATE(_upb_MiniTableField_IsAlternate)(f)) {
1574 if (type == kUpb_FieldType_Int32) return kUpb_FieldType_Enum;
1575 if (type == kUpb_FieldType_Bytes) return kUpb_FieldType_String;
1576 UPB_ASSERT(false);
1577 }
1578 return type;
1579 }
1580
1581 UPB_API_INLINE
upb_MiniTableField_CType(const struct upb_MiniTableField * f)1582 upb_CType upb_MiniTableField_CType(const struct upb_MiniTableField* f) {
1583 return upb_FieldType_CType(upb_MiniTableField_Type(f));
1584 }
1585
UPB_PRIVATE(_upb_MiniTableField_HasHasbit)1586 UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(
1587 const struct upb_MiniTableField* f) {
1588 return f->presence > 0;
1589 }
1590
UPB_PRIVATE(_upb_MiniTableField_HasbitMask)1591 UPB_INLINE char UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(
1592 const struct upb_MiniTableField* f) {
1593 UPB_ASSERT(UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f));
1594 const size_t index = f->presence;
1595 return 1 << (index % 8);
1596 }
1597
UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)1598 UPB_INLINE size_t UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(
1599 const struct upb_MiniTableField* f) {
1600 UPB_ASSERT(UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f));
1601 const size_t index = f->presence;
1602 return index / 8;
1603 }
1604
upb_MiniTableField_IsClosedEnum(const struct upb_MiniTableField * f)1605 UPB_API_INLINE bool upb_MiniTableField_IsClosedEnum(
1606 const struct upb_MiniTableField* f) {
1607 return f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Enum;
1608 }
1609
upb_MiniTableField_IsInOneof(const struct upb_MiniTableField * f)1610 UPB_API_INLINE bool upb_MiniTableField_IsInOneof(
1611 const struct upb_MiniTableField* f) {
1612 return f->presence < 0;
1613 }
1614
upb_MiniTableField_IsSubMessage(const struct upb_MiniTableField * f)1615 UPB_API_INLINE bool upb_MiniTableField_IsSubMessage(
1616 const struct upb_MiniTableField* f) {
1617 return f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Message ||
1618 f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Group;
1619 }
1620
upb_MiniTableField_HasPresence(const struct upb_MiniTableField * f)1621 UPB_API_INLINE bool upb_MiniTableField_HasPresence(
1622 const struct upb_MiniTableField* f) {
1623 if (upb_MiniTableField_IsExtension(f)) {
1624 return upb_MiniTableField_IsScalar(f);
1625 } else {
1626 return f->presence != 0;
1627 }
1628 }
1629
1630 UPB_API_INLINE uint32_t
upb_MiniTableField_Number(const struct upb_MiniTableField * f)1631 upb_MiniTableField_Number(const struct upb_MiniTableField* f) {
1632 return f->UPB_ONLYBITS(number);
1633 }
1634
1635 UPB_INLINE uint16_t
UPB_PRIVATE(_upb_MiniTableField_Offset)1636 UPB_PRIVATE(_upb_MiniTableField_Offset)(const struct upb_MiniTableField* f) {
1637 return f->UPB_ONLYBITS(offset);
1638 }
1639
UPB_PRIVATE(_upb_MiniTableField_OneofOffset)1640 UPB_INLINE size_t UPB_PRIVATE(_upb_MiniTableField_OneofOffset)(
1641 const struct upb_MiniTableField* f) {
1642 UPB_ASSERT(upb_MiniTableField_IsInOneof(f));
1643 return ~(ptrdiff_t)f->presence;
1644 }
1645
UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)1646 UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(
1647 const struct upb_MiniTableField* f) {
1648 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
1649 kUpb_FieldRep_NativePointer);
1650 UPB_ASSUME(upb_MiniTableField_IsArray(f));
1651 UPB_ASSUME(f->presence == 0);
1652 }
1653
UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)1654 UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(
1655 const struct upb_MiniTableField* f) {
1656 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
1657 kUpb_FieldRep_NativePointer);
1658 UPB_ASSUME(upb_MiniTableField_IsMap(f));
1659 UPB_ASSUME(f->presence == 0);
1660 }
1661
UPB_PRIVATE(_upb_MiniTableField_ElemSizeLg2)1662 UPB_INLINE size_t UPB_PRIVATE(_upb_MiniTableField_ElemSizeLg2)(
1663 const struct upb_MiniTableField* f) {
1664 const upb_FieldType field_type = upb_MiniTableField_Type(f);
1665 return UPB_PRIVATE(_upb_FieldType_SizeLg2)(field_type);
1666 }
1667
1668 // LINT.ThenChange(//depot/google3/third_party/upb/bits/typescript/mini_table_field.ts)
1669
1670 #ifdef __cplusplus
1671 } /* extern "C" */
1672 #endif
1673
1674
1675 #endif /* UPB_MINI_TABLE_INTERNAL_FIELD_H_ */
1676
1677 #ifndef UPB_MINI_TABLE_INTERNAL_SUB_H_
1678 #define UPB_MINI_TABLE_INTERNAL_SUB_H_
1679
1680 // Must be last.
1681
1682 typedef union {
1683 const struct upb_MiniTable* const* UPB_PRIVATE(submsg);
1684 const struct upb_MiniTableEnum* UPB_PRIVATE(subenum);
1685 } upb_MiniTableSubInternal;
1686
1687 union upb_MiniTableSub {
1688 const struct upb_MiniTable* UPB_PRIVATE(submsg);
1689 const struct upb_MiniTableEnum* UPB_PRIVATE(subenum);
1690 };
1691
1692 #ifdef __cplusplus
1693 extern "C" {
1694 #endif
1695
upb_MiniTableSub_FromEnum(const struct upb_MiniTableEnum * subenum)1696 UPB_API_INLINE union upb_MiniTableSub upb_MiniTableSub_FromEnum(
1697 const struct upb_MiniTableEnum* subenum) {
1698 union upb_MiniTableSub out;
1699 out.UPB_PRIVATE(subenum) = subenum;
1700 return out;
1701 }
1702
upb_MiniTableSub_FromMessage(const struct upb_MiniTable * submsg)1703 UPB_API_INLINE union upb_MiniTableSub upb_MiniTableSub_FromMessage(
1704 const struct upb_MiniTable* submsg) {
1705 union upb_MiniTableSub out;
1706 out.UPB_PRIVATE(submsg) = submsg;
1707 return out;
1708 }
1709
upb_MiniTableSub_Enum(const union upb_MiniTableSub sub)1710 UPB_API_INLINE const struct upb_MiniTableEnum* upb_MiniTableSub_Enum(
1711 const union upb_MiniTableSub sub) {
1712 return sub.UPB_PRIVATE(subenum);
1713 }
1714
upb_MiniTableSub_Message(const union upb_MiniTableSub sub)1715 UPB_API_INLINE const struct upb_MiniTable* upb_MiniTableSub_Message(
1716 const union upb_MiniTableSub sub) {
1717 return sub.UPB_PRIVATE(submsg);
1718 }
1719
1720 #ifdef __cplusplus
1721 } /* extern "C" */
1722 #endif
1723
1724
1725 #endif /* UPB_MINI_TABLE_INTERNAL_SUB_H_ */
1726
1727 // Must be last.
1728
1729 struct upb_MiniTableExtension {
1730 // Do not move this field. We need to be able to alias pointers.
1731 struct upb_MiniTableField UPB_PRIVATE(field);
1732
1733 const struct upb_MiniTable* UPB_PRIVATE(extendee);
1734 union upb_MiniTableSub UPB_PRIVATE(sub); // NULL unless submsg or proto2 enum
1735 };
1736
1737 #ifdef __cplusplus
1738 extern "C" {
1739 #endif
1740
1741 UPB_API_INLINE upb_CType
upb_MiniTableExtension_CType(const struct upb_MiniTableExtension * e)1742 upb_MiniTableExtension_CType(const struct upb_MiniTableExtension* e) {
1743 return upb_MiniTableField_CType(&e->UPB_PRIVATE(field));
1744 }
1745
1746 UPB_API_INLINE uint32_t
upb_MiniTableExtension_Number(const struct upb_MiniTableExtension * e)1747 upb_MiniTableExtension_Number(const struct upb_MiniTableExtension* e) {
1748 return e->UPB_PRIVATE(field).UPB_ONLYBITS(number);
1749 }
1750
upb_MiniTableExtension_GetSubMessage(const struct upb_MiniTableExtension * e)1751 UPB_API_INLINE const struct upb_MiniTable* upb_MiniTableExtension_GetSubMessage(
1752 const struct upb_MiniTableExtension* e) {
1753 if (upb_MiniTableExtension_CType(e) != kUpb_CType_Message) {
1754 return NULL;
1755 }
1756 return upb_MiniTableSub_Message(e->UPB_PRIVATE(sub));
1757 }
1758
upb_MiniTableExtension_SetSubMessage(struct upb_MiniTableExtension * e,const struct upb_MiniTable * m)1759 UPB_API_INLINE void upb_MiniTableExtension_SetSubMessage(
1760 struct upb_MiniTableExtension* e, const struct upb_MiniTable* m) {
1761 e->UPB_PRIVATE(sub).UPB_PRIVATE(submsg) = m;
1762 }
1763
UPB_PRIVATE(_upb_MiniTableExtension_GetRep)1764 UPB_INLINE upb_FieldRep UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(
1765 const struct upb_MiniTableExtension* e) {
1766 return UPB_PRIVATE(_upb_MiniTableField_GetRep)(&e->UPB_PRIVATE(field));
1767 }
1768
1769 #ifdef __cplusplus
1770 } /* extern "C" */
1771 #endif
1772
1773
1774 #endif /* UPB_MINI_TABLE_INTERNAL_EXTENSION_H_ */
1775
1776 #ifndef UPB_MINI_TABLE_MESSAGE_H_
1777 #define UPB_MINI_TABLE_MESSAGE_H_
1778
1779
1780 #ifndef UPB_MINI_TABLE_ENUM_H_
1781 #define UPB_MINI_TABLE_ENUM_H_
1782
1783 #include <stdint.h>
1784
1785
1786 #ifndef UPB_MINI_TABLE_INTERNAL_ENUM_H_
1787 #define UPB_MINI_TABLE_INTERNAL_ENUM_H_
1788
1789 #include <stdint.h>
1790
1791 // Must be last.
1792
1793 struct upb_MiniTableEnum {
1794 uint32_t UPB_PRIVATE(mask_limit); // Highest that can be tested with mask.
1795 uint32_t UPB_PRIVATE(value_count); // Number of values after the bitfield.
1796 uint32_t UPB_PRIVATE(data)[]; // Bitmask + enumerated values follow.
1797 };
1798
1799 #ifdef __cplusplus
1800 extern "C" {
1801 #endif
1802
upb_MiniTableEnum_CheckValue(const struct upb_MiniTableEnum * e,uint32_t val)1803 UPB_API_INLINE bool upb_MiniTableEnum_CheckValue(
1804 const struct upb_MiniTableEnum* e, uint32_t val) {
1805 if (UPB_LIKELY(val < 64)) {
1806 const uint64_t mask =
1807 e->UPB_PRIVATE(data)[0] | ((uint64_t)e->UPB_PRIVATE(data)[1] << 32);
1808 const uint64_t bit = 1ULL << val;
1809 return (mask & bit) != 0;
1810 }
1811 if (UPB_LIKELY(val < e->UPB_PRIVATE(mask_limit))) {
1812 const uint32_t mask = e->UPB_PRIVATE(data)[val / 32];
1813 const uint32_t bit = 1ULL << (val % 32);
1814 return (mask & bit) != 0;
1815 }
1816
1817 // OPT: binary search long lists?
1818 const uint32_t* start =
1819 &e->UPB_PRIVATE(data)[e->UPB_PRIVATE(mask_limit) / 32];
1820 const uint32_t* limit = &e->UPB_PRIVATE(
1821 data)[e->UPB_PRIVATE(mask_limit) / 32 + e->UPB_PRIVATE(value_count)];
1822 for (const uint32_t* p = start; p < limit; p++) {
1823 if (*p == val) return true;
1824 }
1825 return false;
1826 }
1827
1828 #ifdef __cplusplus
1829 } /* extern "C" */
1830 #endif
1831
1832
1833 #endif /* UPB_MINI_TABLE_INTERNAL_ENUM_H_ */
1834
1835 // Must be last
1836
1837 typedef struct upb_MiniTableEnum upb_MiniTableEnum;
1838
1839 #ifdef __cplusplus
1840 extern "C" {
1841 #endif
1842
1843 // Validates enum value against range defined by enum mini table.
1844 UPB_API_INLINE bool upb_MiniTableEnum_CheckValue(const upb_MiniTableEnum* e,
1845 uint32_t val);
1846
1847 #ifdef __cplusplus
1848 } /* extern "C" */
1849 #endif
1850
1851
1852 #endif /* UPB_MINI_TABLE_ENUM_H_ */
1853
1854 #ifndef UPB_MINI_TABLE_FIELD_H_
1855 #define UPB_MINI_TABLE_FIELD_H_
1856
1857 #include <stdint.h>
1858
1859
1860 // Must be last.
1861
1862 typedef struct upb_MiniTableField upb_MiniTableField;
1863
1864 #ifdef __cplusplus
1865 extern "C" {
1866 #endif
1867
1868 UPB_API_INLINE upb_CType upb_MiniTableField_CType(const upb_MiniTableField* f);
1869
1870 UPB_API_INLINE bool upb_MiniTableField_HasPresence(const upb_MiniTableField* f);
1871
1872 UPB_API_INLINE bool upb_MiniTableField_IsArray(const upb_MiniTableField* f);
1873
1874 UPB_API_INLINE bool upb_MiniTableField_IsClosedEnum(
1875 const upb_MiniTableField* f);
1876
1877 UPB_API_INLINE bool upb_MiniTableField_IsExtension(const upb_MiniTableField* f);
1878
1879 UPB_API_INLINE bool upb_MiniTableField_IsInOneof(const upb_MiniTableField* f);
1880
1881 UPB_API_INLINE bool upb_MiniTableField_IsMap(const upb_MiniTableField* f);
1882
1883 UPB_API_INLINE bool upb_MiniTableField_IsPacked(const upb_MiniTableField* f);
1884
1885 UPB_API_INLINE bool upb_MiniTableField_IsScalar(const upb_MiniTableField* f);
1886
1887 UPB_API_INLINE bool upb_MiniTableField_IsSubMessage(
1888 const upb_MiniTableField* f);
1889
1890 UPB_API_INLINE uint32_t upb_MiniTableField_Number(const upb_MiniTableField* f);
1891
1892 UPB_API_INLINE upb_FieldType
1893 upb_MiniTableField_Type(const upb_MiniTableField* f);
1894
1895 #ifdef __cplusplus
1896 } /* extern "C" */
1897 #endif
1898
1899
1900 #endif /* UPB_MINI_TABLE_FIELD_H_ */
1901
1902 #ifndef UPB_MINI_TABLE_INTERNAL_MESSAGE_H_
1903 #define UPB_MINI_TABLE_INTERNAL_MESSAGE_H_
1904
1905 #include <stddef.h>
1906 #include <stdint.h>
1907
1908
1909 // Must be last.
1910
1911 struct upb_Decoder;
1912 struct upb_Message;
1913 typedef const char* _upb_FieldParser(struct upb_Decoder* d, const char* ptr,
1914 struct upb_Message* msg, intptr_t table,
1915 uint64_t hasbits, uint64_t data);
1916 typedef struct {
1917 uint64_t field_data;
1918 _upb_FieldParser* field_parser;
1919 } _upb_FastTable_Entry;
1920
1921 typedef enum {
1922 kUpb_ExtMode_NonExtendable = 0, // Non-extendable message.
1923 kUpb_ExtMode_Extendable = 1, // Normal extendable message.
1924 kUpb_ExtMode_IsMessageSet = 2, // MessageSet message.
1925 kUpb_ExtMode_IsMessageSet_ITEM =
1926 3, // MessageSet item (temporary only, see decode.c)
1927
1928 // During table building we steal a bit to indicate that the message is a map
1929 // entry. *Only* used during table building!
1930 kUpb_ExtMode_IsMapEntry = 4,
1931 } upb_ExtMode;
1932
1933 // upb_MiniTable represents the memory layout of a given upb_MessageDef.
1934 // The members are public so generated code can initialize them,
1935 // but users MUST NOT directly read or write any of its members.
1936
1937 // LINT.IfChange(minitable_struct_definition)
1938 struct upb_MiniTable {
1939 const upb_MiniTableSubInternal* UPB_PRIVATE(subs);
1940 const struct upb_MiniTableField* UPB_ONLYBITS(fields);
1941
1942 // Must be aligned to sizeof(void*). Doesn't include internal members like
1943 // unknown fields, extension dict, pointer to msglayout, etc.
1944 uint16_t UPB_PRIVATE(size);
1945
1946 uint16_t UPB_ONLYBITS(field_count);
1947
1948 uint8_t UPB_PRIVATE(ext); // upb_ExtMode, uint8_t here so sizeof(ext) == 1
1949 uint8_t UPB_PRIVATE(dense_below);
1950 uint8_t UPB_PRIVATE(table_mask);
1951 uint8_t UPB_PRIVATE(required_count); // Required fields have the low hasbits.
1952
1953 #ifdef UPB_TRACING_ENABLED
1954 const char* UPB_PRIVATE(full_name);
1955 #endif
1956
1957 #ifdef UPB_FASTTABLE_ENABLED
1958 // To statically initialize the tables of variable length, we need a flexible
1959 // array member, and we need to compile in gnu99 mode (constant initialization
1960 // of flexible array members is a GNU extension, not in C99 unfortunately.
1961 _upb_FastTable_Entry UPB_PRIVATE(fasttable)[];
1962 #endif
1963 };
1964 // LINT.ThenChange(//depot/google3/third_party/upb/bits/typescript/mini_table.ts)
1965
1966 #ifdef __cplusplus
1967 extern "C" {
1968 #endif
1969
UPB_PRIVATE(_upb_MiniTable_StrongReference)1970 UPB_INLINE const struct upb_MiniTable* UPB_PRIVATE(
1971 _upb_MiniTable_StrongReference)(const struct upb_MiniTable* mt) {
1972 #if defined(__GNUC__)
1973 __asm__("" : : "r"(mt));
1974 #else
1975 const struct upb_MiniTable* volatile unused = mt;
1976 (void)&unused; // Use address to avoid an extra load of "unused".
1977 #endif
1978 return mt;
1979 }
1980
UPB_PRIVATE(_upb_MiniTable_Empty)1981 UPB_INLINE const struct upb_MiniTable* UPB_PRIVATE(_upb_MiniTable_Empty)(void) {
1982 extern const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_Empty);
1983
1984 return &UPB_PRIVATE(_kUpb_MiniTable_Empty);
1985 }
1986
upb_MiniTable_FieldCount(const struct upb_MiniTable * m)1987 UPB_API_INLINE int upb_MiniTable_FieldCount(const struct upb_MiniTable* m) {
1988 return m->UPB_ONLYBITS(field_count);
1989 }
1990
UPB_PRIVATE(_upb_MiniTable_IsEmpty)1991 UPB_INLINE bool UPB_PRIVATE(_upb_MiniTable_IsEmpty)(
1992 const struct upb_MiniTable* m) {
1993 extern const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_Empty);
1994
1995 return m == &UPB_PRIVATE(_kUpb_MiniTable_Empty);
1996 }
1997
upb_MiniTable_GetFieldByIndex(const struct upb_MiniTable * m,uint32_t i)1998 UPB_API_INLINE const struct upb_MiniTableField* upb_MiniTable_GetFieldByIndex(
1999 const struct upb_MiniTable* m, uint32_t i) {
2000 return &m->UPB_ONLYBITS(fields)[i];
2001 }
2002
UPB_PRIVATE(_upb_MiniTable_GetSubTableByIndex)2003 UPB_INLINE const struct upb_MiniTable* UPB_PRIVATE(
2004 _upb_MiniTable_GetSubTableByIndex)(const struct upb_MiniTable* m,
2005 uint32_t i) {
2006 return *m->UPB_PRIVATE(subs)[i].UPB_PRIVATE(submsg);
2007 }
2008
upb_MiniTable_SubMessage(const struct upb_MiniTable * m,const struct upb_MiniTableField * f)2009 UPB_API_INLINE const struct upb_MiniTable* upb_MiniTable_SubMessage(
2010 const struct upb_MiniTable* m, const struct upb_MiniTableField* f) {
2011 if (upb_MiniTableField_CType(f) != kUpb_CType_Message) {
2012 return NULL;
2013 }
2014 return UPB_PRIVATE(_upb_MiniTable_GetSubTableByIndex)(
2015 m, f->UPB_PRIVATE(submsg_index));
2016 }
2017
upb_MiniTable_GetSubMessageTable(const struct upb_MiniTable * m,const struct upb_MiniTableField * f)2018 UPB_API_INLINE const struct upb_MiniTable* upb_MiniTable_GetSubMessageTable(
2019 const struct upb_MiniTable* m, const struct upb_MiniTableField* f) {
2020 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
2021 const struct upb_MiniTable* ret = upb_MiniTable_SubMessage(m, f);
2022 UPB_ASSUME(ret);
2023 return UPB_PRIVATE(_upb_MiniTable_IsEmpty)(ret) ? NULL : ret;
2024 }
2025
upb_MiniTable_FieldIsLinked(const struct upb_MiniTable * m,const struct upb_MiniTableField * f)2026 UPB_API_INLINE bool upb_MiniTable_FieldIsLinked(
2027 const struct upb_MiniTable* m, const struct upb_MiniTableField* f) {
2028 return upb_MiniTable_GetSubMessageTable(m, f) != NULL;
2029 }
2030
upb_MiniTable_MapEntrySubMessage(const struct upb_MiniTable * m,const struct upb_MiniTableField * f)2031 UPB_API_INLINE const struct upb_MiniTable* upb_MiniTable_MapEntrySubMessage(
2032 const struct upb_MiniTable* m, const struct upb_MiniTableField* f) {
2033 UPB_ASSERT(upb_MiniTable_FieldIsLinked(m, f)); // Map entries must be linked.
2034 UPB_ASSERT(upb_MiniTableField_IsMap(f)); // Function precondition.
2035 return upb_MiniTable_SubMessage(m, f);
2036 }
2037
upb_MiniTable_GetSubEnumTable(const struct upb_MiniTable * m,const struct upb_MiniTableField * f)2038 UPB_API_INLINE const struct upb_MiniTableEnum* upb_MiniTable_GetSubEnumTable(
2039 const struct upb_MiniTable* m, const struct upb_MiniTableField* f) {
2040 UPB_ASSERT(upb_MiniTableField_CType(f) == kUpb_CType_Enum);
2041 return m->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)].UPB_PRIVATE(
2042 subenum);
2043 }
2044
upb_MiniTable_MapKey(const struct upb_MiniTable * m)2045 UPB_API_INLINE const struct upb_MiniTableField* upb_MiniTable_MapKey(
2046 const struct upb_MiniTable* m) {
2047 UPB_ASSERT(upb_MiniTable_FieldCount(m) == 2);
2048 const struct upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, 0);
2049 UPB_ASSERT(upb_MiniTableField_Number(f) == 1);
2050 return f;
2051 }
2052
upb_MiniTable_MapValue(const struct upb_MiniTable * m)2053 UPB_API_INLINE const struct upb_MiniTableField* upb_MiniTable_MapValue(
2054 const struct upb_MiniTable* m) {
2055 UPB_ASSERT(upb_MiniTable_FieldCount(m) == 2);
2056 const struct upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, 1);
2057 UPB_ASSERT(upb_MiniTableField_Number(f) == 2);
2058 return f;
2059 }
2060
2061 // Computes a bitmask in which the |m->required_count| lowest bits are set.
2062 //
2063 // Sample output:
2064 // RequiredMask(1) => 0b1 (0x1)
2065 // RequiredMask(5) => 0b11111 (0x1f)
2066 UPB_INLINE uint64_t
UPB_PRIVATE(_upb_MiniTable_RequiredMask)2067 UPB_PRIVATE(_upb_MiniTable_RequiredMask)(const struct upb_MiniTable* m) {
2068 int n = m->UPB_PRIVATE(required_count);
2069 UPB_ASSERT(0 < n && n <= 64);
2070 return (1ULL << n) - 1;
2071 }
2072
2073 #ifdef UPB_TRACING_ENABLED
upb_MiniTable_FullName(const struct upb_MiniTable * mini_table)2074 UPB_INLINE const char* upb_MiniTable_FullName(
2075 const struct upb_MiniTable* mini_table) {
2076 return mini_table->UPB_PRIVATE(full_name);
2077 }
2078 // Initializes tracing proto name from language runtimes that construct
2079 // mini tables dynamically at runtime. The runtime is responsible for passing
2080 // controlling lifetime of name such as storing in same arena as mini_table.
upb_MiniTable_SetFullName(struct upb_MiniTable * mini_table,const char * full_name)2081 UPB_INLINE void upb_MiniTable_SetFullName(struct upb_MiniTable* mini_table,
2082 const char* full_name) {
2083 mini_table->UPB_PRIVATE(full_name) = full_name;
2084 }
2085 #endif
2086
2087 #ifdef __cplusplus
2088 } /* extern "C" */
2089 #endif
2090
2091
2092 #endif /* UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ */
2093
2094 // Must be last.
2095
2096 typedef struct upb_MiniTable upb_MiniTable;
2097
2098 #ifdef __cplusplus
2099 extern "C" {
2100 #endif
2101
2102 UPB_API const upb_MiniTableField* upb_MiniTable_FindFieldByNumber(
2103 const upb_MiniTable* m, uint32_t number);
2104
2105 UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_GetFieldByIndex(
2106 const upb_MiniTable* m, uint32_t index);
2107
2108 UPB_API_INLINE int upb_MiniTable_FieldCount(const upb_MiniTable* m);
2109
2110 // DEPRECATED: use upb_MiniTable_SubMessage() instead
2111 // Returns the MiniTable for a message field, NULL if the field is unlinked.
2112 UPB_API_INLINE const upb_MiniTable* upb_MiniTable_GetSubMessageTable(
2113 const upb_MiniTable* m, const upb_MiniTableField* f);
2114
2115 // Returns the MiniTable for a message field if it is a submessage, otherwise
2116 // returns NULL.
2117 //
2118 // WARNING: if dynamic tree shaking is in use, the return value may be the
2119 // "empty", zero-field placeholder message instead of the real message type.
2120 // If the message is later linked, this function will begin returning the real
2121 // message type.
2122 UPB_API_INLINE const upb_MiniTable* upb_MiniTable_SubMessage(
2123 const upb_MiniTable* m, const upb_MiniTableField* f);
2124
2125 // Returns the MiniTable for a map field. The given field must refer to a map.
2126 UPB_API_INLINE const upb_MiniTable* upb_MiniTable_MapEntrySubMessage(
2127 const upb_MiniTable* m, const upb_MiniTableField* f);
2128
2129 // Returns the MiniTableEnum for a message field, NULL if the field is unlinked.
2130 UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTable_GetSubEnumTable(
2131 const upb_MiniTable* m, const upb_MiniTableField* f);
2132
2133 // Returns the MiniTableField for the key of a map.
2134 UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_MapKey(
2135 const upb_MiniTable* m);
2136
2137 // Returns the MiniTableField for the value of a map.
2138 UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_MapValue(
2139 const upb_MiniTable* m);
2140
2141 // Returns true if this MiniTable field is linked to a MiniTable for the
2142 // sub-message.
2143 UPB_API_INLINE bool upb_MiniTable_FieldIsLinked(const upb_MiniTable* m,
2144 const upb_MiniTableField* f);
2145
2146 // If this field is in a oneof, returns the first field in the oneof.
2147 //
2148 // Otherwise returns NULL.
2149 //
2150 // Usage:
2151 // const upb_MiniTableField* field = upb_MiniTable_GetOneof(m, f);
2152 // do {
2153 // ..
2154 // } while (upb_MiniTable_NextOneofField(m, &field);
2155 //
2156 const upb_MiniTableField* upb_MiniTable_GetOneof(const upb_MiniTable* m,
2157 const upb_MiniTableField* f);
2158
2159 // Iterates to the next field in the oneof. If this is the last field in the
2160 // oneof, returns false. The ordering of fields in the oneof is not
2161 // guaranteed.
2162 // REQUIRES: |f| is the field initialized by upb_MiniTable_GetOneof and updated
2163 // by prior upb_MiniTable_NextOneofField calls.
2164 bool upb_MiniTable_NextOneofField(const upb_MiniTable* m,
2165 const upb_MiniTableField** f);
2166
2167 #ifdef __cplusplus
2168 } /* extern "C" */
2169 #endif
2170
2171
2172 #endif /* UPB_MINI_TABLE_MESSAGE_H_ */
2173
2174 // Must be last.
2175
2176 typedef struct upb_MiniTableExtension upb_MiniTableExtension;
2177
2178 #ifdef __cplusplus
2179 extern "C" {
2180 #endif
2181
2182 UPB_API_INLINE upb_CType
2183 upb_MiniTableExtension_CType(const upb_MiniTableExtension* e);
2184
2185 UPB_API_INLINE uint32_t
2186 upb_MiniTableExtension_Number(const upb_MiniTableExtension* e);
2187
2188 UPB_API_INLINE const upb_MiniTable* upb_MiniTableExtension_GetSubMessage(
2189 const upb_MiniTableExtension* e);
2190
2191 UPB_API_INLINE void upb_MiniTableExtension_SetSubMessage(
2192 upb_MiniTableExtension* e, const upb_MiniTable* m);
2193
2194 #ifdef __cplusplus
2195 } /* extern "C" */
2196 #endif
2197
2198
2199 #endif /* UPB_MINI_TABLE_EXTENSION_H_ */
2200
2201 // Must be last.
2202
2203 // The internal representation of an extension is self-describing: it contains
2204 // enough information that we can serialize it to binary format without needing
2205 // to look it up in a upb_ExtensionRegistry.
2206 //
2207 // This representation allocates 16 bytes to data on 64-bit platforms.
2208 // This is rather wasteful for scalars (in the extreme case of bool,
2209 // it wastes 15 bytes). We accept this because we expect messages to be
2210 // the most common extension type.
2211 typedef struct {
2212 const upb_MiniTableExtension* ext;
2213 upb_MessageValue data;
2214 } upb_Extension;
2215
2216 #ifdef __cplusplus
2217 extern "C" {
2218 #endif
2219
2220 // Adds the given extension data to the given message.
2221 // |ext| is copied into the message instance.
2222 // This logically replaces any previously-added extension with this number.
2223 upb_Extension* UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(
2224 struct upb_Message* msg, const upb_MiniTableExtension* ext,
2225 upb_Arena* arena);
2226
2227 // Returns an array of extensions for this message.
2228 // Note: the array is ordered in reverse relative to the order of creation.
2229 const upb_Extension* UPB_PRIVATE(_upb_Message_Getexts)(
2230 const struct upb_Message* msg, size_t* count);
2231
2232 // Returns an extension for a message with a given mini table,
2233 // or NULL if no extension exists with this mini table.
2234 const upb_Extension* UPB_PRIVATE(_upb_Message_Getext)(
2235 const struct upb_Message* msg, const upb_MiniTableExtension* ext);
2236
2237 #ifdef __cplusplus
2238 } /* extern "C" */
2239 #endif
2240
2241
2242 #endif /* UPB_MESSAGE_INTERNAL_EXTENSION_H_ */
2243
2244 // Must be last.
2245
2246 #ifdef __cplusplus
2247 extern "C" {
2248 #endif
2249
2250 extern const float kUpb_FltInfinity;
2251 extern const double kUpb_Infinity;
2252 extern const double kUpb_NaN;
2253
2254 // Internal members of a upb_Message that track unknown fields and/or
2255 // extensions. We can change this without breaking binary compatibility.
2256
2257 typedef struct upb_Message_Internal {
2258 // Total size of this structure, including the data that follows.
2259 // Must be aligned to 8, which is alignof(upb_Extension)
2260 uint32_t size;
2261
2262 /* Offsets relative to the beginning of this structure.
2263 *
2264 * Unknown data grows forward from the beginning to unknown_end.
2265 * Extension data grows backward from size to ext_begin.
2266 * When the two meet, we're out of data and have to realloc.
2267 *
2268 * If we imagine that the final member of this struct is:
2269 * char data[size - overhead]; // overhead = sizeof(upb_Message_Internal)
2270 *
2271 * Then we have:
2272 * unknown data: data[0 .. (unknown_end - overhead)]
2273 * extensions data: data[(ext_begin - overhead) .. (size - overhead)] */
2274 uint32_t unknown_end;
2275 uint32_t ext_begin;
2276 // Data follows, as if there were an array:
2277 // char data[size - sizeof(upb_Message_Internal)];
2278 } upb_Message_Internal;
2279
2280 #ifdef UPB_TRACING_ENABLED
2281 UPB_API void upb_Message_LogNewMessage(const upb_MiniTable* m,
2282 const upb_Arena* arena);
2283 UPB_API void upb_Message_SetNewMessageTraceHandler(
2284 void (*handler)(const upb_MiniTable*, const upb_Arena*));
2285 #endif // UPB_TRACING_ENABLED
2286
2287 // Inline version upb_Message_New(), for internal use.
_upb_Message_New(const upb_MiniTable * m,upb_Arena * a)2288 UPB_INLINE struct upb_Message* _upb_Message_New(const upb_MiniTable* m,
2289 upb_Arena* a) {
2290 #ifdef UPB_TRACING_ENABLED
2291 upb_Message_LogNewMessage(m, a);
2292 #endif // UPB_TRACING_ENABLED
2293
2294 const int size = m->UPB_PRIVATE(size);
2295 struct upb_Message* msg = (struct upb_Message*)upb_Arena_Malloc(a, size);
2296 if (UPB_UNLIKELY(!msg)) return NULL;
2297 memset(msg, 0, size);
2298 return msg;
2299 }
2300
2301 // Discards the unknown fields for this message only.
2302 void _upb_Message_DiscardUnknown_shallow(struct upb_Message* msg);
2303
2304 // Adds unknown data (serialized protobuf data) to the given message.
2305 // The data is copied into the message instance.
2306 bool UPB_PRIVATE(_upb_Message_AddUnknown)(struct upb_Message* msg,
2307 const char* data, size_t len,
2308 upb_Arena* arena);
2309
2310 bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need,
2311 upb_Arena* arena);
2312
2313 #ifdef __cplusplus
2314 } /* extern "C" */
2315 #endif
2316
2317
2318 #endif /* UPB_MESSAGE_INTERNAL_MESSAGE_H_ */
2319
2320 #ifndef UPB_MESSAGE_INTERNAL_TYPES_H_
2321 #define UPB_MESSAGE_INTERNAL_TYPES_H_
2322
2323 #include <stdint.h>
2324
2325 // Must be last.
2326
2327 #define UPB_OPAQUE(x) x##_opaque
2328
2329 struct upb_Message {
2330 union {
2331 uintptr_t UPB_OPAQUE(internal); // tagged pointer, low bit == frozen
2332 double d; // Forces same size for 32-bit/64-bit builds
2333 };
2334 };
2335
2336 #ifdef __cplusplus
2337 extern "C" {
2338 #endif
2339
UPB_PRIVATE(_upb_Message_ShallowFreeze)2340 UPB_INLINE void UPB_PRIVATE(_upb_Message_ShallowFreeze)(
2341 struct upb_Message* msg) {
2342 msg->UPB_OPAQUE(internal) |= 1ULL;
2343 }
2344
upb_Message_IsFrozen(const struct upb_Message * msg)2345 UPB_API_INLINE bool upb_Message_IsFrozen(const struct upb_Message* msg) {
2346 return (msg->UPB_OPAQUE(internal) & 1ULL) != 0;
2347 }
2348
UPB_PRIVATE(_upb_Message_GetInternal)2349 UPB_INLINE struct upb_Message_Internal* UPB_PRIVATE(_upb_Message_GetInternal)(
2350 const struct upb_Message* msg) {
2351 const uintptr_t tmp = msg->UPB_OPAQUE(internal) & ~1ULL;
2352 return (struct upb_Message_Internal*)tmp;
2353 }
2354
UPB_PRIVATE(_upb_Message_SetInternal)2355 UPB_INLINE void UPB_PRIVATE(_upb_Message_SetInternal)(
2356 struct upb_Message* msg, struct upb_Message_Internal* internal) {
2357 UPB_ASSERT(!upb_Message_IsFrozen(msg));
2358 msg->UPB_OPAQUE(internal) = (uintptr_t)internal;
2359 }
2360
2361 #ifdef __cplusplus
2362 } /* extern "C" */
2363 #endif
2364
2365 #undef UPB_OPAQUE
2366
2367
2368 #endif /* UPB_MESSAGE_INTERNAL_TYPES_H_ */
2369
2370 // Must be last.
2371
2372 typedef struct upb_Message upb_Message;
2373
2374 #ifdef __cplusplus
2375 extern "C" {
2376 #endif
2377
2378 // Creates a new message with the given mini_table on the given arena.
2379 UPB_API upb_Message* upb_Message_New(const upb_MiniTable* m, upb_Arena* arena);
2380
2381 // Returns a reference to the message's unknown data.
2382 const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len);
2383
2384 // Removes partial unknown data from message.
2385 void upb_Message_DeleteUnknown(upb_Message* msg, const char* data, size_t len);
2386
2387 // Returns the number of extensions present in this message.
2388 size_t upb_Message_ExtensionCount(const upb_Message* msg);
2389
2390 // Mark a message and all of its descendents as frozen/immutable.
2391 UPB_API void upb_Message_Freeze(upb_Message* msg, const upb_MiniTable* m);
2392
2393 // Returns whether a message has been frozen.
2394 UPB_API_INLINE bool upb_Message_IsFrozen(const upb_Message* msg);
2395
2396 #ifdef UPB_TRACING_ENABLED
2397 UPB_API void upb_Message_LogNewMessage(const upb_MiniTable* m,
2398 const upb_Arena* arena);
2399
2400 UPB_API void upb_Message_SetNewMessageTraceHandler(
2401 void (*handler)(const upb_MiniTable* m, const upb_Arena* arena));
2402 #endif // UPB_TRACING_ENABLED
2403
2404 #ifdef __cplusplus
2405 } /* extern "C" */
2406 #endif
2407
2408
2409 #endif /* UPB_MESSAGE_MESSAGE_H_ */
2410
2411 #ifndef UPB_REFLECTION_DEF_H_
2412 #define UPB_REFLECTION_DEF_H_
2413
2414 // IWYU pragma: begin_exports
2415
2416 // IWYU pragma: private, include "upb/reflection/def.h"
2417
2418 #ifndef UPB_REFLECTION_DEF_POOL_H_
2419 #define UPB_REFLECTION_DEF_POOL_H_
2420
2421
2422 // IWYU pragma: private, include "upb/reflection/def.h"
2423
2424 // Declarations common to all public def types.
2425
2426 #ifndef UPB_REFLECTION_COMMON_H_
2427 #define UPB_REFLECTION_COMMON_H_
2428
2429 #ifndef THIRD_PARTY_UPB_UPB_REFLECTION_DESCRIPTOR_BOOTSTRAP_H_
2430 #define THIRD_PARTY_UPB_UPB_REFLECTION_DESCRIPTOR_BOOTSTRAP_H_
2431
2432 // IWYU pragma: begin_exports
2433
2434 #if defined(UPB_BOOTSTRAP_STAGE) && UPB_BOOTSTRAP_STAGE == 0
2435 // This header is checked in.
2436 #elif UPB_BOOTSTRAP_STAGE == 1
2437 // This header is generated at build time by the bootstrapping process.
2438 #else
2439 // This is the normal header, generated by upb_c_proto_library().
2440 /* This file was generated by upb_generator from the input file:
2441 *
2442 * google/protobuf/descriptor.proto
2443 *
2444 * Do not edit -- your changes will be discarded when the file is
2445 * regenerated.
2446 * NO CHECKED-IN PROTOBUF GENCODE */
2447
2448 #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H__UPB_H_
2449 #define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H__UPB_H_
2450
2451
2452 #ifndef UPB_GENERATED_CODE_SUPPORT_H_
2453 #define UPB_GENERATED_CODE_SUPPORT_H_
2454
2455 // IWYU pragma: begin_exports
2456
2457 #ifndef UPB_BASE_UPCAST_H_
2458 #define UPB_BASE_UPCAST_H_
2459
2460 // Must be last.
2461
2462 // This macro provides a way to upcast message pointers in a way that is
2463 // somewhat more bulletproof than blindly casting a pointer. Example:
2464 //
2465 // typedef struct {
2466 // upb_Message UPB_PRIVATE(base);
2467 // } pkg_FooMessage;
2468 //
2469 // void f(pkg_FooMessage* msg) {
2470 // upb_Decode(UPB_UPCAST(msg), ...);
2471 // }
2472
2473 #define UPB_UPCAST(x) (&(x)->base##_dont_copy_me__upb_internal_use_only)
2474
2475
2476 #endif /* UPB_BASE_UPCAST_H_ */
2477
2478 #ifndef UPB_MESSAGE_ACCESSORS_H_
2479 #define UPB_MESSAGE_ACCESSORS_H_
2480
2481 #include <stdint.h>
2482
2483
2484 #ifndef UPB_MESSAGE_ARRAY_H_
2485 #define UPB_MESSAGE_ARRAY_H_
2486
2487 #include <stddef.h>
2488
2489
2490 #ifndef UPB_MESSAGE_INTERNAL_ARRAY_H_
2491 #define UPB_MESSAGE_INTERNAL_ARRAY_H_
2492
2493 #include <stdint.h>
2494 #include <string.h>
2495
2496
2497 // Must be last.
2498
2499 #define _UPB_ARRAY_MASK_IMM 0x4 // Frozen/immutable bit.
2500 #define _UPB_ARRAY_MASK_LG2 0x3 // Encoded elem size.
2501 #define _UPB_ARRAY_MASK_ALL (_UPB_ARRAY_MASK_IMM | _UPB_ARRAY_MASK_LG2)
2502
2503 #ifdef __cplusplus
2504 extern "C" {
2505 #endif
2506
2507 // LINT.IfChange(upb_Array)
2508
2509 // Our internal representation for repeated fields.
2510 struct upb_Array {
2511 // This is a tagged pointer. Bits #0 and #1 encode the elem size as follows:
2512 // 0 maps to elem size 1
2513 // 1 maps to elem size 4
2514 // 2 maps to elem size 8
2515 // 3 maps to elem size 16
2516 //
2517 // Bit #2 contains the frozen/immutable flag.
2518 uintptr_t UPB_ONLYBITS(data);
2519
2520 size_t UPB_ONLYBITS(size); // The number of elements in the array.
2521 size_t UPB_PRIVATE(capacity); // Allocated storage. Measured in elements.
2522 };
2523
UPB_PRIVATE(_upb_Array_ShallowFreeze)2524 UPB_INLINE void UPB_PRIVATE(_upb_Array_ShallowFreeze)(struct upb_Array* arr) {
2525 arr->UPB_ONLYBITS(data) |= _UPB_ARRAY_MASK_IMM;
2526 }
2527
upb_Array_IsFrozen(const struct upb_Array * arr)2528 UPB_API_INLINE bool upb_Array_IsFrozen(const struct upb_Array* arr) {
2529 return (arr->UPB_ONLYBITS(data) & _UPB_ARRAY_MASK_IMM) != 0;
2530 }
2531
UPB_PRIVATE(_upb_Array_SetTaggedPtr)2532 UPB_INLINE void UPB_PRIVATE(_upb_Array_SetTaggedPtr)(struct upb_Array* array,
2533 void* data, size_t lg2) {
2534 UPB_ASSERT(lg2 != 1);
2535 UPB_ASSERT(lg2 <= 4);
2536 const size_t bits = lg2 - (lg2 != 0);
2537 array->UPB_ONLYBITS(data) = (uintptr_t)data | bits;
2538 }
2539
2540 UPB_INLINE size_t
UPB_PRIVATE(_upb_Array_ElemSizeLg2)2541 UPB_PRIVATE(_upb_Array_ElemSizeLg2)(const struct upb_Array* array) {
2542 const size_t bits = array->UPB_ONLYBITS(data) & _UPB_ARRAY_MASK_LG2;
2543 const size_t lg2 = bits + (bits != 0);
2544 return lg2;
2545 }
2546
upb_Array_DataPtr(const struct upb_Array * array)2547 UPB_API_INLINE const void* upb_Array_DataPtr(const struct upb_Array* array) {
2548 UPB_PRIVATE(_upb_Array_ElemSizeLg2)(array); // Check assertions.
2549 return (void*)(array->UPB_ONLYBITS(data) & ~(uintptr_t)_UPB_ARRAY_MASK_ALL);
2550 }
2551
upb_Array_MutableDataPtr(struct upb_Array * array)2552 UPB_API_INLINE void* upb_Array_MutableDataPtr(struct upb_Array* array) {
2553 return (void*)upb_Array_DataPtr(array);
2554 }
2555
UPB_PRIVATE(_upb_Array_New)2556 UPB_INLINE struct upb_Array* UPB_PRIVATE(_upb_Array_New)(upb_Arena* arena,
2557 size_t init_capacity,
2558 int elem_size_lg2) {
2559 UPB_ASSERT(elem_size_lg2 != 1);
2560 UPB_ASSERT(elem_size_lg2 <= 4);
2561 const size_t array_size =
2562 UPB_ALIGN_UP(sizeof(struct upb_Array), UPB_MALLOC_ALIGN);
2563 const size_t bytes = array_size + (init_capacity << elem_size_lg2);
2564 struct upb_Array* array = (struct upb_Array*)upb_Arena_Malloc(arena, bytes);
2565 if (!array) return NULL;
2566 UPB_PRIVATE(_upb_Array_SetTaggedPtr)
2567 (array, UPB_PTR_AT(array, array_size, void), elem_size_lg2);
2568 array->UPB_ONLYBITS(size) = 0;
2569 array->UPB_PRIVATE(capacity) = init_capacity;
2570 return array;
2571 }
2572
2573 // Resizes the capacity of the array to be at least min_size.
2574 bool UPB_PRIVATE(_upb_Array_Realloc)(struct upb_Array* array, size_t min_size,
2575 upb_Arena* arena);
2576
upb_Array_Reserve(struct upb_Array * array,size_t size,upb_Arena * arena)2577 UPB_API_INLINE bool upb_Array_Reserve(struct upb_Array* array, size_t size,
2578 upb_Arena* arena) {
2579 UPB_ASSERT(!upb_Array_IsFrozen(array));
2580 if (array->UPB_PRIVATE(capacity) < size)
2581 return UPB_PRIVATE(_upb_Array_Realloc)(array, size, arena);
2582 return true;
2583 }
2584
2585 // Resize without initializing new elements.
UPB_PRIVATE(_upb_Array_ResizeUninitialized)2586 UPB_INLINE bool UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
2587 struct upb_Array* array, size_t size, upb_Arena* arena) {
2588 UPB_ASSERT(!upb_Array_IsFrozen(array));
2589 UPB_ASSERT(size <= array->UPB_ONLYBITS(size) ||
2590 arena); // Allow NULL arena when shrinking.
2591 if (!upb_Array_Reserve(array, size, arena)) return false;
2592 array->UPB_ONLYBITS(size) = size;
2593 return true;
2594 }
2595
2596 // This function is intended for situations where elem_size is compile-time
2597 // constant or a known expression of the form (1 << lg2), so that the expression
2598 // i*elem_size does not result in an actual multiplication.
UPB_PRIVATE(_upb_Array_Set)2599 UPB_INLINE void UPB_PRIVATE(_upb_Array_Set)(struct upb_Array* array, size_t i,
2600 const void* data,
2601 size_t elem_size) {
2602 UPB_ASSERT(!upb_Array_IsFrozen(array));
2603 UPB_ASSERT(i < array->UPB_ONLYBITS(size));
2604 UPB_ASSERT(elem_size == 1U << UPB_PRIVATE(_upb_Array_ElemSizeLg2)(array));
2605 char* arr_data = (char*)upb_Array_MutableDataPtr(array);
2606 memcpy(arr_data + (i * elem_size), data, elem_size);
2607 }
2608
upb_Array_Size(const struct upb_Array * arr)2609 UPB_API_INLINE size_t upb_Array_Size(const struct upb_Array* arr) {
2610 return arr->UPB_ONLYBITS(size);
2611 }
2612
2613 // LINT.ThenChange(GoogleInternalName0)
2614
2615 #ifdef __cplusplus
2616 } /* extern "C" */
2617 #endif
2618
2619 #undef _UPB_ARRAY_MASK_IMM
2620 #undef _UPB_ARRAY_MASK_LG2
2621 #undef _UPB_ARRAY_MASK_ALL
2622
2623
2624 #endif /* UPB_MESSAGE_INTERNAL_ARRAY_H_ */
2625
2626 // Must be last.
2627
2628 typedef struct upb_Array upb_Array;
2629
2630 #ifdef __cplusplus
2631 extern "C" {
2632 #endif
2633
2634 // Creates a new array on the given arena that holds elements of this type.
2635 UPB_API upb_Array* upb_Array_New(upb_Arena* a, upb_CType type);
2636
2637 // Returns the number of elements in the array.
2638 UPB_API_INLINE size_t upb_Array_Size(const upb_Array* arr);
2639
2640 // Returns the given element, which must be within the array's current size.
2641 UPB_API upb_MessageValue upb_Array_Get(const upb_Array* arr, size_t i);
2642
2643 // Returns a mutating pointer to the given element, which must be within the
2644 // array's current size.
2645 UPB_API upb_MutableMessageValue upb_Array_GetMutable(upb_Array* arr, size_t i);
2646
2647 // Sets the given element, which must be within the array's current size.
2648 UPB_API void upb_Array_Set(upb_Array* arr, size_t i, upb_MessageValue val);
2649
2650 // Appends an element to the array. Returns false on allocation failure.
2651 UPB_API bool upb_Array_Append(upb_Array* array, upb_MessageValue val,
2652 upb_Arena* arena);
2653
2654 // Moves elements within the array using memmove().
2655 // Like memmove(), the source and destination elements may be overlapping.
2656 UPB_API void upb_Array_Move(upb_Array* array, size_t dst_idx, size_t src_idx,
2657 size_t count);
2658
2659 // Inserts one or more empty elements into the array.
2660 // Existing elements are shifted right.
2661 // The new elements have undefined state and must be set with `upb_Array_Set()`.
2662 // REQUIRES: `i <= upb_Array_Size(arr)`
2663 UPB_API bool upb_Array_Insert(upb_Array* array, size_t i, size_t count,
2664 upb_Arena* arena);
2665
2666 // Deletes one or more elements from the array.
2667 // Existing elements are shifted left.
2668 // REQUIRES: `i + count <= upb_Array_Size(arr)`
2669 UPB_API void upb_Array_Delete(upb_Array* array, size_t i, size_t count);
2670
2671 // Reserves |size| elements of storage for the array.
2672 UPB_API_INLINE bool upb_Array_Reserve(struct upb_Array* array, size_t size,
2673 upb_Arena* arena);
2674
2675 // Changes the size of a vector. New elements are initialized to NULL/0.
2676 // Returns false on allocation failure.
2677 UPB_API bool upb_Array_Resize(upb_Array* array, size_t size, upb_Arena* arena);
2678
2679 // Returns pointer to array data.
2680 UPB_API_INLINE const void* upb_Array_DataPtr(const upb_Array* arr);
2681
2682 // Returns mutable pointer to array data.
2683 UPB_API_INLINE void* upb_Array_MutableDataPtr(upb_Array* arr);
2684
2685 // Mark an array and all of its descendents as frozen/immutable.
2686 // If the array elements are messages then |m| must point to the minitable for
2687 // those messages. Otherwise |m| must be NULL.
2688 UPB_API void upb_Array_Freeze(upb_Array* arr, const upb_MiniTable* m);
2689
2690 // Returns whether an array has been frozen.
2691 UPB_API_INLINE bool upb_Array_IsFrozen(const upb_Array* arr);
2692
2693 #ifdef __cplusplus
2694 } /* extern "C" */
2695 #endif
2696
2697
2698 #endif /* UPB_MESSAGE_ARRAY_H_ */
2699
2700 #ifndef UPB_MESSAGE_INTERNAL_ACCESSORS_H_
2701 #define UPB_MESSAGE_INTERNAL_ACCESSORS_H_
2702
2703 #include <stddef.h>
2704 #include <stdint.h>
2705 #include <string.h>
2706
2707
2708 #ifndef UPB_BASE_INTERNAL_ENDIAN_H_
2709 #define UPB_BASE_INTERNAL_ENDIAN_H_
2710
2711 #include <stdint.h>
2712
2713 // Must be last.
2714
2715 #ifdef __cplusplus
2716 extern "C" {
2717 #endif
2718
upb_IsLittleEndian(void)2719 UPB_INLINE bool upb_IsLittleEndian(void) {
2720 const int x = 1;
2721 return *(char*)&x == 1;
2722 }
2723
upb_BigEndian32(uint32_t val)2724 UPB_INLINE uint32_t upb_BigEndian32(uint32_t val) {
2725 if (upb_IsLittleEndian()) return val;
2726
2727 return ((val & 0xff) << 24) | ((val & 0xff00) << 8) |
2728 ((val & 0xff0000) >> 8) | ((val & 0xff000000) >> 24);
2729 }
2730
upb_BigEndian64(uint64_t val)2731 UPB_INLINE uint64_t upb_BigEndian64(uint64_t val) {
2732 if (upb_IsLittleEndian()) return val;
2733
2734 const uint64_t hi = ((uint64_t)upb_BigEndian32((uint32_t)val)) << 32;
2735 const uint64_t lo = upb_BigEndian32((uint32_t)(val >> 32));
2736 return hi | lo;
2737 }
2738
2739 #ifdef __cplusplus
2740 } /* extern "C" */
2741 #endif
2742
2743
2744 #endif /* UPB_BASE_INTERNAL_ENDIAN_H_ */
2745
2746 #ifndef UPB_MESSAGE_INTERNAL_MAP_H_
2747 #define UPB_MESSAGE_INTERNAL_MAP_H_
2748
2749 #include <stddef.h>
2750 #include <string.h>
2751
2752
2753 #ifndef UPB_HASH_STR_TABLE_H_
2754 #define UPB_HASH_STR_TABLE_H_
2755
2756
2757 /*
2758 * upb_table
2759 *
2760 * This header is INTERNAL-ONLY! Its interfaces are not public or stable!
2761 * This file defines very fast int->upb_value (inttable) and string->upb_value
2762 * (strtable) hash tables.
2763 *
2764 * The table uses chained scatter with Brent's variation (inspired by the Lua
2765 * implementation of hash tables). The hash function for strings is Austin
2766 * Appleby's "MurmurHash."
2767 *
2768 * The inttable uses uintptr_t as its key, which guarantees it can be used to
2769 * store pointers or integers of at least 32 bits (upb isn't really useful on
2770 * systems where sizeof(void*) < 4).
2771 *
2772 * The table must be homogeneous (all values of the same type). In debug
2773 * mode, we check this on insert and lookup.
2774 */
2775
2776 #ifndef UPB_HASH_COMMON_H_
2777 #define UPB_HASH_COMMON_H_
2778
2779 #include <string.h>
2780
2781
2782 // Must be last.
2783
2784 #ifdef __cplusplus
2785 extern "C" {
2786 #endif
2787
2788 /* upb_value ******************************************************************/
2789
2790 typedef struct {
2791 uint64_t val;
2792 } upb_value;
2793
_upb_value_setval(upb_value * v,uint64_t val)2794 UPB_INLINE void _upb_value_setval(upb_value* v, uint64_t val) { v->val = val; }
2795
2796 /* For each value ctype, define the following set of functions:
2797 *
2798 * // Get/set an int32 from a upb_value.
2799 * int32_t upb_value_getint32(upb_value val);
2800 * void upb_value_setint32(upb_value *val, int32_t cval);
2801 *
2802 * // Construct a new upb_value from an int32.
2803 * upb_value upb_value_int32(int32_t val); */
2804 #define FUNCS(name, membername, type_t, converter) \
2805 UPB_INLINE void upb_value_set##name(upb_value* val, type_t cval) { \
2806 val->val = (converter)cval; \
2807 } \
2808 UPB_INLINE upb_value upb_value_##name(type_t val) { \
2809 upb_value ret; \
2810 upb_value_set##name(&ret, val); \
2811 return ret; \
2812 } \
2813 UPB_INLINE type_t upb_value_get##name(upb_value val) { \
2814 return (type_t)(converter)val.val; \
2815 }
2816
FUNCS(int32,int32,int32_t,int32_t)2817 FUNCS(int32, int32, int32_t, int32_t)
2818 FUNCS(int64, int64, int64_t, int64_t)
2819 FUNCS(uint32, uint32, uint32_t, uint32_t)
2820 FUNCS(uint64, uint64, uint64_t, uint64_t)
2821 FUNCS(bool, _bool, bool, bool)
2822 FUNCS(cstr, cstr, char*, uintptr_t)
2823 FUNCS(uintptr, uptr, uintptr_t, uintptr_t)
2824 FUNCS(ptr, ptr, void*, uintptr_t)
2825 FUNCS(constptr, constptr, const void*, uintptr_t)
2826
2827 #undef FUNCS
2828
2829 UPB_INLINE void upb_value_setfloat(upb_value* val, float cval) {
2830 memcpy(&val->val, &cval, sizeof(cval));
2831 }
2832
upb_value_setdouble(upb_value * val,double cval)2833 UPB_INLINE void upb_value_setdouble(upb_value* val, double cval) {
2834 memcpy(&val->val, &cval, sizeof(cval));
2835 }
2836
upb_value_float(float cval)2837 UPB_INLINE upb_value upb_value_float(float cval) {
2838 upb_value ret;
2839 upb_value_setfloat(&ret, cval);
2840 return ret;
2841 }
2842
upb_value_double(double cval)2843 UPB_INLINE upb_value upb_value_double(double cval) {
2844 upb_value ret;
2845 upb_value_setdouble(&ret, cval);
2846 return ret;
2847 }
2848
2849 /* upb_tabkey *****************************************************************/
2850
2851 /* Either:
2852 * 1. an actual integer key, or
2853 * 2. a pointer to a string prefixed by its uint32_t length, owned by us.
2854 *
2855 * ...depending on whether this is a string table or an int table. We would
2856 * make this a union of those two types, but C89 doesn't support statically
2857 * initializing a non-first union member. */
2858 typedef uintptr_t upb_tabkey;
2859
upb_tabstr(upb_tabkey key,uint32_t * len)2860 UPB_INLINE char* upb_tabstr(upb_tabkey key, uint32_t* len) {
2861 char* mem = (char*)key;
2862 if (len) memcpy(len, mem, sizeof(*len));
2863 return mem + sizeof(*len);
2864 }
2865
upb_tabstrview(upb_tabkey key)2866 UPB_INLINE upb_StringView upb_tabstrview(upb_tabkey key) {
2867 upb_StringView ret;
2868 uint32_t len;
2869 ret.data = upb_tabstr(key, &len);
2870 ret.size = len;
2871 return ret;
2872 }
2873
2874 /* upb_tabval *****************************************************************/
2875
2876 typedef struct upb_tabval {
2877 uint64_t val;
2878 } upb_tabval;
2879
2880 #define UPB_TABVALUE_EMPTY_INIT \
2881 { -1 }
2882
2883 /* upb_table ******************************************************************/
2884
2885 typedef struct _upb_tabent {
2886 upb_tabkey key;
2887 upb_tabval val;
2888
2889 /* Internal chaining. This is const so we can create static initializers for
2890 * tables. We cast away const sometimes, but *only* when the containing
2891 * upb_table is known to be non-const. This requires a bit of care, but
2892 * the subtlety is confined to table.c. */
2893 const struct _upb_tabent* next;
2894 } upb_tabent;
2895
2896 typedef struct {
2897 size_t count; /* Number of entries in the hash part. */
2898 uint32_t mask; /* Mask to turn hash value -> bucket. */
2899 uint32_t max_count; /* Max count before we hit our load limit. */
2900 uint8_t size_lg2; /* Size of the hashtable part is 2^size_lg2 entries. */
2901 upb_tabent* entries;
2902 } upb_table;
2903
upb_table_size(const upb_table * t)2904 UPB_INLINE size_t upb_table_size(const upb_table* t) {
2905 return t->size_lg2 ? 1 << t->size_lg2 : 0;
2906 }
2907
2908 // Internal-only functions, in .h file only out of necessity.
2909
upb_tabent_isempty(const upb_tabent * e)2910 UPB_INLINE bool upb_tabent_isempty(const upb_tabent* e) { return e->key == 0; }
2911
2912 uint32_t _upb_Hash(const void* p, size_t n, uint64_t seed);
2913
2914 #ifdef __cplusplus
2915 } /* extern "C" */
2916 #endif
2917
2918
2919 #endif /* UPB_HASH_COMMON_H_ */
2920
2921 // Must be last.
2922
2923 typedef struct {
2924 upb_table t;
2925 } upb_strtable;
2926
2927 #ifdef __cplusplus
2928 extern "C" {
2929 #endif
2930
2931 // Initialize a table. If memory allocation failed, false is returned and
2932 // the table is uninitialized.
2933 bool upb_strtable_init(upb_strtable* table, size_t expected_size, upb_Arena* a);
2934
2935 // Returns the number of values in the table.
upb_strtable_count(const upb_strtable * t)2936 UPB_INLINE size_t upb_strtable_count(const upb_strtable* t) {
2937 return t->t.count;
2938 }
2939
2940 void upb_strtable_clear(upb_strtable* t);
2941
2942 // Inserts the given key into the hashtable with the given value.
2943 // The key must not already exist in the hash table. The key is not required
2944 // to be NULL-terminated, and the table will make an internal copy of the key.
2945 //
2946 // If a table resize was required but memory allocation failed, false is
2947 // returned and the table is unchanged. */
2948 bool upb_strtable_insert(upb_strtable* t, const char* key, size_t len,
2949 upb_value val, upb_Arena* a);
2950
2951 // Looks up key in this table, returning "true" if the key was found.
2952 // If v is non-NULL, copies the value for this key into *v.
2953 bool upb_strtable_lookup2(const upb_strtable* t, const char* key, size_t len,
2954 upb_value* v);
2955
2956 // For NULL-terminated strings.
upb_strtable_lookup(const upb_strtable * t,const char * key,upb_value * v)2957 UPB_INLINE bool upb_strtable_lookup(const upb_strtable* t, const char* key,
2958 upb_value* v) {
2959 return upb_strtable_lookup2(t, key, strlen(key), v);
2960 }
2961
2962 // Removes an item from the table. Returns true if the remove was successful,
2963 // and stores the removed item in *val if non-NULL.
2964 bool upb_strtable_remove2(upb_strtable* t, const char* key, size_t len,
2965 upb_value* val);
2966
upb_strtable_remove(upb_strtable * t,const char * key,upb_value * v)2967 UPB_INLINE bool upb_strtable_remove(upb_strtable* t, const char* key,
2968 upb_value* v) {
2969 return upb_strtable_remove2(t, key, strlen(key), v);
2970 }
2971
2972 // Exposed for testing only.
2973 bool upb_strtable_resize(upb_strtable* t, size_t size_lg2, upb_Arena* a);
2974
2975 /* Iteration over strtable:
2976 *
2977 * intptr_t iter = UPB_STRTABLE_BEGIN;
2978 * upb_StringView key;
2979 * upb_value val;
2980 * while (upb_strtable_next2(t, &key, &val, &iter)) {
2981 * // ...
2982 * }
2983 */
2984
2985 #define UPB_STRTABLE_BEGIN -1
2986
2987 bool upb_strtable_next2(const upb_strtable* t, upb_StringView* key,
2988 upb_value* val, intptr_t* iter);
2989 void upb_strtable_removeiter(upb_strtable* t, intptr_t* iter);
2990 void upb_strtable_setentryvalue(upb_strtable* t, intptr_t iter, upb_value v);
2991
2992 /* DEPRECATED iterators, slated for removal.
2993 *
2994 * Iterators for string tables. We are subject to some kind of unusual
2995 * design constraints:
2996 *
2997 * For high-level languages:
2998 * - we must be able to guarantee that we don't crash or corrupt memory even if
2999 * the program accesses an invalidated iterator.
3000 *
3001 * For C++11 range-based for:
3002 * - iterators must be copyable
3003 * - iterators must be comparable
3004 * - it must be possible to construct an "end" value.
3005 *
3006 * Iteration order is undefined.
3007 *
3008 * Modifying the table invalidates iterators. upb_{str,int}table_done() is
3009 * guaranteed to work even on an invalidated iterator, as long as the table it
3010 * is iterating over has not been freed. Calling next() or accessing data from
3011 * an invalidated iterator yields unspecified elements from the table, but it is
3012 * guaranteed not to crash and to return real table elements (except when done()
3013 * is true). */
3014 /* upb_strtable_iter **********************************************************/
3015
3016 /* upb_strtable_iter i;
3017 * upb_strtable_begin(&i, t);
3018 * for(; !upb_strtable_done(&i); upb_strtable_next(&i)) {
3019 * const char *key = upb_strtable_iter_key(&i);
3020 * const upb_value val = upb_strtable_iter_value(&i);
3021 * // ...
3022 * }
3023 */
3024
3025 typedef struct {
3026 const upb_strtable* t;
3027 size_t index;
3028 } upb_strtable_iter;
3029
str_tabent(const upb_strtable_iter * i)3030 UPB_INLINE const upb_tabent* str_tabent(const upb_strtable_iter* i) {
3031 return &i->t->t.entries[i->index];
3032 }
3033
3034 void upb_strtable_begin(upb_strtable_iter* i, const upb_strtable* t);
3035 void upb_strtable_next(upb_strtable_iter* i);
3036 bool upb_strtable_done(const upb_strtable_iter* i);
3037 upb_StringView upb_strtable_iter_key(const upb_strtable_iter* i);
3038 upb_value upb_strtable_iter_value(const upb_strtable_iter* i);
3039 void upb_strtable_iter_setdone(upb_strtable_iter* i);
3040 bool upb_strtable_iter_isequal(const upb_strtable_iter* i1,
3041 const upb_strtable_iter* i2);
3042
3043 #ifdef __cplusplus
3044 } /* extern "C" */
3045 #endif
3046
3047
3048 #endif /* UPB_HASH_STR_TABLE_H_ */
3049
3050 // Must be last.
3051
3052 typedef enum {
3053 kUpb_MapInsertStatus_Inserted = 0,
3054 kUpb_MapInsertStatus_Replaced = 1,
3055 kUpb_MapInsertStatus_OutOfMemory = 2,
3056 } upb_MapInsertStatus;
3057
3058 // EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
3059
3060 struct upb_Map {
3061 // Size of key and val, based on the map type.
3062 // Strings are represented as '0' because they must be handled specially.
3063 char key_size;
3064 char val_size;
3065 bool UPB_PRIVATE(is_frozen);
3066
3067 upb_strtable table;
3068 };
3069
3070 #ifdef __cplusplus
3071 extern "C" {
3072 #endif
3073
UPB_PRIVATE(_upb_Map_ShallowFreeze)3074 UPB_INLINE void UPB_PRIVATE(_upb_Map_ShallowFreeze)(struct upb_Map* map) {
3075 map->UPB_PRIVATE(is_frozen) = true;
3076 }
3077
upb_Map_IsFrozen(const struct upb_Map * map)3078 UPB_API_INLINE bool upb_Map_IsFrozen(const struct upb_Map* map) {
3079 return map->UPB_PRIVATE(is_frozen);
3080 }
3081
3082 // Converting between internal table representation and user values.
3083 //
3084 // _upb_map_tokey() and _upb_map_fromkey() are inverses.
3085 // _upb_map_tovalue() and _upb_map_fromvalue() are inverses.
3086 //
3087 // These functions account for the fact that strings are treated differently
3088 // from other types when stored in a map.
3089
_upb_map_tokey(const void * key,size_t size)3090 UPB_INLINE upb_StringView _upb_map_tokey(const void* key, size_t size) {
3091 if (size == UPB_MAPTYPE_STRING) {
3092 return *(upb_StringView*)key;
3093 } else {
3094 return upb_StringView_FromDataAndSize((const char*)key, size);
3095 }
3096 }
3097
_upb_map_fromkey(upb_StringView key,void * out,size_t size)3098 UPB_INLINE void _upb_map_fromkey(upb_StringView key, void* out, size_t size) {
3099 if (size == UPB_MAPTYPE_STRING) {
3100 memcpy(out, &key, sizeof(key));
3101 } else {
3102 memcpy(out, key.data, size);
3103 }
3104 }
3105
_upb_map_tovalue(const void * val,size_t size,upb_value * msgval,upb_Arena * a)3106 UPB_INLINE bool _upb_map_tovalue(const void* val, size_t size,
3107 upb_value* msgval, upb_Arena* a) {
3108 if (size == UPB_MAPTYPE_STRING) {
3109 upb_StringView* strp = (upb_StringView*)upb_Arena_Malloc(a, sizeof(*strp));
3110 if (!strp) return false;
3111 *strp = *(upb_StringView*)val;
3112 *msgval = upb_value_ptr(strp);
3113 } else {
3114 memcpy(msgval, val, size);
3115 }
3116 return true;
3117 }
3118
_upb_map_fromvalue(upb_value val,void * out,size_t size)3119 UPB_INLINE void _upb_map_fromvalue(upb_value val, void* out, size_t size) {
3120 if (size == UPB_MAPTYPE_STRING) {
3121 const upb_StringView* strp = (const upb_StringView*)upb_value_getptr(val);
3122 memcpy(out, strp, sizeof(upb_StringView));
3123 } else {
3124 memcpy(out, &val, size);
3125 }
3126 }
3127
_upb_map_next(const struct upb_Map * map,size_t * iter)3128 UPB_INLINE void* _upb_map_next(const struct upb_Map* map, size_t* iter) {
3129 upb_strtable_iter it;
3130 it.t = &map->table;
3131 it.index = *iter;
3132 upb_strtable_next(&it);
3133 *iter = it.index;
3134 if (upb_strtable_done(&it)) return NULL;
3135 return (void*)str_tabent(&it);
3136 }
3137
_upb_Map_Clear(struct upb_Map * map)3138 UPB_INLINE void _upb_Map_Clear(struct upb_Map* map) {
3139 UPB_ASSERT(!upb_Map_IsFrozen(map));
3140
3141 upb_strtable_clear(&map->table);
3142 }
3143
_upb_Map_Delete(struct upb_Map * map,const void * key,size_t key_size,upb_value * val)3144 UPB_INLINE bool _upb_Map_Delete(struct upb_Map* map, const void* key,
3145 size_t key_size, upb_value* val) {
3146 UPB_ASSERT(!upb_Map_IsFrozen(map));
3147
3148 upb_StringView k = _upb_map_tokey(key, key_size);
3149 return upb_strtable_remove2(&map->table, k.data, k.size, val);
3150 }
3151
_upb_Map_Get(const struct upb_Map * map,const void * key,size_t key_size,void * val,size_t val_size)3152 UPB_INLINE bool _upb_Map_Get(const struct upb_Map* map, const void* key,
3153 size_t key_size, void* val, size_t val_size) {
3154 upb_value tabval;
3155 upb_StringView k = _upb_map_tokey(key, key_size);
3156 bool ret = upb_strtable_lookup2(&map->table, k.data, k.size, &tabval);
3157 if (ret && val) {
3158 _upb_map_fromvalue(tabval, val, val_size);
3159 }
3160 return ret;
3161 }
3162
_upb_Map_Insert(struct upb_Map * map,const void * key,size_t key_size,void * val,size_t val_size,upb_Arena * a)3163 UPB_INLINE upb_MapInsertStatus _upb_Map_Insert(struct upb_Map* map,
3164 const void* key, size_t key_size,
3165 void* val, size_t val_size,
3166 upb_Arena* a) {
3167 UPB_ASSERT(!upb_Map_IsFrozen(map));
3168
3169 upb_StringView strkey = _upb_map_tokey(key, key_size);
3170 upb_value tabval = {0};
3171 if (!_upb_map_tovalue(val, val_size, &tabval, a)) {
3172 return kUpb_MapInsertStatus_OutOfMemory;
3173 }
3174
3175 // TODO: add overwrite operation to minimize number of lookups.
3176 bool removed =
3177 upb_strtable_remove2(&map->table, strkey.data, strkey.size, NULL);
3178 if (!upb_strtable_insert(&map->table, strkey.data, strkey.size, tabval, a)) {
3179 return kUpb_MapInsertStatus_OutOfMemory;
3180 }
3181 return removed ? kUpb_MapInsertStatus_Replaced
3182 : kUpb_MapInsertStatus_Inserted;
3183 }
3184
_upb_Map_Size(const struct upb_Map * map)3185 UPB_INLINE size_t _upb_Map_Size(const struct upb_Map* map) {
3186 return map->table.t.count;
3187 }
3188
3189 // Strings/bytes are special-cased in maps.
3190 extern char _upb_Map_CTypeSizeTable[12];
3191
_upb_Map_CTypeSize(upb_CType ctype)3192 UPB_INLINE size_t _upb_Map_CTypeSize(upb_CType ctype) {
3193 return _upb_Map_CTypeSizeTable[ctype];
3194 }
3195
3196 // Creates a new map on the given arena with this key/value type.
3197 struct upb_Map* _upb_Map_New(upb_Arena* a, size_t key_size, size_t value_size);
3198
3199 #ifdef __cplusplus
3200 } /* extern "C" */
3201 #endif
3202
3203
3204 #endif /* UPB_MESSAGE_INTERNAL_MAP_H_ */
3205
3206 #ifndef UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_
3207 #define UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_
3208
3209 #include <stdint.h>
3210
3211
3212 // Must be last.
3213
3214 #ifdef __cplusplus
3215 extern "C" {
3216 #endif
3217
3218 // Internal-only because empty messages cannot be created by the user.
3219 UPB_INLINE uintptr_t
UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)3220 UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(struct upb_Message* ptr, bool empty) {
3221 UPB_ASSERT(((uintptr_t)ptr & 1) == 0);
3222 return (uintptr_t)ptr | (empty ? 1 : 0);
3223 }
3224
upb_TaggedMessagePtr_IsEmpty(uintptr_t ptr)3225 UPB_API_INLINE bool upb_TaggedMessagePtr_IsEmpty(uintptr_t ptr) {
3226 return ptr & 1;
3227 }
3228
UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)3229 UPB_INLINE struct upb_Message* UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(
3230 uintptr_t ptr) {
3231 return (struct upb_Message*)(ptr & ~(uintptr_t)1);
3232 }
3233
upb_TaggedMessagePtr_GetNonEmptyMessage(uintptr_t ptr)3234 UPB_API_INLINE struct upb_Message* upb_TaggedMessagePtr_GetNonEmptyMessage(
3235 uintptr_t ptr) {
3236 UPB_ASSERT(!upb_TaggedMessagePtr_IsEmpty(ptr));
3237 return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr);
3238 }
3239
UPB_PRIVATE(_upb_TaggedMessagePtr_GetEmptyMessage)3240 UPB_INLINE struct upb_Message* UPB_PRIVATE(
3241 _upb_TaggedMessagePtr_GetEmptyMessage)(uintptr_t ptr) {
3242 UPB_ASSERT(upb_TaggedMessagePtr_IsEmpty(ptr));
3243 return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr);
3244 }
3245
3246 #ifdef __cplusplus
3247 } /* extern "C" */
3248 #endif
3249
3250
3251 #endif /* UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_ */
3252
3253 // Must be last.
3254
3255 #if defined(__GNUC__) && !defined(__clang__)
3256 // GCC raises incorrect warnings in these functions. It thinks that we are
3257 // overrunning buffers, but we carefully write the functions in this file to
3258 // guarantee that this is impossible. GCC gets this wrong due it its failure
3259 // to perform constant propagation as we expect:
3260 // - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108217
3261 // - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108226
3262 //
3263 // Unfortunately this also indicates that GCC is not optimizing away the
3264 // switch() in cases where it should be, compromising the performance.
3265 #pragma GCC diagnostic push
3266 #pragma GCC diagnostic ignored "-Warray-bounds"
3267 #pragma GCC diagnostic ignored "-Wstringop-overflow"
3268 #if __GNUC__ >= 11
3269 #pragma GCC diagnostic ignored "-Wstringop-overread"
3270 #endif
3271 #endif
3272
3273 #ifdef __cplusplus
3274 extern "C" {
3275 #endif
3276
3277 // LINT.IfChange(presence_logic)
3278
3279 // Hasbit access ///////////////////////////////////////////////////////////////
3280
UPB_PRIVATE(_upb_Message_GetHasbit)3281 UPB_INLINE bool UPB_PRIVATE(_upb_Message_GetHasbit)(
3282 const struct upb_Message* msg, const upb_MiniTableField* f) {
3283 const size_t offset = UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(f);
3284 const char mask = UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(f);
3285
3286 return (*UPB_PTR_AT(msg, offset, const char) & mask) != 0;
3287 }
3288
UPB_PRIVATE(_upb_Message_SetHasbit)3289 UPB_INLINE void UPB_PRIVATE(_upb_Message_SetHasbit)(
3290 const struct upb_Message* msg, const upb_MiniTableField* f) {
3291 const size_t offset = UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(f);
3292 const char mask = UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(f);
3293
3294 (*UPB_PTR_AT(msg, offset, char)) |= mask;
3295 }
3296
UPB_PRIVATE(_upb_Message_ClearHasbit)3297 UPB_INLINE void UPB_PRIVATE(_upb_Message_ClearHasbit)(
3298 const struct upb_Message* msg, const upb_MiniTableField* f) {
3299 const size_t offset = UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(f);
3300 const char mask = UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(f);
3301
3302 (*UPB_PTR_AT(msg, offset, char)) &= ~mask;
3303 }
3304
3305 // Oneof case access ///////////////////////////////////////////////////////////
3306
UPB_PRIVATE(_upb_Message_OneofCasePtr)3307 UPB_INLINE uint32_t* UPB_PRIVATE(_upb_Message_OneofCasePtr)(
3308 struct upb_Message* msg, const upb_MiniTableField* f) {
3309 return UPB_PTR_AT(msg, UPB_PRIVATE(_upb_MiniTableField_OneofOffset)(f),
3310 uint32_t);
3311 }
3312
UPB_PRIVATE(_upb_Message_GetOneofCase)3313 UPB_INLINE uint32_t UPB_PRIVATE(_upb_Message_GetOneofCase)(
3314 const struct upb_Message* msg, const upb_MiniTableField* f) {
3315 const uint32_t* ptr =
3316 UPB_PRIVATE(_upb_Message_OneofCasePtr)((struct upb_Message*)msg, f);
3317
3318 return *ptr;
3319 }
3320
UPB_PRIVATE(_upb_Message_SetOneofCase)3321 UPB_INLINE void UPB_PRIVATE(_upb_Message_SetOneofCase)(
3322 struct upb_Message* msg, const upb_MiniTableField* f) {
3323 uint32_t* ptr = UPB_PRIVATE(_upb_Message_OneofCasePtr)(msg, f);
3324
3325 *ptr = upb_MiniTableField_Number(f);
3326 }
3327
3328 // Returns true if the given field is the current oneof case.
3329 // Does nothing if it is not the current oneof case.
UPB_PRIVATE(_upb_Message_ClearOneofCase)3330 UPB_INLINE bool UPB_PRIVATE(_upb_Message_ClearOneofCase)(
3331 struct upb_Message* msg, const upb_MiniTableField* f) {
3332 uint32_t* ptr = UPB_PRIVATE(_upb_Message_OneofCasePtr)(msg, f);
3333
3334 if (*ptr != upb_MiniTableField_Number(f)) return false;
3335 *ptr = 0;
3336 return true;
3337 }
3338
upb_Message_WhichOneofFieldNumber(const struct upb_Message * message,const upb_MiniTableField * oneof_field)3339 UPB_API_INLINE uint32_t upb_Message_WhichOneofFieldNumber(
3340 const struct upb_Message* message, const upb_MiniTableField* oneof_field) {
3341 UPB_ASSUME(upb_MiniTableField_IsInOneof(oneof_field));
3342 return UPB_PRIVATE(_upb_Message_GetOneofCase)(message, oneof_field);
3343 }
3344
upb_Message_WhichOneof(const struct upb_Message * msg,const upb_MiniTable * m,const upb_MiniTableField * f)3345 UPB_API_INLINE const upb_MiniTableField* upb_Message_WhichOneof(
3346 const struct upb_Message* msg, const upb_MiniTable* m,
3347 const upb_MiniTableField* f) {
3348 uint32_t field_number = upb_Message_WhichOneofFieldNumber(msg, f);
3349 if (field_number == 0) {
3350 // No field in the oneof is set.
3351 return NULL;
3352 }
3353 return upb_MiniTable_FindFieldByNumber(m, field_number);
3354 }
3355
3356 // LINT.ThenChange(GoogleInternalName2)
3357
3358 // Returns false if the message is missing any of its required fields.
UPB_PRIVATE(_upb_Message_IsInitializedShallow)3359 UPB_INLINE bool UPB_PRIVATE(_upb_Message_IsInitializedShallow)(
3360 const struct upb_Message* msg, const upb_MiniTable* m) {
3361 uint64_t bits;
3362 memcpy(&bits, msg + 1, sizeof(bits));
3363 bits = upb_BigEndian64(bits);
3364 return (UPB_PRIVATE(_upb_MiniTable_RequiredMask)(m) & ~bits) == 0;
3365 }
3366
UPB_PRIVATE(_upb_Message_MutableDataPtr)3367 UPB_INLINE void* UPB_PRIVATE(_upb_Message_MutableDataPtr)(
3368 struct upb_Message* msg, const upb_MiniTableField* f) {
3369 return (char*)msg + f->UPB_ONLYBITS(offset);
3370 }
3371
UPB_PRIVATE(_upb_Message_DataPtr)3372 UPB_INLINE const void* UPB_PRIVATE(_upb_Message_DataPtr)(
3373 const struct upb_Message* msg, const upb_MiniTableField* f) {
3374 return (const char*)msg + f->UPB_ONLYBITS(offset);
3375 }
3376
UPB_PRIVATE(_upb_Message_SetPresence)3377 UPB_INLINE void UPB_PRIVATE(_upb_Message_SetPresence)(
3378 struct upb_Message* msg, const upb_MiniTableField* f) {
3379 if (UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f)) {
3380 UPB_PRIVATE(_upb_Message_SetHasbit)(msg, f);
3381 } else if (upb_MiniTableField_IsInOneof(f)) {
3382 UPB_PRIVATE(_upb_Message_SetOneofCase)(msg, f);
3383 }
3384 }
3385
UPB_PRIVATE(_upb_MiniTableField_DataCopy)3386 UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_DataCopy)(
3387 const upb_MiniTableField* f, void* to, const void* from) {
3388 switch (UPB_PRIVATE(_upb_MiniTableField_GetRep)(f)) {
3389 case kUpb_FieldRep_1Byte:
3390 memcpy(to, from, 1);
3391 return;
3392 case kUpb_FieldRep_4Byte:
3393 memcpy(to, from, 4);
3394 return;
3395 case kUpb_FieldRep_8Byte:
3396 memcpy(to, from, 8);
3397 return;
3398 case kUpb_FieldRep_StringView: {
3399 memcpy(to, from, sizeof(upb_StringView));
3400 return;
3401 }
3402 }
3403 UPB_UNREACHABLE();
3404 }
3405
UPB_PRIVATE(_upb_MiniTableField_DataEquals)3406 UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_DataEquals)(
3407 const upb_MiniTableField* f, const void* a, const void* b) {
3408 switch (UPB_PRIVATE(_upb_MiniTableField_GetRep)(f)) {
3409 case kUpb_FieldRep_1Byte:
3410 return memcmp(a, b, 1) == 0;
3411 case kUpb_FieldRep_4Byte:
3412 return memcmp(a, b, 4) == 0;
3413 case kUpb_FieldRep_8Byte:
3414 return memcmp(a, b, 8) == 0;
3415 case kUpb_FieldRep_StringView: {
3416 const upb_StringView sa = *(const upb_StringView*)a;
3417 const upb_StringView sb = *(const upb_StringView*)b;
3418 return upb_StringView_IsEqual(sa, sb);
3419 }
3420 }
3421 UPB_UNREACHABLE();
3422 }
3423
UPB_PRIVATE(_upb_MiniTableField_DataClear)3424 UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_DataClear)(
3425 const upb_MiniTableField* f, void* val) {
3426 const char zero[16] = {0};
3427 UPB_PRIVATE(_upb_MiniTableField_DataCopy)(f, val, zero);
3428 }
3429
UPB_PRIVATE(_upb_MiniTableField_DataIsZero)3430 UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_DataIsZero)(
3431 const upb_MiniTableField* f, const void* val) {
3432 const char zero[16] = {0};
3433 return UPB_PRIVATE(_upb_MiniTableField_DataEquals)(f, val, zero);
3434 }
3435
3436 // Here we define universal getter/setter functions for message fields.
3437 // These look very branchy and inefficient, but as long as the MiniTableField
3438 // values are known at compile time, all the branches are optimized away and
3439 // we are left with ideal code. This can happen either through through
3440 // literals or UPB_ASSUME():
3441 //
3442 // // Via struct literals.
3443 // bool FooMessage_set_bool_field(const upb_Message* msg, bool val) {
3444 // const upb_MiniTableField field = {1, 0, 0, /* etc... */};
3445 // // All value in "field" are compile-time known.
3446 // upb_Message_SetBaseField(msg, &field, &value);
3447 // }
3448 //
3449 // // Via UPB_ASSUME().
3450 // UPB_INLINE bool upb_Message_SetBool(upb_Message* msg,
3451 // const upb_MiniTableField* field,
3452 // bool value, upb_Arena* a) {
3453 // UPB_ASSUME(field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Bool);
3454 // UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) ==
3455 // kUpb_FieldRep_1Byte);
3456 // upb_Message_SetField(msg, field, &value, a);
3457 // }
3458 //
3459 // As a result, we can use these universal getters/setters for *all* message
3460 // accessors: generated code, MiniTable accessors, and reflection. The only
3461 // exception is the binary encoder/decoder, which need to be a bit more clever
3462 // about how they read/write the message data, for efficiency.
3463 //
3464 // These functions work on both extensions and non-extensions. If the field
3465 // of a setter is known to be a non-extension, the arena may be NULL and the
3466 // returned bool value may be ignored since it will always succeed.
3467
upb_Message_HasBaseField(const struct upb_Message * msg,const upb_MiniTableField * field)3468 UPB_API_INLINE bool upb_Message_HasBaseField(const struct upb_Message* msg,
3469 const upb_MiniTableField* field) {
3470 UPB_ASSERT(upb_MiniTableField_HasPresence(field));
3471 UPB_ASSUME(!upb_MiniTableField_IsExtension(field));
3472 if (upb_MiniTableField_IsInOneof(field)) {
3473 return UPB_PRIVATE(_upb_Message_GetOneofCase)(msg, field) ==
3474 upb_MiniTableField_Number(field);
3475 } else {
3476 return UPB_PRIVATE(_upb_Message_GetHasbit)(msg, field);
3477 }
3478 }
3479
upb_Message_HasExtension(const struct upb_Message * msg,const upb_MiniTableExtension * e)3480 UPB_API_INLINE bool upb_Message_HasExtension(const struct upb_Message* msg,
3481 const upb_MiniTableExtension* e) {
3482 UPB_ASSERT(upb_MiniTableField_HasPresence(&e->UPB_PRIVATE(field)));
3483 return UPB_PRIVATE(_upb_Message_Getext)(msg, e) != NULL;
3484 }
3485
_upb_Message_GetNonExtensionField(const struct upb_Message * msg,const upb_MiniTableField * field,const void * default_val,void * val)3486 UPB_FORCEINLINE void _upb_Message_GetNonExtensionField(
3487 const struct upb_Message* msg, const upb_MiniTableField* field,
3488 const void* default_val, void* val) {
3489 UPB_ASSUME(!upb_MiniTableField_IsExtension(field));
3490 if ((upb_MiniTableField_IsInOneof(field) ||
3491 !UPB_PRIVATE(_upb_MiniTableField_DataIsZero)(field, default_val)) &&
3492 !upb_Message_HasBaseField(msg, field)) {
3493 UPB_PRIVATE(_upb_MiniTableField_DataCopy)(field, val, default_val);
3494 return;
3495 }
3496 UPB_PRIVATE(_upb_MiniTableField_DataCopy)
3497 (field, val, UPB_PRIVATE(_upb_Message_DataPtr)(msg, field));
3498 }
3499
_upb_Message_GetExtensionField(const struct upb_Message * msg,const upb_MiniTableExtension * mt_ext,const void * default_val,void * val)3500 UPB_INLINE void _upb_Message_GetExtensionField(
3501 const struct upb_Message* msg, const upb_MiniTableExtension* mt_ext,
3502 const void* default_val, void* val) {
3503 const upb_Extension* ext = UPB_PRIVATE(_upb_Message_Getext)(msg, mt_ext);
3504 const upb_MiniTableField* f = &mt_ext->UPB_PRIVATE(field);
3505 UPB_ASSUME(upb_MiniTableField_IsExtension(f));
3506
3507 if (ext) {
3508 UPB_PRIVATE(_upb_MiniTableField_DataCopy)(f, val, &ext->data);
3509 } else {
3510 UPB_PRIVATE(_upb_MiniTableField_DataCopy)(f, val, default_val);
3511 }
3512 }
3513
3514 // NOTE: The default_val is only used for fields that support presence.
3515 // For repeated/map fields, the resulting upb_Array*/upb_Map* can be NULL if a
3516 // upb_Array/upb_Map has not been allocated yet. Array/map fields do not have
3517 // presence, so this is semantically identical to a pointer to an empty
3518 // array/map, and must be treated the same for all semantic purposes.
upb_Message_GetField(const struct upb_Message * msg,const upb_MiniTableField * field,upb_MessageValue default_val)3519 UPB_API_INLINE upb_MessageValue upb_Message_GetField(
3520 const struct upb_Message* msg, const upb_MiniTableField* field,
3521 upb_MessageValue default_val) {
3522 upb_MessageValue ret;
3523 if (upb_MiniTableField_IsExtension(field)) {
3524 _upb_Message_GetExtensionField(msg, (upb_MiniTableExtension*)field,
3525 &default_val, &ret);
3526 } else {
3527 _upb_Message_GetNonExtensionField(msg, field, &default_val, &ret);
3528 }
3529 return ret;
3530 }
3531
upb_Message_SetBaseField(struct upb_Message * msg,const upb_MiniTableField * f,const void * val)3532 UPB_API_INLINE void upb_Message_SetBaseField(struct upb_Message* msg,
3533 const upb_MiniTableField* f,
3534 const void* val) {
3535 UPB_ASSERT(!upb_Message_IsFrozen(msg));
3536 UPB_ASSUME(!upb_MiniTableField_IsExtension(f));
3537 UPB_PRIVATE(_upb_Message_SetPresence)(msg, f);
3538 UPB_PRIVATE(_upb_MiniTableField_DataCopy)
3539 (f, UPB_PRIVATE(_upb_Message_MutableDataPtr)(msg, f), val);
3540 }
3541
upb_Message_SetExtension(struct upb_Message * msg,const upb_MiniTableExtension * e,const void * val,upb_Arena * a)3542 UPB_API_INLINE bool upb_Message_SetExtension(struct upb_Message* msg,
3543 const upb_MiniTableExtension* e,
3544 const void* val, upb_Arena* a) {
3545 UPB_ASSERT(!upb_Message_IsFrozen(msg));
3546 UPB_ASSERT(a);
3547 upb_Extension* ext =
3548 UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(msg, e, a);
3549 if (!ext) return false;
3550 UPB_PRIVATE(_upb_MiniTableField_DataCopy)
3551 (&e->UPB_PRIVATE(field), &ext->data, val);
3552 return true;
3553 }
3554
3555 // Sets the value of the given field in the given msg. The return value is true
3556 // if the operation completed successfully, or false if memory allocation
3557 // failed.
UPB_PRIVATE(_upb_Message_SetField)3558 UPB_INLINE bool UPB_PRIVATE(_upb_Message_SetField)(struct upb_Message* msg,
3559 const upb_MiniTableField* f,
3560 upb_MessageValue val,
3561 upb_Arena* a) {
3562 if (upb_MiniTableField_IsExtension(f)) {
3563 const upb_MiniTableExtension* ext = (const upb_MiniTableExtension*)f;
3564 return upb_Message_SetExtension(msg, ext, &val, a);
3565 } else {
3566 upb_Message_SetBaseField(msg, f, &val);
3567 return true;
3568 }
3569 }
3570
upb_Message_GetArray(const struct upb_Message * msg,const upb_MiniTableField * f)3571 UPB_API_INLINE const upb_Array* upb_Message_GetArray(
3572 const struct upb_Message* msg, const upb_MiniTableField* f) {
3573 UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(f);
3574 upb_Array* ret;
3575 const upb_Array* default_val = NULL;
3576 _upb_Message_GetNonExtensionField(msg, f, &default_val, &ret);
3577 return ret;
3578 }
3579
upb_Message_GetBool(const struct upb_Message * msg,const upb_MiniTableField * f,bool default_val)3580 UPB_API_INLINE bool upb_Message_GetBool(const struct upb_Message* msg,
3581 const upb_MiniTableField* f,
3582 bool default_val) {
3583 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Bool);
3584 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3585 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_1Byte);
3586 upb_MessageValue def;
3587 def.bool_val = default_val;
3588 return upb_Message_GetField(msg, f, def).bool_val;
3589 }
3590
upb_Message_GetDouble(const struct upb_Message * msg,const upb_MiniTableField * f,double default_val)3591 UPB_API_INLINE double upb_Message_GetDouble(const struct upb_Message* msg,
3592 const upb_MiniTableField* f,
3593 double default_val) {
3594 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Double);
3595 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3596 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte);
3597
3598 upb_MessageValue def;
3599 def.double_val = default_val;
3600 return upb_Message_GetField(msg, f, def).double_val;
3601 }
3602
upb_Message_GetFloat(const struct upb_Message * msg,const upb_MiniTableField * f,float default_val)3603 UPB_API_INLINE float upb_Message_GetFloat(const struct upb_Message* msg,
3604 const upb_MiniTableField* f,
3605 float default_val) {
3606 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Float);
3607 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3608 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte);
3609
3610 upb_MessageValue def;
3611 def.float_val = default_val;
3612 return upb_Message_GetField(msg, f, def).float_val;
3613 }
3614
upb_Message_GetInt32(const struct upb_Message * msg,const upb_MiniTableField * f,int32_t default_val)3615 UPB_API_INLINE int32_t upb_Message_GetInt32(const struct upb_Message* msg,
3616 const upb_MiniTableField* f,
3617 int32_t default_val) {
3618 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Int32 ||
3619 upb_MiniTableField_CType(f) == kUpb_CType_Enum);
3620 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3621 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte);
3622
3623 upb_MessageValue def;
3624 def.int32_val = default_val;
3625 return upb_Message_GetField(msg, f, def).int32_val;
3626 }
3627
upb_Message_GetInt64(const struct upb_Message * msg,const upb_MiniTableField * f,int64_t default_val)3628 UPB_API_INLINE int64_t upb_Message_GetInt64(const struct upb_Message* msg,
3629 const upb_MiniTableField* f,
3630 int64_t default_val) {
3631 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Int64);
3632 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3633 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte);
3634
3635 upb_MessageValue def;
3636 def.int64_val = default_val;
3637 return upb_Message_GetField(msg, f, def).int64_val;
3638 }
3639
UPB_PRIVATE(_upb_Message_AssertMapIsUntagged)3640 UPB_INLINE void UPB_PRIVATE(_upb_Message_AssertMapIsUntagged)(
3641 const struct upb_Message* msg, const upb_MiniTableField* field) {
3642 UPB_UNUSED(msg);
3643 UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(field);
3644 #ifndef NDEBUG
3645 uintptr_t default_val = 0;
3646 uintptr_t tagged;
3647 _upb_Message_GetNonExtensionField(msg, field, &default_val, &tagged);
3648 UPB_ASSERT(!upb_TaggedMessagePtr_IsEmpty(tagged));
3649 #endif
3650 }
3651
upb_Message_GetMap(const struct upb_Message * msg,const upb_MiniTableField * f)3652 UPB_API_INLINE const struct upb_Map* upb_Message_GetMap(
3653 const struct upb_Message* msg, const upb_MiniTableField* f) {
3654 UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(f);
3655 UPB_PRIVATE(_upb_Message_AssertMapIsUntagged)(msg, f);
3656 struct upb_Map* ret;
3657 const struct upb_Map* default_val = NULL;
3658 _upb_Message_GetNonExtensionField(msg, f, &default_val, &ret);
3659 return ret;
3660 }
3661
upb_Message_GetTaggedMessagePtr(const struct upb_Message * msg,const upb_MiniTableField * f,struct upb_Message * default_val)3662 UPB_API_INLINE uintptr_t upb_Message_GetTaggedMessagePtr(
3663 const struct upb_Message* msg, const upb_MiniTableField* f,
3664 struct upb_Message* default_val) {
3665 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
3666 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
3667 UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
3668 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3669 uintptr_t tagged;
3670 _upb_Message_GetNonExtensionField(msg, f, &default_val, &tagged);
3671 return tagged;
3672 }
3673
3674 // For internal use only; users cannot set tagged messages because only the
3675 // parser and the message copier are allowed to directly create an empty
3676 // message.
UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)3677 UPB_INLINE void UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)(
3678 struct upb_Message* msg, const upb_MiniTableField* f,
3679 uintptr_t sub_message) {
3680 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
3681 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
3682 UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
3683 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3684 upb_Message_SetBaseField(msg, f, &sub_message);
3685 }
3686
upb_Message_GetMessage(const struct upb_Message * msg,const upb_MiniTableField * f)3687 UPB_API_INLINE const struct upb_Message* upb_Message_GetMessage(
3688 const struct upb_Message* msg, const upb_MiniTableField* f) {
3689 uintptr_t tagged = upb_Message_GetTaggedMessagePtr(msg, f, NULL);
3690 return upb_TaggedMessagePtr_GetNonEmptyMessage(tagged);
3691 }
3692
upb_Message_GetMutableArray(struct upb_Message * msg,const upb_MiniTableField * f)3693 UPB_API_INLINE upb_Array* upb_Message_GetMutableArray(
3694 struct upb_Message* msg, const upb_MiniTableField* f) {
3695 UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(f);
3696 return (upb_Array*)upb_Message_GetArray(msg, f);
3697 }
3698
upb_Message_GetMutableMap(struct upb_Message * msg,const upb_MiniTableField * f)3699 UPB_API_INLINE struct upb_Map* upb_Message_GetMutableMap(
3700 struct upb_Message* msg, const upb_MiniTableField* f) {
3701 return (struct upb_Map*)upb_Message_GetMap(msg, f);
3702 }
3703
upb_Message_GetMutableMessage(struct upb_Message * msg,const upb_MiniTableField * f)3704 UPB_API_INLINE struct upb_Message* upb_Message_GetMutableMessage(
3705 struct upb_Message* msg, const upb_MiniTableField* f) {
3706 return (struct upb_Message*)upb_Message_GetMessage(msg, f);
3707 }
3708
upb_Message_GetOrCreateMutableArray(struct upb_Message * msg,const upb_MiniTableField * f,upb_Arena * arena)3709 UPB_API_INLINE upb_Array* upb_Message_GetOrCreateMutableArray(
3710 struct upb_Message* msg, const upb_MiniTableField* f, upb_Arena* arena) {
3711 UPB_ASSERT(arena);
3712 UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(f);
3713 upb_Array* array = upb_Message_GetMutableArray(msg, f);
3714 if (!array) {
3715 array = UPB_PRIVATE(_upb_Array_New)(
3716 arena, 4, UPB_PRIVATE(_upb_MiniTableField_ElemSizeLg2)(f));
3717 // Check again due to: https://godbolt.org/z/7WfaoKG1r
3718 UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(f);
3719 upb_MessageValue val;
3720 val.array_val = array;
3721 UPB_PRIVATE(_upb_Message_SetField)(msg, f, val, arena);
3722 }
3723 return array;
3724 }
3725
_upb_Message_GetOrCreateMutableMap(struct upb_Message * msg,const upb_MiniTableField * field,size_t key_size,size_t val_size,upb_Arena * arena)3726 UPB_INLINE struct upb_Map* _upb_Message_GetOrCreateMutableMap(
3727 struct upb_Message* msg, const upb_MiniTableField* field, size_t key_size,
3728 size_t val_size, upb_Arena* arena) {
3729 UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(field);
3730 UPB_PRIVATE(_upb_Message_AssertMapIsUntagged)(msg, field);
3731 struct upb_Map* map = NULL;
3732 struct upb_Map* default_map_value = NULL;
3733 _upb_Message_GetNonExtensionField(msg, field, &default_map_value, &map);
3734 if (!map) {
3735 map = _upb_Map_New(arena, key_size, val_size);
3736 // Check again due to: https://godbolt.org/z/7WfaoKG1r
3737 UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(field);
3738 upb_Message_SetBaseField(msg, field, &map);
3739 }
3740 return map;
3741 }
3742
upb_Message_GetOrCreateMutableMap(struct upb_Message * msg,const upb_MiniTable * map_entry_mini_table,const upb_MiniTableField * f,upb_Arena * arena)3743 UPB_API_INLINE struct upb_Map* upb_Message_GetOrCreateMutableMap(
3744 struct upb_Message* msg, const upb_MiniTable* map_entry_mini_table,
3745 const upb_MiniTableField* f, upb_Arena* arena) {
3746 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
3747 const upb_MiniTableField* map_entry_key_field =
3748 &map_entry_mini_table->UPB_ONLYBITS(fields)[0];
3749 const upb_MiniTableField* map_entry_value_field =
3750 &map_entry_mini_table->UPB_ONLYBITS(fields)[1];
3751 return _upb_Message_GetOrCreateMutableMap(
3752 msg, f, _upb_Map_CTypeSize(upb_MiniTableField_CType(map_entry_key_field)),
3753 _upb_Map_CTypeSize(upb_MiniTableField_CType(map_entry_value_field)),
3754 arena);
3755 }
3756
upb_Message_GetOrCreateMutableMessage(struct upb_Message * msg,const upb_MiniTable * mini_table,const upb_MiniTableField * f,upb_Arena * arena)3757 UPB_API_INLINE struct upb_Message* upb_Message_GetOrCreateMutableMessage(
3758 struct upb_Message* msg, const upb_MiniTable* mini_table,
3759 const upb_MiniTableField* f, upb_Arena* arena) {
3760 UPB_ASSERT(arena);
3761 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
3762 UPB_ASSUME(!upb_MiniTableField_IsExtension(f));
3763 struct upb_Message* sub_message =
3764 *UPB_PTR_AT(msg, f->UPB_ONLYBITS(offset), struct upb_Message*);
3765 if (!sub_message) {
3766 const upb_MiniTable* sub_mini_table =
3767 upb_MiniTable_SubMessage(mini_table, f);
3768 UPB_ASSERT(sub_mini_table);
3769 sub_message = _upb_Message_New(sub_mini_table, arena);
3770 *UPB_PTR_AT(msg, f->UPB_ONLYBITS(offset), struct upb_Message*) =
3771 sub_message;
3772 UPB_PRIVATE(_upb_Message_SetPresence)(msg, f);
3773 }
3774 return sub_message;
3775 }
3776
3777 UPB_API_INLINE upb_StringView
upb_Message_GetString(const struct upb_Message * msg,const upb_MiniTableField * f,upb_StringView default_val)3778 upb_Message_GetString(const struct upb_Message* msg,
3779 const upb_MiniTableField* f, upb_StringView default_val) {
3780 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_String ||
3781 upb_MiniTableField_CType(f) == kUpb_CType_Bytes);
3782 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
3783 kUpb_FieldRep_StringView);
3784
3785 upb_MessageValue def;
3786 def.str_val = default_val;
3787 return upb_Message_GetField(msg, f, def).str_val;
3788 }
3789
upb_Message_GetUInt32(const struct upb_Message * msg,const upb_MiniTableField * f,uint32_t default_val)3790 UPB_API_INLINE uint32_t upb_Message_GetUInt32(const struct upb_Message* msg,
3791 const upb_MiniTableField* f,
3792 uint32_t default_val) {
3793 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_UInt32);
3794 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3795 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte);
3796
3797 upb_MessageValue def;
3798 def.uint32_val = default_val;
3799 return upb_Message_GetField(msg, f, def).uint32_val;
3800 }
3801
upb_Message_GetUInt64(const struct upb_Message * msg,const upb_MiniTableField * f,uint64_t default_val)3802 UPB_API_INLINE uint64_t upb_Message_GetUInt64(const struct upb_Message* msg,
3803 const upb_MiniTableField* f,
3804 uint64_t default_val) {
3805 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_UInt64);
3806 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3807 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte);
3808
3809 upb_MessageValue def;
3810 def.uint64_val = default_val;
3811 return upb_Message_GetField(msg, f, def).uint64_val;
3812 }
3813
3814 // BaseField Setters ///////////////////////////////////////////////////////////
3815
upb_Message_SetBaseFieldBool(struct upb_Message * msg,const upb_MiniTableField * f,bool value)3816 UPB_API_INLINE void upb_Message_SetBaseFieldBool(struct upb_Message* msg,
3817 const upb_MiniTableField* f,
3818 bool value) {
3819 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Bool);
3820 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3821 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_1Byte);
3822 upb_Message_SetBaseField(msg, f, &value);
3823 }
3824
upb_Message_SetBaseFieldDouble(struct upb_Message * msg,const upb_MiniTableField * f,double value)3825 UPB_API_INLINE void upb_Message_SetBaseFieldDouble(struct upb_Message* msg,
3826 const upb_MiniTableField* f,
3827 double value) {
3828 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Double);
3829 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3830 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte);
3831 upb_Message_SetBaseField(msg, f, &value);
3832 }
3833
upb_Message_SetBaseFieldFloat(struct upb_Message * msg,const upb_MiniTableField * f,float value)3834 UPB_API_INLINE void upb_Message_SetBaseFieldFloat(struct upb_Message* msg,
3835 const upb_MiniTableField* f,
3836 float value) {
3837 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Float);
3838 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3839 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte);
3840 upb_Message_SetBaseField(msg, f, &value);
3841 }
3842
upb_Message_SetBaseFieldInt32(struct upb_Message * msg,const upb_MiniTableField * f,int32_t value)3843 UPB_API_INLINE void upb_Message_SetBaseFieldInt32(struct upb_Message* msg,
3844 const upb_MiniTableField* f,
3845 int32_t value) {
3846 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Int32 ||
3847 upb_MiniTableField_CType(f) == kUpb_CType_Enum);
3848 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3849 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte);
3850 upb_Message_SetBaseField(msg, f, &value);
3851 }
3852
upb_Message_SetBaseFieldInt64(struct upb_Message * msg,const upb_MiniTableField * f,int64_t value)3853 UPB_API_INLINE void upb_Message_SetBaseFieldInt64(struct upb_Message* msg,
3854 const upb_MiniTableField* f,
3855 int64_t value) {
3856 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Int64);
3857 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3858 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte);
3859 upb_Message_SetBaseField(msg, f, &value);
3860 }
3861
upb_Message_SetBaseFieldMessage(struct upb_Message * msg,const upb_MiniTableField * f,struct upb_Message * value)3862 UPB_API_INLINE void upb_Message_SetBaseFieldMessage(struct upb_Message* msg,
3863 const upb_MiniTableField* f,
3864 struct upb_Message* value) {
3865 UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)
3866 (msg, f, UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(value, false));
3867 }
3868
upb_Message_SetBaseFieldString(struct upb_Message * msg,const upb_MiniTableField * f,upb_StringView value)3869 UPB_API_INLINE void upb_Message_SetBaseFieldString(struct upb_Message* msg,
3870 const upb_MiniTableField* f,
3871 upb_StringView value) {
3872 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_String ||
3873 upb_MiniTableField_CType(f) == kUpb_CType_Bytes);
3874 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3875 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
3876 kUpb_FieldRep_StringView);
3877 upb_Message_SetBaseField(msg, f, &value);
3878 }
3879
upb_Message_SetBaseFieldUInt32(struct upb_Message * msg,const upb_MiniTableField * f,uint32_t value)3880 UPB_API_INLINE void upb_Message_SetBaseFieldUInt32(struct upb_Message* msg,
3881 const upb_MiniTableField* f,
3882 uint32_t value) {
3883 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_UInt32);
3884 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3885 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte);
3886 upb_Message_SetBaseField(msg, f, &value);
3887 }
3888
upb_Message_SetBaseFieldUInt64(struct upb_Message * msg,const upb_MiniTableField * f,uint64_t value)3889 UPB_API_INLINE void upb_Message_SetBaseFieldUInt64(struct upb_Message* msg,
3890 const upb_MiniTableField* f,
3891 uint64_t value) {
3892 UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_UInt64);
3893 UPB_ASSUME(upb_MiniTableField_IsScalar(f));
3894 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte);
3895 upb_Message_SetBaseField(msg, f, &value);
3896 }
3897
upb_Message_SetClosedEnum(struct upb_Message * msg,const upb_MiniTable * m,const upb_MiniTableField * f,int32_t value)3898 UPB_API_INLINE void upb_Message_SetClosedEnum(struct upb_Message* msg,
3899 const upb_MiniTable* m,
3900 const upb_MiniTableField* f,
3901 int32_t value) {
3902 UPB_ASSERT(upb_MiniTableField_IsClosedEnum(f));
3903 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte);
3904 UPB_ASSERT(
3905 upb_MiniTableEnum_CheckValue(upb_MiniTable_GetSubEnumTable(m, f), value));
3906 upb_Message_SetBaseField(msg, f, &value);
3907 }
3908
3909 // Extension Setters ///////////////////////////////////////////////////////////
3910
upb_Message_SetExtensionBool(struct upb_Message * msg,const upb_MiniTableExtension * e,bool value,upb_Arena * a)3911 UPB_API_INLINE bool upb_Message_SetExtensionBool(
3912 struct upb_Message* msg, const upb_MiniTableExtension* e, bool value,
3913 upb_Arena* a) {
3914 UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Bool);
3915 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) ==
3916 kUpb_FieldRep_1Byte);
3917 return upb_Message_SetExtension(msg, e, &value, a);
3918 }
3919
upb_Message_SetExtensionDouble(struct upb_Message * msg,const upb_MiniTableExtension * e,double value,upb_Arena * a)3920 UPB_API_INLINE bool upb_Message_SetExtensionDouble(
3921 struct upb_Message* msg, const upb_MiniTableExtension* e, double value,
3922 upb_Arena* a) {
3923 UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Double);
3924 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) ==
3925 kUpb_FieldRep_8Byte);
3926 return upb_Message_SetExtension(msg, e, &value, a);
3927 }
3928
upb_Message_SetExtensionFloat(struct upb_Message * msg,const upb_MiniTableExtension * e,float value,upb_Arena * a)3929 UPB_API_INLINE bool upb_Message_SetExtensionFloat(
3930 struct upb_Message* msg, const upb_MiniTableExtension* e, float value,
3931 upb_Arena* a) {
3932 UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Float);
3933 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) ==
3934 kUpb_FieldRep_4Byte);
3935 return upb_Message_SetExtension(msg, e, &value, a);
3936 }
3937
upb_Message_SetExtensionInt32(struct upb_Message * msg,const upb_MiniTableExtension * e,int32_t value,upb_Arena * a)3938 UPB_API_INLINE bool upb_Message_SetExtensionInt32(
3939 struct upb_Message* msg, const upb_MiniTableExtension* e, int32_t value,
3940 upb_Arena* a) {
3941 UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Int32 ||
3942 upb_MiniTableExtension_CType(e) == kUpb_CType_Enum);
3943 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) ==
3944 kUpb_FieldRep_4Byte);
3945 return upb_Message_SetExtension(msg, e, &value, a);
3946 }
3947
upb_Message_SetExtensionInt64(struct upb_Message * msg,const upb_MiniTableExtension * e,int64_t value,upb_Arena * a)3948 UPB_API_INLINE bool upb_Message_SetExtensionInt64(
3949 struct upb_Message* msg, const upb_MiniTableExtension* e, int64_t value,
3950 upb_Arena* a) {
3951 UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Int64);
3952 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) ==
3953 kUpb_FieldRep_8Byte);
3954 return upb_Message_SetExtension(msg, e, &value, a);
3955 }
3956
upb_Message_SetExtensionString(struct upb_Message * msg,const upb_MiniTableExtension * e,upb_StringView value,upb_Arena * a)3957 UPB_API_INLINE bool upb_Message_SetExtensionString(
3958 struct upb_Message* msg, const upb_MiniTableExtension* e,
3959 upb_StringView value, upb_Arena* a) {
3960 UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_String ||
3961 upb_MiniTableExtension_CType(e) == kUpb_CType_Bytes);
3962 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) ==
3963 kUpb_FieldRep_StringView);
3964 return upb_Message_SetExtension(msg, e, &value, a);
3965 }
3966
upb_Message_SetExtensionUInt32(struct upb_Message * msg,const upb_MiniTableExtension * e,uint32_t value,upb_Arena * a)3967 UPB_API_INLINE bool upb_Message_SetExtensionUInt32(
3968 struct upb_Message* msg, const upb_MiniTableExtension* e, uint32_t value,
3969 upb_Arena* a) {
3970 UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_UInt32);
3971 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) ==
3972 kUpb_FieldRep_4Byte);
3973 return upb_Message_SetExtension(msg, e, &value, a);
3974 }
3975
upb_Message_SetExtensionUInt64(struct upb_Message * msg,const upb_MiniTableExtension * e,uint64_t value,upb_Arena * a)3976 UPB_API_INLINE bool upb_Message_SetExtensionUInt64(
3977 struct upb_Message* msg, const upb_MiniTableExtension* e, uint64_t value,
3978 upb_Arena* a) {
3979 UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_UInt64);
3980 UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) ==
3981 kUpb_FieldRep_8Byte);
3982 return upb_Message_SetExtension(msg, e, &value, a);
3983 }
3984
3985 // Universal Setters ///////////////////////////////////////////////////////////
3986
upb_Message_SetBool(struct upb_Message * msg,const upb_MiniTableField * f,bool value,upb_Arena * a)3987 UPB_API_INLINE bool upb_Message_SetBool(struct upb_Message* msg,
3988 const upb_MiniTableField* f, bool value,
3989 upb_Arena* a) {
3990 return upb_MiniTableField_IsExtension(f)
3991 ? upb_Message_SetExtensionBool(
3992 msg, (const upb_MiniTableExtension*)f, value, a)
3993 : (upb_Message_SetBaseFieldBool(msg, f, value), true);
3994 }
3995
upb_Message_SetDouble(struct upb_Message * msg,const upb_MiniTableField * f,double value,upb_Arena * a)3996 UPB_API_INLINE bool upb_Message_SetDouble(struct upb_Message* msg,
3997 const upb_MiniTableField* f,
3998 double value, upb_Arena* a) {
3999 return upb_MiniTableField_IsExtension(f)
4000 ? upb_Message_SetExtensionDouble(
4001 msg, (const upb_MiniTableExtension*)f, value, a)
4002 : (upb_Message_SetBaseFieldDouble(msg, f, value), true);
4003 }
4004
upb_Message_SetFloat(struct upb_Message * msg,const upb_MiniTableField * f,float value,upb_Arena * a)4005 UPB_API_INLINE bool upb_Message_SetFloat(struct upb_Message* msg,
4006 const upb_MiniTableField* f,
4007 float value, upb_Arena* a) {
4008 return upb_MiniTableField_IsExtension(f)
4009 ? upb_Message_SetExtensionFloat(
4010 msg, (const upb_MiniTableExtension*)f, value, a)
4011 : (upb_Message_SetBaseFieldFloat(msg, f, value), true);
4012 }
4013
upb_Message_SetInt32(struct upb_Message * msg,const upb_MiniTableField * f,int32_t value,upb_Arena * a)4014 UPB_API_INLINE bool upb_Message_SetInt32(struct upb_Message* msg,
4015 const upb_MiniTableField* f,
4016 int32_t value, upb_Arena* a) {
4017 return upb_MiniTableField_IsExtension(f)
4018 ? upb_Message_SetExtensionInt32(
4019 msg, (const upb_MiniTableExtension*)f, value, a)
4020 : (upb_Message_SetBaseFieldInt32(msg, f, value), true);
4021 }
4022
upb_Message_SetInt64(struct upb_Message * msg,const upb_MiniTableField * f,int64_t value,upb_Arena * a)4023 UPB_API_INLINE bool upb_Message_SetInt64(struct upb_Message* msg,
4024 const upb_MiniTableField* f,
4025 int64_t value, upb_Arena* a) {
4026 return upb_MiniTableField_IsExtension(f)
4027 ? upb_Message_SetExtensionInt64(
4028 msg, (const upb_MiniTableExtension*)f, value, a)
4029 : (upb_Message_SetBaseFieldInt64(msg, f, value), true);
4030 }
4031
4032 // Sets the value of a message-typed field. The mini_tables of `msg` and
4033 // `value` must have been linked for this to work correctly.
upb_Message_SetMessage(struct upb_Message * msg,const upb_MiniTableField * f,struct upb_Message * value)4034 UPB_API_INLINE void upb_Message_SetMessage(struct upb_Message* msg,
4035 const upb_MiniTableField* f,
4036 struct upb_Message* value) {
4037 UPB_ASSERT(!upb_MiniTableField_IsExtension(f));
4038 upb_Message_SetBaseFieldMessage(msg, f, value);
4039 }
4040
4041 // Sets the value of a `string` or `bytes` field. The bytes of the value are not
4042 // copied, so it is the caller's responsibility to ensure that they remain valid
4043 // for the lifetime of `msg`. That might be done by copying them into the given
4044 // arena, or by fusing that arena with the arena the bytes live in, for example.
upb_Message_SetString(struct upb_Message * msg,const upb_MiniTableField * f,upb_StringView value,upb_Arena * a)4045 UPB_API_INLINE bool upb_Message_SetString(struct upb_Message* msg,
4046 const upb_MiniTableField* f,
4047 upb_StringView value, upb_Arena* a) {
4048 return upb_MiniTableField_IsExtension(f)
4049 ? upb_Message_SetExtensionString(
4050 msg, (const upb_MiniTableExtension*)f, value, a)
4051 : (upb_Message_SetBaseFieldString(msg, f, value), true);
4052 }
4053
upb_Message_SetUInt32(struct upb_Message * msg,const upb_MiniTableField * f,uint32_t value,upb_Arena * a)4054 UPB_API_INLINE bool upb_Message_SetUInt32(struct upb_Message* msg,
4055 const upb_MiniTableField* f,
4056 uint32_t value, upb_Arena* a) {
4057 return upb_MiniTableField_IsExtension(f)
4058 ? upb_Message_SetExtensionUInt32(
4059 msg, (const upb_MiniTableExtension*)f, value, a)
4060 : (upb_Message_SetBaseFieldUInt32(msg, f, value), true);
4061 }
4062
upb_Message_SetUInt64(struct upb_Message * msg,const upb_MiniTableField * f,uint64_t value,upb_Arena * a)4063 UPB_API_INLINE bool upb_Message_SetUInt64(struct upb_Message* msg,
4064 const upb_MiniTableField* f,
4065 uint64_t value, upb_Arena* a) {
4066 return upb_MiniTableField_IsExtension(f)
4067 ? upb_Message_SetExtensionUInt64(
4068 msg, (const upb_MiniTableExtension*)f, value, a)
4069 : (upb_Message_SetBaseFieldUInt64(msg, f, value), true);
4070 }
4071
upb_Message_Clear(struct upb_Message * msg,const upb_MiniTable * m)4072 UPB_API_INLINE void upb_Message_Clear(struct upb_Message* msg,
4073 const upb_MiniTable* m) {
4074 UPB_ASSERT(!upb_Message_IsFrozen(msg));
4075 upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
4076 memset(msg, 0, m->UPB_PRIVATE(size));
4077 if (in) {
4078 // Reset the internal buffer to empty.
4079 in->unknown_end = sizeof(upb_Message_Internal);
4080 in->ext_begin = in->size;
4081 UPB_PRIVATE(_upb_Message_SetInternal)(msg, in);
4082 }
4083 }
4084
upb_Message_ClearBaseField(struct upb_Message * msg,const upb_MiniTableField * f)4085 UPB_API_INLINE void upb_Message_ClearBaseField(struct upb_Message* msg,
4086 const upb_MiniTableField* f) {
4087 UPB_ASSERT(!upb_Message_IsFrozen(msg));
4088 if (UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f)) {
4089 UPB_PRIVATE(_upb_Message_ClearHasbit)(msg, f);
4090 } else if (upb_MiniTableField_IsInOneof(f)) {
4091 uint32_t* ptr = UPB_PRIVATE(_upb_Message_OneofCasePtr)(msg, f);
4092 if (*ptr != upb_MiniTableField_Number(f)) return;
4093 *ptr = 0;
4094 }
4095 const char zeros[16] = {0};
4096 UPB_PRIVATE(_upb_MiniTableField_DataCopy)
4097 (f, UPB_PRIVATE(_upb_Message_MutableDataPtr)(msg, f), zeros);
4098 }
4099
upb_Message_ClearExtension(struct upb_Message * msg,const upb_MiniTableExtension * e)4100 UPB_API_INLINE void upb_Message_ClearExtension(
4101 struct upb_Message* msg, const upb_MiniTableExtension* e) {
4102 UPB_ASSERT(!upb_Message_IsFrozen(msg));
4103 upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
4104 if (!in) return;
4105 const upb_Extension* base = UPB_PTR_AT(in, in->ext_begin, upb_Extension);
4106 upb_Extension* ext = (upb_Extension*)UPB_PRIVATE(_upb_Message_Getext)(msg, e);
4107 if (ext) {
4108 *ext = *base;
4109 in->ext_begin += sizeof(upb_Extension);
4110 }
4111 }
4112
upb_Message_ClearOneof(struct upb_Message * msg,const upb_MiniTable * m,const upb_MiniTableField * f)4113 UPB_API_INLINE void upb_Message_ClearOneof(struct upb_Message* msg,
4114 const upb_MiniTable* m,
4115 const upb_MiniTableField* f) {
4116 UPB_ASSERT(!upb_Message_IsFrozen(msg));
4117 uint32_t field_number = upb_Message_WhichOneofFieldNumber(msg, f);
4118 if (field_number == 0) {
4119 // No field in the oneof is set.
4120 return;
4121 }
4122
4123 const upb_MiniTableField* field =
4124 upb_MiniTable_FindFieldByNumber(m, field_number);
4125 upb_Message_ClearBaseField(msg, field);
4126 }
4127
upb_Message_ResizeArrayUninitialized(struct upb_Message * msg,const upb_MiniTableField * f,size_t size,upb_Arena * arena)4128 UPB_API_INLINE void* upb_Message_ResizeArrayUninitialized(
4129 struct upb_Message* msg, const upb_MiniTableField* f, size_t size,
4130 upb_Arena* arena) {
4131 UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(f);
4132 upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, f, arena);
4133 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(arr, size, arena)) {
4134 return NULL;
4135 }
4136 return upb_Array_MutableDataPtr(arr);
4137 }
4138
4139 #ifdef __cplusplus
4140 } /* extern "C" */
4141 #endif
4142
4143 #if defined(__GNUC__) && !defined(__clang__)
4144 #pragma GCC diagnostic pop
4145 #endif
4146
4147
4148 #endif // UPB_MESSAGE_INTERNAL_ACCESSORS_H_
4149
4150 #ifndef UPB_MESSAGE_MAP_H_
4151 #define UPB_MESSAGE_MAP_H_
4152
4153 #include <stddef.h>
4154
4155
4156 // Must be last.
4157
4158 typedef struct upb_Map upb_Map;
4159
4160 #ifdef __cplusplus
4161 extern "C" {
4162 #endif
4163
4164 // Creates a new map on the given arena with the given key/value size.
4165 UPB_API upb_Map* upb_Map_New(upb_Arena* a, upb_CType key_type,
4166 upb_CType value_type);
4167
4168 // Returns the number of entries in the map.
4169 UPB_API size_t upb_Map_Size(const upb_Map* map);
4170
4171 // Stores a value for the given key into |*val| (or the zero value if the key is
4172 // not present). Returns whether the key was present. The |val| pointer may be
4173 // NULL, in which case the function tests whether the given key is present.
4174 UPB_API bool upb_Map_Get(const upb_Map* map, upb_MessageValue key,
4175 upb_MessageValue* val);
4176
4177 // Removes all entries in the map.
4178 UPB_API void upb_Map_Clear(upb_Map* map);
4179
4180 // Sets the given key to the given value, returning whether the key was inserted
4181 // or replaced. If the key was inserted, then any existing iterators will be
4182 // invalidated.
4183 UPB_API upb_MapInsertStatus upb_Map_Insert(upb_Map* map, upb_MessageValue key,
4184 upb_MessageValue val,
4185 upb_Arena* arena);
4186
4187 // Sets the given key to the given value. Returns false if memory allocation
4188 // failed. If the key is newly inserted, then any existing iterators will be
4189 // invalidated.
upb_Map_Set(upb_Map * map,upb_MessageValue key,upb_MessageValue val,upb_Arena * arena)4190 UPB_API_INLINE bool upb_Map_Set(upb_Map* map, upb_MessageValue key,
4191 upb_MessageValue val, upb_Arena* arena) {
4192 return upb_Map_Insert(map, key, val, arena) !=
4193 kUpb_MapInsertStatus_OutOfMemory;
4194 }
4195
4196 // Deletes this key from the table. Returns true if the key was present.
4197 // If present and |val| is non-NULL, stores the deleted value.
4198 UPB_API bool upb_Map_Delete(upb_Map* map, upb_MessageValue key,
4199 upb_MessageValue* val);
4200
4201 // Map iteration:
4202 //
4203 // size_t iter = kUpb_Map_Begin;
4204 // upb_MessageValue key, val;
4205 // while (upb_Map_Next(map, &key, &val, &iter)) {
4206 // ...
4207 // }
4208
4209 #define kUpb_Map_Begin ((size_t) - 1)
4210
4211 // Advances to the next entry. Returns false if no more entries are present.
4212 // Otherwise returns true and populates both *key and *value.
4213 UPB_API bool upb_Map_Next(const upb_Map* map, upb_MessageValue* key,
4214 upb_MessageValue* val, size_t* iter);
4215
4216 // Sets the value for the entry pointed to by iter.
4217 // WARNING: this does not currently work for string values!
4218 UPB_API void upb_Map_SetEntryValue(upb_Map* map, size_t iter,
4219 upb_MessageValue val);
4220
4221 // DEPRECATED iterator, slated for removal.
4222
4223 /* Map iteration:
4224 *
4225 * size_t iter = kUpb_Map_Begin;
4226 * while (upb_MapIterator_Next(map, &iter)) {
4227 * upb_MessageValue key = upb_MapIterator_Key(map, iter);
4228 * upb_MessageValue val = upb_MapIterator_Value(map, iter);
4229 * }
4230 */
4231
4232 // Advances to the next entry. Returns false if no more entries are present.
4233 UPB_API bool upb_MapIterator_Next(const upb_Map* map, size_t* iter);
4234
4235 // Returns true if the iterator still points to a valid entry, or false if the
4236 // iterator is past the last element. It is an error to call this function with
4237 // kUpb_Map_Begin (you must call next() at least once first).
4238 UPB_API bool upb_MapIterator_Done(const upb_Map* map, size_t iter);
4239
4240 // Returns the key and value for this entry of the map.
4241 UPB_API upb_MessageValue upb_MapIterator_Key(const upb_Map* map, size_t iter);
4242 UPB_API upb_MessageValue upb_MapIterator_Value(const upb_Map* map, size_t iter);
4243
4244 // Mark a map and all of its descendents as frozen/immutable.
4245 // If the map values are messages then |m| must point to the minitable for
4246 // those messages. Otherwise |m| must be NULL.
4247 UPB_API void upb_Map_Freeze(upb_Map* map, const upb_MiniTable* m);
4248
4249 // Returns whether a map has been frozen.
4250 UPB_API_INLINE bool upb_Map_IsFrozen(const upb_Map* map);
4251
4252 #ifdef __cplusplus
4253 } /* extern "C" */
4254 #endif
4255
4256
4257 #endif /* UPB_MESSAGE_MAP_H_ */
4258
4259 #ifndef UPB_MINI_TABLE_TAGGED_PTR_H_
4260 #define UPB_MINI_TABLE_TAGGED_PTR_H_
4261
4262 #include <stdint.h>
4263
4264
4265 // Must be last.
4266
4267 // When a upb_Message* is stored in a message, array, or map, it is stored in a
4268 // tagged form. If the tag bit is set, the referenced upb_Message is of type
4269 // _kUpb_MiniTable_Empty (a sentinel message type with no fields) instead of
4270 // that field's true message type. This forms the basis of what we call
4271 // "dynamic tree shaking."
4272 //
4273 // See the documentation for kUpb_DecodeOption_ExperimentalAllowUnlinked for
4274 // more information.
4275
4276 typedef uintptr_t upb_TaggedMessagePtr;
4277
4278 #ifdef __cplusplus
4279 extern "C" {
4280 #endif
4281
4282 // Users who enable unlinked sub-messages must use this to test whether a
4283 // message is empty before accessing it. If a message is empty, it must be
4284 // first promoted using the interfaces in message/promote.h.
4285 UPB_API_INLINE bool upb_TaggedMessagePtr_IsEmpty(upb_TaggedMessagePtr ptr);
4286
4287 UPB_API_INLINE upb_Message* upb_TaggedMessagePtr_GetNonEmptyMessage(
4288 upb_TaggedMessagePtr ptr);
4289
4290 #ifdef __cplusplus
4291 } /* extern "C" */
4292 #endif
4293
4294
4295 #endif /* UPB_MINI_TABLE_TAGGED_PTR_H_ */
4296
4297 // Must be last.
4298
4299 #ifdef __cplusplus
4300 extern "C" {
4301 #endif
4302
4303 // Functions ending in BaseField() take a (upb_MiniTableField*) argument
4304 // and work only on non-extension fields.
4305 //
4306 // Functions ending in Extension() take a (upb_MiniTableExtension*) argument
4307 // and work only on extensions.
4308
4309 UPB_API_INLINE void upb_Message_Clear(upb_Message* msg, const upb_MiniTable* m);
4310
4311 UPB_API_INLINE void upb_Message_ClearBaseField(upb_Message* msg,
4312 const upb_MiniTableField* f);
4313
4314 UPB_API_INLINE void upb_Message_ClearExtension(upb_Message* msg,
4315 const upb_MiniTableExtension* e);
4316
4317 UPB_API_INLINE void upb_Message_ClearOneof(upb_Message* msg,
4318 const upb_MiniTable* m,
4319 const upb_MiniTableField* f);
4320
4321 UPB_API_INLINE bool upb_Message_HasBaseField(const upb_Message* msg,
4322 const upb_MiniTableField* f);
4323
4324 UPB_API_INLINE bool upb_Message_HasExtension(const upb_Message* msg,
4325 const upb_MiniTableExtension* e);
4326
4327 UPB_API_INLINE upb_MessageValue
4328 upb_Message_GetField(const upb_Message* msg, const upb_MiniTableField* f,
4329 upb_MessageValue default_val);
4330
4331 UPB_API_INLINE upb_TaggedMessagePtr upb_Message_GetTaggedMessagePtr(
4332 const upb_Message* msg, const upb_MiniTableField* field,
4333 upb_Message* default_val);
4334
4335 UPB_API_INLINE const upb_Array* upb_Message_GetArray(
4336 const upb_Message* msg, const upb_MiniTableField* f);
4337
4338 UPB_API_INLINE bool upb_Message_GetBool(const upb_Message* msg,
4339 const upb_MiniTableField* f,
4340 bool default_val);
4341
4342 UPB_API_INLINE double upb_Message_GetDouble(const upb_Message* msg,
4343 const upb_MiniTableField* field,
4344 double default_val);
4345
4346 UPB_API_INLINE float upb_Message_GetFloat(const upb_Message* msg,
4347 const upb_MiniTableField* f,
4348 float default_val);
4349
4350 UPB_API_INLINE int32_t upb_Message_GetInt32(const upb_Message* msg,
4351 const upb_MiniTableField* f,
4352 int32_t default_val);
4353
4354 UPB_API_INLINE int64_t upb_Message_GetInt64(const upb_Message* msg,
4355 const upb_MiniTableField* f,
4356 int64_t default_val);
4357
4358 UPB_API_INLINE const upb_Map* upb_Message_GetMap(const upb_Message* msg,
4359 const upb_MiniTableField* f);
4360
4361 UPB_API_INLINE const upb_Message* upb_Message_GetMessage(
4362 const upb_Message* msg, const upb_MiniTableField* f);
4363
4364 UPB_API_INLINE upb_Array* upb_Message_GetMutableArray(
4365 upb_Message* msg, const upb_MiniTableField* f);
4366
4367 UPB_API_INLINE upb_Map* upb_Message_GetMutableMap(upb_Message* msg,
4368 const upb_MiniTableField* f);
4369
4370 UPB_API_INLINE upb_Message* upb_Message_GetMutableMessage(
4371 upb_Message* msg, const upb_MiniTableField* f);
4372
4373 UPB_API_INLINE upb_Array* upb_Message_GetOrCreateMutableArray(
4374 upb_Message* msg, const upb_MiniTableField* f, upb_Arena* arena);
4375
4376 UPB_API_INLINE upb_Map* upb_Message_GetOrCreateMutableMap(
4377 upb_Message* msg, const upb_MiniTable* map_entry_mini_table,
4378 const upb_MiniTableField* f, upb_Arena* arena);
4379
4380 UPB_API_INLINE upb_Message* upb_Message_GetOrCreateMutableMessage(
4381 upb_Message* msg, const upb_MiniTable* mini_table,
4382 const upb_MiniTableField* f, upb_Arena* arena);
4383
4384 UPB_API_INLINE upb_StringView
4385 upb_Message_GetString(const upb_Message* msg, const upb_MiniTableField* field,
4386 upb_StringView default_val);
4387
4388 UPB_API_INLINE uint32_t upb_Message_GetUInt32(const upb_Message* msg,
4389 const upb_MiniTableField* f,
4390 uint32_t default_val);
4391
4392 UPB_API_INLINE uint64_t upb_Message_GetUInt64(const upb_Message* msg,
4393 const upb_MiniTableField* f,
4394 uint64_t default_val);
4395
4396 UPB_API_INLINE void upb_Message_SetClosedEnum(
4397 upb_Message* msg, const upb_MiniTable* msg_mini_table,
4398 const upb_MiniTableField* f, int32_t value);
4399
4400 // BaseField Setters ///////////////////////////////////////////////////////////
4401
4402 UPB_API_INLINE void upb_Message_SetBaseField(upb_Message* msg,
4403 const upb_MiniTableField* f,
4404 const void* val);
4405
4406 UPB_API_INLINE void upb_Message_SetBaseFieldBool(struct upb_Message* msg,
4407 const upb_MiniTableField* f,
4408 bool value);
4409
4410 UPB_API_INLINE void upb_Message_SetBaseFieldDouble(struct upb_Message* msg,
4411 const upb_MiniTableField* f,
4412 double value);
4413
4414 UPB_API_INLINE void upb_Message_SetBaseFieldFloat(struct upb_Message* msg,
4415 const upb_MiniTableField* f,
4416 float value);
4417
4418 UPB_API_INLINE void upb_Message_SetBaseFieldInt32(struct upb_Message* msg,
4419 const upb_MiniTableField* f,
4420 int32_t value);
4421
4422 UPB_API_INLINE void upb_Message_SetBaseFieldInt64(struct upb_Message* msg,
4423 const upb_MiniTableField* f,
4424 int64_t value);
4425
4426 UPB_API_INLINE void upb_Message_SetBaseFieldMessage(struct upb_Message* msg,
4427 const upb_MiniTableField* f,
4428 upb_Message* value);
4429
4430 UPB_API_INLINE void upb_Message_SetBaseFieldString(struct upb_Message* msg,
4431 const upb_MiniTableField* f,
4432 upb_StringView value);
4433
4434 UPB_API_INLINE void upb_Message_SetBaseFieldUInt32(struct upb_Message* msg,
4435 const upb_MiniTableField* f,
4436 uint32_t value);
4437
4438 UPB_API_INLINE void upb_Message_SetBaseFieldUInt64(struct upb_Message* msg,
4439 const upb_MiniTableField* f,
4440 uint64_t value);
4441
4442 // Extension Setters ///////////////////////////////////////////////////////////
4443
4444 UPB_API_INLINE bool upb_Message_SetExtension(upb_Message* msg,
4445 const upb_MiniTableExtension* e,
4446 const void* value, upb_Arena* a);
4447
4448 UPB_API_INLINE bool upb_Message_SetExtensionBool(
4449 struct upb_Message* msg, const upb_MiniTableExtension* e, bool value,
4450 upb_Arena* a);
4451
4452 UPB_API_INLINE bool upb_Message_SetExtensionDouble(
4453 struct upb_Message* msg, const upb_MiniTableExtension* e, double value,
4454 upb_Arena* a);
4455
4456 UPB_API_INLINE bool upb_Message_SetExtensionFloat(
4457 struct upb_Message* msg, const upb_MiniTableExtension* e, float value,
4458 upb_Arena* a);
4459
4460 UPB_API_INLINE bool upb_Message_SetExtensionInt32(
4461 struct upb_Message* msg, const upb_MiniTableExtension* e, int32_t value,
4462 upb_Arena* a);
4463
4464 UPB_API_INLINE bool upb_Message_SetExtensionInt64(
4465 struct upb_Message* msg, const upb_MiniTableExtension* e, int64_t value,
4466 upb_Arena* a);
4467
4468 UPB_API_INLINE bool upb_Message_SetExtensionString(
4469 struct upb_Message* msg, const upb_MiniTableExtension* e,
4470 upb_StringView value, upb_Arena* a);
4471
4472 UPB_API_INLINE bool upb_Message_SetExtensionUInt32(
4473 struct upb_Message* msg, const upb_MiniTableExtension* e, uint32_t value,
4474 upb_Arena* a);
4475
4476 UPB_API_INLINE bool upb_Message_SetExtensionUInt64(
4477 struct upb_Message* msg, const upb_MiniTableExtension* e, uint64_t value,
4478 upb_Arena* a);
4479
4480 // Universal Setters ///////////////////////////////////////////////////////////
4481
4482 UPB_API_INLINE bool upb_Message_SetBool(upb_Message* msg,
4483 const upb_MiniTableField* f, bool value,
4484 upb_Arena* a);
4485
4486 UPB_API_INLINE bool upb_Message_SetDouble(upb_Message* msg,
4487 const upb_MiniTableField* f,
4488 double value, upb_Arena* a);
4489
4490 UPB_API_INLINE bool upb_Message_SetFloat(upb_Message* msg,
4491 const upb_MiniTableField* f,
4492 float value, upb_Arena* a);
4493
4494 UPB_API_INLINE bool upb_Message_SetInt32(upb_Message* msg,
4495 const upb_MiniTableField* f,
4496 int32_t value, upb_Arena* a);
4497
4498 UPB_API_INLINE bool upb_Message_SetInt64(upb_Message* msg,
4499 const upb_MiniTableField* f,
4500 int64_t value, upb_Arena* a);
4501
4502 // Unlike the other similarly-named setters, this function can only be
4503 // called on base fields. Prefer upb_Message_SetBaseFieldMessage().
4504 UPB_API_INLINE void upb_Message_SetMessage(upb_Message* msg,
4505 const upb_MiniTableField* f,
4506 upb_Message* value);
4507
4508 UPB_API_INLINE bool upb_Message_SetString(upb_Message* msg,
4509 const upb_MiniTableField* f,
4510 upb_StringView value, upb_Arena* a);
4511
4512 UPB_API_INLINE bool upb_Message_SetUInt32(upb_Message* msg,
4513 const upb_MiniTableField* f,
4514 uint32_t value, upb_Arena* a);
4515
4516 UPB_API_INLINE bool upb_Message_SetUInt64(upb_Message* msg,
4517 const upb_MiniTableField* f,
4518 uint64_t value, upb_Arena* a);
4519
4520 ////////////////////////////////////////////////////////////////////////////////
4521
4522 UPB_API_INLINE void* upb_Message_ResizeArrayUninitialized(
4523 upb_Message* msg, const upb_MiniTableField* f, size_t size,
4524 upb_Arena* arena);
4525
4526 UPB_API_INLINE uint32_t upb_Message_WhichOneofFieldNumber(
4527 const upb_Message* message, const upb_MiniTableField* oneof_field);
4528
4529 // For a field `f` which is in a oneof, return the field of that
4530 // oneof that is actually set (or NULL if none).
4531 UPB_API_INLINE const upb_MiniTableField* upb_Message_WhichOneof(
4532 const upb_Message* msg, const upb_MiniTable* m,
4533 const upb_MiniTableField* f);
4534
4535 // Updates a map entry given an entry message.
4536 bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* mini_table,
4537 const upb_MiniTableField* field,
4538 upb_Message* map_entry_message, upb_Arena* arena);
4539
4540 #ifdef __cplusplus
4541 } /* extern "C" */
4542 #endif
4543
4544
4545 #endif // UPB_MESSAGE_ACCESSORS_H_
4546
4547 // These functions are only used by generated code.
4548
4549 #ifndef UPB_MESSAGE_MAP_GENCODE_UTIL_H_
4550 #define UPB_MESSAGE_MAP_GENCODE_UTIL_H_
4551
4552
4553 // Must be last.
4554
4555 #ifdef __cplusplus
4556 extern "C" {
4557 #endif
4558
4559 // Message map operations, these get the map from the message first.
4560
_upb_msg_map_key(const void * msg,void * key,size_t size)4561 UPB_INLINE void _upb_msg_map_key(const void* msg, void* key, size_t size) {
4562 const upb_tabent* ent = (const upb_tabent*)msg;
4563 uint32_t u32len;
4564 upb_StringView k;
4565 k.data = upb_tabstr(ent->key, &u32len);
4566 k.size = u32len;
4567 _upb_map_fromkey(k, key, size);
4568 }
4569
_upb_msg_map_value(const void * msg,void * val,size_t size)4570 UPB_INLINE void _upb_msg_map_value(const void* msg, void* val, size_t size) {
4571 const upb_tabent* ent = (const upb_tabent*)msg;
4572 upb_value v = {ent->val.val};
4573 _upb_map_fromvalue(v, val, size);
4574 }
4575
_upb_msg_map_set_value(void * msg,const void * val,size_t size)4576 UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val,
4577 size_t size) {
4578 upb_tabent* ent = (upb_tabent*)msg;
4579 // This is like _upb_map_tovalue() except the entry already exists
4580 // so we can reuse the allocated upb_StringView for string fields.
4581 if (size == UPB_MAPTYPE_STRING) {
4582 upb_StringView* strp = (upb_StringView*)(uintptr_t)ent->val.val;
4583 memcpy(strp, val, sizeof(*strp));
4584 } else {
4585 memcpy(&ent->val.val, val, size);
4586 }
4587 }
4588
4589 #ifdef __cplusplus
4590 } /* extern "C" */
4591 #endif
4592
4593
4594 #endif /* UPB_MESSAGE_MAP_GENCODE_UTIL_H_ */
4595
4596 #ifndef UPB_MINI_TABLE_DECODE_H_
4597 #define UPB_MINI_TABLE_DECODE_H_
4598
4599
4600 #ifndef UPB_MINI_TABLE_SUB_H_
4601 #define UPB_MINI_TABLE_SUB_H_
4602
4603
4604 // Must be last.
4605
4606 typedef union upb_MiniTableSub upb_MiniTableSub;
4607
4608 #ifdef __cplusplus
4609 extern "C" {
4610 #endif
4611
4612 // Constructors
4613
4614 UPB_API_INLINE upb_MiniTableSub
4615 upb_MiniTableSub_FromEnum(const upb_MiniTableEnum* subenum);
4616
4617 UPB_API_INLINE upb_MiniTableSub
4618 upb_MiniTableSub_FromMessage(const upb_MiniTable* submsg);
4619
4620 // Getters
4621
4622 UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTableSub_Enum(
4623 upb_MiniTableSub sub);
4624
4625 UPB_API_INLINE const upb_MiniTable* upb_MiniTableSub_Message(
4626 upb_MiniTableSub sub);
4627
4628 #ifdef __cplusplus
4629 } /* extern "C" */
4630 #endif
4631
4632
4633 #endif /* UPB_MINI_TABLE_SUB_H_ */
4634
4635 // Export the newer headers, for legacy users. New users should include the
4636 // more specific headers directly.
4637 // IWYU pragma: begin_exports
4638
4639 #ifndef UPB_MINI_DESCRIPTOR_BUILD_ENUM_H_
4640 #define UPB_MINI_DESCRIPTOR_BUILD_ENUM_H_
4641
4642
4643 // Must be last.
4644
4645 #ifdef __cplusplus
4646 extern "C" {
4647 #endif
4648
4649 // Builds a upb_MiniTableEnum from an enum mini descriptor.
4650 // The mini descriptor must be for an enum, not a message.
4651 UPB_API upb_MiniTableEnum* upb_MiniTableEnum_Build(const char* data, size_t len,
4652 upb_Arena* arena,
4653 upb_Status* status);
4654
4655 #ifdef __cplusplus
4656 } /* extern "C" */
4657 #endif
4658
4659
4660 #endif // UPB_MINI_DESCRIPTOR_BUILD_ENUM_H_
4661
4662 // Functions for linking MiniTables together once they are built from a
4663 // MiniDescriptor.
4664 //
4665 // These functions have names like upb_MiniTable_Link() because they operate on
4666 // MiniTables. We put them here, rather than in the mini_table/ directory,
4667 // because they are only needed when building MiniTables from MiniDescriptors.
4668 // The interfaces in mini_table/ assume that MiniTables are immutable.
4669
4670 #ifndef UPB_MINI_DESCRIPTOR_LINK_H_
4671 #define UPB_MINI_DESCRIPTOR_LINK_H_
4672
4673
4674 // Must be last.
4675
4676 #ifdef __cplusplus
4677 extern "C" {
4678 #endif
4679
4680 // Links a sub-message field to a MiniTable for that sub-message. If a
4681 // sub-message field is not linked, it will be treated as an unknown field
4682 // during parsing, and setting the field will not be allowed. It is possible
4683 // to link the message field later, at which point it will no longer be treated
4684 // as unknown. However there is no synchronization for this operation, which
4685 // means parallel mutation requires external synchronization.
4686 // Returns success/failure.
4687 UPB_API bool upb_MiniTable_SetSubMessage(upb_MiniTable* table,
4688 upb_MiniTableField* field,
4689 const upb_MiniTable* sub);
4690
4691 // Links an enum field to a MiniTable for that enum.
4692 // All enum fields must be linked prior to parsing.
4693 // Returns success/failure.
4694 UPB_API bool upb_MiniTable_SetSubEnum(upb_MiniTable* table,
4695 upb_MiniTableField* field,
4696 const upb_MiniTableEnum* sub);
4697
4698 // Returns a list of fields that require linking at runtime, to connect the
4699 // MiniTable to its sub-messages and sub-enums. The list of fields will be
4700 // written to the `subs` array, which must have been allocated by the caller
4701 // and must be large enough to hold a list of all fields in the message.
4702 //
4703 // The order of the fields returned by this function is significant: it matches
4704 // the order expected by upb_MiniTable_Link() below.
4705 //
4706 // The return value packs the sub-message count and sub-enum count into a single
4707 // integer like so:
4708 // return (msg_count << 16) | enum_count;
4709 UPB_API uint32_t upb_MiniTable_GetSubList(const upb_MiniTable* mt,
4710 const upb_MiniTableField** subs);
4711
4712 // Links a message to its sub-messages and sub-enums. The caller must pass
4713 // arrays of sub-tables and sub-enums, in the same length and order as is
4714 // returned by upb_MiniTable_GetSubList() above. However, individual elements
4715 // of the sub_tables may be NULL if those sub-messages were tree shaken.
4716 //
4717 // Returns false if either array is too short, or if any of the tables fails
4718 // to link.
4719 UPB_API bool upb_MiniTable_Link(upb_MiniTable* mt,
4720 const upb_MiniTable** sub_tables,
4721 size_t sub_table_count,
4722 const upb_MiniTableEnum** sub_enums,
4723 size_t sub_enum_count);
4724
4725 #ifdef __cplusplus
4726 } /* extern "C" */
4727 #endif
4728
4729
4730 #endif // UPB_MINI_DESCRIPTOR_LINK_H_
4731 // IWYU pragma: end_exports
4732
4733 // Must be last.
4734
4735 typedef enum {
4736 kUpb_MiniTablePlatform_32Bit,
4737 kUpb_MiniTablePlatform_64Bit,
4738 kUpb_MiniTablePlatform_Native =
4739 UPB_SIZE(kUpb_MiniTablePlatform_32Bit, kUpb_MiniTablePlatform_64Bit),
4740 } upb_MiniTablePlatform;
4741
4742 #ifdef __cplusplus
4743 extern "C" {
4744 #endif
4745
4746 // Builds a mini table from the data encoded in the buffer [data, len]. If any
4747 // errors occur, returns NULL and sets a status message. In the success case,
4748 // the caller must call upb_MiniTable_SetSub*() for all message or proto2 enum
4749 // fields to link the table to the appropriate sub-tables.
4750 upb_MiniTable* _upb_MiniTable_Build(const char* data, size_t len,
4751 upb_MiniTablePlatform platform,
4752 upb_Arena* arena, upb_Status* status);
4753
upb_MiniTable_Build(const char * data,size_t len,upb_Arena * arena,upb_Status * status)4754 UPB_API_INLINE upb_MiniTable* upb_MiniTable_Build(const char* data, size_t len,
4755 upb_Arena* arena,
4756 upb_Status* status) {
4757 return _upb_MiniTable_Build(data, len, kUpb_MiniTablePlatform_Native, arena,
4758 status);
4759 }
4760
4761 // Initializes a MiniTableExtension buffer that has already been allocated.
4762 // This is needed by upb_FileDef and upb_MessageDef, which allocate all of the
4763 // extensions together in a single contiguous array.
4764 const char* _upb_MiniTableExtension_Init(const char* data, size_t len,
4765 upb_MiniTableExtension* ext,
4766 const upb_MiniTable* extendee,
4767 upb_MiniTableSub sub,
4768 upb_MiniTablePlatform platform,
4769 upb_Status* status);
4770
upb_MiniTableExtension_Init(const char * data,size_t len,upb_MiniTableExtension * ext,const upb_MiniTable * extendee,upb_MiniTableSub sub,upb_Status * status)4771 UPB_API_INLINE const char* upb_MiniTableExtension_Init(
4772 const char* data, size_t len, upb_MiniTableExtension* ext,
4773 const upb_MiniTable* extendee, upb_MiniTableSub sub, upb_Status* status) {
4774 return _upb_MiniTableExtension_Init(data, len, ext, extendee, sub,
4775 kUpb_MiniTablePlatform_Native, status);
4776 }
4777
4778 UPB_API upb_MiniTableExtension* _upb_MiniTableExtension_Build(
4779 const char* data, size_t len, const upb_MiniTable* extendee,
4780 upb_MiniTableSub sub, upb_MiniTablePlatform platform, upb_Arena* arena,
4781 upb_Status* status);
4782
upb_MiniTableExtension_Build(const char * data,size_t len,const upb_MiniTable * extendee,upb_Arena * arena,upb_Status * status)4783 UPB_API_INLINE upb_MiniTableExtension* upb_MiniTableExtension_Build(
4784 const char* data, size_t len, const upb_MiniTable* extendee,
4785 upb_Arena* arena, upb_Status* status) {
4786 upb_MiniTableSub sub = upb_MiniTableSub_FromMessage(NULL);
4787 return _upb_MiniTableExtension_Build(
4788 data, len, extendee, sub, kUpb_MiniTablePlatform_Native, arena, status);
4789 }
4790
upb_MiniTableExtension_BuildMessage(const char * data,size_t len,const upb_MiniTable * extendee,upb_MiniTable * submsg,upb_Arena * arena,upb_Status * status)4791 UPB_API_INLINE upb_MiniTableExtension* upb_MiniTableExtension_BuildMessage(
4792 const char* data, size_t len, const upb_MiniTable* extendee,
4793 upb_MiniTable* submsg, upb_Arena* arena, upb_Status* status) {
4794 upb_MiniTableSub sub = upb_MiniTableSub_FromMessage(submsg);
4795 return _upb_MiniTableExtension_Build(
4796 data, len, extendee, sub, kUpb_MiniTablePlatform_Native, arena, status);
4797 }
4798
upb_MiniTableExtension_BuildEnum(const char * data,size_t len,const upb_MiniTable * extendee,upb_MiniTableEnum * subenum,upb_Arena * arena,upb_Status * status)4799 UPB_API_INLINE upb_MiniTableExtension* upb_MiniTableExtension_BuildEnum(
4800 const char* data, size_t len, const upb_MiniTable* extendee,
4801 upb_MiniTableEnum* subenum, upb_Arena* arena, upb_Status* status) {
4802 upb_MiniTableSub sub = upb_MiniTableSub_FromEnum(subenum);
4803 return _upb_MiniTableExtension_Build(
4804 data, len, extendee, sub, kUpb_MiniTablePlatform_Native, arena, status);
4805 }
4806
4807 // Like upb_MiniTable_Build(), but the user provides a buffer of layout data so
4808 // it can be reused from call to call, avoiding repeated realloc()/free().
4809 //
4810 // The caller owns `*buf` both before and after the call, and must free() it
4811 // when it is no longer in use. The function will realloc() `*buf` as
4812 // necessary, updating `*size` accordingly.
4813 upb_MiniTable* upb_MiniTable_BuildWithBuf(const char* data, size_t len,
4814 upb_MiniTablePlatform platform,
4815 upb_Arena* arena, void** buf,
4816 size_t* buf_size, upb_Status* status);
4817
4818 #ifdef __cplusplus
4819 } /* extern "C" */
4820 #endif
4821
4822
4823 #endif /* UPB_MINI_TABLE_DECODE_H_ */
4824
4825 #ifndef UPB_MINI_TABLE_EXTENSION_REGISTRY_H_
4826 #define UPB_MINI_TABLE_EXTENSION_REGISTRY_H_
4827
4828
4829 // Must be last.
4830
4831 #ifdef __cplusplus
4832 extern "C" {
4833 #endif
4834
4835 /* Extension registry: a dynamic data structure that stores a map of:
4836 * (upb_MiniTable, number) -> extension info
4837 *
4838 * upb_decode() uses upb_ExtensionRegistry to look up extensions while parsing
4839 * binary format.
4840 *
4841 * upb_ExtensionRegistry is part of the mini-table (msglayout) family of
4842 * objects. Like all mini-table objects, it is suitable for reflection-less
4843 * builds that do not want to expose names into the binary.
4844 *
4845 * Unlike most mini-table types, upb_ExtensionRegistry requires dynamic memory
4846 * allocation and dynamic initialization:
4847 * * If reflection is being used, then upb_DefPool will construct an appropriate
4848 * upb_ExtensionRegistry automatically.
4849 * * For a mini-table only build, the user must manually construct the
4850 * upb_ExtensionRegistry and populate it with all of the extensions the user
4851 * cares about.
4852 * * A third alternative is to manually unpack relevant extensions after the
4853 * main parse is complete, similar to how Any works. This is perhaps the
4854 * nicest solution from the perspective of reducing dependencies, avoiding
4855 * dynamic memory allocation, and avoiding the need to parse uninteresting
4856 * extensions. The downsides are:
4857 * (1) parse errors are not caught during the main parse
4858 * (2) the CPU hit of parsing comes during access, which could cause an
4859 * undesirable stutter in application performance.
4860 *
4861 * Users cannot directly get or put into this map. Users can only add the
4862 * extensions from a generated module and pass the extension registry to the
4863 * binary decoder.
4864 *
4865 * A upb_DefPool provides a upb_ExtensionRegistry, so any users who use
4866 * reflection do not need to populate a upb_ExtensionRegistry directly.
4867 */
4868
4869 typedef struct upb_ExtensionRegistry upb_ExtensionRegistry;
4870
4871 // Creates a upb_ExtensionRegistry in the given arena.
4872 // The arena must outlive any use of the extreg.
4873 UPB_API upb_ExtensionRegistry* upb_ExtensionRegistry_New(upb_Arena* arena);
4874
4875 UPB_API bool upb_ExtensionRegistry_Add(upb_ExtensionRegistry* r,
4876 const upb_MiniTableExtension* e);
4877
4878 // Adds the given extension info for the array |e| of size |count| into the
4879 // registry. If there are any errors, the entire array is backed out.
4880 // The extensions must outlive the registry.
4881 // Possible errors include OOM or an extension number that already exists.
4882 // TODO: There is currently no way to know the exact reason for failure.
4883 bool upb_ExtensionRegistry_AddArray(upb_ExtensionRegistry* r,
4884 const upb_MiniTableExtension** e,
4885 size_t count);
4886
4887 #ifdef UPB_LINKARR_DECLARE
4888
4889 // Adds all extensions linked into the binary into the registry. The set of
4890 // linked extensions is assembled by the linker using linker arrays. This
4891 // will likely not work properly if the extensions are split across multiple
4892 // shared libraries.
4893 //
4894 // Returns true if all extensions were added successfully, false on out of
4895 // memory or if any extensions were already present.
4896 //
4897 // This API is currently not available on MSVC (though it *is* available on
4898 // Windows using clang-cl).
4899 UPB_API bool upb_ExtensionRegistry_AddAllLinkedExtensions(
4900 upb_ExtensionRegistry* r);
4901
4902 #endif // UPB_LINKARR_DECLARE
4903
4904 // Looks up the extension (if any) defined for message type |t| and field
4905 // number |num|. Returns the extension if found, otherwise NULL.
4906 UPB_API const upb_MiniTableExtension* upb_ExtensionRegistry_Lookup(
4907 const upb_ExtensionRegistry* r, const upb_MiniTable* t, uint32_t num);
4908
4909 #ifdef __cplusplus
4910 } /* extern "C" */
4911 #endif
4912
4913
4914 #endif /* UPB_MINI_TABLE_EXTENSION_REGISTRY_H_ */
4915
4916 #ifndef UPB_MINI_TABLE_FILE_H_
4917 #define UPB_MINI_TABLE_FILE_H_
4918
4919
4920 #ifndef UPB_MINI_TABLE_INTERNAL_FILE_H_
4921 #define UPB_MINI_TABLE_INTERNAL_FILE_H_
4922
4923 // Must be last.
4924
4925 struct upb_MiniTableFile {
4926 const struct upb_MiniTable** UPB_PRIVATE(msgs);
4927 const struct upb_MiniTableEnum** UPB_PRIVATE(enums);
4928 const struct upb_MiniTableExtension** UPB_PRIVATE(exts);
4929 int UPB_PRIVATE(msg_count);
4930 int UPB_PRIVATE(enum_count);
4931 int UPB_PRIVATE(ext_count);
4932 };
4933
4934 #ifdef __cplusplus
4935 extern "C" {
4936 #endif
4937
upb_MiniTableFile_EnumCount(const struct upb_MiniTableFile * f)4938 UPB_API_INLINE int upb_MiniTableFile_EnumCount(
4939 const struct upb_MiniTableFile* f) {
4940 return f->UPB_PRIVATE(enum_count);
4941 }
4942
upb_MiniTableFile_ExtensionCount(const struct upb_MiniTableFile * f)4943 UPB_API_INLINE int upb_MiniTableFile_ExtensionCount(
4944 const struct upb_MiniTableFile* f) {
4945 return f->UPB_PRIVATE(ext_count);
4946 }
4947
upb_MiniTableFile_MessageCount(const struct upb_MiniTableFile * f)4948 UPB_API_INLINE int upb_MiniTableFile_MessageCount(
4949 const struct upb_MiniTableFile* f) {
4950 return f->UPB_PRIVATE(msg_count);
4951 }
4952
upb_MiniTableFile_Enum(const struct upb_MiniTableFile * f,int i)4953 UPB_API_INLINE const struct upb_MiniTableEnum* upb_MiniTableFile_Enum(
4954 const struct upb_MiniTableFile* f, int i) {
4955 UPB_ASSERT(i < f->UPB_PRIVATE(enum_count));
4956 return f->UPB_PRIVATE(enums)[i];
4957 }
4958
upb_MiniTableFile_Extension(const struct upb_MiniTableFile * f,int i)4959 UPB_API_INLINE const struct upb_MiniTableExtension* upb_MiniTableFile_Extension(
4960 const struct upb_MiniTableFile* f, int i) {
4961 UPB_ASSERT(i < f->UPB_PRIVATE(ext_count));
4962 return f->UPB_PRIVATE(exts)[i];
4963 }
4964
upb_MiniTableFile_Message(const struct upb_MiniTableFile * f,int i)4965 UPB_API_INLINE const struct upb_MiniTable* upb_MiniTableFile_Message(
4966 const struct upb_MiniTableFile* f, int i) {
4967 UPB_ASSERT(i < f->UPB_PRIVATE(msg_count));
4968 return f->UPB_PRIVATE(msgs)[i];
4969 }
4970
4971 #ifdef __cplusplus
4972 } /* extern "C" */
4973 #endif
4974
4975
4976 #endif /* UPB_MINI_TABLE_INTERNAL_FILE_H_ */
4977
4978 // Must be last.
4979
4980 typedef struct upb_MiniTableFile upb_MiniTableFile;
4981
4982 #ifdef __cplusplus
4983 extern "C" {
4984 #endif
4985
4986 UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTableFile_Enum(
4987 const upb_MiniTableFile* f, int i);
4988
4989 UPB_API_INLINE int upb_MiniTableFile_EnumCount(const upb_MiniTableFile* f);
4990
4991 UPB_API_INLINE const upb_MiniTableExtension* upb_MiniTableFile_Extension(
4992 const upb_MiniTableFile* f, int i);
4993
4994 UPB_API_INLINE int upb_MiniTableFile_ExtensionCount(const upb_MiniTableFile* f);
4995
4996 UPB_API_INLINE const upb_MiniTable* upb_MiniTableFile_Message(
4997 const upb_MiniTableFile* f, int i);
4998
4999 UPB_API_INLINE int upb_MiniTableFile_MessageCount(const upb_MiniTableFile* f);
5000
5001 #ifdef __cplusplus
5002 } /* extern "C" */
5003 #endif
5004
5005
5006 #endif /* UPB_MINI_TABLE_FILE_H_ */
5007
5008 // upb_decode: parsing into a upb_Message using a upb_MiniTable.
5009
5010 #ifndef UPB_WIRE_DECODE_H_
5011 #define UPB_WIRE_DECODE_H_
5012
5013 #include <stddef.h>
5014 #include <stdint.h>
5015
5016
5017 // Must be last.
5018
5019 #ifdef __cplusplus
5020 extern "C" {
5021 #endif
5022
5023 enum {
5024 /* If set, strings will alias the input buffer instead of copying into the
5025 * arena. */
5026 kUpb_DecodeOption_AliasString = 1,
5027
5028 /* If set, the parse will return failure if any message is missing any
5029 * required fields when the message data ends. The parse will still continue,
5030 * and the failure will only be reported at the end.
5031 *
5032 * IMPORTANT CAVEATS:
5033 *
5034 * 1. This can throw a false positive failure if an incomplete message is seen
5035 * on the wire but is later completed when the sub-message occurs again.
5036 * For this reason, a second pass is required to verify a failure, to be
5037 * truly robust.
5038 *
5039 * 2. This can return a false success if you are decoding into a message that
5040 * already has some sub-message fields present. If the sub-message does
5041 * not occur in the binary payload, we will never visit it and discover the
5042 * incomplete sub-message. For this reason, this check is only useful for
5043 * implementing ParseFromString() semantics. For MergeFromString(), a
5044 * post-parse validation step will always be necessary. */
5045 kUpb_DecodeOption_CheckRequired = 2,
5046
5047 /* EXPERIMENTAL:
5048 *
5049 * If set, the parser will allow parsing of sub-message fields that were not
5050 * previously linked using upb_MiniTable_SetSubMessage(). The data will be
5051 * parsed into an internal "empty" message type that cannot be accessed
5052 * directly, but can be later promoted into the true message type if the
5053 * sub-message fields are linked at a later time.
5054 *
5055 * Users should set this option if they intend to perform dynamic tree shaking
5056 * and promoting using the interfaces in message/promote.h. If this option is
5057 * enabled, it is important that the resulting messages are only accessed by
5058 * code that is aware of promotion rules:
5059 *
5060 * 1. Message pointers in upb_Message, upb_Array, and upb_Map are represented
5061 * by a tagged pointer upb_TaggedMessagePointer. The tag indicates whether
5062 * the message uses the internal "empty" type.
5063 *
5064 * 2. Any code *reading* these message pointers must test whether the "empty"
5065 * tag bit is set, using the interfaces in mini_table/types.h. However
5066 * writing of message pointers should always use plain upb_Message*, since
5067 * users are not allowed to create "empty" messages.
5068 *
5069 * 3. It is always safe to test whether a field is present or test the array
5070 * length; these interfaces will reflect that empty messages are present,
5071 * even though their data cannot be accessed without promoting first.
5072 *
5073 * 4. If a message pointer is indeed tagged as empty, the message may not be
5074 * accessed directly, only promoted through the interfaces in
5075 * message/promote.h.
5076 *
5077 * 5. Tagged/empty messages may never be created by the user. They may only
5078 * be created by the parser or the message-copying logic in message/copy.h.
5079 */
5080 kUpb_DecodeOption_ExperimentalAllowUnlinked = 4,
5081
5082 /* EXPERIMENTAL:
5083 *
5084 * If set, decoding will enforce UTF-8 validation for string fields, even for
5085 * proto2 or fields with `features.utf8_validation = NONE`. Normally, only
5086 * proto3 string fields will be validated for UTF-8. Decoding will return
5087 * kUpb_DecodeStatus_BadUtf8 for non-UTF-8 strings, which is the same behavior
5088 * as non-UTF-8 proto3 string fields.
5089 */
5090 kUpb_DecodeOption_AlwaysValidateUtf8 = 8,
5091 };
5092
upb_DecodeOptions_MaxDepth(uint16_t depth)5093 UPB_INLINE uint32_t upb_DecodeOptions_MaxDepth(uint16_t depth) {
5094 return (uint32_t)depth << 16;
5095 }
5096
upb_DecodeOptions_GetMaxDepth(uint32_t options)5097 UPB_INLINE uint16_t upb_DecodeOptions_GetMaxDepth(uint32_t options) {
5098 return options >> 16;
5099 }
5100
5101 // Enforce an upper bound on recursion depth.
upb_Decode_LimitDepth(uint32_t decode_options,uint32_t limit)5102 UPB_INLINE int upb_Decode_LimitDepth(uint32_t decode_options, uint32_t limit) {
5103 uint32_t max_depth = upb_DecodeOptions_GetMaxDepth(decode_options);
5104 if (max_depth > limit) max_depth = limit;
5105 return upb_DecodeOptions_MaxDepth(max_depth) | (decode_options & 0xffff);
5106 }
5107
5108 // LINT.IfChange
5109 typedef enum {
5110 kUpb_DecodeStatus_Ok = 0,
5111 kUpb_DecodeStatus_Malformed = 1, // Wire format was corrupt
5112 kUpb_DecodeStatus_OutOfMemory = 2, // Arena alloc failed
5113 kUpb_DecodeStatus_BadUtf8 = 3, // String field had bad UTF-8
5114 kUpb_DecodeStatus_MaxDepthExceeded =
5115 4, // Exceeded upb_DecodeOptions_MaxDepth
5116
5117 // kUpb_DecodeOption_CheckRequired failed (see above), but the parse otherwise
5118 // succeeded.
5119 kUpb_DecodeStatus_MissingRequired = 5,
5120
5121 // Unlinked sub-message field was present, but
5122 // kUpb_DecodeOptions_ExperimentalAllowUnlinked was not specified in the list
5123 // of options.
5124 kUpb_DecodeStatus_UnlinkedSubMessage = 6,
5125 } upb_DecodeStatus;
5126 // LINT.ThenChange(//depot/google3/third_party/protobuf/rust/upb.rs:decode_status)
5127
5128 UPB_API upb_DecodeStatus upb_Decode(const char* buf, size_t size,
5129 upb_Message* msg, const upb_MiniTable* mt,
5130 const upb_ExtensionRegistry* extreg,
5131 int options, upb_Arena* arena);
5132
5133 // Same as upb_Decode but with a varint-encoded length prepended.
5134 // On success 'num_bytes_read' will be set to the how many bytes were read,
5135 // on failure the contents of num_bytes_read is undefined.
5136 UPB_API upb_DecodeStatus upb_DecodeLengthPrefixed(
5137 const char* buf, size_t size, upb_Message* msg, size_t* num_bytes_read,
5138 const upb_MiniTable* mt, const upb_ExtensionRegistry* extreg, int options,
5139 upb_Arena* arena);
5140
5141 // Utility function for wrapper languages to get an error string from a
5142 // upb_DecodeStatus.
5143 UPB_API const char* upb_DecodeStatus_String(upb_DecodeStatus status);
5144 #ifdef __cplusplus
5145 } /* extern "C" */
5146 #endif
5147
5148
5149 #endif /* UPB_WIRE_DECODE_H_ */
5150
5151 // upb_Encode: parsing from a upb_Message using a upb_MiniTable.
5152
5153 #ifndef UPB_WIRE_ENCODE_H_
5154 #define UPB_WIRE_ENCODE_H_
5155
5156 #include <stddef.h>
5157 #include <stdint.h>
5158
5159
5160 // Must be last.
5161
5162 #ifdef __cplusplus
5163 extern "C" {
5164 #endif
5165
5166 enum {
5167 /* If set, the results of serializing will be deterministic across all
5168 * instances of this binary. There are no guarantees across different
5169 * binary builds.
5170 *
5171 * If your proto contains maps, the encoder will need to malloc()/free()
5172 * memory during encode. */
5173 kUpb_EncodeOption_Deterministic = 1,
5174
5175 // When set, unknown fields are not encoded.
5176 kUpb_EncodeOption_SkipUnknown = 2,
5177
5178 // When set, the encode will fail if any required fields are missing.
5179 kUpb_EncodeOption_CheckRequired = 4,
5180 };
5181
5182 // LINT.IfChange
5183 typedef enum {
5184 kUpb_EncodeStatus_Ok = 0,
5185 kUpb_EncodeStatus_OutOfMemory = 1, // Arena alloc failed
5186 kUpb_EncodeStatus_MaxDepthExceeded = 2,
5187
5188 // kUpb_EncodeOption_CheckRequired failed but the parse otherwise succeeded.
5189 kUpb_EncodeStatus_MissingRequired = 3,
5190 } upb_EncodeStatus;
5191 // LINT.ThenChange(//depot/google3/third_party/protobuf/rust/upb.rs:encode_status)
5192
upb_EncodeOptions_MaxDepth(uint16_t depth)5193 UPB_INLINE uint32_t upb_EncodeOptions_MaxDepth(uint16_t depth) {
5194 return (uint32_t)depth << 16;
5195 }
5196
upb_EncodeOptions_GetMaxDepth(uint32_t options)5197 UPB_INLINE uint16_t upb_EncodeOptions_GetMaxDepth(uint32_t options) {
5198 return options >> 16;
5199 }
5200
5201 // Enforce an upper bound on recursion depth.
upb_Encode_LimitDepth(uint32_t encode_options,uint32_t limit)5202 UPB_INLINE int upb_Encode_LimitDepth(uint32_t encode_options, uint32_t limit) {
5203 uint32_t max_depth = upb_EncodeOptions_GetMaxDepth(encode_options);
5204 if (max_depth > limit) max_depth = limit;
5205 return upb_EncodeOptions_MaxDepth(max_depth) | (encode_options & 0xffff);
5206 }
5207
5208 UPB_API upb_EncodeStatus upb_Encode(const upb_Message* msg,
5209 const upb_MiniTable* l, int options,
5210 upb_Arena* arena, char** buf, size_t* size);
5211
5212 // Encodes the message prepended by a varint of the serialized length.
5213 UPB_API upb_EncodeStatus upb_EncodeLengthPrefixed(const upb_Message* msg,
5214 const upb_MiniTable* l,
5215 int options, upb_Arena* arena,
5216 char** buf, size_t* size);
5217 // Utility function for wrapper languages to get an error string from a
5218 // upb_EncodeStatus.
5219 UPB_API const char* upb_EncodeStatus_String(upb_EncodeStatus status);
5220
5221 #ifdef __cplusplus
5222 } /* extern "C" */
5223 #endif
5224
5225
5226 #endif /* UPB_WIRE_ENCODE_H_ */
5227
5228 // These are the specialized field parser functions for the fast parser.
5229 // Generated tables will refer to these by name.
5230 //
5231 // The function names are encoded with names like:
5232 //
5233 // // 123 4
5234 // upb_pss_1bt(); // Parse singular string, 1 byte tag.
5235 //
5236 // In position 1:
5237 // - 'p' for parse, most function use this
5238 // - 'c' for copy, for when we are copying strings instead of aliasing
5239 //
5240 // In position 2 (cardinality):
5241 // - 's' for singular, with or without hasbit
5242 // - 'o' for oneof
5243 // - 'r' for non-packed repeated
5244 // - 'p' for packed repeated
5245 //
5246 // In position 3 (type):
5247 // - 'b1' for bool
5248 // - 'v4' for 4-byte varint
5249 // - 'v8' for 8-byte varint
5250 // - 'z4' for zig-zag-encoded 4-byte varint
5251 // - 'z8' for zig-zag-encoded 8-byte varint
5252 // - 'f4' for 4-byte fixed
5253 // - 'f8' for 8-byte fixed
5254 // - 'm' for sub-message
5255 // - 's' for string (validate UTF-8)
5256 // - 'b' for bytes
5257 //
5258 // In position 4 (tag length):
5259 // - '1' for one-byte tags (field numbers 1-15)
5260 // - '2' for two-byte tags (field numbers 16-2048)
5261
5262 #ifndef UPB_WIRE_INTERNAL_DECODE_FAST_H_
5263 #define UPB_WIRE_INTERNAL_DECODE_FAST_H_
5264
5265
5266 // Must be last.
5267
5268 #ifdef __cplusplus
5269 extern "C" {
5270 #endif
5271
5272 struct upb_Decoder;
5273
5274 // The fallback, generic parsing function that can handle any field type.
5275 // This just uses the regular (non-fast) parser to parse a single field.
5276 const char* _upb_FastDecoder_DecodeGeneric(struct upb_Decoder* d,
5277 const char* ptr, upb_Message* msg,
5278 intptr_t table, uint64_t hasbits,
5279 uint64_t data);
5280
5281 #define UPB_PARSE_PARAMS \
5282 struct upb_Decoder *d, const char *ptr, upb_Message *msg, intptr_t table, \
5283 uint64_t hasbits, uint64_t data
5284
5285 /* primitive fields ***********************************************************/
5286
5287 #define F(card, type, valbytes, tagbytes) \
5288 const char* upb_p##card##type##valbytes##_##tagbytes##bt(UPB_PARSE_PARAMS);
5289
5290 #define TYPES(card, tagbytes) \
5291 F(card, b, 1, tagbytes) \
5292 F(card, v, 4, tagbytes) \
5293 F(card, v, 8, tagbytes) \
5294 F(card, z, 4, tagbytes) \
5295 F(card, z, 8, tagbytes) \
5296 F(card, f, 4, tagbytes) \
5297 F(card, f, 8, tagbytes)
5298
5299 #define TAGBYTES(card) \
5300 TYPES(card, 1) \
5301 TYPES(card, 2)
5302
5303 TAGBYTES(s)
5304 TAGBYTES(o)
5305 TAGBYTES(r)
5306 TAGBYTES(p)
5307
5308 #undef F
5309 #undef TYPES
5310 #undef TAGBYTES
5311
5312 /* string fields **************************************************************/
5313
5314 #define F(card, tagbytes, type) \
5315 const char* upb_p##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS); \
5316 const char* upb_c##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS);
5317
5318 #define UTF8(card, tagbytes) \
5319 F(card, tagbytes, s) \
5320 F(card, tagbytes, b)
5321
5322 #define TAGBYTES(card) \
5323 UTF8(card, 1) \
5324 UTF8(card, 2)
5325
5326 TAGBYTES(s)
5327 TAGBYTES(o)
5328 TAGBYTES(r)
5329
5330 #undef F
5331 #undef UTF8
5332 #undef TAGBYTES
5333
5334 /* sub-message fields *********************************************************/
5335
5336 #define F(card, tagbytes, size_ceil, ceil_arg) \
5337 const char* upb_p##card##m_##tagbytes##bt_max##size_ceil##b(UPB_PARSE_PARAMS);
5338
5339 #define SIZES(card, tagbytes) \
5340 F(card, tagbytes, 64, 64) \
5341 F(card, tagbytes, 128, 128) \
5342 F(card, tagbytes, 192, 192) \
5343 F(card, tagbytes, 256, 256) \
5344 F(card, tagbytes, max, -1)
5345
5346 #define TAGBYTES(card) \
5347 SIZES(card, 1) \
5348 SIZES(card, 2)
5349
5350 TAGBYTES(s)
5351 TAGBYTES(o)
5352 TAGBYTES(r)
5353
5354 #undef F
5355 #undef SIZES
5356 #undef TAGBYTES
5357
5358 #undef UPB_PARSE_PARAMS
5359
5360 #ifdef __cplusplus
5361 } /* extern "C" */
5362 #endif
5363
5364
5365 #endif /* UPB_WIRE_INTERNAL_DECODE_FAST_H_ */
5366 // IWYU pragma: end_exports
5367
5368 #endif // UPB_GENERATED_CODE_SUPPORT_H_
5369
5370 /* This file was generated by upb_generator from the input file:
5371 *
5372 * google/protobuf/descriptor.proto
5373 *
5374 * Do not edit -- your changes will be discarded when the file is
5375 * regenerated.
5376 * NO CHECKED-IN PROTOBUF GENCODE */
5377
5378 #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H__UPB_MINITABLE_H_
5379 #define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H__UPB_MINITABLE_H_
5380
5381
5382 // Must be last.
5383
5384 #ifdef __cplusplus
5385 extern "C" {
5386 #endif
5387
5388 extern const upb_MiniTable google__protobuf__FileDescriptorSet_msg_init;
5389 extern const upb_MiniTable* google__protobuf__FileDescriptorSet_msg_init_ptr;
5390 extern const upb_MiniTable google__protobuf__FileDescriptorProto_msg_init;
5391 extern const upb_MiniTable* google__protobuf__FileDescriptorProto_msg_init_ptr;
5392 extern const upb_MiniTable google__protobuf__DescriptorProto_msg_init;
5393 extern const upb_MiniTable* google__protobuf__DescriptorProto_msg_init_ptr;
5394 extern const upb_MiniTable google__protobuf__DescriptorProto__ExtensionRange_msg_init;
5395 extern const upb_MiniTable* google__protobuf__DescriptorProto__ExtensionRange_msg_init_ptr;
5396 extern const upb_MiniTable google__protobuf__DescriptorProto__ReservedRange_msg_init;
5397 extern const upb_MiniTable* google__protobuf__DescriptorProto__ReservedRange_msg_init_ptr;
5398 extern const upb_MiniTable google__protobuf__ExtensionRangeOptions_msg_init;
5399 extern const upb_MiniTable* google__protobuf__ExtensionRangeOptions_msg_init_ptr;
5400 extern const upb_MiniTable google__protobuf__ExtensionRangeOptions__Declaration_msg_init;
5401 extern const upb_MiniTable* google__protobuf__ExtensionRangeOptions__Declaration_msg_init_ptr;
5402 extern const upb_MiniTable google__protobuf__FieldDescriptorProto_msg_init;
5403 extern const upb_MiniTable* google__protobuf__FieldDescriptorProto_msg_init_ptr;
5404 extern const upb_MiniTable google__protobuf__OneofDescriptorProto_msg_init;
5405 extern const upb_MiniTable* google__protobuf__OneofDescriptorProto_msg_init_ptr;
5406 extern const upb_MiniTable google__protobuf__EnumDescriptorProto_msg_init;
5407 extern const upb_MiniTable* google__protobuf__EnumDescriptorProto_msg_init_ptr;
5408 extern const upb_MiniTable google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init;
5409 extern const upb_MiniTable* google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init_ptr;
5410 extern const upb_MiniTable google__protobuf__EnumValueDescriptorProto_msg_init;
5411 extern const upb_MiniTable* google__protobuf__EnumValueDescriptorProto_msg_init_ptr;
5412 extern const upb_MiniTable google__protobuf__ServiceDescriptorProto_msg_init;
5413 extern const upb_MiniTable* google__protobuf__ServiceDescriptorProto_msg_init_ptr;
5414 extern const upb_MiniTable google__protobuf__MethodDescriptorProto_msg_init;
5415 extern const upb_MiniTable* google__protobuf__MethodDescriptorProto_msg_init_ptr;
5416 extern const upb_MiniTable google__protobuf__FileOptions_msg_init;
5417 extern const upb_MiniTable* google__protobuf__FileOptions_msg_init_ptr;
5418 extern const upb_MiniTable google__protobuf__MessageOptions_msg_init;
5419 extern const upb_MiniTable* google__protobuf__MessageOptions_msg_init_ptr;
5420 extern const upb_MiniTable google__protobuf__FieldOptions_msg_init;
5421 extern const upb_MiniTable* google__protobuf__FieldOptions_msg_init_ptr;
5422 extern const upb_MiniTable google__protobuf__FieldOptions__EditionDefault_msg_init;
5423 extern const upb_MiniTable* google__protobuf__FieldOptions__EditionDefault_msg_init_ptr;
5424 extern const upb_MiniTable google__protobuf__FieldOptions__FeatureSupport_msg_init;
5425 extern const upb_MiniTable* google__protobuf__FieldOptions__FeatureSupport_msg_init_ptr;
5426 extern const upb_MiniTable google__protobuf__OneofOptions_msg_init;
5427 extern const upb_MiniTable* google__protobuf__OneofOptions_msg_init_ptr;
5428 extern const upb_MiniTable google__protobuf__EnumOptions_msg_init;
5429 extern const upb_MiniTable* google__protobuf__EnumOptions_msg_init_ptr;
5430 extern const upb_MiniTable google__protobuf__EnumValueOptions_msg_init;
5431 extern const upb_MiniTable* google__protobuf__EnumValueOptions_msg_init_ptr;
5432 extern const upb_MiniTable google__protobuf__ServiceOptions_msg_init;
5433 extern const upb_MiniTable* google__protobuf__ServiceOptions_msg_init_ptr;
5434 extern const upb_MiniTable google__protobuf__MethodOptions_msg_init;
5435 extern const upb_MiniTable* google__protobuf__MethodOptions_msg_init_ptr;
5436 extern const upb_MiniTable google__protobuf__UninterpretedOption_msg_init;
5437 extern const upb_MiniTable* google__protobuf__UninterpretedOption_msg_init_ptr;
5438 extern const upb_MiniTable google__protobuf__UninterpretedOption__NamePart_msg_init;
5439 extern const upb_MiniTable* google__protobuf__UninterpretedOption__NamePart_msg_init_ptr;
5440 extern const upb_MiniTable google__protobuf__FeatureSet_msg_init;
5441 extern const upb_MiniTable* google__protobuf__FeatureSet_msg_init_ptr;
5442 extern const upb_MiniTable google__protobuf__FeatureSetDefaults_msg_init;
5443 extern const upb_MiniTable* google__protobuf__FeatureSetDefaults_msg_init_ptr;
5444 extern const upb_MiniTable google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init;
5445 extern const upb_MiniTable* google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init_ptr;
5446 extern const upb_MiniTable google__protobuf__SourceCodeInfo_msg_init;
5447 extern const upb_MiniTable* google__protobuf__SourceCodeInfo_msg_init_ptr;
5448 extern const upb_MiniTable google__protobuf__SourceCodeInfo__Location_msg_init;
5449 extern const upb_MiniTable* google__protobuf__SourceCodeInfo__Location_msg_init_ptr;
5450 extern const upb_MiniTable google__protobuf__GeneratedCodeInfo_msg_init;
5451 extern const upb_MiniTable* google__protobuf__GeneratedCodeInfo_msg_init_ptr;
5452 extern const upb_MiniTable google__protobuf__GeneratedCodeInfo__Annotation_msg_init;
5453 extern const upb_MiniTable* google__protobuf__GeneratedCodeInfo__Annotation_msg_init_ptr;
5454
5455 extern const upb_MiniTableEnum google__protobuf__Edition_enum_init;
5456 extern const upb_MiniTableEnum google__protobuf__ExtensionRangeOptions__VerificationState_enum_init;
5457 extern const upb_MiniTableEnum google__protobuf__FeatureSet__EnumType_enum_init;
5458 extern const upb_MiniTableEnum google__protobuf__FeatureSet__FieldPresence_enum_init;
5459 extern const upb_MiniTableEnum google__protobuf__FeatureSet__JsonFormat_enum_init;
5460 extern const upb_MiniTableEnum google__protobuf__FeatureSet__MessageEncoding_enum_init;
5461 extern const upb_MiniTableEnum google__protobuf__FeatureSet__RepeatedFieldEncoding_enum_init;
5462 extern const upb_MiniTableEnum google__protobuf__FeatureSet__Utf8Validation_enum_init;
5463 extern const upb_MiniTableEnum google__protobuf__FieldDescriptorProto__Label_enum_init;
5464 extern const upb_MiniTableEnum google__protobuf__FieldDescriptorProto__Type_enum_init;
5465 extern const upb_MiniTableEnum google__protobuf__FieldOptions__CType_enum_init;
5466 extern const upb_MiniTableEnum google__protobuf__FieldOptions__JSType_enum_init;
5467 extern const upb_MiniTableEnum google__protobuf__FieldOptions__OptionRetention_enum_init;
5468 extern const upb_MiniTableEnum google__protobuf__FieldOptions__OptionTargetType_enum_init;
5469 extern const upb_MiniTableEnum google__protobuf__FileOptions__OptimizeMode_enum_init;
5470 extern const upb_MiniTableEnum google__protobuf__GeneratedCodeInfo__Annotation__Semantic_enum_init;
5471 extern const upb_MiniTableEnum google__protobuf__MethodOptions__IdempotencyLevel_enum_init;
5472 extern const upb_MiniTableFile google_protobuf_descriptor_proto_upb_file_layout;
5473
5474 #ifdef __cplusplus
5475 } /* extern "C" */
5476 #endif
5477
5478
5479 #endif /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H__UPB_MINITABLE_H_ */
5480
5481
5482 // Must be last.
5483
5484 #ifdef __cplusplus
5485 extern "C" {
5486 #endif
5487
5488 typedef struct google_protobuf_FileDescriptorSet { upb_Message UPB_PRIVATE(base); } google_protobuf_FileDescriptorSet;
5489 typedef struct google_protobuf_FileDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_FileDescriptorProto;
5490 typedef struct google_protobuf_DescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_DescriptorProto;
5491 typedef struct google_protobuf_DescriptorProto_ExtensionRange { upb_Message UPB_PRIVATE(base); } google_protobuf_DescriptorProto_ExtensionRange;
5492 typedef struct google_protobuf_DescriptorProto_ReservedRange { upb_Message UPB_PRIVATE(base); } google_protobuf_DescriptorProto_ReservedRange;
5493 typedef struct google_protobuf_ExtensionRangeOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_ExtensionRangeOptions;
5494 typedef struct google_protobuf_ExtensionRangeOptions_Declaration { upb_Message UPB_PRIVATE(base); } google_protobuf_ExtensionRangeOptions_Declaration;
5495 typedef struct google_protobuf_FieldDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_FieldDescriptorProto;
5496 typedef struct google_protobuf_OneofDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_OneofDescriptorProto;
5497 typedef struct google_protobuf_EnumDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_EnumDescriptorProto;
5498 typedef struct google_protobuf_EnumDescriptorProto_EnumReservedRange { upb_Message UPB_PRIVATE(base); } google_protobuf_EnumDescriptorProto_EnumReservedRange;
5499 typedef struct google_protobuf_EnumValueDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_EnumValueDescriptorProto;
5500 typedef struct google_protobuf_ServiceDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_ServiceDescriptorProto;
5501 typedef struct google_protobuf_MethodDescriptorProto { upb_Message UPB_PRIVATE(base); } google_protobuf_MethodDescriptorProto;
5502 typedef struct google_protobuf_FileOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_FileOptions;
5503 typedef struct google_protobuf_MessageOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_MessageOptions;
5504 typedef struct google_protobuf_FieldOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_FieldOptions;
5505 typedef struct google_protobuf_FieldOptions_EditionDefault { upb_Message UPB_PRIVATE(base); } google_protobuf_FieldOptions_EditionDefault;
5506 typedef struct google_protobuf_FieldOptions_FeatureSupport { upb_Message UPB_PRIVATE(base); } google_protobuf_FieldOptions_FeatureSupport;
5507 typedef struct google_protobuf_OneofOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_OneofOptions;
5508 typedef struct google_protobuf_EnumOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_EnumOptions;
5509 typedef struct google_protobuf_EnumValueOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_EnumValueOptions;
5510 typedef struct google_protobuf_ServiceOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_ServiceOptions;
5511 typedef struct google_protobuf_MethodOptions { upb_Message UPB_PRIVATE(base); } google_protobuf_MethodOptions;
5512 typedef struct google_protobuf_UninterpretedOption { upb_Message UPB_PRIVATE(base); } google_protobuf_UninterpretedOption;
5513 typedef struct google_protobuf_UninterpretedOption_NamePart { upb_Message UPB_PRIVATE(base); } google_protobuf_UninterpretedOption_NamePart;
5514 typedef struct google_protobuf_FeatureSet { upb_Message UPB_PRIVATE(base); } google_protobuf_FeatureSet;
5515 typedef struct google_protobuf_FeatureSetDefaults { upb_Message UPB_PRIVATE(base); } google_protobuf_FeatureSetDefaults;
5516 typedef struct google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault { upb_Message UPB_PRIVATE(base); } google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault;
5517 typedef struct google_protobuf_SourceCodeInfo { upb_Message UPB_PRIVATE(base); } google_protobuf_SourceCodeInfo;
5518 typedef struct google_protobuf_SourceCodeInfo_Location { upb_Message UPB_PRIVATE(base); } google_protobuf_SourceCodeInfo_Location;
5519 typedef struct google_protobuf_GeneratedCodeInfo { upb_Message UPB_PRIVATE(base); } google_protobuf_GeneratedCodeInfo;
5520 typedef struct google_protobuf_GeneratedCodeInfo_Annotation { upb_Message UPB_PRIVATE(base); } google_protobuf_GeneratedCodeInfo_Annotation;
5521
5522 typedef enum {
5523 google_protobuf_EDITION_UNKNOWN = 0,
5524 google_protobuf_EDITION_1_TEST_ONLY = 1,
5525 google_protobuf_EDITION_2_TEST_ONLY = 2,
5526 google_protobuf_EDITION_LEGACY = 900,
5527 google_protobuf_EDITION_PROTO2 = 998,
5528 google_protobuf_EDITION_PROTO3 = 999,
5529 google_protobuf_EDITION_2023 = 1000,
5530 google_protobuf_EDITION_2024 = 1001,
5531 google_protobuf_EDITION_99997_TEST_ONLY = 99997,
5532 google_protobuf_EDITION_99998_TEST_ONLY = 99998,
5533 google_protobuf_EDITION_99999_TEST_ONLY = 99999,
5534 google_protobuf_EDITION_MAX = 2147483647
5535 } google_protobuf_Edition;
5536
5537 typedef enum {
5538 google_protobuf_ExtensionRangeOptions_DECLARATION = 0,
5539 google_protobuf_ExtensionRangeOptions_UNVERIFIED = 1
5540 } google_protobuf_ExtensionRangeOptions_VerificationState;
5541
5542 typedef enum {
5543 google_protobuf_FeatureSet_ENUM_TYPE_UNKNOWN = 0,
5544 google_protobuf_FeatureSet_OPEN = 1,
5545 google_protobuf_FeatureSet_CLOSED = 2
5546 } google_protobuf_FeatureSet_EnumType;
5547
5548 typedef enum {
5549 google_protobuf_FeatureSet_FIELD_PRESENCE_UNKNOWN = 0,
5550 google_protobuf_FeatureSet_EXPLICIT = 1,
5551 google_protobuf_FeatureSet_IMPLICIT = 2,
5552 google_protobuf_FeatureSet_LEGACY_REQUIRED = 3
5553 } google_protobuf_FeatureSet_FieldPresence;
5554
5555 typedef enum {
5556 google_protobuf_FeatureSet_JSON_FORMAT_UNKNOWN = 0,
5557 google_protobuf_FeatureSet_ALLOW = 1,
5558 google_protobuf_FeatureSet_LEGACY_BEST_EFFORT = 2
5559 } google_protobuf_FeatureSet_JsonFormat;
5560
5561 typedef enum {
5562 google_protobuf_FeatureSet_MESSAGE_ENCODING_UNKNOWN = 0,
5563 google_protobuf_FeatureSet_LENGTH_PREFIXED = 1,
5564 google_protobuf_FeatureSet_DELIMITED = 2
5565 } google_protobuf_FeatureSet_MessageEncoding;
5566
5567 typedef enum {
5568 google_protobuf_FeatureSet_REPEATED_FIELD_ENCODING_UNKNOWN = 0,
5569 google_protobuf_FeatureSet_PACKED = 1,
5570 google_protobuf_FeatureSet_EXPANDED = 2
5571 } google_protobuf_FeatureSet_RepeatedFieldEncoding;
5572
5573 typedef enum {
5574 google_protobuf_FeatureSet_UTF8_VALIDATION_UNKNOWN = 0,
5575 google_protobuf_FeatureSet_VERIFY = 2,
5576 google_protobuf_FeatureSet_NONE = 3
5577 } google_protobuf_FeatureSet_Utf8Validation;
5578
5579 typedef enum {
5580 google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1,
5581 google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2,
5582 google_protobuf_FieldDescriptorProto_LABEL_REPEATED = 3
5583 } google_protobuf_FieldDescriptorProto_Label;
5584
5585 typedef enum {
5586 google_protobuf_FieldDescriptorProto_TYPE_DOUBLE = 1,
5587 google_protobuf_FieldDescriptorProto_TYPE_FLOAT = 2,
5588 google_protobuf_FieldDescriptorProto_TYPE_INT64 = 3,
5589 google_protobuf_FieldDescriptorProto_TYPE_UINT64 = 4,
5590 google_protobuf_FieldDescriptorProto_TYPE_INT32 = 5,
5591 google_protobuf_FieldDescriptorProto_TYPE_FIXED64 = 6,
5592 google_protobuf_FieldDescriptorProto_TYPE_FIXED32 = 7,
5593 google_protobuf_FieldDescriptorProto_TYPE_BOOL = 8,
5594 google_protobuf_FieldDescriptorProto_TYPE_STRING = 9,
5595 google_protobuf_FieldDescriptorProto_TYPE_GROUP = 10,
5596 google_protobuf_FieldDescriptorProto_TYPE_MESSAGE = 11,
5597 google_protobuf_FieldDescriptorProto_TYPE_BYTES = 12,
5598 google_protobuf_FieldDescriptorProto_TYPE_UINT32 = 13,
5599 google_protobuf_FieldDescriptorProto_TYPE_ENUM = 14,
5600 google_protobuf_FieldDescriptorProto_TYPE_SFIXED32 = 15,
5601 google_protobuf_FieldDescriptorProto_TYPE_SFIXED64 = 16,
5602 google_protobuf_FieldDescriptorProto_TYPE_SINT32 = 17,
5603 google_protobuf_FieldDescriptorProto_TYPE_SINT64 = 18
5604 } google_protobuf_FieldDescriptorProto_Type;
5605
5606 typedef enum {
5607 google_protobuf_FieldOptions_STRING = 0,
5608 google_protobuf_FieldOptions_CORD = 1,
5609 google_protobuf_FieldOptions_STRING_PIECE = 2
5610 } google_protobuf_FieldOptions_CType;
5611
5612 typedef enum {
5613 google_protobuf_FieldOptions_JS_NORMAL = 0,
5614 google_protobuf_FieldOptions_JS_STRING = 1,
5615 google_protobuf_FieldOptions_JS_NUMBER = 2
5616 } google_protobuf_FieldOptions_JSType;
5617
5618 typedef enum {
5619 google_protobuf_FieldOptions_RETENTION_UNKNOWN = 0,
5620 google_protobuf_FieldOptions_RETENTION_RUNTIME = 1,
5621 google_protobuf_FieldOptions_RETENTION_SOURCE = 2
5622 } google_protobuf_FieldOptions_OptionRetention;
5623
5624 typedef enum {
5625 google_protobuf_FieldOptions_TARGET_TYPE_UNKNOWN = 0,
5626 google_protobuf_FieldOptions_TARGET_TYPE_FILE = 1,
5627 google_protobuf_FieldOptions_TARGET_TYPE_EXTENSION_RANGE = 2,
5628 google_protobuf_FieldOptions_TARGET_TYPE_MESSAGE = 3,
5629 google_protobuf_FieldOptions_TARGET_TYPE_FIELD = 4,
5630 google_protobuf_FieldOptions_TARGET_TYPE_ONEOF = 5,
5631 google_protobuf_FieldOptions_TARGET_TYPE_ENUM = 6,
5632 google_protobuf_FieldOptions_TARGET_TYPE_ENUM_ENTRY = 7,
5633 google_protobuf_FieldOptions_TARGET_TYPE_SERVICE = 8,
5634 google_protobuf_FieldOptions_TARGET_TYPE_METHOD = 9
5635 } google_protobuf_FieldOptions_OptionTargetType;
5636
5637 typedef enum {
5638 google_protobuf_FileOptions_SPEED = 1,
5639 google_protobuf_FileOptions_CODE_SIZE = 2,
5640 google_protobuf_FileOptions_LITE_RUNTIME = 3
5641 } google_protobuf_FileOptions_OptimizeMode;
5642
5643 typedef enum {
5644 google_protobuf_GeneratedCodeInfo_Annotation_NONE = 0,
5645 google_protobuf_GeneratedCodeInfo_Annotation_SET = 1,
5646 google_protobuf_GeneratedCodeInfo_Annotation_ALIAS = 2
5647 } google_protobuf_GeneratedCodeInfo_Annotation_Semantic;
5648
5649 typedef enum {
5650 google_protobuf_MethodOptions_IDEMPOTENCY_UNKNOWN = 0,
5651 google_protobuf_MethodOptions_NO_SIDE_EFFECTS = 1,
5652 google_protobuf_MethodOptions_IDEMPOTENT = 2
5653 } google_protobuf_MethodOptions_IdempotencyLevel;
5654
5655
5656
5657 /* google.protobuf.FileDescriptorSet */
5658
google_protobuf_FileDescriptorSet_new(upb_Arena * arena)5659 UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_new(upb_Arena* arena) {
5660 return (google_protobuf_FileDescriptorSet*)_upb_Message_New(&google__protobuf__FileDescriptorSet_msg_init, arena);
5661 }
google_protobuf_FileDescriptorSet_parse(const char * buf,size_t size,upb_Arena * arena)5662 UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_parse(const char* buf, size_t size, upb_Arena* arena) {
5663 google_protobuf_FileDescriptorSet* ret = google_protobuf_FileDescriptorSet_new(arena);
5664 if (!ret) return NULL;
5665 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FileDescriptorSet_msg_init, NULL, 0, arena) !=
5666 kUpb_DecodeStatus_Ok) {
5667 return NULL;
5668 }
5669 return ret;
5670 }
google_protobuf_FileDescriptorSet_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)5671 UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_parse_ex(const char* buf, size_t size,
5672 const upb_ExtensionRegistry* extreg,
5673 int options, upb_Arena* arena) {
5674 google_protobuf_FileDescriptorSet* ret = google_protobuf_FileDescriptorSet_new(arena);
5675 if (!ret) return NULL;
5676 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FileDescriptorSet_msg_init, extreg, options,
5677 arena) != kUpb_DecodeStatus_Ok) {
5678 return NULL;
5679 }
5680 return ret;
5681 }
google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet * msg,upb_Arena * arena,size_t * len)5682 UPB_INLINE char* google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet* msg, upb_Arena* arena, size_t* len) {
5683 char* ptr;
5684 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FileDescriptorSet_msg_init, 0, arena, &ptr, len);
5685 return ptr;
5686 }
google_protobuf_FileDescriptorSet_serialize_ex(const google_protobuf_FileDescriptorSet * msg,int options,upb_Arena * arena,size_t * len)5687 UPB_INLINE char* google_protobuf_FileDescriptorSet_serialize_ex(const google_protobuf_FileDescriptorSet* msg, int options,
5688 upb_Arena* arena, size_t* len) {
5689 char* ptr;
5690 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FileDescriptorSet_msg_init, options, arena, &ptr, len);
5691 return ptr;
5692 }
google_protobuf_FileDescriptorSet_clear_file(google_protobuf_FileDescriptorSet * msg)5693 UPB_INLINE void google_protobuf_FileDescriptorSet_clear_file(google_protobuf_FileDescriptorSet* msg) {
5694 const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5695 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
5696 }
google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet * msg,size_t * size)5697 UPB_INLINE const google_protobuf_FileDescriptorProto* const* google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet* msg, size_t* size) {
5698 const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5699 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FileDescriptorProto_msg_init);
5700 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
5701 if (arr) {
5702 if (size) *size = arr->UPB_PRIVATE(size);
5703 return (const google_protobuf_FileDescriptorProto* const*)upb_Array_DataPtr(arr);
5704 } else {
5705 if (size) *size = 0;
5706 return NULL;
5707 }
5708 }
_google_protobuf_FileDescriptorSet_file_upb_array(const google_protobuf_FileDescriptorSet * msg,size_t * size)5709 UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorSet_file_upb_array(const google_protobuf_FileDescriptorSet* msg, size_t* size) {
5710 const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5711 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FileDescriptorProto_msg_init);
5712 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
5713 if (size) {
5714 *size = arr ? arr->UPB_PRIVATE(size) : 0;
5715 }
5716 return arr;
5717 }
_google_protobuf_FileDescriptorSet_file_mutable_upb_array(google_protobuf_FileDescriptorSet * msg,size_t * size,upb_Arena * arena)5718 UPB_INLINE upb_Array* _google_protobuf_FileDescriptorSet_file_mutable_upb_array(google_protobuf_FileDescriptorSet* msg, size_t* size, upb_Arena* arena) {
5719 const upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5720 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FileDescriptorProto_msg_init);
5721 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
5722 &field, arena);
5723 if (size) {
5724 *size = arr ? arr->UPB_PRIVATE(size) : 0;
5725 }
5726 return arr;
5727 }
5728
google_protobuf_FileDescriptorSet_mutable_file(google_protobuf_FileDescriptorSet * msg,size_t * size)5729 UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_mutable_file(google_protobuf_FileDescriptorSet* msg, size_t* size) {
5730 upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5731 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FileDescriptorProto_msg_init);
5732 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
5733 if (arr) {
5734 if (size) *size = arr->UPB_PRIVATE(size);
5735 return (google_protobuf_FileDescriptorProto**)upb_Array_MutableDataPtr(arr);
5736 } else {
5737 if (size) *size = 0;
5738 return NULL;
5739 }
5740 }
google_protobuf_FileDescriptorSet_resize_file(google_protobuf_FileDescriptorSet * msg,size_t size,upb_Arena * arena)5741 UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_resize_file(google_protobuf_FileDescriptorSet* msg, size_t size, upb_Arena* arena) {
5742 upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5743 return (google_protobuf_FileDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
5744 &field, size, arena);
5745 }
google_protobuf_FileDescriptorSet_add_file(google_protobuf_FileDescriptorSet * msg,upb_Arena * arena)5746 UPB_INLINE struct google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorSet_add_file(google_protobuf_FileDescriptorSet* msg, upb_Arena* arena) {
5747 upb_MiniTableField field = {1, 8, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5748 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FileDescriptorProto_msg_init);
5749 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
5750 UPB_UPCAST(msg), &field, arena);
5751 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
5752 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
5753 return NULL;
5754 }
5755 struct google_protobuf_FileDescriptorProto* sub = (struct google_protobuf_FileDescriptorProto*)_upb_Message_New(&google__protobuf__FileDescriptorProto_msg_init, arena);
5756 if (!arr || !sub) return NULL;
5757 UPB_PRIVATE(_upb_Array_Set)
5758 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
5759 return sub;
5760 }
5761
5762 /* google.protobuf.FileDescriptorProto */
5763
google_protobuf_FileDescriptorProto_new(upb_Arena * arena)5764 UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_new(upb_Arena* arena) {
5765 return (google_protobuf_FileDescriptorProto*)_upb_Message_New(&google__protobuf__FileDescriptorProto_msg_init, arena);
5766 }
google_protobuf_FileDescriptorProto_parse(const char * buf,size_t size,upb_Arena * arena)5767 UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
5768 google_protobuf_FileDescriptorProto* ret = google_protobuf_FileDescriptorProto_new(arena);
5769 if (!ret) return NULL;
5770 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FileDescriptorProto_msg_init, NULL, 0, arena) !=
5771 kUpb_DecodeStatus_Ok) {
5772 return NULL;
5773 }
5774 return ret;
5775 }
google_protobuf_FileDescriptorProto_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)5776 UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_parse_ex(const char* buf, size_t size,
5777 const upb_ExtensionRegistry* extreg,
5778 int options, upb_Arena* arena) {
5779 google_protobuf_FileDescriptorProto* ret = google_protobuf_FileDescriptorProto_new(arena);
5780 if (!ret) return NULL;
5781 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FileDescriptorProto_msg_init, extreg, options,
5782 arena) != kUpb_DecodeStatus_Ok) {
5783 return NULL;
5784 }
5785 return ret;
5786 }
google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto * msg,upb_Arena * arena,size_t * len)5787 UPB_INLINE char* google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto* msg, upb_Arena* arena, size_t* len) {
5788 char* ptr;
5789 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FileDescriptorProto_msg_init, 0, arena, &ptr, len);
5790 return ptr;
5791 }
google_protobuf_FileDescriptorProto_serialize_ex(const google_protobuf_FileDescriptorProto * msg,int options,upb_Arena * arena,size_t * len)5792 UPB_INLINE char* google_protobuf_FileDescriptorProto_serialize_ex(const google_protobuf_FileDescriptorProto* msg, int options,
5793 upb_Arena* arena, size_t* len) {
5794 char* ptr;
5795 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FileDescriptorProto_msg_init, options, arena, &ptr, len);
5796 return ptr;
5797 }
google_protobuf_FileDescriptorProto_clear_name(google_protobuf_FileDescriptorProto * msg)5798 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_name(google_protobuf_FileDescriptorProto* msg) {
5799 const upb_MiniTableField field = {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
5800 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
5801 }
google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto * msg)5802 UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto* msg) {
5803 upb_StringView default_val = upb_StringView_FromString("");
5804 upb_StringView ret;
5805 const upb_MiniTableField field = {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
5806 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
5807 &default_val, &ret);
5808 return ret;
5809 }
google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto * msg)5810 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto* msg) {
5811 const upb_MiniTableField field = {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
5812 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
5813 }
google_protobuf_FileDescriptorProto_clear_package(google_protobuf_FileDescriptorProto * msg)5814 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_package(google_protobuf_FileDescriptorProto* msg) {
5815 const upb_MiniTableField field = {2, UPB_SIZE(60, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
5816 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
5817 }
google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto * msg)5818 UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto* msg) {
5819 upb_StringView default_val = upb_StringView_FromString("");
5820 upb_StringView ret;
5821 const upb_MiniTableField field = {2, UPB_SIZE(60, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
5822 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
5823 &default_val, &ret);
5824 return ret;
5825 }
google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto * msg)5826 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto* msg) {
5827 const upb_MiniTableField field = {2, UPB_SIZE(60, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
5828 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
5829 }
google_protobuf_FileDescriptorProto_clear_dependency(google_protobuf_FileDescriptorProto * msg)5830 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_dependency(google_protobuf_FileDescriptorProto* msg) {
5831 const upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5832 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
5833 }
google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto * msg,size_t * size)5834 UPB_INLINE upb_StringView const* google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
5835 const upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5836 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
5837 if (arr) {
5838 if (size) *size = arr->UPB_PRIVATE(size);
5839 return (upb_StringView const*)upb_Array_DataPtr(arr);
5840 } else {
5841 if (size) *size = 0;
5842 return NULL;
5843 }
5844 }
_google_protobuf_FileDescriptorProto_dependency_upb_array(const google_protobuf_FileDescriptorProto * msg,size_t * size)5845 UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
5846 const upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5847 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
5848 if (size) {
5849 *size = arr ? arr->UPB_PRIVATE(size) : 0;
5850 }
5851 return arr;
5852 }
_google_protobuf_FileDescriptorProto_dependency_mutable_upb_array(google_protobuf_FileDescriptorProto * msg,size_t * size,upb_Arena * arena)5853 UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_dependency_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
5854 const upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5855 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
5856 &field, arena);
5857 if (size) {
5858 *size = arr ? arr->UPB_PRIVATE(size) : 0;
5859 }
5860 return arr;
5861 }
google_protobuf_FileDescriptorProto_clear_message_type(google_protobuf_FileDescriptorProto * msg)5862 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_message_type(google_protobuf_FileDescriptorProto* msg) {
5863 const upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5864 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
5865 }
google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto * msg,size_t * size)5866 UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
5867 const upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5868 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto_msg_init);
5869 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
5870 if (arr) {
5871 if (size) *size = arr->UPB_PRIVATE(size);
5872 return (const google_protobuf_DescriptorProto* const*)upb_Array_DataPtr(arr);
5873 } else {
5874 if (size) *size = 0;
5875 return NULL;
5876 }
5877 }
_google_protobuf_FileDescriptorProto_message_type_upb_array(const google_protobuf_FileDescriptorProto * msg,size_t * size)5878 UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_message_type_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
5879 const upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5880 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto_msg_init);
5881 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
5882 if (size) {
5883 *size = arr ? arr->UPB_PRIVATE(size) : 0;
5884 }
5885 return arr;
5886 }
_google_protobuf_FileDescriptorProto_message_type_mutable_upb_array(google_protobuf_FileDescriptorProto * msg,size_t * size,upb_Arena * arena)5887 UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_message_type_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
5888 const upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5889 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto_msg_init);
5890 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
5891 &field, arena);
5892 if (size) {
5893 *size = arr ? arr->UPB_PRIVATE(size) : 0;
5894 }
5895 return arr;
5896 }
google_protobuf_FileDescriptorProto_clear_enum_type(google_protobuf_FileDescriptorProto * msg)5897 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_enum_type(google_protobuf_FileDescriptorProto* msg) {
5898 const upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5899 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
5900 }
google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto * msg,size_t * size)5901 UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
5902 const upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5903 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__EnumDescriptorProto_msg_init);
5904 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
5905 if (arr) {
5906 if (size) *size = arr->UPB_PRIVATE(size);
5907 return (const google_protobuf_EnumDescriptorProto* const*)upb_Array_DataPtr(arr);
5908 } else {
5909 if (size) *size = 0;
5910 return NULL;
5911 }
5912 }
_google_protobuf_FileDescriptorProto_enum_type_upb_array(const google_protobuf_FileDescriptorProto * msg,size_t * size)5913 UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_enum_type_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
5914 const upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5915 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__EnumDescriptorProto_msg_init);
5916 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
5917 if (size) {
5918 *size = arr ? arr->UPB_PRIVATE(size) : 0;
5919 }
5920 return arr;
5921 }
_google_protobuf_FileDescriptorProto_enum_type_mutable_upb_array(google_protobuf_FileDescriptorProto * msg,size_t * size,upb_Arena * arena)5922 UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_enum_type_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
5923 const upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5924 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__EnumDescriptorProto_msg_init);
5925 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
5926 &field, arena);
5927 if (size) {
5928 *size = arr ? arr->UPB_PRIVATE(size) : 0;
5929 }
5930 return arr;
5931 }
google_protobuf_FileDescriptorProto_clear_service(google_protobuf_FileDescriptorProto * msg)5932 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_service(google_protobuf_FileDescriptorProto* msg) {
5933 const upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5934 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
5935 }
google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto * msg,size_t * size)5936 UPB_INLINE const google_protobuf_ServiceDescriptorProto* const* google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
5937 const upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5938 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__ServiceDescriptorProto_msg_init);
5939 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
5940 if (arr) {
5941 if (size) *size = arr->UPB_PRIVATE(size);
5942 return (const google_protobuf_ServiceDescriptorProto* const*)upb_Array_DataPtr(arr);
5943 } else {
5944 if (size) *size = 0;
5945 return NULL;
5946 }
5947 }
_google_protobuf_FileDescriptorProto_service_upb_array(const google_protobuf_FileDescriptorProto * msg,size_t * size)5948 UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_service_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
5949 const upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5950 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__ServiceDescriptorProto_msg_init);
5951 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
5952 if (size) {
5953 *size = arr ? arr->UPB_PRIVATE(size) : 0;
5954 }
5955 return arr;
5956 }
_google_protobuf_FileDescriptorProto_service_mutable_upb_array(google_protobuf_FileDescriptorProto * msg,size_t * size,upb_Arena * arena)5957 UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_service_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
5958 const upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5959 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__ServiceDescriptorProto_msg_init);
5960 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
5961 &field, arena);
5962 if (size) {
5963 *size = arr ? arr->UPB_PRIVATE(size) : 0;
5964 }
5965 return arr;
5966 }
google_protobuf_FileDescriptorProto_clear_extension(google_protobuf_FileDescriptorProto * msg)5967 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_extension(google_protobuf_FileDescriptorProto* msg) {
5968 const upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5969 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
5970 }
google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto * msg,size_t * size)5971 UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
5972 const upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5973 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
5974 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
5975 if (arr) {
5976 if (size) *size = arr->UPB_PRIVATE(size);
5977 return (const google_protobuf_FieldDescriptorProto* const*)upb_Array_DataPtr(arr);
5978 } else {
5979 if (size) *size = 0;
5980 return NULL;
5981 }
5982 }
_google_protobuf_FileDescriptorProto_extension_upb_array(const google_protobuf_FileDescriptorProto * msg,size_t * size)5983 UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_extension_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
5984 const upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5985 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
5986 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
5987 if (size) {
5988 *size = arr ? arr->UPB_PRIVATE(size) : 0;
5989 }
5990 return arr;
5991 }
_google_protobuf_FileDescriptorProto_extension_mutable_upb_array(google_protobuf_FileDescriptorProto * msg,size_t * size,upb_Arena * arena)5992 UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_extension_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
5993 const upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
5994 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
5995 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
5996 &field, arena);
5997 if (size) {
5998 *size = arr ? arr->UPB_PRIVATE(size) : 0;
5999 }
6000 return arr;
6001 }
google_protobuf_FileDescriptorProto_clear_options(google_protobuf_FileDescriptorProto * msg)6002 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_options(google_protobuf_FileDescriptorProto* msg) {
6003 const upb_MiniTableField field = {8, UPB_SIZE(32, 88), 66, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6004 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6005 }
google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto * msg)6006 UPB_INLINE const google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto* msg) {
6007 const google_protobuf_FileOptions* default_val = NULL;
6008 const google_protobuf_FileOptions* ret;
6009 const upb_MiniTableField field = {8, UPB_SIZE(32, 88), 66, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6010 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FileOptions_msg_init);
6011 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
6012 &default_val, &ret);
6013 return ret;
6014 }
google_protobuf_FileDescriptorProto_has_options(const google_protobuf_FileDescriptorProto * msg)6015 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_options(const google_protobuf_FileDescriptorProto* msg) {
6016 const upb_MiniTableField field = {8, UPB_SIZE(32, 88), 66, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6017 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
6018 }
google_protobuf_FileDescriptorProto_clear_source_code_info(google_protobuf_FileDescriptorProto * msg)6019 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_source_code_info(google_protobuf_FileDescriptorProto* msg) {
6020 const upb_MiniTableField field = {9, UPB_SIZE(36, 96), 67, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6021 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6022 }
google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto * msg)6023 UPB_INLINE const google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto* msg) {
6024 const google_protobuf_SourceCodeInfo* default_val = NULL;
6025 const google_protobuf_SourceCodeInfo* ret;
6026 const upb_MiniTableField field = {9, UPB_SIZE(36, 96), 67, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6027 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__SourceCodeInfo_msg_init);
6028 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
6029 &default_val, &ret);
6030 return ret;
6031 }
google_protobuf_FileDescriptorProto_has_source_code_info(const google_protobuf_FileDescriptorProto * msg)6032 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_source_code_info(const google_protobuf_FileDescriptorProto* msg) {
6033 const upb_MiniTableField field = {9, UPB_SIZE(36, 96), 67, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6034 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
6035 }
google_protobuf_FileDescriptorProto_clear_public_dependency(google_protobuf_FileDescriptorProto * msg)6036 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_public_dependency(google_protobuf_FileDescriptorProto* msg) {
6037 const upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6038 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6039 }
google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto * msg,size_t * size)6040 UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
6041 const upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6042 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6043 if (arr) {
6044 if (size) *size = arr->UPB_PRIVATE(size);
6045 return (int32_t const*)upb_Array_DataPtr(arr);
6046 } else {
6047 if (size) *size = 0;
6048 return NULL;
6049 }
6050 }
_google_protobuf_FileDescriptorProto_public_dependency_upb_array(const google_protobuf_FileDescriptorProto * msg,size_t * size)6051 UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_public_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
6052 const upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6053 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6054 if (size) {
6055 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6056 }
6057 return arr;
6058 }
_google_protobuf_FileDescriptorProto_public_dependency_mutable_upb_array(google_protobuf_FileDescriptorProto * msg,size_t * size,upb_Arena * arena)6059 UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_public_dependency_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
6060 const upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6061 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
6062 &field, arena);
6063 if (size) {
6064 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6065 }
6066 return arr;
6067 }
google_protobuf_FileDescriptorProto_clear_weak_dependency(google_protobuf_FileDescriptorProto * msg)6068 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_weak_dependency(google_protobuf_FileDescriptorProto* msg) {
6069 const upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6070 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6071 }
google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto * msg,size_t * size)6072 UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
6073 const upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6074 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6075 if (arr) {
6076 if (size) *size = arr->UPB_PRIVATE(size);
6077 return (int32_t const*)upb_Array_DataPtr(arr);
6078 } else {
6079 if (size) *size = 0;
6080 return NULL;
6081 }
6082 }
_google_protobuf_FileDescriptorProto_weak_dependency_upb_array(const google_protobuf_FileDescriptorProto * msg,size_t * size)6083 UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_weak_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
6084 const upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6085 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6086 if (size) {
6087 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6088 }
6089 return arr;
6090 }
_google_protobuf_FileDescriptorProto_weak_dependency_mutable_upb_array(google_protobuf_FileDescriptorProto * msg,size_t * size,upb_Arena * arena)6091 UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_weak_dependency_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
6092 const upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6093 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
6094 &field, arena);
6095 if (size) {
6096 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6097 }
6098 return arr;
6099 }
google_protobuf_FileDescriptorProto_clear_syntax(google_protobuf_FileDescriptorProto * msg)6100 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_syntax(google_protobuf_FileDescriptorProto* msg) {
6101 const upb_MiniTableField field = {12, UPB_SIZE(68, 120), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
6102 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6103 }
google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto * msg)6104 UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto* msg) {
6105 upb_StringView default_val = upb_StringView_FromString("");
6106 upb_StringView ret;
6107 const upb_MiniTableField field = {12, UPB_SIZE(68, 120), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
6108 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
6109 &default_val, &ret);
6110 return ret;
6111 }
google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto * msg)6112 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto* msg) {
6113 const upb_MiniTableField field = {12, UPB_SIZE(68, 120), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
6114 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
6115 }
google_protobuf_FileDescriptorProto_clear_edition(google_protobuf_FileDescriptorProto * msg)6116 UPB_INLINE void google_protobuf_FileDescriptorProto_clear_edition(google_protobuf_FileDescriptorProto* msg) {
6117 const upb_MiniTableField field = {14, UPB_SIZE(48, 12), 69, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
6118 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6119 }
google_protobuf_FileDescriptorProto_edition(const google_protobuf_FileDescriptorProto * msg)6120 UPB_INLINE int32_t google_protobuf_FileDescriptorProto_edition(const google_protobuf_FileDescriptorProto* msg) {
6121 int32_t default_val = 0;
6122 int32_t ret;
6123 const upb_MiniTableField field = {14, UPB_SIZE(48, 12), 69, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
6124 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
6125 &default_val, &ret);
6126 return ret;
6127 }
google_protobuf_FileDescriptorProto_has_edition(const google_protobuf_FileDescriptorProto * msg)6128 UPB_INLINE bool google_protobuf_FileDescriptorProto_has_edition(const google_protobuf_FileDescriptorProto* msg) {
6129 const upb_MiniTableField field = {14, UPB_SIZE(48, 12), 69, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
6130 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
6131 }
6132
google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto * msg,upb_StringView value)6133 UPB_INLINE void google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto *msg, upb_StringView value) {
6134 const upb_MiniTableField field = {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
6135 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
6136 }
google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto * msg,upb_StringView value)6137 UPB_INLINE void google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto *msg, upb_StringView value) {
6138 const upb_MiniTableField field = {2, UPB_SIZE(60, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
6139 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
6140 }
google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto * msg,size_t * size)6141 UPB_INLINE upb_StringView* google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto* msg, size_t* size) {
6142 upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6143 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6144 if (arr) {
6145 if (size) *size = arr->UPB_PRIVATE(size);
6146 return (upb_StringView*)upb_Array_MutableDataPtr(arr);
6147 } else {
6148 if (size) *size = 0;
6149 return NULL;
6150 }
6151 }
google_protobuf_FileDescriptorProto_resize_dependency(google_protobuf_FileDescriptorProto * msg,size_t size,upb_Arena * arena)6152 UPB_INLINE upb_StringView* google_protobuf_FileDescriptorProto_resize_dependency(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) {
6153 upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6154 return (upb_StringView*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6155 &field, size, arena);
6156 }
google_protobuf_FileDescriptorProto_add_dependency(google_protobuf_FileDescriptorProto * msg,upb_StringView val,upb_Arena * arena)6157 UPB_INLINE bool google_protobuf_FileDescriptorProto_add_dependency(google_protobuf_FileDescriptorProto* msg, upb_StringView val, upb_Arena* arena) {
6158 upb_MiniTableField field = {3, UPB_SIZE(12, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6159 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6160 UPB_UPCAST(msg), &field, arena);
6161 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6162 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6163 return false;
6164 }
6165 UPB_PRIVATE(_upb_Array_Set)
6166 (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val));
6167 return true;
6168 }
google_protobuf_FileDescriptorProto_mutable_message_type(google_protobuf_FileDescriptorProto * msg,size_t * size)6169 UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_mutable_message_type(google_protobuf_FileDescriptorProto* msg, size_t* size) {
6170 upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6171 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto_msg_init);
6172 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6173 if (arr) {
6174 if (size) *size = arr->UPB_PRIVATE(size);
6175 return (google_protobuf_DescriptorProto**)upb_Array_MutableDataPtr(arr);
6176 } else {
6177 if (size) *size = 0;
6178 return NULL;
6179 }
6180 }
google_protobuf_FileDescriptorProto_resize_message_type(google_protobuf_FileDescriptorProto * msg,size_t size,upb_Arena * arena)6181 UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_resize_message_type(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) {
6182 upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6183 return (google_protobuf_DescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6184 &field, size, arena);
6185 }
google_protobuf_FileDescriptorProto_add_message_type(google_protobuf_FileDescriptorProto * msg,upb_Arena * arena)6186 UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_FileDescriptorProto_add_message_type(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) {
6187 upb_MiniTableField field = {4, UPB_SIZE(16, 56), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6188 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto_msg_init);
6189 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6190 UPB_UPCAST(msg), &field, arena);
6191 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6192 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6193 return NULL;
6194 }
6195 struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)_upb_Message_New(&google__protobuf__DescriptorProto_msg_init, arena);
6196 if (!arr || !sub) return NULL;
6197 UPB_PRIVATE(_upb_Array_Set)
6198 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
6199 return sub;
6200 }
google_protobuf_FileDescriptorProto_mutable_enum_type(google_protobuf_FileDescriptorProto * msg,size_t * size)6201 UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_mutable_enum_type(google_protobuf_FileDescriptorProto* msg, size_t* size) {
6202 upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6203 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__EnumDescriptorProto_msg_init);
6204 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6205 if (arr) {
6206 if (size) *size = arr->UPB_PRIVATE(size);
6207 return (google_protobuf_EnumDescriptorProto**)upb_Array_MutableDataPtr(arr);
6208 } else {
6209 if (size) *size = 0;
6210 return NULL;
6211 }
6212 }
google_protobuf_FileDescriptorProto_resize_enum_type(google_protobuf_FileDescriptorProto * msg,size_t size,upb_Arena * arena)6213 UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_resize_enum_type(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) {
6214 upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6215 return (google_protobuf_EnumDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6216 &field, size, arena);
6217 }
google_protobuf_FileDescriptorProto_add_enum_type(google_protobuf_FileDescriptorProto * msg,upb_Arena * arena)6218 UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_FileDescriptorProto_add_enum_type(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) {
6219 upb_MiniTableField field = {5, UPB_SIZE(20, 64), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6220 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__EnumDescriptorProto_msg_init);
6221 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6222 UPB_UPCAST(msg), &field, arena);
6223 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6224 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6225 return NULL;
6226 }
6227 struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)_upb_Message_New(&google__protobuf__EnumDescriptorProto_msg_init, arena);
6228 if (!arr || !sub) return NULL;
6229 UPB_PRIVATE(_upb_Array_Set)
6230 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
6231 return sub;
6232 }
google_protobuf_FileDescriptorProto_mutable_service(google_protobuf_FileDescriptorProto * msg,size_t * size)6233 UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_mutable_service(google_protobuf_FileDescriptorProto* msg, size_t* size) {
6234 upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6235 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__ServiceDescriptorProto_msg_init);
6236 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6237 if (arr) {
6238 if (size) *size = arr->UPB_PRIVATE(size);
6239 return (google_protobuf_ServiceDescriptorProto**)upb_Array_MutableDataPtr(arr);
6240 } else {
6241 if (size) *size = 0;
6242 return NULL;
6243 }
6244 }
google_protobuf_FileDescriptorProto_resize_service(google_protobuf_FileDescriptorProto * msg,size_t size,upb_Arena * arena)6245 UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_resize_service(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) {
6246 upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6247 return (google_protobuf_ServiceDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6248 &field, size, arena);
6249 }
google_protobuf_FileDescriptorProto_add_service(google_protobuf_FileDescriptorProto * msg,upb_Arena * arena)6250 UPB_INLINE struct google_protobuf_ServiceDescriptorProto* google_protobuf_FileDescriptorProto_add_service(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) {
6251 upb_MiniTableField field = {6, UPB_SIZE(24, 72), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6252 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__ServiceDescriptorProto_msg_init);
6253 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6254 UPB_UPCAST(msg), &field, arena);
6255 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6256 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6257 return NULL;
6258 }
6259 struct google_protobuf_ServiceDescriptorProto* sub = (struct google_protobuf_ServiceDescriptorProto*)_upb_Message_New(&google__protobuf__ServiceDescriptorProto_msg_init, arena);
6260 if (!arr || !sub) return NULL;
6261 UPB_PRIVATE(_upb_Array_Set)
6262 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
6263 return sub;
6264 }
google_protobuf_FileDescriptorProto_mutable_extension(google_protobuf_FileDescriptorProto * msg,size_t * size)6265 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_mutable_extension(google_protobuf_FileDescriptorProto* msg, size_t* size) {
6266 upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6267 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
6268 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6269 if (arr) {
6270 if (size) *size = arr->UPB_PRIVATE(size);
6271 return (google_protobuf_FieldDescriptorProto**)upb_Array_MutableDataPtr(arr);
6272 } else {
6273 if (size) *size = 0;
6274 return NULL;
6275 }
6276 }
google_protobuf_FileDescriptorProto_resize_extension(google_protobuf_FileDescriptorProto * msg,size_t size,upb_Arena * arena)6277 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_resize_extension(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) {
6278 upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6279 return (google_protobuf_FieldDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6280 &field, size, arena);
6281 }
google_protobuf_FileDescriptorProto_add_extension(google_protobuf_FileDescriptorProto * msg,upb_Arena * arena)6282 UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_FileDescriptorProto_add_extension(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) {
6283 upb_MiniTableField field = {7, UPB_SIZE(28, 80), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6284 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
6285 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6286 UPB_UPCAST(msg), &field, arena);
6287 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6288 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6289 return NULL;
6290 }
6291 struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_Message_New(&google__protobuf__FieldDescriptorProto_msg_init, arena);
6292 if (!arr || !sub) return NULL;
6293 UPB_PRIVATE(_upb_Array_Set)
6294 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
6295 return sub;
6296 }
google_protobuf_FileDescriptorProto_set_options(google_protobuf_FileDescriptorProto * msg,google_protobuf_FileOptions * value)6297 UPB_INLINE void google_protobuf_FileDescriptorProto_set_options(google_protobuf_FileDescriptorProto *msg, google_protobuf_FileOptions* value) {
6298 const upb_MiniTableField field = {8, UPB_SIZE(32, 88), 66, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6299 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FileOptions_msg_init);
6300 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
6301 }
google_protobuf_FileDescriptorProto_mutable_options(google_protobuf_FileDescriptorProto * msg,upb_Arena * arena)6302 UPB_INLINE struct google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_mutable_options(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) {
6303 struct google_protobuf_FileOptions* sub = (struct google_protobuf_FileOptions*)google_protobuf_FileDescriptorProto_options(msg);
6304 if (sub == NULL) {
6305 sub = (struct google_protobuf_FileOptions*)_upb_Message_New(&google__protobuf__FileOptions_msg_init, arena);
6306 if (sub) google_protobuf_FileDescriptorProto_set_options(msg, sub);
6307 }
6308 return sub;
6309 }
google_protobuf_FileDescriptorProto_set_source_code_info(google_protobuf_FileDescriptorProto * msg,google_protobuf_SourceCodeInfo * value)6310 UPB_INLINE void google_protobuf_FileDescriptorProto_set_source_code_info(google_protobuf_FileDescriptorProto *msg, google_protobuf_SourceCodeInfo* value) {
6311 const upb_MiniTableField field = {9, UPB_SIZE(36, 96), 67, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6312 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__SourceCodeInfo_msg_init);
6313 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
6314 }
google_protobuf_FileDescriptorProto_mutable_source_code_info(google_protobuf_FileDescriptorProto * msg,upb_Arena * arena)6315 UPB_INLINE struct google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_mutable_source_code_info(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) {
6316 struct google_protobuf_SourceCodeInfo* sub = (struct google_protobuf_SourceCodeInfo*)google_protobuf_FileDescriptorProto_source_code_info(msg);
6317 if (sub == NULL) {
6318 sub = (struct google_protobuf_SourceCodeInfo*)_upb_Message_New(&google__protobuf__SourceCodeInfo_msg_init, arena);
6319 if (sub) google_protobuf_FileDescriptorProto_set_source_code_info(msg, sub);
6320 }
6321 return sub;
6322 }
google_protobuf_FileDescriptorProto_mutable_public_dependency(google_protobuf_FileDescriptorProto * msg,size_t * size)6323 UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_public_dependency(google_protobuf_FileDescriptorProto* msg, size_t* size) {
6324 upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6325 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6326 if (arr) {
6327 if (size) *size = arr->UPB_PRIVATE(size);
6328 return (int32_t*)upb_Array_MutableDataPtr(arr);
6329 } else {
6330 if (size) *size = 0;
6331 return NULL;
6332 }
6333 }
google_protobuf_FileDescriptorProto_resize_public_dependency(google_protobuf_FileDescriptorProto * msg,size_t size,upb_Arena * arena)6334 UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_public_dependency(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) {
6335 upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6336 return (int32_t*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6337 &field, size, arena);
6338 }
google_protobuf_FileDescriptorProto_add_public_dependency(google_protobuf_FileDescriptorProto * msg,int32_t val,upb_Arena * arena)6339 UPB_INLINE bool google_protobuf_FileDescriptorProto_add_public_dependency(google_protobuf_FileDescriptorProto* msg, int32_t val, upb_Arena* arena) {
6340 upb_MiniTableField field = {10, UPB_SIZE(40, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6341 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6342 UPB_UPCAST(msg), &field, arena);
6343 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6344 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6345 return false;
6346 }
6347 UPB_PRIVATE(_upb_Array_Set)
6348 (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val));
6349 return true;
6350 }
google_protobuf_FileDescriptorProto_mutable_weak_dependency(google_protobuf_FileDescriptorProto * msg,size_t * size)6351 UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_weak_dependency(google_protobuf_FileDescriptorProto* msg, size_t* size) {
6352 upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6353 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6354 if (arr) {
6355 if (size) *size = arr->UPB_PRIVATE(size);
6356 return (int32_t*)upb_Array_MutableDataPtr(arr);
6357 } else {
6358 if (size) *size = 0;
6359 return NULL;
6360 }
6361 }
google_protobuf_FileDescriptorProto_resize_weak_dependency(google_protobuf_FileDescriptorProto * msg,size_t size,upb_Arena * arena)6362 UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_weak_dependency(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) {
6363 upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6364 return (int32_t*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6365 &field, size, arena);
6366 }
google_protobuf_FileDescriptorProto_add_weak_dependency(google_protobuf_FileDescriptorProto * msg,int32_t val,upb_Arena * arena)6367 UPB_INLINE bool google_protobuf_FileDescriptorProto_add_weak_dependency(google_protobuf_FileDescriptorProto* msg, int32_t val, upb_Arena* arena) {
6368 upb_MiniTableField field = {11, UPB_SIZE(44, 112), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6369 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6370 UPB_UPCAST(msg), &field, arena);
6371 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6372 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6373 return false;
6374 }
6375 UPB_PRIVATE(_upb_Array_Set)
6376 (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val));
6377 return true;
6378 }
google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto * msg,upb_StringView value)6379 UPB_INLINE void google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto *msg, upb_StringView value) {
6380 const upb_MiniTableField field = {12, UPB_SIZE(68, 120), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
6381 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
6382 }
google_protobuf_FileDescriptorProto_set_edition(google_protobuf_FileDescriptorProto * msg,int32_t value)6383 UPB_INLINE void google_protobuf_FileDescriptorProto_set_edition(google_protobuf_FileDescriptorProto *msg, int32_t value) {
6384 const upb_MiniTableField field = {14, UPB_SIZE(48, 12), 69, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
6385 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
6386 }
6387
6388 /* google.protobuf.DescriptorProto */
6389
google_protobuf_DescriptorProto_new(upb_Arena * arena)6390 UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_new(upb_Arena* arena) {
6391 return (google_protobuf_DescriptorProto*)_upb_Message_New(&google__protobuf__DescriptorProto_msg_init, arena);
6392 }
google_protobuf_DescriptorProto_parse(const char * buf,size_t size,upb_Arena * arena)6393 UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
6394 google_protobuf_DescriptorProto* ret = google_protobuf_DescriptorProto_new(arena);
6395 if (!ret) return NULL;
6396 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__DescriptorProto_msg_init, NULL, 0, arena) !=
6397 kUpb_DecodeStatus_Ok) {
6398 return NULL;
6399 }
6400 return ret;
6401 }
google_protobuf_DescriptorProto_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)6402 UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_parse_ex(const char* buf, size_t size,
6403 const upb_ExtensionRegistry* extreg,
6404 int options, upb_Arena* arena) {
6405 google_protobuf_DescriptorProto* ret = google_protobuf_DescriptorProto_new(arena);
6406 if (!ret) return NULL;
6407 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__DescriptorProto_msg_init, extreg, options,
6408 arena) != kUpb_DecodeStatus_Ok) {
6409 return NULL;
6410 }
6411 return ret;
6412 }
google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto * msg,upb_Arena * arena,size_t * len)6413 UPB_INLINE char* google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto* msg, upb_Arena* arena, size_t* len) {
6414 char* ptr;
6415 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__DescriptorProto_msg_init, 0, arena, &ptr, len);
6416 return ptr;
6417 }
google_protobuf_DescriptorProto_serialize_ex(const google_protobuf_DescriptorProto * msg,int options,upb_Arena * arena,size_t * len)6418 UPB_INLINE char* google_protobuf_DescriptorProto_serialize_ex(const google_protobuf_DescriptorProto* msg, int options,
6419 upb_Arena* arena, size_t* len) {
6420 char* ptr;
6421 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__DescriptorProto_msg_init, options, arena, &ptr, len);
6422 return ptr;
6423 }
google_protobuf_DescriptorProto_clear_name(google_protobuf_DescriptorProto * msg)6424 UPB_INLINE void google_protobuf_DescriptorProto_clear_name(google_protobuf_DescriptorProto* msg) {
6425 const upb_MiniTableField field = {1, UPB_SIZE(48, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
6426 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6427 }
google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto * msg)6428 UPB_INLINE upb_StringView google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto* msg) {
6429 upb_StringView default_val = upb_StringView_FromString("");
6430 upb_StringView ret;
6431 const upb_MiniTableField field = {1, UPB_SIZE(48, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
6432 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
6433 &default_val, &ret);
6434 return ret;
6435 }
google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto * msg)6436 UPB_INLINE bool google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto* msg) {
6437 const upb_MiniTableField field = {1, UPB_SIZE(48, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
6438 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
6439 }
google_protobuf_DescriptorProto_clear_field(google_protobuf_DescriptorProto * msg)6440 UPB_INLINE void google_protobuf_DescriptorProto_clear_field(google_protobuf_DescriptorProto* msg) {
6441 const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6442 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6443 }
google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto * msg,size_t * size)6444 UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto* msg, size_t* size) {
6445 const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6446 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
6447 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6448 if (arr) {
6449 if (size) *size = arr->UPB_PRIVATE(size);
6450 return (const google_protobuf_FieldDescriptorProto* const*)upb_Array_DataPtr(arr);
6451 } else {
6452 if (size) *size = 0;
6453 return NULL;
6454 }
6455 }
_google_protobuf_DescriptorProto_field_upb_array(const google_protobuf_DescriptorProto * msg,size_t * size)6456 UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_field_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
6457 const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6458 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
6459 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6460 if (size) {
6461 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6462 }
6463 return arr;
6464 }
_google_protobuf_DescriptorProto_field_mutable_upb_array(google_protobuf_DescriptorProto * msg,size_t * size,upb_Arena * arena)6465 UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_field_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
6466 const upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6467 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
6468 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
6469 &field, arena);
6470 if (size) {
6471 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6472 }
6473 return arr;
6474 }
google_protobuf_DescriptorProto_clear_nested_type(google_protobuf_DescriptorProto * msg)6475 UPB_INLINE void google_protobuf_DescriptorProto_clear_nested_type(google_protobuf_DescriptorProto* msg) {
6476 const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6477 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6478 }
google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto * msg,size_t * size)6479 UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto* msg, size_t* size) {
6480 const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6481 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto_msg_init);
6482 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6483 if (arr) {
6484 if (size) *size = arr->UPB_PRIVATE(size);
6485 return (const google_protobuf_DescriptorProto* const*)upb_Array_DataPtr(arr);
6486 } else {
6487 if (size) *size = 0;
6488 return NULL;
6489 }
6490 }
_google_protobuf_DescriptorProto_nested_type_upb_array(const google_protobuf_DescriptorProto * msg,size_t * size)6491 UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_nested_type_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
6492 const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6493 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto_msg_init);
6494 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6495 if (size) {
6496 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6497 }
6498 return arr;
6499 }
_google_protobuf_DescriptorProto_nested_type_mutable_upb_array(google_protobuf_DescriptorProto * msg,size_t * size,upb_Arena * arena)6500 UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_nested_type_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
6501 const upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6502 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto_msg_init);
6503 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
6504 &field, arena);
6505 if (size) {
6506 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6507 }
6508 return arr;
6509 }
google_protobuf_DescriptorProto_clear_enum_type(google_protobuf_DescriptorProto * msg)6510 UPB_INLINE void google_protobuf_DescriptorProto_clear_enum_type(google_protobuf_DescriptorProto* msg) {
6511 const upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6512 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6513 }
google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto * msg,size_t * size)6514 UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto* msg, size_t* size) {
6515 const upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6516 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__EnumDescriptorProto_msg_init);
6517 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6518 if (arr) {
6519 if (size) *size = arr->UPB_PRIVATE(size);
6520 return (const google_protobuf_EnumDescriptorProto* const*)upb_Array_DataPtr(arr);
6521 } else {
6522 if (size) *size = 0;
6523 return NULL;
6524 }
6525 }
_google_protobuf_DescriptorProto_enum_type_upb_array(const google_protobuf_DescriptorProto * msg,size_t * size)6526 UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_enum_type_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
6527 const upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6528 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__EnumDescriptorProto_msg_init);
6529 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6530 if (size) {
6531 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6532 }
6533 return arr;
6534 }
_google_protobuf_DescriptorProto_enum_type_mutable_upb_array(google_protobuf_DescriptorProto * msg,size_t * size,upb_Arena * arena)6535 UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_enum_type_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
6536 const upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6537 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__EnumDescriptorProto_msg_init);
6538 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
6539 &field, arena);
6540 if (size) {
6541 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6542 }
6543 return arr;
6544 }
google_protobuf_DescriptorProto_clear_extension_range(google_protobuf_DescriptorProto * msg)6545 UPB_INLINE void google_protobuf_DescriptorProto_clear_extension_range(google_protobuf_DescriptorProto* msg) {
6546 const upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6547 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6548 }
google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto * msg,size_t * size)6549 UPB_INLINE const google_protobuf_DescriptorProto_ExtensionRange* const* google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto* msg, size_t* size) {
6550 const upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6551 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto__ExtensionRange_msg_init);
6552 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6553 if (arr) {
6554 if (size) *size = arr->UPB_PRIVATE(size);
6555 return (const google_protobuf_DescriptorProto_ExtensionRange* const*)upb_Array_DataPtr(arr);
6556 } else {
6557 if (size) *size = 0;
6558 return NULL;
6559 }
6560 }
_google_protobuf_DescriptorProto_extension_range_upb_array(const google_protobuf_DescriptorProto * msg,size_t * size)6561 UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_extension_range_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
6562 const upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6563 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto__ExtensionRange_msg_init);
6564 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6565 if (size) {
6566 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6567 }
6568 return arr;
6569 }
_google_protobuf_DescriptorProto_extension_range_mutable_upb_array(google_protobuf_DescriptorProto * msg,size_t * size,upb_Arena * arena)6570 UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_extension_range_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
6571 const upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6572 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto__ExtensionRange_msg_init);
6573 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
6574 &field, arena);
6575 if (size) {
6576 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6577 }
6578 return arr;
6579 }
google_protobuf_DescriptorProto_clear_extension(google_protobuf_DescriptorProto * msg)6580 UPB_INLINE void google_protobuf_DescriptorProto_clear_extension(google_protobuf_DescriptorProto* msg) {
6581 const upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6582 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6583 }
google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto * msg,size_t * size)6584 UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto* msg, size_t* size) {
6585 const upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6586 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
6587 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6588 if (arr) {
6589 if (size) *size = arr->UPB_PRIVATE(size);
6590 return (const google_protobuf_FieldDescriptorProto* const*)upb_Array_DataPtr(arr);
6591 } else {
6592 if (size) *size = 0;
6593 return NULL;
6594 }
6595 }
_google_protobuf_DescriptorProto_extension_upb_array(const google_protobuf_DescriptorProto * msg,size_t * size)6596 UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_extension_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
6597 const upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6598 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
6599 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6600 if (size) {
6601 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6602 }
6603 return arr;
6604 }
_google_protobuf_DescriptorProto_extension_mutable_upb_array(google_protobuf_DescriptorProto * msg,size_t * size,upb_Arena * arena)6605 UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_extension_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
6606 const upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6607 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
6608 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
6609 &field, arena);
6610 if (size) {
6611 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6612 }
6613 return arr;
6614 }
google_protobuf_DescriptorProto_clear_options(google_protobuf_DescriptorProto * msg)6615 UPB_INLINE void google_protobuf_DescriptorProto_clear_options(google_protobuf_DescriptorProto* msg) {
6616 const upb_MiniTableField field = {7, UPB_SIZE(32, 72), 65, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6617 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6618 }
google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto * msg)6619 UPB_INLINE const google_protobuf_MessageOptions* google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto* msg) {
6620 const google_protobuf_MessageOptions* default_val = NULL;
6621 const google_protobuf_MessageOptions* ret;
6622 const upb_MiniTableField field = {7, UPB_SIZE(32, 72), 65, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6623 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__MessageOptions_msg_init);
6624 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
6625 &default_val, &ret);
6626 return ret;
6627 }
google_protobuf_DescriptorProto_has_options(const google_protobuf_DescriptorProto * msg)6628 UPB_INLINE bool google_protobuf_DescriptorProto_has_options(const google_protobuf_DescriptorProto* msg) {
6629 const upb_MiniTableField field = {7, UPB_SIZE(32, 72), 65, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6630 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
6631 }
google_protobuf_DescriptorProto_clear_oneof_decl(google_protobuf_DescriptorProto * msg)6632 UPB_INLINE void google_protobuf_DescriptorProto_clear_oneof_decl(google_protobuf_DescriptorProto* msg) {
6633 const upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6634 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6635 }
google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto * msg,size_t * size)6636 UPB_INLINE const google_protobuf_OneofDescriptorProto* const* google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto* msg, size_t* size) {
6637 const upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6638 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__OneofDescriptorProto_msg_init);
6639 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6640 if (arr) {
6641 if (size) *size = arr->UPB_PRIVATE(size);
6642 return (const google_protobuf_OneofDescriptorProto* const*)upb_Array_DataPtr(arr);
6643 } else {
6644 if (size) *size = 0;
6645 return NULL;
6646 }
6647 }
_google_protobuf_DescriptorProto_oneof_decl_upb_array(const google_protobuf_DescriptorProto * msg,size_t * size)6648 UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_oneof_decl_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
6649 const upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6650 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__OneofDescriptorProto_msg_init);
6651 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6652 if (size) {
6653 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6654 }
6655 return arr;
6656 }
_google_protobuf_DescriptorProto_oneof_decl_mutable_upb_array(google_protobuf_DescriptorProto * msg,size_t * size,upb_Arena * arena)6657 UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_oneof_decl_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
6658 const upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6659 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__OneofDescriptorProto_msg_init);
6660 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
6661 &field, arena);
6662 if (size) {
6663 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6664 }
6665 return arr;
6666 }
google_protobuf_DescriptorProto_clear_reserved_range(google_protobuf_DescriptorProto * msg)6667 UPB_INLINE void google_protobuf_DescriptorProto_clear_reserved_range(google_protobuf_DescriptorProto* msg) {
6668 const upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6669 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6670 }
google_protobuf_DescriptorProto_reserved_range(const google_protobuf_DescriptorProto * msg,size_t * size)6671 UPB_INLINE const google_protobuf_DescriptorProto_ReservedRange* const* google_protobuf_DescriptorProto_reserved_range(const google_protobuf_DescriptorProto* msg, size_t* size) {
6672 const upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6673 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto__ReservedRange_msg_init);
6674 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6675 if (arr) {
6676 if (size) *size = arr->UPB_PRIVATE(size);
6677 return (const google_protobuf_DescriptorProto_ReservedRange* const*)upb_Array_DataPtr(arr);
6678 } else {
6679 if (size) *size = 0;
6680 return NULL;
6681 }
6682 }
_google_protobuf_DescriptorProto_reserved_range_upb_array(const google_protobuf_DescriptorProto * msg,size_t * size)6683 UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_reserved_range_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
6684 const upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6685 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto__ReservedRange_msg_init);
6686 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6687 if (size) {
6688 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6689 }
6690 return arr;
6691 }
_google_protobuf_DescriptorProto_reserved_range_mutable_upb_array(google_protobuf_DescriptorProto * msg,size_t * size,upb_Arena * arena)6692 UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_reserved_range_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
6693 const upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6694 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto__ReservedRange_msg_init);
6695 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
6696 &field, arena);
6697 if (size) {
6698 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6699 }
6700 return arr;
6701 }
google_protobuf_DescriptorProto_clear_reserved_name(google_protobuf_DescriptorProto * msg)6702 UPB_INLINE void google_protobuf_DescriptorProto_clear_reserved_name(google_protobuf_DescriptorProto* msg) {
6703 const upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6704 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
6705 }
google_protobuf_DescriptorProto_reserved_name(const google_protobuf_DescriptorProto * msg,size_t * size)6706 UPB_INLINE upb_StringView const* google_protobuf_DescriptorProto_reserved_name(const google_protobuf_DescriptorProto* msg, size_t* size) {
6707 const upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6708 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6709 if (arr) {
6710 if (size) *size = arr->UPB_PRIVATE(size);
6711 return (upb_StringView const*)upb_Array_DataPtr(arr);
6712 } else {
6713 if (size) *size = 0;
6714 return NULL;
6715 }
6716 }
_google_protobuf_DescriptorProto_reserved_name_upb_array(const google_protobuf_DescriptorProto * msg,size_t * size)6717 UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_reserved_name_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
6718 const upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6719 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
6720 if (size) {
6721 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6722 }
6723 return arr;
6724 }
_google_protobuf_DescriptorProto_reserved_name_mutable_upb_array(google_protobuf_DescriptorProto * msg,size_t * size,upb_Arena * arena)6725 UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_reserved_name_mutable_upb_array(google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
6726 const upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6727 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
6728 &field, arena);
6729 if (size) {
6730 *size = arr ? arr->UPB_PRIVATE(size) : 0;
6731 }
6732 return arr;
6733 }
6734
google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto * msg,upb_StringView value)6735 UPB_INLINE void google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto *msg, upb_StringView value) {
6736 const upb_MiniTableField field = {1, UPB_SIZE(48, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
6737 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
6738 }
google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto * msg,size_t * size)6739 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto* msg, size_t* size) {
6740 upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6741 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
6742 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6743 if (arr) {
6744 if (size) *size = arr->UPB_PRIVATE(size);
6745 return (google_protobuf_FieldDescriptorProto**)upb_Array_MutableDataPtr(arr);
6746 } else {
6747 if (size) *size = 0;
6748 return NULL;
6749 }
6750 }
google_protobuf_DescriptorProto_resize_field(google_protobuf_DescriptorProto * msg,size_t size,upb_Arena * arena)6751 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_field(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) {
6752 upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6753 return (google_protobuf_FieldDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6754 &field, size, arena);
6755 }
google_protobuf_DescriptorProto_add_field(google_protobuf_DescriptorProto * msg,upb_Arena * arena)6756 UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_field(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
6757 upb_MiniTableField field = {2, UPB_SIZE(12, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6758 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
6759 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6760 UPB_UPCAST(msg), &field, arena);
6761 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6762 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6763 return NULL;
6764 }
6765 struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_Message_New(&google__protobuf__FieldDescriptorProto_msg_init, arena);
6766 if (!arr || !sub) return NULL;
6767 UPB_PRIVATE(_upb_Array_Set)
6768 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
6769 return sub;
6770 }
google_protobuf_DescriptorProto_mutable_nested_type(google_protobuf_DescriptorProto * msg,size_t * size)6771 UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_mutable_nested_type(google_protobuf_DescriptorProto* msg, size_t* size) {
6772 upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6773 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto_msg_init);
6774 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6775 if (arr) {
6776 if (size) *size = arr->UPB_PRIVATE(size);
6777 return (google_protobuf_DescriptorProto**)upb_Array_MutableDataPtr(arr);
6778 } else {
6779 if (size) *size = 0;
6780 return NULL;
6781 }
6782 }
google_protobuf_DescriptorProto_resize_nested_type(google_protobuf_DescriptorProto * msg,size_t size,upb_Arena * arena)6783 UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_resize_nested_type(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) {
6784 upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6785 return (google_protobuf_DescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6786 &field, size, arena);
6787 }
google_protobuf_DescriptorProto_add_nested_type(google_protobuf_DescriptorProto * msg,upb_Arena * arena)6788 UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_add_nested_type(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
6789 upb_MiniTableField field = {3, UPB_SIZE(16, 40), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6790 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto_msg_init);
6791 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6792 UPB_UPCAST(msg), &field, arena);
6793 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6794 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6795 return NULL;
6796 }
6797 struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)_upb_Message_New(&google__protobuf__DescriptorProto_msg_init, arena);
6798 if (!arr || !sub) return NULL;
6799 UPB_PRIVATE(_upb_Array_Set)
6800 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
6801 return sub;
6802 }
google_protobuf_DescriptorProto_mutable_enum_type(google_protobuf_DescriptorProto * msg,size_t * size)6803 UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_mutable_enum_type(google_protobuf_DescriptorProto* msg, size_t* size) {
6804 upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6805 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__EnumDescriptorProto_msg_init);
6806 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6807 if (arr) {
6808 if (size) *size = arr->UPB_PRIVATE(size);
6809 return (google_protobuf_EnumDescriptorProto**)upb_Array_MutableDataPtr(arr);
6810 } else {
6811 if (size) *size = 0;
6812 return NULL;
6813 }
6814 }
google_protobuf_DescriptorProto_resize_enum_type(google_protobuf_DescriptorProto * msg,size_t size,upb_Arena * arena)6815 UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_resize_enum_type(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) {
6816 upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6817 return (google_protobuf_EnumDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6818 &field, size, arena);
6819 }
google_protobuf_DescriptorProto_add_enum_type(google_protobuf_DescriptorProto * msg,upb_Arena * arena)6820 UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_DescriptorProto_add_enum_type(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
6821 upb_MiniTableField field = {4, UPB_SIZE(20, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6822 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__EnumDescriptorProto_msg_init);
6823 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6824 UPB_UPCAST(msg), &field, arena);
6825 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6826 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6827 return NULL;
6828 }
6829 struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)_upb_Message_New(&google__protobuf__EnumDescriptorProto_msg_init, arena);
6830 if (!arr || !sub) return NULL;
6831 UPB_PRIVATE(_upb_Array_Set)
6832 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
6833 return sub;
6834 }
google_protobuf_DescriptorProto_mutable_extension_range(google_protobuf_DescriptorProto * msg,size_t * size)6835 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_mutable_extension_range(google_protobuf_DescriptorProto* msg, size_t* size) {
6836 upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6837 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto__ExtensionRange_msg_init);
6838 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6839 if (arr) {
6840 if (size) *size = arr->UPB_PRIVATE(size);
6841 return (google_protobuf_DescriptorProto_ExtensionRange**)upb_Array_MutableDataPtr(arr);
6842 } else {
6843 if (size) *size = 0;
6844 return NULL;
6845 }
6846 }
google_protobuf_DescriptorProto_resize_extension_range(google_protobuf_DescriptorProto * msg,size_t size,upb_Arena * arena)6847 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_resize_extension_range(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) {
6848 upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6849 return (google_protobuf_DescriptorProto_ExtensionRange**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6850 &field, size, arena);
6851 }
google_protobuf_DescriptorProto_add_extension_range(google_protobuf_DescriptorProto * msg,upb_Arena * arena)6852 UPB_INLINE struct google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_add_extension_range(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
6853 upb_MiniTableField field = {5, UPB_SIZE(24, 56), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6854 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto__ExtensionRange_msg_init);
6855 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6856 UPB_UPCAST(msg), &field, arena);
6857 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6858 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6859 return NULL;
6860 }
6861 struct google_protobuf_DescriptorProto_ExtensionRange* sub = (struct google_protobuf_DescriptorProto_ExtensionRange*)_upb_Message_New(&google__protobuf__DescriptorProto__ExtensionRange_msg_init, arena);
6862 if (!arr || !sub) return NULL;
6863 UPB_PRIVATE(_upb_Array_Set)
6864 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
6865 return sub;
6866 }
google_protobuf_DescriptorProto_mutable_extension(google_protobuf_DescriptorProto * msg,size_t * size)6867 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_extension(google_protobuf_DescriptorProto* msg, size_t* size) {
6868 upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6869 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
6870 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6871 if (arr) {
6872 if (size) *size = arr->UPB_PRIVATE(size);
6873 return (google_protobuf_FieldDescriptorProto**)upb_Array_MutableDataPtr(arr);
6874 } else {
6875 if (size) *size = 0;
6876 return NULL;
6877 }
6878 }
google_protobuf_DescriptorProto_resize_extension(google_protobuf_DescriptorProto * msg,size_t size,upb_Arena * arena)6879 UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_extension(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) {
6880 upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6881 return (google_protobuf_FieldDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6882 &field, size, arena);
6883 }
google_protobuf_DescriptorProto_add_extension(google_protobuf_DescriptorProto * msg,upb_Arena * arena)6884 UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_extension(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
6885 upb_MiniTableField field = {6, UPB_SIZE(28, 64), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6886 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FieldDescriptorProto_msg_init);
6887 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6888 UPB_UPCAST(msg), &field, arena);
6889 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6890 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6891 return NULL;
6892 }
6893 struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_Message_New(&google__protobuf__FieldDescriptorProto_msg_init, arena);
6894 if (!arr || !sub) return NULL;
6895 UPB_PRIVATE(_upb_Array_Set)
6896 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
6897 return sub;
6898 }
google_protobuf_DescriptorProto_set_options(google_protobuf_DescriptorProto * msg,google_protobuf_MessageOptions * value)6899 UPB_INLINE void google_protobuf_DescriptorProto_set_options(google_protobuf_DescriptorProto *msg, google_protobuf_MessageOptions* value) {
6900 const upb_MiniTableField field = {7, UPB_SIZE(32, 72), 65, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6901 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__MessageOptions_msg_init);
6902 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
6903 }
google_protobuf_DescriptorProto_mutable_options(google_protobuf_DescriptorProto * msg,upb_Arena * arena)6904 UPB_INLINE struct google_protobuf_MessageOptions* google_protobuf_DescriptorProto_mutable_options(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
6905 struct google_protobuf_MessageOptions* sub = (struct google_protobuf_MessageOptions*)google_protobuf_DescriptorProto_options(msg);
6906 if (sub == NULL) {
6907 sub = (struct google_protobuf_MessageOptions*)_upb_Message_New(&google__protobuf__MessageOptions_msg_init, arena);
6908 if (sub) google_protobuf_DescriptorProto_set_options(msg, sub);
6909 }
6910 return sub;
6911 }
google_protobuf_DescriptorProto_mutable_oneof_decl(google_protobuf_DescriptorProto * msg,size_t * size)6912 UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_mutable_oneof_decl(google_protobuf_DescriptorProto* msg, size_t* size) {
6913 upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6914 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__OneofDescriptorProto_msg_init);
6915 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6916 if (arr) {
6917 if (size) *size = arr->UPB_PRIVATE(size);
6918 return (google_protobuf_OneofDescriptorProto**)upb_Array_MutableDataPtr(arr);
6919 } else {
6920 if (size) *size = 0;
6921 return NULL;
6922 }
6923 }
google_protobuf_DescriptorProto_resize_oneof_decl(google_protobuf_DescriptorProto * msg,size_t size,upb_Arena * arena)6924 UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_resize_oneof_decl(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) {
6925 upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6926 return (google_protobuf_OneofDescriptorProto**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6927 &field, size, arena);
6928 }
google_protobuf_DescriptorProto_add_oneof_decl(google_protobuf_DescriptorProto * msg,upb_Arena * arena)6929 UPB_INLINE struct google_protobuf_OneofDescriptorProto* google_protobuf_DescriptorProto_add_oneof_decl(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
6930 upb_MiniTableField field = {8, UPB_SIZE(36, 80), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6931 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__OneofDescriptorProto_msg_init);
6932 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6933 UPB_UPCAST(msg), &field, arena);
6934 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6935 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6936 return NULL;
6937 }
6938 struct google_protobuf_OneofDescriptorProto* sub = (struct google_protobuf_OneofDescriptorProto*)_upb_Message_New(&google__protobuf__OneofDescriptorProto_msg_init, arena);
6939 if (!arr || !sub) return NULL;
6940 UPB_PRIVATE(_upb_Array_Set)
6941 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
6942 return sub;
6943 }
google_protobuf_DescriptorProto_mutable_reserved_range(google_protobuf_DescriptorProto * msg,size_t * size)6944 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_mutable_reserved_range(google_protobuf_DescriptorProto* msg, size_t* size) {
6945 upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6946 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto__ReservedRange_msg_init);
6947 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6948 if (arr) {
6949 if (size) *size = arr->UPB_PRIVATE(size);
6950 return (google_protobuf_DescriptorProto_ReservedRange**)upb_Array_MutableDataPtr(arr);
6951 } else {
6952 if (size) *size = 0;
6953 return NULL;
6954 }
6955 }
google_protobuf_DescriptorProto_resize_reserved_range(google_protobuf_DescriptorProto * msg,size_t size,upb_Arena * arena)6956 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_resize_reserved_range(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) {
6957 upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6958 return (google_protobuf_DescriptorProto_ReservedRange**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6959 &field, size, arena);
6960 }
google_protobuf_DescriptorProto_add_reserved_range(google_protobuf_DescriptorProto * msg,upb_Arena * arena)6961 UPB_INLINE struct google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_add_reserved_range(google_protobuf_DescriptorProto* msg, upb_Arena* arena) {
6962 upb_MiniTableField field = {9, UPB_SIZE(40, 88), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6963 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__DescriptorProto__ReservedRange_msg_init);
6964 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6965 UPB_UPCAST(msg), &field, arena);
6966 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6967 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6968 return NULL;
6969 }
6970 struct google_protobuf_DescriptorProto_ReservedRange* sub = (struct google_protobuf_DescriptorProto_ReservedRange*)_upb_Message_New(&google__protobuf__DescriptorProto__ReservedRange_msg_init, arena);
6971 if (!arr || !sub) return NULL;
6972 UPB_PRIVATE(_upb_Array_Set)
6973 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
6974 return sub;
6975 }
google_protobuf_DescriptorProto_mutable_reserved_name(google_protobuf_DescriptorProto * msg,size_t * size)6976 UPB_INLINE upb_StringView* google_protobuf_DescriptorProto_mutable_reserved_name(google_protobuf_DescriptorProto* msg, size_t* size) {
6977 upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6978 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
6979 if (arr) {
6980 if (size) *size = arr->UPB_PRIVATE(size);
6981 return (upb_StringView*)upb_Array_MutableDataPtr(arr);
6982 } else {
6983 if (size) *size = 0;
6984 return NULL;
6985 }
6986 }
google_protobuf_DescriptorProto_resize_reserved_name(google_protobuf_DescriptorProto * msg,size_t size,upb_Arena * arena)6987 UPB_INLINE upb_StringView* google_protobuf_DescriptorProto_resize_reserved_name(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) {
6988 upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6989 return (upb_StringView*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
6990 &field, size, arena);
6991 }
google_protobuf_DescriptorProto_add_reserved_name(google_protobuf_DescriptorProto * msg,upb_StringView val,upb_Arena * arena)6992 UPB_INLINE bool google_protobuf_DescriptorProto_add_reserved_name(google_protobuf_DescriptorProto* msg, upb_StringView val, upb_Arena* arena) {
6993 upb_MiniTableField field = {10, UPB_SIZE(44, 96), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
6994 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
6995 UPB_UPCAST(msg), &field, arena);
6996 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
6997 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
6998 return false;
6999 }
7000 UPB_PRIVATE(_upb_Array_Set)
7001 (arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val));
7002 return true;
7003 }
7004
7005 /* google.protobuf.DescriptorProto.ExtensionRange */
7006
google_protobuf_DescriptorProto_ExtensionRange_new(upb_Arena * arena)7007 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_new(upb_Arena* arena) {
7008 return (google_protobuf_DescriptorProto_ExtensionRange*)_upb_Message_New(&google__protobuf__DescriptorProto__ExtensionRange_msg_init, arena);
7009 }
google_protobuf_DescriptorProto_ExtensionRange_parse(const char * buf,size_t size,upb_Arena * arena)7010 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_parse(const char* buf, size_t size, upb_Arena* arena) {
7011 google_protobuf_DescriptorProto_ExtensionRange* ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena);
7012 if (!ret) return NULL;
7013 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__DescriptorProto__ExtensionRange_msg_init, NULL, 0, arena) !=
7014 kUpb_DecodeStatus_Ok) {
7015 return NULL;
7016 }
7017 return ret;
7018 }
google_protobuf_DescriptorProto_ExtensionRange_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)7019 UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_parse_ex(const char* buf, size_t size,
7020 const upb_ExtensionRegistry* extreg,
7021 int options, upb_Arena* arena) {
7022 google_protobuf_DescriptorProto_ExtensionRange* ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena);
7023 if (!ret) return NULL;
7024 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__DescriptorProto__ExtensionRange_msg_init, extreg, options,
7025 arena) != kUpb_DecodeStatus_Ok) {
7026 return NULL;
7027 }
7028 return ret;
7029 }
google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange * msg,upb_Arena * arena,size_t * len)7030 UPB_INLINE char* google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange* msg, upb_Arena* arena, size_t* len) {
7031 char* ptr;
7032 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__DescriptorProto__ExtensionRange_msg_init, 0, arena, &ptr, len);
7033 return ptr;
7034 }
google_protobuf_DescriptorProto_ExtensionRange_serialize_ex(const google_protobuf_DescriptorProto_ExtensionRange * msg,int options,upb_Arena * arena,size_t * len)7035 UPB_INLINE char* google_protobuf_DescriptorProto_ExtensionRange_serialize_ex(const google_protobuf_DescriptorProto_ExtensionRange* msg, int options,
7036 upb_Arena* arena, size_t* len) {
7037 char* ptr;
7038 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__DescriptorProto__ExtensionRange_msg_init, options, arena, &ptr, len);
7039 return ptr;
7040 }
google_protobuf_DescriptorProto_ExtensionRange_clear_start(google_protobuf_DescriptorProto_ExtensionRange * msg)7041 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_start(google_protobuf_DescriptorProto_ExtensionRange* msg) {
7042 const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7043 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7044 }
google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange * msg)7045 UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
7046 int32_t default_val = (int32_t)0;
7047 int32_t ret;
7048 const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7049 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7050 &default_val, &ret);
7051 return ret;
7052 }
google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange * msg)7053 UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
7054 const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7055 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7056 }
google_protobuf_DescriptorProto_ExtensionRange_clear_end(google_protobuf_DescriptorProto_ExtensionRange * msg)7057 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_end(google_protobuf_DescriptorProto_ExtensionRange* msg) {
7058 const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7059 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7060 }
google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange * msg)7061 UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
7062 int32_t default_val = (int32_t)0;
7063 int32_t ret;
7064 const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7065 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7066 &default_val, &ret);
7067 return ret;
7068 }
google_protobuf_DescriptorProto_ExtensionRange_has_end(const google_protobuf_DescriptorProto_ExtensionRange * msg)7069 UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_end(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
7070 const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7071 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7072 }
google_protobuf_DescriptorProto_ExtensionRange_clear_options(google_protobuf_DescriptorProto_ExtensionRange * msg)7073 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_options(google_protobuf_DescriptorProto_ExtensionRange* msg) {
7074 const upb_MiniTableField field = {3, UPB_SIZE(20, 24), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7075 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7076 }
google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange * msg)7077 UPB_INLINE const google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
7078 const google_protobuf_ExtensionRangeOptions* default_val = NULL;
7079 const google_protobuf_ExtensionRangeOptions* ret;
7080 const upb_MiniTableField field = {3, UPB_SIZE(20, 24), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7081 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__ExtensionRangeOptions_msg_init);
7082 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7083 &default_val, &ret);
7084 return ret;
7085 }
google_protobuf_DescriptorProto_ExtensionRange_has_options(const google_protobuf_DescriptorProto_ExtensionRange * msg)7086 UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_options(const google_protobuf_DescriptorProto_ExtensionRange* msg) {
7087 const upb_MiniTableField field = {3, UPB_SIZE(20, 24), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7088 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7089 }
7090
google_protobuf_DescriptorProto_ExtensionRange_set_start(google_protobuf_DescriptorProto_ExtensionRange * msg,int32_t value)7091 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_start(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) {
7092 const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7093 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
7094 }
google_protobuf_DescriptorProto_ExtensionRange_set_end(google_protobuf_DescriptorProto_ExtensionRange * msg,int32_t value)7095 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_end(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) {
7096 const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7097 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
7098 }
google_protobuf_DescriptorProto_ExtensionRange_set_options(google_protobuf_DescriptorProto_ExtensionRange * msg,google_protobuf_ExtensionRangeOptions * value)7099 UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_options(google_protobuf_DescriptorProto_ExtensionRange *msg, google_protobuf_ExtensionRangeOptions* value) {
7100 const upb_MiniTableField field = {3, UPB_SIZE(20, 24), 66, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7101 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__ExtensionRangeOptions_msg_init);
7102 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
7103 }
google_protobuf_DescriptorProto_ExtensionRange_mutable_options(google_protobuf_DescriptorProto_ExtensionRange * msg,upb_Arena * arena)7104 UPB_INLINE struct google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_mutable_options(google_protobuf_DescriptorProto_ExtensionRange* msg, upb_Arena* arena) {
7105 struct google_protobuf_ExtensionRangeOptions* sub = (struct google_protobuf_ExtensionRangeOptions*)google_protobuf_DescriptorProto_ExtensionRange_options(msg);
7106 if (sub == NULL) {
7107 sub = (struct google_protobuf_ExtensionRangeOptions*)_upb_Message_New(&google__protobuf__ExtensionRangeOptions_msg_init, arena);
7108 if (sub) google_protobuf_DescriptorProto_ExtensionRange_set_options(msg, sub);
7109 }
7110 return sub;
7111 }
7112
7113 /* google.protobuf.DescriptorProto.ReservedRange */
7114
google_protobuf_DescriptorProto_ReservedRange_new(upb_Arena * arena)7115 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_new(upb_Arena* arena) {
7116 return (google_protobuf_DescriptorProto_ReservedRange*)_upb_Message_New(&google__protobuf__DescriptorProto__ReservedRange_msg_init, arena);
7117 }
google_protobuf_DescriptorProto_ReservedRange_parse(const char * buf,size_t size,upb_Arena * arena)7118 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_parse(const char* buf, size_t size, upb_Arena* arena) {
7119 google_protobuf_DescriptorProto_ReservedRange* ret = google_protobuf_DescriptorProto_ReservedRange_new(arena);
7120 if (!ret) return NULL;
7121 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__DescriptorProto__ReservedRange_msg_init, NULL, 0, arena) !=
7122 kUpb_DecodeStatus_Ok) {
7123 return NULL;
7124 }
7125 return ret;
7126 }
google_protobuf_DescriptorProto_ReservedRange_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)7127 UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_parse_ex(const char* buf, size_t size,
7128 const upb_ExtensionRegistry* extreg,
7129 int options, upb_Arena* arena) {
7130 google_protobuf_DescriptorProto_ReservedRange* ret = google_protobuf_DescriptorProto_ReservedRange_new(arena);
7131 if (!ret) return NULL;
7132 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__DescriptorProto__ReservedRange_msg_init, extreg, options,
7133 arena) != kUpb_DecodeStatus_Ok) {
7134 return NULL;
7135 }
7136 return ret;
7137 }
google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange * msg,upb_Arena * arena,size_t * len)7138 UPB_INLINE char* google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange* msg, upb_Arena* arena, size_t* len) {
7139 char* ptr;
7140 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__DescriptorProto__ReservedRange_msg_init, 0, arena, &ptr, len);
7141 return ptr;
7142 }
google_protobuf_DescriptorProto_ReservedRange_serialize_ex(const google_protobuf_DescriptorProto_ReservedRange * msg,int options,upb_Arena * arena,size_t * len)7143 UPB_INLINE char* google_protobuf_DescriptorProto_ReservedRange_serialize_ex(const google_protobuf_DescriptorProto_ReservedRange* msg, int options,
7144 upb_Arena* arena, size_t* len) {
7145 char* ptr;
7146 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__DescriptorProto__ReservedRange_msg_init, options, arena, &ptr, len);
7147 return ptr;
7148 }
google_protobuf_DescriptorProto_ReservedRange_clear_start(google_protobuf_DescriptorProto_ReservedRange * msg)7149 UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_clear_start(google_protobuf_DescriptorProto_ReservedRange* msg) {
7150 const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7151 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7152 }
google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange * msg)7153 UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange* msg) {
7154 int32_t default_val = (int32_t)0;
7155 int32_t ret;
7156 const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7157 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7158 &default_val, &ret);
7159 return ret;
7160 }
google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange * msg)7161 UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange* msg) {
7162 const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7163 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7164 }
google_protobuf_DescriptorProto_ReservedRange_clear_end(google_protobuf_DescriptorProto_ReservedRange * msg)7165 UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_clear_end(google_protobuf_DescriptorProto_ReservedRange* msg) {
7166 const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7167 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7168 }
google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange * msg)7169 UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange* msg) {
7170 int32_t default_val = (int32_t)0;
7171 int32_t ret;
7172 const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7173 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7174 &default_val, &ret);
7175 return ret;
7176 }
google_protobuf_DescriptorProto_ReservedRange_has_end(const google_protobuf_DescriptorProto_ReservedRange * msg)7177 UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_end(const google_protobuf_DescriptorProto_ReservedRange* msg) {
7178 const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7179 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7180 }
7181
google_protobuf_DescriptorProto_ReservedRange_set_start(google_protobuf_DescriptorProto_ReservedRange * msg,int32_t value)7182 UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_start(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) {
7183 const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7184 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
7185 }
google_protobuf_DescriptorProto_ReservedRange_set_end(google_protobuf_DescriptorProto_ReservedRange * msg,int32_t value)7186 UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_end(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) {
7187 const upb_MiniTableField field = {2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7188 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
7189 }
7190
7191 /* google.protobuf.ExtensionRangeOptions */
7192
google_protobuf_ExtensionRangeOptions_new(upb_Arena * arena)7193 UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_new(upb_Arena* arena) {
7194 return (google_protobuf_ExtensionRangeOptions*)_upb_Message_New(&google__protobuf__ExtensionRangeOptions_msg_init, arena);
7195 }
google_protobuf_ExtensionRangeOptions_parse(const char * buf,size_t size,upb_Arena * arena)7196 UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_parse(const char* buf, size_t size, upb_Arena* arena) {
7197 google_protobuf_ExtensionRangeOptions* ret = google_protobuf_ExtensionRangeOptions_new(arena);
7198 if (!ret) return NULL;
7199 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__ExtensionRangeOptions_msg_init, NULL, 0, arena) !=
7200 kUpb_DecodeStatus_Ok) {
7201 return NULL;
7202 }
7203 return ret;
7204 }
google_protobuf_ExtensionRangeOptions_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)7205 UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_parse_ex(const char* buf, size_t size,
7206 const upb_ExtensionRegistry* extreg,
7207 int options, upb_Arena* arena) {
7208 google_protobuf_ExtensionRangeOptions* ret = google_protobuf_ExtensionRangeOptions_new(arena);
7209 if (!ret) return NULL;
7210 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__ExtensionRangeOptions_msg_init, extreg, options,
7211 arena) != kUpb_DecodeStatus_Ok) {
7212 return NULL;
7213 }
7214 return ret;
7215 }
google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions * msg,upb_Arena * arena,size_t * len)7216 UPB_INLINE char* google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena, size_t* len) {
7217 char* ptr;
7218 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__ExtensionRangeOptions_msg_init, 0, arena, &ptr, len);
7219 return ptr;
7220 }
google_protobuf_ExtensionRangeOptions_serialize_ex(const google_protobuf_ExtensionRangeOptions * msg,int options,upb_Arena * arena,size_t * len)7221 UPB_INLINE char* google_protobuf_ExtensionRangeOptions_serialize_ex(const google_protobuf_ExtensionRangeOptions* msg, int options,
7222 upb_Arena* arena, size_t* len) {
7223 char* ptr;
7224 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__ExtensionRangeOptions_msg_init, options, arena, &ptr, len);
7225 return ptr;
7226 }
google_protobuf_ExtensionRangeOptions_clear_declaration(google_protobuf_ExtensionRangeOptions * msg)7227 UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_declaration(google_protobuf_ExtensionRangeOptions* msg) {
7228 const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7229 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7230 }
google_protobuf_ExtensionRangeOptions_declaration(const google_protobuf_ExtensionRangeOptions * msg,size_t * size)7231 UPB_INLINE const google_protobuf_ExtensionRangeOptions_Declaration* const* google_protobuf_ExtensionRangeOptions_declaration(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) {
7232 const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7233 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__ExtensionRangeOptions__Declaration_msg_init);
7234 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
7235 if (arr) {
7236 if (size) *size = arr->UPB_PRIVATE(size);
7237 return (const google_protobuf_ExtensionRangeOptions_Declaration* const*)upb_Array_DataPtr(arr);
7238 } else {
7239 if (size) *size = 0;
7240 return NULL;
7241 }
7242 }
_google_protobuf_ExtensionRangeOptions_declaration_upb_array(const google_protobuf_ExtensionRangeOptions * msg,size_t * size)7243 UPB_INLINE const upb_Array* _google_protobuf_ExtensionRangeOptions_declaration_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) {
7244 const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7245 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__ExtensionRangeOptions__Declaration_msg_init);
7246 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
7247 if (size) {
7248 *size = arr ? arr->UPB_PRIVATE(size) : 0;
7249 }
7250 return arr;
7251 }
_google_protobuf_ExtensionRangeOptions_declaration_mutable_upb_array(google_protobuf_ExtensionRangeOptions * msg,size_t * size,upb_Arena * arena)7252 UPB_INLINE upb_Array* _google_protobuf_ExtensionRangeOptions_declaration_mutable_upb_array(google_protobuf_ExtensionRangeOptions* msg, size_t* size, upb_Arena* arena) {
7253 const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7254 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__ExtensionRangeOptions__Declaration_msg_init);
7255 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
7256 &field, arena);
7257 if (size) {
7258 *size = arr ? arr->UPB_PRIVATE(size) : 0;
7259 }
7260 return arr;
7261 }
google_protobuf_ExtensionRangeOptions_clear_verification(google_protobuf_ExtensionRangeOptions * msg)7262 UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_verification(google_protobuf_ExtensionRangeOptions* msg) {
7263 const upb_MiniTableField field = {3, UPB_SIZE(16, 12), 64, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7264 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7265 }
google_protobuf_ExtensionRangeOptions_verification(const google_protobuf_ExtensionRangeOptions * msg)7266 UPB_INLINE int32_t google_protobuf_ExtensionRangeOptions_verification(const google_protobuf_ExtensionRangeOptions* msg) {
7267 int32_t default_val = 1;
7268 int32_t ret;
7269 const upb_MiniTableField field = {3, UPB_SIZE(16, 12), 64, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7270 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7271 &default_val, &ret);
7272 return ret;
7273 }
google_protobuf_ExtensionRangeOptions_has_verification(const google_protobuf_ExtensionRangeOptions * msg)7274 UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_verification(const google_protobuf_ExtensionRangeOptions* msg) {
7275 const upb_MiniTableField field = {3, UPB_SIZE(16, 12), 64, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7276 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7277 }
google_protobuf_ExtensionRangeOptions_clear_features(google_protobuf_ExtensionRangeOptions * msg)7278 UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_features(google_protobuf_ExtensionRangeOptions* msg) {
7279 const upb_MiniTableField field = {50, UPB_SIZE(20, 24), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7280 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7281 }
google_protobuf_ExtensionRangeOptions_features(const google_protobuf_ExtensionRangeOptions * msg)7282 UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_ExtensionRangeOptions_features(const google_protobuf_ExtensionRangeOptions* msg) {
7283 const google_protobuf_FeatureSet* default_val = NULL;
7284 const google_protobuf_FeatureSet* ret;
7285 const upb_MiniTableField field = {50, UPB_SIZE(20, 24), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7286 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FeatureSet_msg_init);
7287 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7288 &default_val, &ret);
7289 return ret;
7290 }
google_protobuf_ExtensionRangeOptions_has_features(const google_protobuf_ExtensionRangeOptions * msg)7291 UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_features(const google_protobuf_ExtensionRangeOptions* msg) {
7292 const upb_MiniTableField field = {50, UPB_SIZE(20, 24), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7293 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7294 }
google_protobuf_ExtensionRangeOptions_clear_uninterpreted_option(google_protobuf_ExtensionRangeOptions * msg)7295 UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg) {
7296 const upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7297 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7298 }
google_protobuf_ExtensionRangeOptions_uninterpreted_option(const google_protobuf_ExtensionRangeOptions * msg,size_t * size)7299 UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ExtensionRangeOptions_uninterpreted_option(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) {
7300 const upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7301 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__UninterpretedOption_msg_init);
7302 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
7303 if (arr) {
7304 if (size) *size = arr->UPB_PRIVATE(size);
7305 return (const google_protobuf_UninterpretedOption* const*)upb_Array_DataPtr(arr);
7306 } else {
7307 if (size) *size = 0;
7308 return NULL;
7309 }
7310 }
_google_protobuf_ExtensionRangeOptions_uninterpreted_option_upb_array(const google_protobuf_ExtensionRangeOptions * msg,size_t * size)7311 UPB_INLINE const upb_Array* _google_protobuf_ExtensionRangeOptions_uninterpreted_option_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) {
7312 const upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7313 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__UninterpretedOption_msg_init);
7314 const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
7315 if (size) {
7316 *size = arr ? arr->UPB_PRIVATE(size) : 0;
7317 }
7318 return arr;
7319 }
_google_protobuf_ExtensionRangeOptions_uninterpreted_option_mutable_upb_array(google_protobuf_ExtensionRangeOptions * msg,size_t * size,upb_Arena * arena)7320 UPB_INLINE upb_Array* _google_protobuf_ExtensionRangeOptions_uninterpreted_option_mutable_upb_array(google_protobuf_ExtensionRangeOptions* msg, size_t* size, upb_Arena* arena) {
7321 const upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7322 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__UninterpretedOption_msg_init);
7323 upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
7324 &field, arena);
7325 if (size) {
7326 *size = arr ? arr->UPB_PRIVATE(size) : 0;
7327 }
7328 return arr;
7329 }
7330
google_protobuf_ExtensionRangeOptions_mutable_declaration(google_protobuf_ExtensionRangeOptions * msg,size_t * size)7331 UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration** google_protobuf_ExtensionRangeOptions_mutable_declaration(google_protobuf_ExtensionRangeOptions* msg, size_t* size) {
7332 upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7333 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__ExtensionRangeOptions__Declaration_msg_init);
7334 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
7335 if (arr) {
7336 if (size) *size = arr->UPB_PRIVATE(size);
7337 return (google_protobuf_ExtensionRangeOptions_Declaration**)upb_Array_MutableDataPtr(arr);
7338 } else {
7339 if (size) *size = 0;
7340 return NULL;
7341 }
7342 }
google_protobuf_ExtensionRangeOptions_resize_declaration(google_protobuf_ExtensionRangeOptions * msg,size_t size,upb_Arena * arena)7343 UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration** google_protobuf_ExtensionRangeOptions_resize_declaration(google_protobuf_ExtensionRangeOptions* msg, size_t size, upb_Arena* arena) {
7344 upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7345 return (google_protobuf_ExtensionRangeOptions_Declaration**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
7346 &field, size, arena);
7347 }
google_protobuf_ExtensionRangeOptions_add_declaration(google_protobuf_ExtensionRangeOptions * msg,upb_Arena * arena)7348 UPB_INLINE struct google_protobuf_ExtensionRangeOptions_Declaration* google_protobuf_ExtensionRangeOptions_add_declaration(google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena) {
7349 upb_MiniTableField field = {2, UPB_SIZE(12, 16), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7350 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__ExtensionRangeOptions__Declaration_msg_init);
7351 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
7352 UPB_UPCAST(msg), &field, arena);
7353 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
7354 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
7355 return NULL;
7356 }
7357 struct google_protobuf_ExtensionRangeOptions_Declaration* sub = (struct google_protobuf_ExtensionRangeOptions_Declaration*)_upb_Message_New(&google__protobuf__ExtensionRangeOptions__Declaration_msg_init, arena);
7358 if (!arr || !sub) return NULL;
7359 UPB_PRIVATE(_upb_Array_Set)
7360 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
7361 return sub;
7362 }
google_protobuf_ExtensionRangeOptions_set_verification(google_protobuf_ExtensionRangeOptions * msg,int32_t value)7363 UPB_INLINE void google_protobuf_ExtensionRangeOptions_set_verification(google_protobuf_ExtensionRangeOptions *msg, int32_t value) {
7364 const upb_MiniTableField field = {3, UPB_SIZE(16, 12), 64, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7365 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
7366 }
google_protobuf_ExtensionRangeOptions_set_features(google_protobuf_ExtensionRangeOptions * msg,google_protobuf_FeatureSet * value)7367 UPB_INLINE void google_protobuf_ExtensionRangeOptions_set_features(google_protobuf_ExtensionRangeOptions *msg, google_protobuf_FeatureSet* value) {
7368 const upb_MiniTableField field = {50, UPB_SIZE(20, 24), 65, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7369 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__FeatureSet_msg_init);
7370 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
7371 }
google_protobuf_ExtensionRangeOptions_mutable_features(google_protobuf_ExtensionRangeOptions * msg,upb_Arena * arena)7372 UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_ExtensionRangeOptions_mutable_features(google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena) {
7373 struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_ExtensionRangeOptions_features(msg);
7374 if (sub == NULL) {
7375 sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google__protobuf__FeatureSet_msg_init, arena);
7376 if (sub) google_protobuf_ExtensionRangeOptions_set_features(msg, sub);
7377 }
7378 return sub;
7379 }
google_protobuf_ExtensionRangeOptions_mutable_uninterpreted_option(google_protobuf_ExtensionRangeOptions * msg,size_t * size)7380 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_mutable_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, size_t* size) {
7381 upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7382 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__UninterpretedOption_msg_init);
7383 upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
7384 if (arr) {
7385 if (size) *size = arr->UPB_PRIVATE(size);
7386 return (google_protobuf_UninterpretedOption**)upb_Array_MutableDataPtr(arr);
7387 } else {
7388 if (size) *size = 0;
7389 return NULL;
7390 }
7391 }
google_protobuf_ExtensionRangeOptions_resize_uninterpreted_option(google_protobuf_ExtensionRangeOptions * msg,size_t size,upb_Arena * arena)7392 UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_resize_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, size_t size, upb_Arena* arena) {
7393 upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7394 return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
7395 &field, size, arena);
7396 }
google_protobuf_ExtensionRangeOptions_add_uninterpreted_option(google_protobuf_ExtensionRangeOptions * msg,upb_Arena * arena)7397 UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ExtensionRangeOptions_add_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena) {
7398 upb_MiniTableField field = {999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
7399 UPB_PRIVATE(_upb_MiniTable_StrongReference)(&google__protobuf__UninterpretedOption_msg_init);
7400 upb_Array* arr = upb_Message_GetOrCreateMutableArray(
7401 UPB_UPCAST(msg), &field, arena);
7402 if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
7403 arr, arr->UPB_PRIVATE(size) + 1, arena)) {
7404 return NULL;
7405 }
7406 struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(&google__protobuf__UninterpretedOption_msg_init, arena);
7407 if (!arr || !sub) return NULL;
7408 UPB_PRIVATE(_upb_Array_Set)
7409 (arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
7410 return sub;
7411 }
7412
7413 /* google.protobuf.ExtensionRangeOptions.Declaration */
7414
google_protobuf_ExtensionRangeOptions_Declaration_new(upb_Arena * arena)7415 UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration* google_protobuf_ExtensionRangeOptions_Declaration_new(upb_Arena* arena) {
7416 return (google_protobuf_ExtensionRangeOptions_Declaration*)_upb_Message_New(&google__protobuf__ExtensionRangeOptions__Declaration_msg_init, arena);
7417 }
google_protobuf_ExtensionRangeOptions_Declaration_parse(const char * buf,size_t size,upb_Arena * arena)7418 UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration* google_protobuf_ExtensionRangeOptions_Declaration_parse(const char* buf, size_t size, upb_Arena* arena) {
7419 google_protobuf_ExtensionRangeOptions_Declaration* ret = google_protobuf_ExtensionRangeOptions_Declaration_new(arena);
7420 if (!ret) return NULL;
7421 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__ExtensionRangeOptions__Declaration_msg_init, NULL, 0, arena) !=
7422 kUpb_DecodeStatus_Ok) {
7423 return NULL;
7424 }
7425 return ret;
7426 }
google_protobuf_ExtensionRangeOptions_Declaration_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)7427 UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration* google_protobuf_ExtensionRangeOptions_Declaration_parse_ex(const char* buf, size_t size,
7428 const upb_ExtensionRegistry* extreg,
7429 int options, upb_Arena* arena) {
7430 google_protobuf_ExtensionRangeOptions_Declaration* ret = google_protobuf_ExtensionRangeOptions_Declaration_new(arena);
7431 if (!ret) return NULL;
7432 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__ExtensionRangeOptions__Declaration_msg_init, extreg, options,
7433 arena) != kUpb_DecodeStatus_Ok) {
7434 return NULL;
7435 }
7436 return ret;
7437 }
google_protobuf_ExtensionRangeOptions_Declaration_serialize(const google_protobuf_ExtensionRangeOptions_Declaration * msg,upb_Arena * arena,size_t * len)7438 UPB_INLINE char* google_protobuf_ExtensionRangeOptions_Declaration_serialize(const google_protobuf_ExtensionRangeOptions_Declaration* msg, upb_Arena* arena, size_t* len) {
7439 char* ptr;
7440 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__ExtensionRangeOptions__Declaration_msg_init, 0, arena, &ptr, len);
7441 return ptr;
7442 }
google_protobuf_ExtensionRangeOptions_Declaration_serialize_ex(const google_protobuf_ExtensionRangeOptions_Declaration * msg,int options,upb_Arena * arena,size_t * len)7443 UPB_INLINE char* google_protobuf_ExtensionRangeOptions_Declaration_serialize_ex(const google_protobuf_ExtensionRangeOptions_Declaration* msg, int options,
7444 upb_Arena* arena, size_t* len) {
7445 char* ptr;
7446 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__ExtensionRangeOptions__Declaration_msg_init, options, arena, &ptr, len);
7447 return ptr;
7448 }
google_protobuf_ExtensionRangeOptions_Declaration_clear_number(google_protobuf_ExtensionRangeOptions_Declaration * msg)7449 UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_number(google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7450 const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7451 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7452 }
google_protobuf_ExtensionRangeOptions_Declaration_number(const google_protobuf_ExtensionRangeOptions_Declaration * msg)7453 UPB_INLINE int32_t google_protobuf_ExtensionRangeOptions_Declaration_number(const google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7454 int32_t default_val = (int32_t)0;
7455 int32_t ret;
7456 const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7457 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7458 &default_val, &ret);
7459 return ret;
7460 }
google_protobuf_ExtensionRangeOptions_Declaration_has_number(const google_protobuf_ExtensionRangeOptions_Declaration * msg)7461 UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_number(const google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7462 const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7463 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7464 }
google_protobuf_ExtensionRangeOptions_Declaration_clear_full_name(google_protobuf_ExtensionRangeOptions_Declaration * msg)7465 UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_full_name(google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7466 const upb_MiniTableField field = {2, UPB_SIZE(20, 24), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7467 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7468 }
google_protobuf_ExtensionRangeOptions_Declaration_full_name(const google_protobuf_ExtensionRangeOptions_Declaration * msg)7469 UPB_INLINE upb_StringView google_protobuf_ExtensionRangeOptions_Declaration_full_name(const google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7470 upb_StringView default_val = upb_StringView_FromString("");
7471 upb_StringView ret;
7472 const upb_MiniTableField field = {2, UPB_SIZE(20, 24), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7473 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7474 &default_val, &ret);
7475 return ret;
7476 }
google_protobuf_ExtensionRangeOptions_Declaration_has_full_name(const google_protobuf_ExtensionRangeOptions_Declaration * msg)7477 UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_full_name(const google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7478 const upb_MiniTableField field = {2, UPB_SIZE(20, 24), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7479 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7480 }
google_protobuf_ExtensionRangeOptions_Declaration_clear_type(google_protobuf_ExtensionRangeOptions_Declaration * msg)7481 UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_type(google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7482 const upb_MiniTableField field = {3, UPB_SIZE(28, 40), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7483 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7484 }
google_protobuf_ExtensionRangeOptions_Declaration_type(const google_protobuf_ExtensionRangeOptions_Declaration * msg)7485 UPB_INLINE upb_StringView google_protobuf_ExtensionRangeOptions_Declaration_type(const google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7486 upb_StringView default_val = upb_StringView_FromString("");
7487 upb_StringView ret;
7488 const upb_MiniTableField field = {3, UPB_SIZE(28, 40), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7489 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7490 &default_val, &ret);
7491 return ret;
7492 }
google_protobuf_ExtensionRangeOptions_Declaration_has_type(const google_protobuf_ExtensionRangeOptions_Declaration * msg)7493 UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_type(const google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7494 const upb_MiniTableField field = {3, UPB_SIZE(28, 40), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7495 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7496 }
google_protobuf_ExtensionRangeOptions_Declaration_clear_reserved(google_protobuf_ExtensionRangeOptions_Declaration * msg)7497 UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_reserved(google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7498 const upb_MiniTableField field = {5, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)};
7499 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7500 }
google_protobuf_ExtensionRangeOptions_Declaration_reserved(const google_protobuf_ExtensionRangeOptions_Declaration * msg)7501 UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_reserved(const google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7502 bool default_val = false;
7503 bool ret;
7504 const upb_MiniTableField field = {5, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)};
7505 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7506 &default_val, &ret);
7507 return ret;
7508 }
google_protobuf_ExtensionRangeOptions_Declaration_has_reserved(const google_protobuf_ExtensionRangeOptions_Declaration * msg)7509 UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_reserved(const google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7510 const upb_MiniTableField field = {5, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)};
7511 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7512 }
google_protobuf_ExtensionRangeOptions_Declaration_clear_repeated(google_protobuf_ExtensionRangeOptions_Declaration * msg)7513 UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_repeated(google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7514 const upb_MiniTableField field = {6, 17, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)};
7515 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7516 }
google_protobuf_ExtensionRangeOptions_Declaration_repeated(const google_protobuf_ExtensionRangeOptions_Declaration * msg)7517 UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_repeated(const google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7518 bool default_val = false;
7519 bool ret;
7520 const upb_MiniTableField field = {6, 17, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)};
7521 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7522 &default_val, &ret);
7523 return ret;
7524 }
google_protobuf_ExtensionRangeOptions_Declaration_has_repeated(const google_protobuf_ExtensionRangeOptions_Declaration * msg)7525 UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_repeated(const google_protobuf_ExtensionRangeOptions_Declaration* msg) {
7526 const upb_MiniTableField field = {6, 17, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)};
7527 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7528 }
7529
google_protobuf_ExtensionRangeOptions_Declaration_set_number(google_protobuf_ExtensionRangeOptions_Declaration * msg,int32_t value)7530 UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_number(google_protobuf_ExtensionRangeOptions_Declaration *msg, int32_t value) {
7531 const upb_MiniTableField field = {1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7532 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
7533 }
google_protobuf_ExtensionRangeOptions_Declaration_set_full_name(google_protobuf_ExtensionRangeOptions_Declaration * msg,upb_StringView value)7534 UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_full_name(google_protobuf_ExtensionRangeOptions_Declaration *msg, upb_StringView value) {
7535 const upb_MiniTableField field = {2, UPB_SIZE(20, 24), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7536 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
7537 }
google_protobuf_ExtensionRangeOptions_Declaration_set_type(google_protobuf_ExtensionRangeOptions_Declaration * msg,upb_StringView value)7538 UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_type(google_protobuf_ExtensionRangeOptions_Declaration *msg, upb_StringView value) {
7539 const upb_MiniTableField field = {3, UPB_SIZE(28, 40), 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7540 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
7541 }
google_protobuf_ExtensionRangeOptions_Declaration_set_reserved(google_protobuf_ExtensionRangeOptions_Declaration * msg,bool value)7542 UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_reserved(google_protobuf_ExtensionRangeOptions_Declaration *msg, bool value) {
7543 const upb_MiniTableField field = {5, 16, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)};
7544 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
7545 }
google_protobuf_ExtensionRangeOptions_Declaration_set_repeated(google_protobuf_ExtensionRangeOptions_Declaration * msg,bool value)7546 UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_repeated(google_protobuf_ExtensionRangeOptions_Declaration *msg, bool value) {
7547 const upb_MiniTableField field = {6, 17, 68, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)};
7548 upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
7549 }
7550
7551 /* google.protobuf.FieldDescriptorProto */
7552
google_protobuf_FieldDescriptorProto_new(upb_Arena * arena)7553 UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_new(upb_Arena* arena) {
7554 return (google_protobuf_FieldDescriptorProto*)_upb_Message_New(&google__protobuf__FieldDescriptorProto_msg_init, arena);
7555 }
google_protobuf_FieldDescriptorProto_parse(const char * buf,size_t size,upb_Arena * arena)7556 UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) {
7557 google_protobuf_FieldDescriptorProto* ret = google_protobuf_FieldDescriptorProto_new(arena);
7558 if (!ret) return NULL;
7559 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FieldDescriptorProto_msg_init, NULL, 0, arena) !=
7560 kUpb_DecodeStatus_Ok) {
7561 return NULL;
7562 }
7563 return ret;
7564 }
google_protobuf_FieldDescriptorProto_parse_ex(const char * buf,size_t size,const upb_ExtensionRegistry * extreg,int options,upb_Arena * arena)7565 UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_parse_ex(const char* buf, size_t size,
7566 const upb_ExtensionRegistry* extreg,
7567 int options, upb_Arena* arena) {
7568 google_protobuf_FieldDescriptorProto* ret = google_protobuf_FieldDescriptorProto_new(arena);
7569 if (!ret) return NULL;
7570 if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FieldDescriptorProto_msg_init, extreg, options,
7571 arena) != kUpb_DecodeStatus_Ok) {
7572 return NULL;
7573 }
7574 return ret;
7575 }
google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto * msg,upb_Arena * arena,size_t * len)7576 UPB_INLINE char* google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto* msg, upb_Arena* arena, size_t* len) {
7577 char* ptr;
7578 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FieldDescriptorProto_msg_init, 0, arena, &ptr, len);
7579 return ptr;
7580 }
google_protobuf_FieldDescriptorProto_serialize_ex(const google_protobuf_FieldDescriptorProto * msg,int options,upb_Arena * arena,size_t * len)7581 UPB_INLINE char* google_protobuf_FieldDescriptorProto_serialize_ex(const google_protobuf_FieldDescriptorProto* msg, int options,
7582 upb_Arena* arena, size_t* len) {
7583 char* ptr;
7584 (void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FieldDescriptorProto_msg_init, options, arena, &ptr, len);
7585 return ptr;
7586 }
google_protobuf_FieldDescriptorProto_clear_name(google_protobuf_FieldDescriptorProto * msg)7587 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_name(google_protobuf_FieldDescriptorProto* msg) {
7588 const upb_MiniTableField field = {1, UPB_SIZE(36, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7589 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7590 }
google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto * msg)7591 UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto* msg) {
7592 upb_StringView default_val = upb_StringView_FromString("");
7593 upb_StringView ret;
7594 const upb_MiniTableField field = {1, UPB_SIZE(36, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7595 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7596 &default_val, &ret);
7597 return ret;
7598 }
google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto * msg)7599 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto* msg) {
7600 const upb_MiniTableField field = {1, UPB_SIZE(36, 32), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7601 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7602 }
google_protobuf_FieldDescriptorProto_clear_extendee(google_protobuf_FieldDescriptorProto * msg)7603 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_extendee(google_protobuf_FieldDescriptorProto* msg) {
7604 const upb_MiniTableField field = {2, UPB_SIZE(44, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7605 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7606 }
google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto * msg)7607 UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto* msg) {
7608 upb_StringView default_val = upb_StringView_FromString("");
7609 upb_StringView ret;
7610 const upb_MiniTableField field = {2, UPB_SIZE(44, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7611 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7612 &default_val, &ret);
7613 return ret;
7614 }
google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto * msg)7615 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto* msg) {
7616 const upb_MiniTableField field = {2, UPB_SIZE(44, 48), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
7617 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7618 }
google_protobuf_FieldDescriptorProto_clear_number(google_protobuf_FieldDescriptorProto * msg)7619 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_number(google_protobuf_FieldDescriptorProto* msg) {
7620 const upb_MiniTableField field = {3, 12, 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7621 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7622 }
google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto * msg)7623 UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto* msg) {
7624 int32_t default_val = (int32_t)0;
7625 int32_t ret;
7626 const upb_MiniTableField field = {3, 12, 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7627 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7628 &default_val, &ret);
7629 return ret;
7630 }
google_protobuf_FieldDescriptorProto_has_number(const google_protobuf_FieldDescriptorProto * msg)7631 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_number(const google_protobuf_FieldDescriptorProto* msg) {
7632 const upb_MiniTableField field = {3, 12, 66, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7633 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7634 }
google_protobuf_FieldDescriptorProto_clear_label(google_protobuf_FieldDescriptorProto * msg)7635 UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_label(google_protobuf_FieldDescriptorProto* msg) {
7636 const upb_MiniTableField field = {4, 16, 67, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7637 upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
7638 }
google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto * msg)7639 UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto* msg) {
7640 int32_t default_val = 1;
7641 int32_t ret;
7642 const upb_MiniTableField field = {4, 16, 67, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7643 _upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
7644 &default_val, &ret);
7645 return ret;
7646 }
google_protobuf_FieldDescriptorProto_has_label(const google_protobuf_FieldDescriptorProto * msg)7647 UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_label(const google_protobuf_FieldDescriptorProto* msg) {
7648 const upb_MiniTableField field = {4, 16, 67, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
7649 return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
7650 }
google_protobuf_FieldDescriptorProto_clear_type(google_protobuf_FieldDescriptorProto * msg)7651