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