google-protobuf 4.35.1-java → 4.36.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/message.c +9 -3
- data/ext/google/protobuf_c/protobuf.c +38 -38
- data/ext/google/protobuf_c/ruby-upb.c +1966 -1276
- data/ext/google/protobuf_c/ruby-upb.h +2124 -867
- data/lib/google/protobuf/descriptor_pb.rb +3 -1
- data/lib/google/protobuf/ffi/message.rb +6 -4
- data/lib/google/protobuf/ffi/repeated_field.rb +3 -3
- data/lib/google/protobuf/json_enumvalue_options_pb.rb +19 -0
- data/lib/google/protobuf/json_options_pb.rb +16 -0
- data/lib/google/protobuf_java.jar +0 -0
- metadata +6 -4
|
@@ -37,6 +37,13 @@
|
|
|
37
37
|
#define UPB_GNUC_MIN(x, y) 0
|
|
38
38
|
#endif
|
|
39
39
|
|
|
40
|
+
#if defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__)
|
|
41
|
+
#define UPB_CLANG_MIN(x, y) \
|
|
42
|
+
(__clang_major__ > (x) || __clang_major__ == (x) && __clang_minor__ >= (y))
|
|
43
|
+
#else
|
|
44
|
+
#define UPB_CLANG_MIN(x, y) 0
|
|
45
|
+
#endif
|
|
46
|
+
|
|
40
47
|
// Macros for checking for compiler attributes, defined here to avoid the
|
|
41
48
|
// problem described in
|
|
42
49
|
// https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html.
|
|
@@ -46,6 +53,12 @@
|
|
|
46
53
|
#define UPB_HAS_ATTRIBUTE(x) 0
|
|
47
54
|
#endif
|
|
48
55
|
|
|
56
|
+
#ifdef __has_c_attribute
|
|
57
|
+
#define UPB_HAS_C_ATTRIBUTE(x) __has_c_attribute(x)
|
|
58
|
+
#else
|
|
59
|
+
#define UPB_HAS_C_ATTRIBUTE(x) 0
|
|
60
|
+
#endif
|
|
61
|
+
|
|
49
62
|
#if defined(__cplusplus) && defined(__has_cpp_attribute)
|
|
50
63
|
// NOTE: requiring __cplusplus above should not be necessary, but
|
|
51
64
|
// works around https://bugs.llvm.org/show_bug.cgi?id=23435.
|
|
@@ -284,12 +297,23 @@ Error, UINTPTR_MAX is undefined
|
|
|
284
297
|
#define UPB_PRINTF(str, first_vararg)
|
|
285
298
|
#endif
|
|
286
299
|
|
|
287
|
-
#if
|
|
300
|
+
#if UPB_HAS_ATTRIBUTE(noderef)
|
|
288
301
|
#define UPB_NODEREF __attribute__((noderef))
|
|
289
302
|
#else
|
|
290
303
|
#define UPB_NODEREF
|
|
291
304
|
#endif
|
|
292
305
|
|
|
306
|
+
// Will be defined properly once call sites are updated
|
|
307
|
+
#if false && UPB_HAS_C_ATTRIBUTE(nodiscard)
|
|
308
|
+
#define UPB_NODISCARD [[nodiscard]]
|
|
309
|
+
#elif false && UPB_HAS_ATTRIBUTE(warn_unused_result)
|
|
310
|
+
#define UPB_NODISCARD __attribute__((warn_unused_result))
|
|
311
|
+
#elif false && UPB_HAS_CPP_ATTRIBUTE(nodiscard)
|
|
312
|
+
#define UPB_NODISCARD [[nodiscard]]
|
|
313
|
+
#else
|
|
314
|
+
#define UPB_NODISCARD
|
|
315
|
+
#endif
|
|
316
|
+
|
|
293
317
|
#define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
|
|
294
318
|
#define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
|
|
295
319
|
|
|
@@ -338,21 +362,42 @@ Error, UINTPTR_MAX is undefined
|
|
|
338
362
|
#endif
|
|
339
363
|
|
|
340
364
|
#if defined(__GNUC__) || defined(__clang__)
|
|
341
|
-
#define
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
365
|
+
#define UPB_PRETTY_FUNCTION __PRETTY_FUNCTION__
|
|
366
|
+
#else
|
|
367
|
+
#define UPB_PRETTY_FUNCTION NULL
|
|
368
|
+
#endif
|
|
369
|
+
|
|
370
|
+
#ifdef __cplusplus
|
|
371
|
+
extern "C" {
|
|
372
|
+
#endif
|
|
373
|
+
UPB_NORETURN void _upb_UnreachableFailure(const char* file, int line,
|
|
374
|
+
const char* function_name);
|
|
375
|
+
#if !defined(NDEBUG)
|
|
376
|
+
#define UPB_UNREACHABLE_FAILURE() \
|
|
377
|
+
_upb_UnreachableFailure(__FILE__, __LINE__, UPB_PRETTY_FUNCTION);
|
|
378
|
+
#else
|
|
379
|
+
#define UPB_UNREACHABLE_FAILURE()
|
|
380
|
+
#endif
|
|
381
|
+
#ifdef __cplusplus
|
|
382
|
+
} /* extern "C" */
|
|
383
|
+
#endif
|
|
384
|
+
|
|
385
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
386
|
+
#define UPB_UNREACHABLE() \
|
|
387
|
+
do { \
|
|
388
|
+
UPB_UNREACHABLE_FAILURE(); \
|
|
389
|
+
__builtin_unreachable(); \
|
|
345
390
|
} while (0)
|
|
346
391
|
#elif defined(_MSC_VER)
|
|
347
|
-
#define UPB_UNREACHABLE()
|
|
348
|
-
do {
|
|
349
|
-
|
|
350
|
-
__assume(0);
|
|
392
|
+
#define UPB_UNREACHABLE() \
|
|
393
|
+
do { \
|
|
394
|
+
UPB_UNREACHABLE_FAILURE(); \
|
|
395
|
+
__assume(0); \
|
|
351
396
|
} while (0)
|
|
352
397
|
#else
|
|
353
|
-
#define UPB_UNREACHABLE()
|
|
354
|
-
do {
|
|
355
|
-
|
|
398
|
+
#define UPB_UNREACHABLE() \
|
|
399
|
+
do { \
|
|
400
|
+
UPB_UNREACHABLE_FAILURE(); \
|
|
356
401
|
} while (0)
|
|
357
402
|
#endif
|
|
358
403
|
|
|
@@ -447,21 +492,10 @@ Error, UINTPTR_MAX is undefined
|
|
|
447
492
|
#define UPB_ARM64_BTI_DEFAULT 0
|
|
448
493
|
#endif
|
|
449
494
|
|
|
450
|
-
/*
|
|
451
|
-
*
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
* GCC/Clang can mostly be trusted to generate tail calls as long as
|
|
455
|
-
* optimization is enabled, but, debug builds will not generate tail calls
|
|
456
|
-
* unless "musttail" is available.
|
|
457
|
-
*
|
|
458
|
-
* We should probably either:
|
|
459
|
-
* 1. require that the compiler supports musttail.
|
|
460
|
-
* 2. add some fallback code for when musttail isn't available (ie. return
|
|
461
|
-
* instead of tail calling). This is safe and portable, but this comes at
|
|
462
|
-
* a CPU cost.
|
|
463
|
-
*/
|
|
464
|
-
#if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__)
|
|
495
|
+
/* aarch64 supports big and little endian modes; fasttable performs multibyte
|
|
496
|
+
* tag loads assumes the tag of a varint is in the low bits. */
|
|
497
|
+
#if (defined(__x86_64__) || defined(__AARCH64EL__)) && \
|
|
498
|
+
UPB_HAS_ATTRIBUTE(preserve_none) && UPB_HAS_ATTRIBUTE(musttail)
|
|
465
499
|
#define UPB_FASTTABLE_SUPPORTED 1
|
|
466
500
|
#else
|
|
467
501
|
#define UPB_FASTTABLE_SUPPORTED 0
|
|
@@ -472,7 +506,7 @@ Error, UINTPTR_MAX is undefined
|
|
|
472
506
|
* for example for testing or benchmarking. */
|
|
473
507
|
#if defined(UPB_ENABLE_FASTTABLE)
|
|
474
508
|
#if !UPB_FASTTABLE_SUPPORTED
|
|
475
|
-
#error fasttable is x86-64/
|
|
509
|
+
#error fasttable is x86-64/ARM64le only and requires preserve_none and musttail.
|
|
476
510
|
#endif
|
|
477
511
|
#define UPB_FASTTABLE 1
|
|
478
512
|
/* Define UPB_TRY_ENABLE_FASTTABLE to use fasttable if possible.
|
|
@@ -574,10 +608,12 @@ Error, UINTPTR_MAX is undefined
|
|
|
574
608
|
#define UPB_LINKARR_APPEND(name) \
|
|
575
609
|
__attribute__(( \
|
|
576
610
|
section("linkarr_" #name))) UPB_LINKARR_ATTR UPB_NO_SANITIZE_ADDRESS
|
|
577
|
-
#define UPB_LINKARR_DECLARE(name, type)
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
611
|
+
#define UPB_LINKARR_DECLARE(name, type) \
|
|
612
|
+
UPB_STATIC_ASSERT(sizeof("__la_" #name) <= 17, \
|
|
613
|
+
"Linker array name too long for Mach-O (16-char limit)"); \
|
|
614
|
+
extern type __start_linkarr_##name; \
|
|
615
|
+
extern type __stop_linkarr_##name; \
|
|
616
|
+
UPB_LINKARR_APPEND(name) \
|
|
581
617
|
UPB_LINKARR_SENTINEL type UPB_linkarr_internal_empty_##name[1]
|
|
582
618
|
#define UPB_LINKARR_START(name) (&__start_linkarr_##name)
|
|
583
619
|
#define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
|
|
@@ -588,13 +624,15 @@ Error, UINTPTR_MAX is undefined
|
|
|
588
624
|
#define UPB_LINKARR_APPEND(name) \
|
|
589
625
|
__attribute__(( \
|
|
590
626
|
section("__DATA,__la_" #name))) UPB_LINKARR_ATTR UPB_NO_SANITIZE_ADDRESS
|
|
591
|
-
#define UPB_LINKARR_DECLARE(name, type)
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
extern type
|
|
595
|
-
"section$
|
|
596
|
-
|
|
597
|
-
|
|
627
|
+
#define UPB_LINKARR_DECLARE(name, type) \
|
|
628
|
+
UPB_STATIC_ASSERT(sizeof("__la_" #name) <= 17, \
|
|
629
|
+
"Linker array name too long for Mach-O (16-char limit)"); \
|
|
630
|
+
extern type __start_linkarr_##name __asm( \
|
|
631
|
+
"section$start$__DATA$__la_" #name); \
|
|
632
|
+
extern type __stop_linkarr_##name __asm( \
|
|
633
|
+
"section$end$__DATA$" \
|
|
634
|
+
"__la_" #name); \
|
|
635
|
+
UPB_LINKARR_APPEND(name) \
|
|
598
636
|
UPB_LINKARR_SENTINEL type UPB_linkarr_internal_empty_##name[1]
|
|
599
637
|
#define UPB_LINKARR_START(name) (&__start_linkarr_##name)
|
|
600
638
|
#define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
|
|
@@ -632,7 +670,9 @@ Error, UINTPTR_MAX is undefined
|
|
|
632
670
|
|
|
633
671
|
// Linker arrays are not supported on this platform. Make macros no-ops.
|
|
634
672
|
#define UPB_LINKARR_APPEND(name)
|
|
635
|
-
#define UPB_LINKARR_DECLARE(name, type)
|
|
673
|
+
#define UPB_LINKARR_DECLARE(name, type) \
|
|
674
|
+
UPB_STATIC_ASSERT(sizeof("__la_" #name) <= 17, \
|
|
675
|
+
"Linker array name too long for Mach-O (16-char limit)")
|
|
636
676
|
#define UPB_LINKARR_START(name) (NULL)
|
|
637
677
|
#define UPB_LINKARR_STOP(name) (NULL)
|
|
638
678
|
|
|
@@ -649,11 +689,46 @@ Error, UINTPTR_MAX is undefined
|
|
|
649
689
|
#define _UPB_CONSTRUCTOR_PLACEHOLDER(unique_name)
|
|
650
690
|
#endif
|
|
651
691
|
|
|
652
|
-
#
|
|
653
|
-
#define
|
|
692
|
+
#define _UPB_STRINGIFY2(x) #x
|
|
693
|
+
#define _UPB_STRINGIFY(x) _UPB_STRINGIFY2(x)
|
|
694
|
+
|
|
695
|
+
#if defined(__ELF__) && (UPB_GNUC_MIN(15, 1) || UPB_CLANG_MIN(21, 1))
|
|
696
|
+
/*
|
|
697
|
+
* Workaround for b/456308964 and b/456317163. Although weak constructors
|
|
698
|
+
* resolve to a single function body, Clang still emits a pointer into
|
|
699
|
+
* .init_array for every translation unit, causing the constructor to be
|
|
700
|
+
* executed multiple times and inflating binary size. We wrap the .init_array
|
|
701
|
+
* entry in a COMDAT group (using inline assembly) to force the linker to
|
|
702
|
+
* deduplicate the pointer to exactly one instance. %cc is used in preference to
|
|
703
|
+
* the more widely available %c because %c may under some circumstances still
|
|
704
|
+
* output a function name including relocation information, which will then
|
|
705
|
+
* confuse the linker. This was only a problem on gcc; when %cc was introduced
|
|
706
|
+
* to clang it was just an alias to %c, and clang's %c had already done the
|
|
707
|
+
* checks that %cc introduced to gcc.
|
|
708
|
+
* References:
|
|
709
|
+
* https://github.com/gcc-mirror/gcc/commit/74d6a676034b3ab20c387f12f19f5597e4f1c9fa
|
|
710
|
+
* https://github.com/llvm/llvm-project/pull/127719#issuecomment-2686276305
|
|
711
|
+
*/
|
|
712
|
+
#define UPB_CONSTRUCTOR(name, unique_name, ...) \
|
|
713
|
+
_UPB_CONSTRUCTOR_PLACEHOLDER(unique_name) \
|
|
714
|
+
__attribute__((weak, used, visibility("hidden"))) void UPB_PRIVATE(name)( \
|
|
715
|
+
void) { \
|
|
716
|
+
__asm__ volatile( \
|
|
717
|
+
".pushsection .init_array,\"awG\",%%init_array, %cc0, comdat\n" \
|
|
718
|
+
".dc.a %cc0\n" \
|
|
719
|
+
".popsection\n" \
|
|
720
|
+
: \
|
|
721
|
+
: "X"(UPB_PRIVATE(name))); \
|
|
722
|
+
__VA_ARGS__ \
|
|
723
|
+
}
|
|
724
|
+
#elif defined(__ELF__) || defined(__wasm__) || defined(__MACH__) || \
|
|
725
|
+
defined(__MINGW32__)
|
|
726
|
+
#define UPB_CONSTRUCTOR(name, unique_name, ...) \
|
|
654
727
|
_UPB_CONSTRUCTOR_PLACEHOLDER(unique_name) \
|
|
655
728
|
__attribute__((weak, visibility("hidden"), constructor)) void UPB_PRIVATE( \
|
|
656
|
-
name)(void)
|
|
729
|
+
name)(void) { \
|
|
730
|
+
__VA_ARGS__ \
|
|
731
|
+
}
|
|
657
732
|
#elif defined(_MSC_VER)
|
|
658
733
|
/*
|
|
659
734
|
* See: https://stackoverflow.com/questions/1113409
|
|
@@ -664,17 +739,22 @@ Error, UINTPTR_MAX is undefined
|
|
|
664
739
|
* create a dummy exported weak symbol that prevent this stripping.
|
|
665
740
|
*/
|
|
666
741
|
#pragma section(".CRT$XCT", read)
|
|
667
|
-
#define UPB_CONSTRUCTOR(name, unique_name)
|
|
742
|
+
#define UPB_CONSTRUCTOR(name, unique_name, ...) \
|
|
668
743
|
static void __cdecl UPB_PRIVATE(name)(void); \
|
|
669
744
|
__declspec(allocate(".CRT$XCT"), selectany) void( \
|
|
670
745
|
__cdecl * UPB_PRIVATE(name##_))(void) = UPB_PRIVATE(name); \
|
|
671
746
|
__declspec(selectany, dllexport) void* UPB_PRIVATE(name##_force_linkage) = \
|
|
672
747
|
&UPB_PRIVATE(name##_); \
|
|
673
|
-
static void __cdecl UPB_PRIVATE(name)(void)
|
|
674
|
-
|
|
748
|
+
static void __cdecl UPB_PRIVATE(name)(void) { __VA_ARGS__ }
|
|
675
749
|
#else
|
|
676
750
|
// No constructor support, nothing we can do except not break builds.
|
|
677
|
-
#
|
|
751
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
752
|
+
#define UPB_CONSTRUCTOR(name, unique_name, ...) \
|
|
753
|
+
static __attribute__((used)) void UPB_PRIVATE(name)(void) { __VA_ARGS__ }
|
|
754
|
+
#else
|
|
755
|
+
#define UPB_CONSTRUCTOR(name, unique_name, ...) \
|
|
756
|
+
static void UPB_PRIVATE(name)(void) { __VA_ARGS__ }
|
|
757
|
+
#endif
|
|
678
758
|
#endif
|
|
679
759
|
|
|
680
760
|
//
|
|
@@ -710,11 +790,11 @@ Error, UINTPTR_MAX is undefined
|
|
|
710
790
|
__asm__(".private_extern _" #to); \
|
|
711
791
|
__asm__(".set _" #to ", _" #from);
|
|
712
792
|
|
|
713
|
-
#elif defined(__ELF__)
|
|
793
|
+
#elif defined(__ELF__) || defined(__wasm__)
|
|
714
794
|
|
|
715
|
-
// On ELF, weak aliases work properly, so we can have all weak MiniTables
|
|
716
|
-
// to the same empty singleton MiniTable. This reduces code size if many
|
|
717
|
-
// MiniTables are tree shaken.
|
|
795
|
+
// On ELF, weak aliases work properly, so we can have all weak MiniTables
|
|
796
|
+
// point to the same empty singleton MiniTable. This reduces code size if many
|
|
797
|
+
// MiniTables are tree shaken.
|
|
718
798
|
#define UPB_WEAK_SINGLETON_PLACEHOLDER_MINITABLE() \
|
|
719
799
|
__attribute__((weak)) \
|
|
720
800
|
const upb_MiniTable kUpb_WeakSingletonPlaceholderMiniTable = { \
|
|
@@ -739,12 +819,6 @@ Error, UINTPTR_MAX is undefined
|
|
|
739
819
|
#define UPB_WEAK_ALIAS(type, from, to) weak_alias_not_supported_on_this_platform
|
|
740
820
|
#define UPB_STRONG_ALIAS(type, from, to) \
|
|
741
821
|
strong_alias_not_supported_on_this_platform
|
|
742
|
-
#endif
|
|
743
|
-
|
|
744
|
-
// Future versions of upb will include breaking changes to some APIs.
|
|
745
|
-
// This macro can be set to enable these API changes ahead of time, so that
|
|
746
|
-
// user code can be updated before upgrading versions of protobuf.
|
|
747
|
-
#ifdef UPB_FUTURE_BREAKING_CHANGES
|
|
748
822
|
|
|
749
823
|
#endif
|
|
750
824
|
|
|
@@ -908,7 +982,7 @@ struct upb_alloc {
|
|
|
908
982
|
upb_alloc_func* func;
|
|
909
983
|
};
|
|
910
984
|
|
|
911
|
-
UPB_INLINE void* upb_malloc(upb_alloc* alloc, size_t size) {
|
|
985
|
+
UPB_NODISCARD UPB_INLINE void* upb_malloc(upb_alloc* alloc, size_t size) {
|
|
912
986
|
UPB_ASSERT(alloc);
|
|
913
987
|
return alloc->func(alloc, NULL, 0, size, NULL);
|
|
914
988
|
}
|
|
@@ -927,8 +1001,8 @@ UPB_INLINE upb_SizedPtr upb_SizeReturningMalloc(upb_alloc* alloc, size_t size) {
|
|
|
927
1001
|
return result;
|
|
928
1002
|
}
|
|
929
1003
|
|
|
930
|
-
UPB_INLINE void* upb_realloc(upb_alloc* alloc, void* ptr,
|
|
931
|
-
|
|
1004
|
+
UPB_NODISCARD UPB_INLINE void* upb_realloc(upb_alloc* alloc, void* ptr,
|
|
1005
|
+
size_t oldsize, size_t size) {
|
|
932
1006
|
UPB_ASSERT(alloc);
|
|
933
1007
|
return alloc->func(alloc, ptr, oldsize, size, NULL);
|
|
934
1008
|
}
|
|
@@ -952,11 +1026,12 @@ extern upb_alloc upb_alloc_global;
|
|
|
952
1026
|
* We still get benefit because we can put custom logic into our global
|
|
953
1027
|
* allocator, like injecting out-of-memory faults in debug/testing builds. */
|
|
954
1028
|
|
|
955
|
-
UPB_INLINE void* upb_gmalloc(size_t size) {
|
|
1029
|
+
UPB_NODISCARD UPB_INLINE void* upb_gmalloc(size_t size) {
|
|
956
1030
|
return upb_malloc(&upb_alloc_global, size);
|
|
957
1031
|
}
|
|
958
1032
|
|
|
959
|
-
UPB_INLINE void* upb_grealloc(void* ptr, size_t oldsize,
|
|
1033
|
+
UPB_NODISCARD UPB_INLINE void* upb_grealloc(void* ptr, size_t oldsize,
|
|
1034
|
+
size_t size) {
|
|
960
1035
|
return upb_realloc(&upb_alloc_global, ptr, oldsize, size);
|
|
961
1036
|
}
|
|
962
1037
|
|
|
@@ -1252,9 +1327,9 @@ UPB_API_INLINE void upb_Arena_ShrinkLast(struct upb_Arena* a, void* ptr,
|
|
|
1252
1327
|
// We can't reclaim any memory, but we need to verify that `ptr` really
|
|
1253
1328
|
// does represent the most recent allocation.
|
|
1254
1329
|
#ifndef NDEBUG
|
|
1255
|
-
bool
|
|
1256
|
-
|
|
1257
|
-
UPB_ASSERT(
|
|
1330
|
+
bool _upb_Arena_WasLastAllocFromPreviousBlock(struct upb_Arena * a,
|
|
1331
|
+
void* ptr, size_t oldsize);
|
|
1332
|
+
UPB_ASSERT(_upb_Arena_WasLastAllocFromPreviousBlock(a, ptr, oldsize));
|
|
1258
1333
|
#endif
|
|
1259
1334
|
}
|
|
1260
1335
|
}
|
|
@@ -1308,6 +1383,58 @@ UPB_API_INLINE void* upb_Arena_Realloc(struct upb_Arena* a, void* ptr,
|
|
|
1308
1383
|
return ret;
|
|
1309
1384
|
}
|
|
1310
1385
|
|
|
1386
|
+
// Returns the next block size to allocate for the arena based on exponential
|
|
1387
|
+
// growth and size hint.
|
|
1388
|
+
size_t UPB_PRIVATE(_upb_Arena_NextBlockSize)(struct upb_Arena* a, size_t span,
|
|
1389
|
+
bool* one_off);
|
|
1390
|
+
|
|
1391
|
+
// Updates the arena's growth state based on the block size actually allocated.
|
|
1392
|
+
void UPB_PRIVATE(_upb_Arena_UpdateGrowthState)(struct upb_Arena* a, size_t span,
|
|
1393
|
+
size_t block_size, bool one_off);
|
|
1394
|
+
|
|
1395
|
+
// Allocates a block for the arena of at least the given size, but does not add
|
|
1396
|
+
// it to the arena. The block must either be added to the arena or manually
|
|
1397
|
+
// freed, otherwise memory will be leaked.
|
|
1398
|
+
//
|
|
1399
|
+
// Returns the allocated block (or NULL on failure), and writes the actual size
|
|
1400
|
+
// of the block to size.
|
|
1401
|
+
void* UPB_PRIVATE(_upb_Arena_AllocBlock)(struct upb_Arena* a, size_t* size);
|
|
1402
|
+
|
|
1403
|
+
// Adds a block previously allocated with _upb_Arena_AllocBlock() to the arena.
|
|
1404
|
+
// This will cause it to be owned by the arena and freed when the arena is
|
|
1405
|
+
// freed.
|
|
1406
|
+
//
|
|
1407
|
+
// Note that this call does *not* cause the block to be used for arena
|
|
1408
|
+
// allocations. Call _upb_Arena_UseBlock() to do that.
|
|
1409
|
+
//
|
|
1410
|
+
// This operation cannot be undone, so the caller should not call it until they
|
|
1411
|
+
// are sure that the block will be useful to the arena.
|
|
1412
|
+
void UPB_PRIVATE(_upb_Arena_AddBlock)(struct upb_Arena* a, void* block);
|
|
1413
|
+
|
|
1414
|
+
// Frees a block previously allocated with _upb_Arena_AllocBlock. This is only
|
|
1415
|
+
// necessary if the block ends up not being useful to the arena.
|
|
1416
|
+
void UPB_PRIVATE(_upb_Arena_FreeBlock)(struct upb_Arena* a, void* block);
|
|
1417
|
+
|
|
1418
|
+
// Sets the arena's current block to the given block. Subsequent allocations
|
|
1419
|
+
// may be made from this block.
|
|
1420
|
+
//
|
|
1421
|
+
// The given memory must be either:
|
|
1422
|
+
// - The arena block most recently returned by _upb_Arena_AllocBlock, or
|
|
1423
|
+
// - A block that was just stolen from the arena using _upb_Arena_Steal.
|
|
1424
|
+
//
|
|
1425
|
+
// After this call, the memory may only be used by the arena -- it is poisoned
|
|
1426
|
+
// against further use by the caller.
|
|
1427
|
+
//
|
|
1428
|
+
// Note: if the arena determines that this block is smaller than the block it
|
|
1429
|
+
// currently has, it may decide to not use the block.
|
|
1430
|
+
void UPB_PRIVATE(_upb_Arena_UseBlock)(struct upb_Arena* a, void* ptr,
|
|
1431
|
+
size_t size);
|
|
1432
|
+
|
|
1433
|
+
// Steals all available memory from the current arena block, but only if at
|
|
1434
|
+
// least `size` bytes are available. The number of bytes stolen is written to
|
|
1435
|
+
// size. The memory will be unpoisoned and ready for use.
|
|
1436
|
+
void* UPB_PRIVATE(_upb_Arena_Steal)(struct upb_Arena* a, size_t* size);
|
|
1437
|
+
|
|
1311
1438
|
#ifdef __cplusplus
|
|
1312
1439
|
} /* extern "C" */
|
|
1313
1440
|
#endif
|
|
@@ -1333,7 +1460,8 @@ extern "C" {
|
|
|
1333
1460
|
// no initial block, |n| is a hint of the size that should be allocated for the
|
|
1334
1461
|
// first block of the arena, such that `upb_Arena_Malloc(hint)` will not require
|
|
1335
1462
|
// another call to |alloc|.
|
|
1336
|
-
UPB_API upb_Arena* upb_Arena_Init(void* mem, size_t n,
|
|
1463
|
+
UPB_NODISCARD UPB_API upb_Arena* upb_Arena_Init(void* mem, size_t n,
|
|
1464
|
+
upb_alloc* alloc);
|
|
1337
1465
|
|
|
1338
1466
|
UPB_API void upb_Arena_Free(upb_Arena* a);
|
|
1339
1467
|
// Sets the cleanup function for the upb_alloc used by the arena. Only one
|
|
@@ -1346,7 +1474,8 @@ UPB_API void upb_Arena_SetAllocCleanup(upb_Arena* a,
|
|
|
1346
1474
|
// transitively fused together will be freed until all of them have reached a
|
|
1347
1475
|
// zero refcount. This operation is safe to use concurrently from multiple
|
|
1348
1476
|
// threads.
|
|
1349
|
-
UPB_API bool upb_Arena_Fuse(const upb_Arena* a,
|
|
1477
|
+
UPB_NODISCARD UPB_API bool upb_Arena_Fuse(const upb_Arena* a,
|
|
1478
|
+
const upb_Arena* b);
|
|
1350
1479
|
|
|
1351
1480
|
// This operation is safe to use concurrently from multiple threads.
|
|
1352
1481
|
UPB_API bool upb_Arena_IsFused(const upb_Arena* a, const upb_Arena* b);
|
|
@@ -1391,7 +1520,7 @@ void upb_Arena_DecRefFor(const upb_Arena* a, const void* owner);
|
|
|
1391
1520
|
// with any other function on `from`.
|
|
1392
1521
|
//
|
|
1393
1522
|
// Returns whether the reference was created successfully.
|
|
1394
|
-
bool upb_Arena_RefArena(upb_Arena* from, const upb_Arena* to);
|
|
1523
|
+
UPB_NODISCARD bool upb_Arena_RefArena(upb_Arena* from, const upb_Arena* to);
|
|
1395
1524
|
|
|
1396
1525
|
#ifndef NDEBUG
|
|
1397
1526
|
// Returns true if upb_Arena_RefArena(from, to) was previously called.
|
|
@@ -1420,18 +1549,20 @@ uint32_t upb_Arena_DebugRefCount(const upb_Arena* a);
|
|
|
1420
1549
|
bool upb_Arena_HasRefChain(const upb_Arena* from, const upb_Arena* to);
|
|
1421
1550
|
#endif
|
|
1422
1551
|
|
|
1423
|
-
UPB_API_INLINE upb_Arena* upb_Arena_New(void) {
|
|
1552
|
+
UPB_NODISCARD UPB_API_INLINE upb_Arena* upb_Arena_New(void) {
|
|
1424
1553
|
return upb_Arena_Init(NULL, 0, &upb_alloc_global);
|
|
1425
1554
|
}
|
|
1426
1555
|
|
|
1427
|
-
UPB_API_INLINE upb_Arena* upb_Arena_NewSized(size_t size_hint) {
|
|
1556
|
+
UPB_NODISCARD UPB_API_INLINE upb_Arena* upb_Arena_NewSized(size_t size_hint) {
|
|
1428
1557
|
return upb_Arena_Init(NULL, size_hint, &upb_alloc_global);
|
|
1429
1558
|
}
|
|
1430
1559
|
|
|
1431
|
-
UPB_API_INLINE void* upb_Arena_Malloc(struct upb_Arena* a,
|
|
1560
|
+
UPB_NODISCARD UPB_API_INLINE void* upb_Arena_Malloc(struct upb_Arena* a,
|
|
1561
|
+
size_t size);
|
|
1432
1562
|
|
|
1433
|
-
UPB_API_INLINE void* upb_Arena_Realloc(upb_Arena* a, void* ptr,
|
|
1434
|
-
|
|
1563
|
+
UPB_NODISCARD UPB_API_INLINE void* upb_Arena_Realloc(upb_Arena* a, void* ptr,
|
|
1564
|
+
size_t oldsize,
|
|
1565
|
+
size_t size);
|
|
1435
1566
|
|
|
1436
1567
|
static const size_t UPB_PRIVATE(kUpbDefaultMaxBlockSize) =
|
|
1437
1568
|
UPB_DEFAULT_MAX_BLOCK_SIZE;
|
|
@@ -1460,8 +1591,9 @@ UPB_API_INLINE void upb_Arena_ShrinkLast(upb_Arena* a, void* ptr,
|
|
|
1460
1591
|
// allocation is unmodified. See also upb_Arena_Realloc.
|
|
1461
1592
|
// REQUIRES: `size > oldsize`; to shrink, use `upb_Arena_Realloc` or
|
|
1462
1593
|
// `upb_Arena_ShrinkLast`.
|
|
1463
|
-
UPB_API_INLINE bool upb_Arena_TryExtend(upb_Arena* a, void* ptr,
|
|
1464
|
-
|
|
1594
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Arena_TryExtend(upb_Arena* a, void* ptr,
|
|
1595
|
+
size_t oldsize,
|
|
1596
|
+
size_t size);
|
|
1465
1597
|
|
|
1466
1598
|
#ifdef UPB_TRACING_ENABLED
|
|
1467
1599
|
void upb_Arena_SetTraceHandler(void (*initArenaTraceHandler)(const upb_Arena*,
|
|
@@ -1604,6 +1736,8 @@ UPB_INLINE bool upb_FieldType_IsPackable(upb_FieldType field_type) {
|
|
|
1604
1736
|
extern "C" {
|
|
1605
1737
|
#endif
|
|
1606
1738
|
|
|
1739
|
+
#define _UPB_ARRAY_DEFAULT_INITIAL_SIZE 4
|
|
1740
|
+
|
|
1607
1741
|
// LINT.IfChange(upb_Array)
|
|
1608
1742
|
|
|
1609
1743
|
// Our internal representation for repeated fields.
|
|
@@ -1653,9 +1787,9 @@ UPB_API_INLINE void* upb_Array_MutableDataPtr(struct upb_Array* array) {
|
|
|
1653
1787
|
return (void*)upb_Array_DataPtr(array);
|
|
1654
1788
|
}
|
|
1655
1789
|
|
|
1656
|
-
UPB_INLINE struct upb_Array* UPB_PRIVATE(
|
|
1657
|
-
upb_Arena* arena, size_t init_capacity,
|
|
1658
|
-
|
|
1790
|
+
UPB_NODISCARD UPB_INLINE struct upb_Array* UPB_PRIVATE(
|
|
1791
|
+
_upb_Array_NewMaybeAllowSlow)(upb_Arena* arena, size_t init_capacity,
|
|
1792
|
+
int elem_size_lg2, bool allow_slow) {
|
|
1659
1793
|
UPB_ASSERT(elem_size_lg2 != 1);
|
|
1660
1794
|
UPB_ASSERT(elem_size_lg2 <= 4);
|
|
1661
1795
|
const size_t array_size =
|
|
@@ -1672,27 +1806,26 @@ UPB_INLINE struct upb_Array* UPB_PRIVATE(_upb_Array_NewMaybeAllowSlow)(
|
|
|
1672
1806
|
return array;
|
|
1673
1807
|
}
|
|
1674
1808
|
|
|
1675
|
-
UPB_INLINE struct upb_Array* UPB_PRIVATE(_upb_Array_New)(
|
|
1676
|
-
|
|
1677
|
-
int elem_size_lg2) {
|
|
1809
|
+
UPB_NODISCARD UPB_INLINE struct upb_Array* UPB_PRIVATE(_upb_Array_New)(
|
|
1810
|
+
upb_Arena* arena, size_t init_capacity, int elem_size_lg2) {
|
|
1678
1811
|
return UPB_PRIVATE(_upb_Array_NewMaybeAllowSlow)(arena, init_capacity,
|
|
1679
1812
|
elem_size_lg2, true);
|
|
1680
1813
|
}
|
|
1681
1814
|
|
|
1682
|
-
UPB_INLINE struct upb_Array* UPB_PRIVATE(_upb_Array_TryFastNew)(
|
|
1815
|
+
UPB_NODISCARD UPB_INLINE struct upb_Array* UPB_PRIVATE(_upb_Array_TryFastNew)(
|
|
1683
1816
|
upb_Arena* arena, size_t init_capacity, int elem_size_lg2) {
|
|
1684
1817
|
return UPB_PRIVATE(_upb_Array_NewMaybeAllowSlow)(arena, init_capacity,
|
|
1685
1818
|
elem_size_lg2, false);
|
|
1686
1819
|
}
|
|
1687
1820
|
|
|
1688
1821
|
// Resizes the capacity of the array to be at least min_size.
|
|
1689
|
-
bool UPB_PRIVATE(_upb_Array_Realloc)(struct upb_Array* array,
|
|
1690
|
-
|
|
1822
|
+
UPB_NODISCARD bool UPB_PRIVATE(_upb_Array_Realloc)(struct upb_Array* array,
|
|
1823
|
+
size_t min_size,
|
|
1824
|
+
upb_Arena* arena);
|
|
1691
1825
|
|
|
1692
|
-
UPB_FORCEINLINE
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
upb_Arena* arena) {
|
|
1826
|
+
UPB_NODISCARD UPB_FORCEINLINE bool UPB_PRIVATE(_upb_Array_TryFastRealloc)(
|
|
1827
|
+
struct upb_Array* array, size_t capacity, int elem_size_lg2,
|
|
1828
|
+
upb_Arena* arena) {
|
|
1696
1829
|
size_t old_bytes = array->UPB_PRIVATE(capacity) << elem_size_lg2;
|
|
1697
1830
|
size_t new_bytes = capacity << elem_size_lg2;
|
|
1698
1831
|
UPB_ASSUME(new_bytes > old_bytes);
|
|
@@ -1701,8 +1834,9 @@ bool UPB_PRIVATE(_upb_Array_TryFastRealloc)(struct upb_Array* array,
|
|
|
1701
1834
|
return true;
|
|
1702
1835
|
}
|
|
1703
1836
|
|
|
1704
|
-
UPB_API_INLINE bool upb_Array_Reserve(struct upb_Array* array,
|
|
1705
|
-
|
|
1837
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Array_Reserve(struct upb_Array* array,
|
|
1838
|
+
size_t size,
|
|
1839
|
+
upb_Arena* arena) {
|
|
1706
1840
|
UPB_ASSERT(!upb_Array_IsFrozen(array));
|
|
1707
1841
|
if (array->UPB_PRIVATE(capacity) < size)
|
|
1708
1842
|
return UPB_PRIVATE(_upb_Array_Realloc)(array, size, arena);
|
|
@@ -1710,7 +1844,7 @@ UPB_API_INLINE bool upb_Array_Reserve(struct upb_Array* array, size_t size,
|
|
|
1710
1844
|
}
|
|
1711
1845
|
|
|
1712
1846
|
// Resize without initializing new elements.
|
|
1713
|
-
UPB_INLINE bool UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
|
|
1847
|
+
UPB_NODISCARD UPB_INLINE bool UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
|
|
1714
1848
|
struct upb_Array* array, size_t size, upb_Arena* arena) {
|
|
1715
1849
|
UPB_ASSERT(!upb_Array_IsFrozen(array));
|
|
1716
1850
|
UPB_ASSERT(size <= array->UPB_ONLYBITS(size) ||
|
|
@@ -2283,6 +2417,7 @@ upb_MiniTableField_Type(const upb_MiniTableField* f);
|
|
|
2283
2417
|
|
|
2284
2418
|
#include <stddef.h>
|
|
2285
2419
|
#include <stdint.h>
|
|
2420
|
+
#include <string.h>
|
|
2286
2421
|
|
|
2287
2422
|
|
|
2288
2423
|
#ifndef UPB_MINI_TABLE_INTERNAL_SUB_H_
|
|
@@ -2336,16 +2471,23 @@ UPB_API_INLINE const struct upb_MiniTable* upb_MiniTableSub_Message(
|
|
|
2336
2471
|
|
|
2337
2472
|
struct upb_Decoder;
|
|
2338
2473
|
struct upb_Message;
|
|
2474
|
+
struct upb_FastDecoder_Return;
|
|
2339
2475
|
|
|
2340
|
-
typedef UPB_PRESERVE_NONE
|
|
2476
|
+
typedef UPB_PRESERVE_NONE struct upb_FastDecoder_Return _upb_FieldParser(
|
|
2341
2477
|
struct upb_Decoder* d, const char* ptr, struct upb_Message* msg,
|
|
2342
|
-
|
|
2478
|
+
const struct upb_MiniTable* table, uint64_t hasbits, uint64_t data,
|
|
2479
|
+
uint64_t data2);
|
|
2343
2480
|
|
|
2344
2481
|
typedef struct {
|
|
2345
2482
|
uint64_t field_data;
|
|
2346
2483
|
_upb_FieldParser* field_parser;
|
|
2347
2484
|
} _upb_FastTable_Entry;
|
|
2348
2485
|
|
|
2486
|
+
// Ext Mode consists of 4 bits:
|
|
2487
|
+
// * Extensibility
|
|
2488
|
+
// * MessageSet
|
|
2489
|
+
// * Map
|
|
2490
|
+
// * FastTable field coverage
|
|
2349
2491
|
typedef enum {
|
|
2350
2492
|
kUpb_ExtMode_NonExtendable = 0, // Non-extendable message.
|
|
2351
2493
|
kUpb_ExtMode_Extendable = 1, // Normal extendable message.
|
|
@@ -2356,8 +2498,17 @@ typedef enum {
|
|
|
2356
2498
|
// During table building we steal a bit to indicate that the message is a map
|
|
2357
2499
|
// entry. *Only* used during table building!
|
|
2358
2500
|
kUpb_ExtMode_IsMapEntry = 4,
|
|
2501
|
+
|
|
2502
|
+
// Indicates that all eligible fields (with 1- or 2-byte) tags were
|
|
2503
|
+
// successfully assigned to the fasttable.
|
|
2504
|
+
kUpb_ExtMode_AllFastFieldsAssigned = 8,
|
|
2359
2505
|
} upb_ExtMode;
|
|
2360
2506
|
|
|
2507
|
+
// Check ExtMode base message info, excluding fasttable state info.
|
|
2508
|
+
UPB_FORCEINLINE uint8_t UPB_PRIVATE(_upb_ExtMode_Base)(uint8_t ext_mode) {
|
|
2509
|
+
return ext_mode & 7;
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2361
2512
|
enum {
|
|
2362
2513
|
kUpb_Message_Align = 8,
|
|
2363
2514
|
};
|
|
@@ -2385,9 +2536,9 @@ struct upb_MiniTable {
|
|
|
2385
2536
|
const char* UPB_PRIVATE(full_name);
|
|
2386
2537
|
#endif
|
|
2387
2538
|
|
|
2388
|
-
#if UPB_FASTTABLE
|
|
2389
|
-
// Flexible array member is not supported in C
|
|
2390
|
-
//
|
|
2539
|
+
#if UPB_FASTTABLE
|
|
2540
|
+
// Flexible array member is not supported in C++ standard, but it is supported
|
|
2541
|
+
// as an extension in all compilers we support.
|
|
2391
2542
|
_upb_FastTable_Entry UPB_PRIVATE(fasttable)[];
|
|
2392
2543
|
#endif
|
|
2393
2544
|
};
|
|
@@ -2419,52 +2570,19 @@ UPB_API_INLINE int upb_MiniTable_FieldCount(const struct upb_MiniTable* m) {
|
|
|
2419
2570
|
return m->UPB_ONLYBITS(field_count);
|
|
2420
2571
|
}
|
|
2421
2572
|
|
|
2422
|
-
|
|
2423
|
-
|
|
2573
|
+
UPB_FORCEINLINE uint8_t
|
|
2574
|
+
UPB_PRIVATE(_upb_MiniTable_ExtModeBase)(const struct upb_MiniTable* m) {
|
|
2575
|
+
return UPB_PRIVATE(_upb_ExtMode_Base)(m->UPB_PRIVATE(ext));
|
|
2424
2576
|
}
|
|
2425
2577
|
|
|
2426
|
-
|
|
2427
|
-
const struct
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
// Ideal case: index into dense fields
|
|
2432
|
-
if (i < m->UPB_PRIVATE(dense_below)) {
|
|
2433
|
-
UPB_ASSERT(m->UPB_ONLYBITS(fields)[i].UPB_ONLYBITS(number) == number);
|
|
2434
|
-
return &m->UPB_ONLYBITS(fields)[i];
|
|
2435
|
-
}
|
|
2436
|
-
|
|
2437
|
-
// Early exit if the field number is out of range.
|
|
2438
|
-
int32_t hi = m->UPB_ONLYBITS(field_count) - 1;
|
|
2439
|
-
if (hi < 0 || number > m->UPB_ONLYBITS(fields)[hi].UPB_ONLYBITS(number)) {
|
|
2440
|
-
return NULL;
|
|
2441
|
-
}
|
|
2442
|
-
|
|
2443
|
-
// Slow case: binary search
|
|
2444
|
-
uint32_t lo = m->UPB_PRIVATE(dense_below);
|
|
2445
|
-
const struct upb_MiniTableField* base = m->UPB_ONLYBITS(fields);
|
|
2446
|
-
while (hi >= (int32_t)lo) {
|
|
2447
|
-
uint32_t mid = ((uint32_t)hi + lo) / 2;
|
|
2448
|
-
uint32_t num = base[mid].UPB_ONLYBITS(number);
|
|
2449
|
-
// These comparison operations allow, on ARM machines, to fuse all these
|
|
2450
|
-
// branches into one comparison followed by two CSELs to set the lo/hi
|
|
2451
|
-
// values, followed by a BNE to continue or terminate the loop. Since binary
|
|
2452
|
-
// search branches are generally unpredictable (50/50 in each direction),
|
|
2453
|
-
// this is a good deal. We use signed for the high, as this decrement may
|
|
2454
|
-
// underflow if mid is 0.
|
|
2455
|
-
int32_t hi_mid = (int32_t)mid - 1;
|
|
2456
|
-
uint32_t lo_mid = mid + 1;
|
|
2457
|
-
if (num == number) {
|
|
2458
|
-
return &base[mid];
|
|
2459
|
-
}
|
|
2460
|
-
if (UPB_UNPREDICTABLE(num < number)) {
|
|
2461
|
-
lo = lo_mid;
|
|
2462
|
-
} else {
|
|
2463
|
-
hi = hi_mid;
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2578
|
+
UPB_FORCEINLINE bool UPB_PRIVATE(_upb_MiniTable_IsExtendable)(
|
|
2579
|
+
const struct upb_MiniTable* m) {
|
|
2580
|
+
return UPB_PRIVATE(_upb_MiniTable_ExtModeBase)(m) == kUpb_ExtMode_Extendable;
|
|
2581
|
+
}
|
|
2466
2582
|
|
|
2467
|
-
|
|
2583
|
+
UPB_API_INLINE bool upb_MiniTable_IsMessageSet(const struct upb_MiniTable* m) {
|
|
2584
|
+
return UPB_PRIVATE(_upb_MiniTable_ExtModeBase)(m) ==
|
|
2585
|
+
kUpb_ExtMode_IsMessageSet;
|
|
2468
2586
|
}
|
|
2469
2587
|
|
|
2470
2588
|
UPB_API_INLINE const struct upb_MiniTableField* upb_MiniTable_GetFieldByIndex(
|
|
@@ -2495,6 +2613,235 @@ UPB_API_INLINE bool upb_MiniTable_FieldIsLinked(
|
|
|
2495
2613
|
return upb_MiniTable_GetSubMessageTable(f) != NULL;
|
|
2496
2614
|
}
|
|
2497
2615
|
|
|
2616
|
+
UPB_FORCEINLINE
|
|
2617
|
+
const struct upb_MiniTableField* UPB_PRIVATE(upb_MiniTable_GenericLowerBound)(
|
|
2618
|
+
const struct upb_MiniTable* m, uint32_t lo, uint32_t search_len,
|
|
2619
|
+
uint32_t number) {
|
|
2620
|
+
const struct upb_MiniTableField* search_base = &m->UPB_ONLYBITS(fields)[lo];
|
|
2621
|
+
while (search_len > 1) {
|
|
2622
|
+
size_t mid_offset = search_len >> 1;
|
|
2623
|
+
if (UPB_UNPREDICTABLE(search_base[mid_offset].UPB_ONLYBITS(number) <=
|
|
2624
|
+
number)) {
|
|
2625
|
+
search_base = &search_base[mid_offset];
|
|
2626
|
+
}
|
|
2627
|
+
search_len -= mid_offset;
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
return search_base;
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
// This implements the same algorithm as upb_MiniTable_GenericLowerBound but
|
|
2634
|
+
// contorts itself to select specific arm instructions, which show significant
|
|
2635
|
+
// effects on little cores.
|
|
2636
|
+
UPB_FORCEINLINE const struct upb_MiniTableField* UPB_PRIVATE(
|
|
2637
|
+
upb_MiniTable_ArmOptimizedLowerBound)(const struct upb_MiniTable* m,
|
|
2638
|
+
uint32_t lo, uint32_t search_len,
|
|
2639
|
+
uint32_t number) {
|
|
2640
|
+
const uint32_t* search_base =
|
|
2641
|
+
&m->UPB_ONLYBITS(fields)[lo].UPB_ONLYBITS(number);
|
|
2642
|
+
UPB_STATIC_ASSERT(sizeof(struct upb_MiniTableField) == sizeof(uint32_t) * 3,
|
|
2643
|
+
"Need to update multiplication");
|
|
2644
|
+
// Address generation units can't multiply by 12, but they can by 4. So we
|
|
2645
|
+
// split it into multiplying by 3 (add and shift) and multiplying by 4 (shift)
|
|
2646
|
+
// This code is carefully tuned to produce an optimal assembly sequence on
|
|
2647
|
+
// arm64, which takes advantage of dual issue on in-order CPUs to maximize
|
|
2648
|
+
// what little instruction level parallelism they have.
|
|
2649
|
+
/*
|
|
2650
|
+
and w9, w1, #0xfffffffe
|
|
2651
|
+
add w9, w9, w1, lsr #1
|
|
2652
|
+
ldr w10, [x0, w9, uxtw #2]
|
|
2653
|
+
sub w1, w1, w1, lsr #1
|
|
2654
|
+
add x9, x0, w9, uxtw #2
|
|
2655
|
+
cmp w10, w2
|
|
2656
|
+
csel x0, x0, x9, hi
|
|
2657
|
+
cmp w1, #1
|
|
2658
|
+
b.hi .LBB3_1
|
|
2659
|
+
*/
|
|
2660
|
+
// Doing this requires inhibiting the natural instincts of the compiler to
|
|
2661
|
+
// eliminate duplicate work, so we introduce an optimization barrier with
|
|
2662
|
+
// asm blocks to defeat common subexpression elimination.
|
|
2663
|
+
UPB_STATIC_ASSERT(
|
|
2664
|
+
offsetof(struct upb_MiniTableField, UPB_ONLYBITS(number)) == 0,
|
|
2665
|
+
"Tag number must be first element of minitable field struct");
|
|
2666
|
+
while (search_len > 1) {
|
|
2667
|
+
#if UPB_ARM64_ASM
|
|
2668
|
+
#define UPB_OPT_LAUNDER(val) __asm__("" : "+r"(val))
|
|
2669
|
+
#define UPB_OPT_LAUNDER2(val1, val2) __asm__("" : "+r"(val1), "+r"(val2))
|
|
2670
|
+
#else
|
|
2671
|
+
#define UPB_OPT_LAUNDER(val)
|
|
2672
|
+
#define UPB_OPT_LAUNDER2(val1, val2)
|
|
2673
|
+
#endif
|
|
2674
|
+
// (search_len & ~1) is exactly (half_len * 2). Adding half_len yields
|
|
2675
|
+
// (half_len * 3).
|
|
2676
|
+
//
|
|
2677
|
+
// and mid_offset_words, search_len, #0xfffffffe
|
|
2678
|
+
uint32_t mid_offset_words = search_len & 0xfffffffe;
|
|
2679
|
+
|
|
2680
|
+
// add mid_offset_words, mid_offset_words, search_len, lsr #1
|
|
2681
|
+
mid_offset_words = mid_offset_words + (search_len >> 1);
|
|
2682
|
+
|
|
2683
|
+
UPB_OPT_LAUNDER(search_len);
|
|
2684
|
+
UPB_OPT_LAUNDER(mid_offset_words);
|
|
2685
|
+
|
|
2686
|
+
// Arm processors, even little cores, have Address Generation Units capable
|
|
2687
|
+
// of performing these extensions, so we achieve more instruction level
|
|
2688
|
+
// parallelism by doing this shift by 2 redundantly with the mid pointer
|
|
2689
|
+
// calculation below.
|
|
2690
|
+
//
|
|
2691
|
+
// ldr mid_num, [search_base, mid_offset_words, uxtw #2]
|
|
2692
|
+
uint32_t mid_num = search_base[mid_offset_words];
|
|
2693
|
+
|
|
2694
|
+
// Shrink the search window by half
|
|
2695
|
+
// sub search_len, search_len, search_len, lsr #1
|
|
2696
|
+
search_len = search_len - (search_len >> 1);
|
|
2697
|
+
UPB_OPT_LAUNDER(search_len);
|
|
2698
|
+
UPB_OPT_LAUNDER(mid_offset_words);
|
|
2699
|
+
|
|
2700
|
+
// Calculate the mid pointer for the next iteration
|
|
2701
|
+
// add mid_ptr, search_base, mid_offset_words, uxtw #2
|
|
2702
|
+
const uint32_t* mid_ptr = search_base + mid_offset_words;
|
|
2703
|
+
|
|
2704
|
+
// Forbids LLVM's CSE pass from attempting to merge mid_ptr and mid_num's
|
|
2705
|
+
// math. It sees that it can do a select before adding, rather than after;
|
|
2706
|
+
// but if it orders it that way it creates a longer dependency chain. We
|
|
2707
|
+
// need both as input/output to the same asm block to force them to be
|
|
2708
|
+
// present in different registers at the same time; two separate LAUNDER
|
|
2709
|
+
// usages could get reordered.
|
|
2710
|
+
UPB_OPT_LAUNDER2(mid_ptr, mid_num);
|
|
2711
|
+
|
|
2712
|
+
// cmp + csel
|
|
2713
|
+
search_base = UPB_UNPREDICTABLE(mid_num <= number) ? mid_ptr : search_base;
|
|
2714
|
+
}
|
|
2715
|
+
#undef UPB_OPT_LAUNDER
|
|
2716
|
+
#undef UPB_OPT_LAUNDER2
|
|
2717
|
+
return (const struct upb_MiniTableField*)search_base;
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2720
|
+
UPB_FORCEINLINE const struct upb_MiniTableField* UPB_PRIVATE(
|
|
2721
|
+
upb_MiniTable_LowerBound)(const struct upb_MiniTable* m, uint32_t lo,
|
|
2722
|
+
uint32_t search_len, uint32_t number) {
|
|
2723
|
+
#ifndef NDEBUG
|
|
2724
|
+
const struct upb_MiniTableField* candidate = UPB_PRIVATE(
|
|
2725
|
+
upb_MiniTable_ArmOptimizedLowerBound)(m, lo, search_len, number);
|
|
2726
|
+
UPB_ASSERT(candidate == UPB_PRIVATE(upb_MiniTable_GenericLowerBound)(
|
|
2727
|
+
m, lo, search_len, number));
|
|
2728
|
+
return candidate;
|
|
2729
|
+
#elif UPB_ARM64_ASM
|
|
2730
|
+
return UPB_PRIVATE(upb_MiniTable_ArmOptimizedLowerBound)(m, lo, search_len,
|
|
2731
|
+
number);
|
|
2732
|
+
#else
|
|
2733
|
+
return UPB_PRIVATE(upb_MiniTable_GenericLowerBound)(m, lo, search_len,
|
|
2734
|
+
number);
|
|
2735
|
+
#endif
|
|
2736
|
+
}
|
|
2737
|
+
|
|
2738
|
+
UPB_API_INLINE
|
|
2739
|
+
const struct upb_MiniTableField* upb_MiniTable_FindFieldByNumber(
|
|
2740
|
+
const struct upb_MiniTable* m, uint32_t number) {
|
|
2741
|
+
const uint32_t i = number - 1; // 0 wraps to UINT32_MAX
|
|
2742
|
+
|
|
2743
|
+
// Ideal case: index into dense fields
|
|
2744
|
+
if (i < m->UPB_PRIVATE(dense_below)) {
|
|
2745
|
+
UPB_ASSERT(m->UPB_ONLYBITS(fields)[i].UPB_ONLYBITS(number) == number);
|
|
2746
|
+
return &m->UPB_ONLYBITS(fields)[i];
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
// Early exit if the field number is out of range.
|
|
2750
|
+
uint32_t hi = m->UPB_ONLYBITS(field_count);
|
|
2751
|
+
uint32_t lo = m->UPB_PRIVATE(dense_below);
|
|
2752
|
+
UPB_ASSERT(hi >= lo);
|
|
2753
|
+
uint32_t search_len = hi - lo;
|
|
2754
|
+
if (search_len == 0 ||
|
|
2755
|
+
number > m->UPB_ONLYBITS(fields)[hi - 1].UPB_ONLYBITS(number)) {
|
|
2756
|
+
return NULL;
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
// Slow case: binary search
|
|
2760
|
+
const struct upb_MiniTableField* candidate =
|
|
2761
|
+
UPB_PRIVATE(upb_MiniTable_LowerBound)(m, lo, search_len, number);
|
|
2762
|
+
|
|
2763
|
+
return candidate->UPB_ONLYBITS(number) == number ? candidate : NULL;
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
UPB_FORCEINLINE bool UPB_PRIVATE(_upb_MiniTable_GapIfUnlinked)(
|
|
2767
|
+
const struct upb_MiniTableField* field, uint32_t number,
|
|
2768
|
+
uint32_t* out_gap_lo, uint32_t* out_gap_hi) {
|
|
2769
|
+
UPB_STATIC_ASSERT(sizeof(upb_MiniTableSubInternal) == sizeof(void*),
|
|
2770
|
+
"SubInternal size must be pointer sized.");
|
|
2771
|
+
if (field->UPB_PRIVATE(submsg_ofs) != kUpb_NoSub) {
|
|
2772
|
+
upb_MiniTableSubInternal* sub = UPB_PTR_AT(
|
|
2773
|
+
field, field->UPB_PRIVATE(submsg_ofs) * kUpb_SubmsgOffsetBytes,
|
|
2774
|
+
upb_MiniTableSubInternal);
|
|
2775
|
+
// Type punning via union is legal in C and we're just checking if it's NULL
|
|
2776
|
+
// but it's UB in C++, and this header could be included in C++.
|
|
2777
|
+
void* sub_ptr;
|
|
2778
|
+
memcpy(&sub_ptr, sub, sizeof(void*));
|
|
2779
|
+
if (sub_ptr == NULL) {
|
|
2780
|
+
UPB_ASSERT(!upb_MiniTableField_IsClosedEnum(field));
|
|
2781
|
+
*out_gap_lo = number - 1;
|
|
2782
|
+
*out_gap_hi = number + 1;
|
|
2783
|
+
return true;
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
return false;
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2789
|
+
// Given a tag number, finds the known field tags bounding the gap of unknown
|
|
2790
|
+
// fields containing it. Returns false and does not set bounds if the tag number
|
|
2791
|
+
// matches a known field and it is linked or primitive. Otherwise returns true
|
|
2792
|
+
// and sets out_gap_lo and out_gap_hi (exclusive/exclusive) to define the range
|
|
2793
|
+
// of unknown fields (out_gap_lo, out_gap_hi). Unlinked submessages are treated
|
|
2794
|
+
// as gaps.
|
|
2795
|
+
UPB_FORCEINLINE bool UPB_PRIVATE(_upb_MiniTable_FindUnknownGap)(
|
|
2796
|
+
const struct upb_MiniTable* m, uint32_t number, uint32_t* out_gap_lo,
|
|
2797
|
+
uint32_t* out_gap_hi) {
|
|
2798
|
+
UPB_ASSERT(number != 0);
|
|
2799
|
+
UPB_ASSERT(number < ((uint32_t)1 << 29));
|
|
2800
|
+
const uint32_t i = number - 1;
|
|
2801
|
+
if (i < m->UPB_PRIVATE(dense_below)) {
|
|
2802
|
+
// Dense field; we know it's present.
|
|
2803
|
+
return UPB_PRIVATE(_upb_MiniTable_GapIfUnlinked)(
|
|
2804
|
+
&m->UPB_ONLYBITS(fields)[i], number, out_gap_lo, out_gap_hi);
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
uint32_t hi = m->UPB_ONLYBITS(field_count);
|
|
2808
|
+
uint32_t lo = m->UPB_PRIVATE(dense_below);
|
|
2809
|
+
if (hi == lo) {
|
|
2810
|
+
*out_gap_lo = lo;
|
|
2811
|
+
*out_gap_hi = UINT32_MAX;
|
|
2812
|
+
return true;
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
uint32_t max_field = m->UPB_ONLYBITS(fields)[hi - 1].UPB_ONLYBITS(number);
|
|
2816
|
+
if (number > max_field) {
|
|
2817
|
+
*out_gap_lo = max_field;
|
|
2818
|
+
*out_gap_hi = UINT32_MAX;
|
|
2819
|
+
return true;
|
|
2820
|
+
}
|
|
2821
|
+
|
|
2822
|
+
uint32_t search_len = hi - lo;
|
|
2823
|
+
const struct upb_MiniTableField* candidate =
|
|
2824
|
+
UPB_PRIVATE(upb_MiniTable_LowerBound)(m, lo, search_len, number);
|
|
2825
|
+
|
|
2826
|
+
uint32_t candidate_num = candidate->UPB_ONLYBITS(number);
|
|
2827
|
+
if (candidate_num == number) {
|
|
2828
|
+
return UPB_PRIVATE(_upb_MiniTable_GapIfUnlinked)(candidate, number,
|
|
2829
|
+
out_gap_lo, out_gap_hi);
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
if (candidate_num < number) {
|
|
2833
|
+
*out_gap_lo = candidate_num;
|
|
2834
|
+
// Checking this next pointer is safe as we have already validated that the
|
|
2835
|
+
// field we're searching for is not greater than or equal to the last field
|
|
2836
|
+
*out_gap_hi = (candidate + 1)->UPB_ONLYBITS(number);
|
|
2837
|
+
} else {
|
|
2838
|
+
UPB_ASSERT(candidate == &m->UPB_ONLYBITS(fields)[lo]);
|
|
2839
|
+
*out_gap_lo = lo;
|
|
2840
|
+
*out_gap_hi = candidate_num;
|
|
2841
|
+
}
|
|
2842
|
+
return true;
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2498
2845
|
UPB_API_INLINE const struct upb_MiniTable* upb_MiniTable_MapEntrySubMessage(
|
|
2499
2846
|
const struct upb_MiniTableField* f) {
|
|
2500
2847
|
UPB_ASSERT(upb_MiniTable_FieldIsLinked(f)); // Map entries must be linked.
|
|
@@ -2672,7 +3019,7 @@ extern "C" {
|
|
|
2672
3019
|
#endif
|
|
2673
3020
|
|
|
2674
3021
|
// Creates a new array on the given arena that holds elements of this type.
|
|
2675
|
-
UPB_API upb_Array* upb_Array_New(upb_Arena* a, upb_CType type);
|
|
3022
|
+
UPB_NODISCARD UPB_API upb_Array* upb_Array_New(upb_Arena* a, upb_CType type);
|
|
2676
3023
|
|
|
2677
3024
|
// Returns the number of elements in the array.
|
|
2678
3025
|
UPB_API_INLINE size_t upb_Array_Size(const upb_Array* arr);
|
|
@@ -2691,18 +3038,20 @@ UPB_API struct upb_Message* upb_Array_GetMutable(upb_Array* arr, size_t i);
|
|
|
2691
3038
|
UPB_API void upb_Array_Set(upb_Array* arr, size_t i, upb_MessageValue val);
|
|
2692
3039
|
|
|
2693
3040
|
// Appends an element to the array. Returns false on allocation failure.
|
|
2694
|
-
UPB_API bool upb_Array_Append(upb_Array* array,
|
|
2695
|
-
|
|
3041
|
+
UPB_NODISCARD UPB_API bool upb_Array_Append(upb_Array* array,
|
|
3042
|
+
upb_MessageValue val,
|
|
3043
|
+
upb_Arena* arena);
|
|
2696
3044
|
|
|
2697
3045
|
// Copies elements from |src| to |dst|, resizing |dst| to match |src| size.
|
|
2698
3046
|
// Returns false on allocation failure.
|
|
2699
|
-
UPB_API bool upb_Array_Copy(upb_Array* dst, const upb_Array* src,
|
|
2700
|
-
|
|
3047
|
+
UPB_NODISCARD UPB_API bool upb_Array_Copy(upb_Array* dst, const upb_Array* src,
|
|
3048
|
+
upb_Arena* arena);
|
|
2701
3049
|
|
|
2702
3050
|
// Appends all elements from |src| to the end of |dst|.
|
|
2703
3051
|
// Returns false on allocation failure.
|
|
2704
|
-
UPB_API bool upb_Array_AppendAll(upb_Array* dst,
|
|
2705
|
-
|
|
3052
|
+
UPB_NODISCARD UPB_API bool upb_Array_AppendAll(upb_Array* dst,
|
|
3053
|
+
const upb_Array* src,
|
|
3054
|
+
upb_Arena* arena);
|
|
2706
3055
|
|
|
2707
3056
|
// Moves elements within the array using memmove().
|
|
2708
3057
|
// Like memmove(), the source and destination elements may be overlapping.
|
|
@@ -2713,8 +3062,8 @@ UPB_API void upb_Array_Move(upb_Array* array, size_t dst_idx, size_t src_idx,
|
|
|
2713
3062
|
// Existing elements are shifted right.
|
|
2714
3063
|
// The new elements have undefined state and must be set with `upb_Array_Set()`.
|
|
2715
3064
|
// REQUIRES: `i <= upb_Array_Size(arr)`
|
|
2716
|
-
UPB_API bool upb_Array_Insert(upb_Array* array, size_t i,
|
|
2717
|
-
|
|
3065
|
+
UPB_NODISCARD UPB_API bool upb_Array_Insert(upb_Array* array, size_t i,
|
|
3066
|
+
size_t count, upb_Arena* arena);
|
|
2718
3067
|
|
|
2719
3068
|
// Deletes one or more elements from the array.
|
|
2720
3069
|
// Existing elements are shifted left.
|
|
@@ -2722,12 +3071,14 @@ UPB_API bool upb_Array_Insert(upb_Array* array, size_t i, size_t count,
|
|
|
2722
3071
|
UPB_API void upb_Array_Delete(upb_Array* array, size_t i, size_t count);
|
|
2723
3072
|
|
|
2724
3073
|
// Reserves |size| elements of storage for the array.
|
|
2725
|
-
UPB_API_INLINE bool upb_Array_Reserve(struct upb_Array* array,
|
|
2726
|
-
|
|
3074
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Array_Reserve(struct upb_Array* array,
|
|
3075
|
+
size_t size,
|
|
3076
|
+
upb_Arena* arena);
|
|
2727
3077
|
|
|
2728
3078
|
// Changes the size of a vector. New elements are initialized to NULL/0.
|
|
2729
3079
|
// Returns false on allocation failure.
|
|
2730
|
-
UPB_API bool upb_Array_Resize(upb_Array* array, size_t size,
|
|
3080
|
+
UPB_NODISCARD UPB_API bool upb_Array_Resize(upb_Array* array, size_t size,
|
|
3081
|
+
upb_Arena* arena);
|
|
2731
3082
|
|
|
2732
3083
|
// Returns pointer to array data.
|
|
2733
3084
|
UPB_API_INLINE const void* upb_Array_DataPtr(const upb_Array* arr);
|
|
@@ -2929,11 +3280,13 @@ typedef struct _upb_tabent {
|
|
|
2929
3280
|
upb_value val;
|
|
2930
3281
|
upb_key key;
|
|
2931
3282
|
|
|
2932
|
-
/* Internal chaining
|
|
2933
|
-
*
|
|
2934
|
-
*
|
|
2935
|
-
*
|
|
2936
|
-
|
|
3283
|
+
/* Internal chaining and presence:
|
|
3284
|
+
* - next == NULL: The entry is empty.
|
|
3285
|
+
* - ent.next == kUpb_NoNextTabent indicating the entry is occupied but has no
|
|
3286
|
+
* successor.
|
|
3287
|
+
* - otherwise: The entry is occupied, and next points to the next entry in
|
|
3288
|
+
* the collision chain. */
|
|
3289
|
+
uintptr_t next;
|
|
2937
3290
|
} upb_tabent;
|
|
2938
3291
|
|
|
2939
3292
|
typedef struct {
|
|
@@ -2949,24 +3302,40 @@ UPB_INLINE size_t upb_table_size(const upb_table* t) { return t->mask + 1; }
|
|
|
2949
3302
|
|
|
2950
3303
|
// Internal-only functions, in .h file only out of necessity.
|
|
2951
3304
|
|
|
2952
|
-
UPB_INLINE
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
3305
|
+
UPB_INLINE bool upb_tabent_isempty(const upb_tabent* e) { return e->next == 0; }
|
|
3306
|
+
|
|
3307
|
+
#define kUpb_NoNextTabent ((uintptr_t)1)
|
|
3308
|
+
|
|
3309
|
+
UPB_INLINE bool upb_tabent_hasnext(const upb_tabent* e) {
|
|
3310
|
+
UPB_STATIC_ASSERT(UPB_ALIGN_OF(upb_tabent) > 1,
|
|
3311
|
+
"valid upb_tabent* can't reference address 1");
|
|
3312
|
+
return e->next != kUpb_NoNextTabent;
|
|
3313
|
+
}
|
|
3314
|
+
|
|
3315
|
+
UPB_INLINE void upb_tabent_clearnext(upb_tabent* e) {
|
|
3316
|
+
e->next = kUpb_NoNextTabent;
|
|
3317
|
+
}
|
|
3318
|
+
|
|
3319
|
+
UPB_INLINE void upb_tabent_clear(upb_tabent* e) {
|
|
3320
|
+
e->next = 0;
|
|
3321
|
+
UPB_ASSERT(upb_tabent_isempty(e));
|
|
2956
3322
|
}
|
|
2957
3323
|
|
|
2958
|
-
UPB_INLINE
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
uintptr_t val;
|
|
2962
|
-
memcpy(&val, &key, sizeof(val));
|
|
2963
|
-
// Note: for upb_inttables a tab_key is a true integer key value, but the
|
|
2964
|
-
// inttable maintains the invariant that 0 value is always stored in the
|
|
2965
|
-
// compact table and never as a upb_tabent* so we can always use the 0
|
|
2966
|
-
// key value to identify an empty tabent.
|
|
2967
|
-
return val == 0;
|
|
3324
|
+
UPB_INLINE upb_tabent* upb_tabent_next(const upb_tabent* e) {
|
|
3325
|
+
UPB_ASSERT(upb_tabent_hasnext(e));
|
|
3326
|
+
return (upb_tabent*)e->next;
|
|
2968
3327
|
}
|
|
2969
3328
|
|
|
3329
|
+
UPB_INLINE void upb_tabent_setnext(upb_tabent* e, upb_tabent* next) {
|
|
3330
|
+
UPB_ASSERT((uintptr_t)next != 0);
|
|
3331
|
+
UPB_ASSERT(next != e);
|
|
3332
|
+
UPB_ASSERT((uintptr_t)next != kUpb_NoNextTabent);
|
|
3333
|
+
e->next = (uintptr_t)next;
|
|
3334
|
+
UPB_ASSERT(upb_tabent_hasnext(e));
|
|
3335
|
+
}
|
|
3336
|
+
|
|
3337
|
+
#undef kUpb_NoNextTabent
|
|
3338
|
+
|
|
2970
3339
|
uint32_t _upb_Hash(const void* p, size_t n, uint64_t seed);
|
|
2971
3340
|
|
|
2972
3341
|
#ifdef __cplusplus
|
|
@@ -2986,18 +3355,7 @@ uint32_t _upb_Hash(const void* p, size_t n, uint64_t seed);
|
|
|
2986
3355
|
// Must be last.
|
|
2987
3356
|
|
|
2988
3357
|
typedef struct {
|
|
2989
|
-
upb_table t;
|
|
2990
|
-
// Array part of the table.
|
|
2991
|
-
// Pointers on this table are const so we can create static initializers for
|
|
2992
|
-
// tables. We cast away const sometimes, but *only* when the containing
|
|
2993
|
-
// upb_table is known to be non-const. This requires a bit of care, but
|
|
2994
|
-
// the subtlety is confined to table.c.
|
|
2995
|
-
const upb_value* array;
|
|
2996
|
-
// Track presence in the array part. Each bit at index (key % 8) at the
|
|
2997
|
-
// presence_mask[key/8] indicates if the element is present in the array part.
|
|
2998
|
-
const uint8_t* presence_mask;
|
|
2999
|
-
uint32_t array_size; // Array part size.
|
|
3000
|
-
uint32_t array_count; // Array part number of elements.
|
|
3358
|
+
upb_table t;
|
|
3001
3359
|
} upb_inttable;
|
|
3002
3360
|
|
|
3003
3361
|
#ifdef __cplusplus
|
|
@@ -3006,19 +3364,18 @@ extern "C" {
|
|
|
3006
3364
|
|
|
3007
3365
|
// Initialize a table. If memory allocation failed, false is returned and
|
|
3008
3366
|
// the table is uninitialized.
|
|
3009
|
-
bool upb_inttable_init(upb_inttable* table, upb_Arena* a);
|
|
3367
|
+
UPB_NODISCARD bool upb_inttable_init(upb_inttable* table, upb_Arena* a);
|
|
3010
3368
|
|
|
3011
3369
|
// Returns the number of values in the table.
|
|
3012
3370
|
size_t upb_inttable_count(const upb_inttable* t);
|
|
3013
3371
|
|
|
3014
3372
|
// Inserts the given key into the hashtable with the given value.
|
|
3015
3373
|
// The key must not already exist in the hash table.
|
|
3016
|
-
// The value must not be UINTPTR_MAX.
|
|
3017
3374
|
//
|
|
3018
3375
|
// If a table resize was required but memory allocation failed, false is
|
|
3019
3376
|
// returned and the table is unchanged.
|
|
3020
|
-
bool upb_inttable_insert(upb_inttable* t, uintptr_t key,
|
|
3021
|
-
|
|
3377
|
+
UPB_NODISCARD bool upb_inttable_insert(upb_inttable* t, uintptr_t key,
|
|
3378
|
+
upb_value val, upb_Arena* a);
|
|
3022
3379
|
|
|
3023
3380
|
// Looks up key in this table, returning "true" if the key was found.
|
|
3024
3381
|
// If v is non-NULL, copies the value for this key into *v.
|
|
@@ -3033,12 +3390,6 @@ bool upb_inttable_remove(upb_inttable* t, uintptr_t key, upb_value* val);
|
|
|
3033
3390
|
// Unlike insert/remove, this does not invalidate iterators.
|
|
3034
3391
|
bool upb_inttable_replace(upb_inttable* t, uintptr_t key, upb_value val);
|
|
3035
3392
|
|
|
3036
|
-
// Optimizes the table for the current set of entries, for both memory use and
|
|
3037
|
-
// lookup time. Client should call this after all entries have been inserted;
|
|
3038
|
-
// inserting more entries is legal, but will likely require a table resize.
|
|
3039
|
-
// Returns false if reallocation fails.
|
|
3040
|
-
bool upb_inttable_compact(upb_inttable* t, upb_Arena* a);
|
|
3041
|
-
|
|
3042
3393
|
// Clears the table.
|
|
3043
3394
|
void upb_inttable_clear(upb_inttable* t);
|
|
3044
3395
|
|
|
@@ -3061,10 +3412,6 @@ bool upb_inttable_done(const upb_inttable* t, intptr_t i);
|
|
|
3061
3412
|
uintptr_t upb_inttable_iter_key(const upb_inttable* t, intptr_t iter);
|
|
3062
3413
|
upb_value upb_inttable_iter_value(const upb_inttable* t, intptr_t iter);
|
|
3063
3414
|
|
|
3064
|
-
UPB_INLINE bool upb_inttable_arrhas(const upb_inttable* t, uintptr_t key) {
|
|
3065
|
-
return (t->presence_mask[key / 8] & (1 << (key % 8))) != 0;
|
|
3066
|
-
}
|
|
3067
|
-
|
|
3068
3415
|
#ifdef __cplusplus
|
|
3069
3416
|
} /* extern "C" */
|
|
3070
3417
|
#endif
|
|
@@ -3092,7 +3439,8 @@ extern "C" {
|
|
|
3092
3439
|
|
|
3093
3440
|
// Initialize a table. If memory allocation failed, false is returned and
|
|
3094
3441
|
// the table is uninitialized.
|
|
3095
|
-
bool upb_strtable_init(upb_strtable* table, size_t expected_size,
|
|
3442
|
+
UPB_NODISCARD bool upb_strtable_init(upb_strtable* table, size_t expected_size,
|
|
3443
|
+
upb_Arena* a);
|
|
3096
3444
|
|
|
3097
3445
|
// Returns the number of values in the table.
|
|
3098
3446
|
UPB_INLINE size_t upb_strtable_count(const upb_strtable* t) {
|
|
@@ -3107,8 +3455,8 @@ void upb_strtable_clear(upb_strtable* t);
|
|
|
3107
3455
|
//
|
|
3108
3456
|
// If a table resize was required but memory allocation failed, false is
|
|
3109
3457
|
// returned and the table is unchanged. */
|
|
3110
|
-
bool upb_strtable_insert(upb_strtable* t, const char* key,
|
|
3111
|
-
|
|
3458
|
+
UPB_NODISCARD bool upb_strtable_insert(upb_strtable* t, const char* key,
|
|
3459
|
+
size_t len, upb_value val, upb_Arena* a);
|
|
3112
3460
|
|
|
3113
3461
|
// Looks up key in this table, returning "true" if the key was found.
|
|
3114
3462
|
// If v is non-NULL, copies the value for this key into *v.
|
|
@@ -3132,7 +3480,8 @@ UPB_INLINE bool upb_strtable_remove(upb_strtable* t, const char* key,
|
|
|
3132
3480
|
}
|
|
3133
3481
|
|
|
3134
3482
|
// Exposed for testing only.
|
|
3135
|
-
bool upb_strtable_resize(upb_strtable* t, size_t size_lg2,
|
|
3483
|
+
UPB_NODISCARD bool upb_strtable_resize(upb_strtable* t, size_t size_lg2,
|
|
3484
|
+
upb_Arena* a);
|
|
3136
3485
|
|
|
3137
3486
|
/* Iteration over strtable:
|
|
3138
3487
|
*
|
|
@@ -3436,6 +3785,12 @@ struct upb_MiniTableExtension {
|
|
|
3436
3785
|
struct upb_MiniTableField UPB_PRIVATE(field);
|
|
3437
3786
|
|
|
3438
3787
|
union upb_MiniTableSub UPB_PRIVATE(sub); // NULL unless submsg or proto2 enum
|
|
3788
|
+
|
|
3789
|
+
// A known extendee schema for a canonical extension. For a non-canonical
|
|
3790
|
+
// extension, it's typically converted from a canonical extension via the
|
|
3791
|
+
// upb_Message_Convert() API, but is not registered on the extension
|
|
3792
|
+
// registry of the target message when it gets converted. In this case, the
|
|
3793
|
+
// `extendee` info is present on the source message before conversion.
|
|
3439
3794
|
const struct upb_MiniTable* UPB_PRIVATE(extendee);
|
|
3440
3795
|
};
|
|
3441
3796
|
|
|
@@ -3574,10 +3929,18 @@ extern "C" {
|
|
|
3574
3929
|
// Adds the given extension data to the given message.
|
|
3575
3930
|
// |ext| is copied into the message instance.
|
|
3576
3931
|
// This logically replaces any previously-added extension with this number.
|
|
3577
|
-
upb_Extension* UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(
|
|
3932
|
+
UPB_NODISCARD upb_Extension* UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(
|
|
3578
3933
|
struct upb_Message* msg, const upb_MiniTableExtension* ext,
|
|
3579
3934
|
upb_Arena* arena);
|
|
3580
3935
|
|
|
3936
|
+
// Adds the given non-canonical extension data to the given message.
|
|
3937
|
+
// |ext| is copied into the message instance.
|
|
3938
|
+
// This logically replaces any previously-added extension with this number.
|
|
3939
|
+
UPB_NODISCARD upb_Extension* UPB_PRIVATE(
|
|
3940
|
+
_upb_Message_CreateNonCanonicalExtension)(struct upb_Message* msg,
|
|
3941
|
+
const upb_MiniTableExtension* ext,
|
|
3942
|
+
upb_Arena* arena);
|
|
3943
|
+
|
|
3581
3944
|
// Returns an extension for a message with a given mini table,
|
|
3582
3945
|
// or NULL if no extension exists with this mini table.
|
|
3583
3946
|
const upb_Extension* UPB_PRIVATE(_upb_Message_Getext)(
|
|
@@ -3631,15 +3994,27 @@ extern const double kUpb_NaN;
|
|
|
3631
3994
|
// Internal members of a upb_Message that track unknown fields and/or
|
|
3632
3995
|
// extensions. We can change this without breaking binary compatibility.
|
|
3633
3996
|
|
|
3997
|
+
// LINT.IfChange(tagged_aux_type)
|
|
3634
3998
|
typedef struct upb_TaggedAuxPtr {
|
|
3635
|
-
//
|
|
3636
|
-
//
|
|
3637
|
-
//
|
|
3638
|
-
//
|
|
3999
|
+
// Three lowest bits form a tag:
|
|
4000
|
+
// 000 - non-aliased unknown data (upb_StringView*)
|
|
4001
|
+
// 100 - aliased unknown data (upb_StringView*)
|
|
4002
|
+
// 001 - non-canonical extension (upb_Extension*)
|
|
4003
|
+
// 011 - canonical extension (upb_Extension*)
|
|
4004
|
+
//
|
|
4005
|
+
// Bit 0 (lowest bit): Represents the data format in memory (1 for parsed
|
|
4006
|
+
// form, 0 for serialized form).
|
|
4007
|
+
// Bit 1 (middle bit): Represents whether the data is semantically known or
|
|
4008
|
+
// not (1 for known, 0 for unknown).
|
|
4009
|
+
// Bit 2 (highest bit): Aliased/Non-aliased (1 for aliased, 0 for
|
|
4010
|
+
// non-aliased).
|
|
3639
4011
|
//
|
|
3640
|
-
//
|
|
3641
|
-
//
|
|
3642
|
-
//
|
|
4012
|
+
// Following this tag structure, we can later use tag `010` for lazy
|
|
4013
|
+
// extensions.
|
|
4014
|
+
//
|
|
4015
|
+
// The main semantic difference between aliased and non-aliased
|
|
4016
|
+
// unknown data is that non-aliased unknown data can be assumed to have the
|
|
4017
|
+
// following layout:
|
|
3643
4018
|
//
|
|
3644
4019
|
// [upb_StringView] [data]
|
|
3645
4020
|
//
|
|
@@ -3653,33 +4028,75 @@ typedef struct upb_TaggedAuxPtr {
|
|
|
3653
4028
|
// For aliased unknown data, this layout is _not_ guaranteed, since the
|
|
3654
4029
|
// pointer to the StringView can be anywhere in the allocation, and the
|
|
3655
4030
|
// StringView may point to non-data memory.
|
|
4031
|
+
//
|
|
4032
|
+
// For a non-canonical extension, its schema is known but not
|
|
4033
|
+
// the one expected by the message, so it should be treated like an unknown
|
|
4034
|
+
// field, but is stored as an extension to lazily defer serialization.
|
|
3656
4035
|
uintptr_t ptr;
|
|
3657
4036
|
} upb_TaggedAuxPtr;
|
|
3658
4037
|
|
|
3659
|
-
|
|
3660
|
-
|
|
4038
|
+
// If this returns true, then the entry is semantically known (but may be in
|
|
4039
|
+
// either parsed or unparsed form).
|
|
4040
|
+
UPB_INLINE bool upb_TaggedAuxPtr_IsSemanticallyKnown(upb_TaggedAuxPtr ptr) {
|
|
4041
|
+
return (ptr.ptr & 0x2) != 0;
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
UPB_INLINE bool upb_TaggedAuxPtr_IsCanonicalExtension(upb_TaggedAuxPtr ptr) {
|
|
4045
|
+
return (ptr.ptr & 3) == 3;
|
|
3661
4046
|
}
|
|
3662
4047
|
|
|
3663
|
-
UPB_INLINE bool
|
|
3664
|
-
return ptr.ptr & 1;
|
|
4048
|
+
UPB_INLINE bool upb_TaggedAuxPtr_IsNonCanonicalExtension(upb_TaggedAuxPtr ptr) {
|
|
4049
|
+
return (ptr.ptr & 3) == 1;
|
|
3665
4050
|
}
|
|
3666
4051
|
|
|
3667
|
-
|
|
3668
|
-
|
|
4052
|
+
// Returns true if the entry is aliased/non-aliased unknown data.
|
|
4053
|
+
UPB_INLINE bool upb_TaggedAuxPtr_IsUnknownStringView(upb_TaggedAuxPtr ptr) {
|
|
4054
|
+
return (ptr.ptr != 0) && ((ptr.ptr & 3) == 0);
|
|
3669
4055
|
}
|
|
3670
4056
|
|
|
3671
4057
|
UPB_INLINE bool upb_TaggedAuxPtr_IsUnknownAliased(upb_TaggedAuxPtr ptr) {
|
|
3672
|
-
return (ptr.ptr != 0) && ((ptr.ptr &
|
|
4058
|
+
return (ptr.ptr != 0) && ((ptr.ptr & 5) == 4);
|
|
3673
4059
|
}
|
|
3674
4060
|
|
|
3675
|
-
UPB_INLINE upb_Extension*
|
|
3676
|
-
|
|
3677
|
-
|
|
4061
|
+
UPB_INLINE upb_Extension* upb_TaggedAuxPtr_CanonicalExtension(
|
|
4062
|
+
upb_TaggedAuxPtr ptr) {
|
|
4063
|
+
UPB_ASSERT(upb_TaggedAuxPtr_IsCanonicalExtension(ptr));
|
|
4064
|
+
return (upb_Extension*)(ptr.ptr & ~7ULL);
|
|
3678
4065
|
}
|
|
3679
4066
|
|
|
3680
|
-
UPB_INLINE
|
|
3681
|
-
|
|
3682
|
-
|
|
4067
|
+
UPB_INLINE upb_Extension* upb_TaggedAuxPtr_NonCanonicalExtension(
|
|
4068
|
+
upb_TaggedAuxPtr ptr) {
|
|
4069
|
+
UPB_ASSERT(upb_TaggedAuxPtr_IsNonCanonicalExtension(ptr));
|
|
4070
|
+
return (upb_Extension*)(ptr.ptr & ~7ULL);
|
|
4071
|
+
}
|
|
4072
|
+
|
|
4073
|
+
// Returns a pointer to the aliased or unaliased unknown upb_StringView* data.
|
|
4074
|
+
UPB_INLINE upb_StringView* upb_TaggedPtrAux_StringViewRepr(
|
|
4075
|
+
upb_TaggedAuxPtr ptr) {
|
|
4076
|
+
UPB_ASSERT(upb_TaggedAuxPtr_IsUnknownStringView(ptr));
|
|
4077
|
+
return (upb_StringView*)(ptr.ptr & ~7ULL);
|
|
4078
|
+
}
|
|
4079
|
+
|
|
4080
|
+
// LINT.ThenChange(//depot/google3/third_party/upb/bits/golang/message.go:tagged_aux_type)
|
|
4081
|
+
|
|
4082
|
+
typedef enum {
|
|
4083
|
+
kUpb_TaggedAuxType_Unknown = 0, // tag 000
|
|
4084
|
+
kUpb_TaggedAuxType_NonCanonicalExtension = 1, // tag 001
|
|
4085
|
+
kUpb_TaggedAuxType_CanonicalExtension = 3, // tag 011
|
|
4086
|
+
kUpb_TaggedAuxType_AliasedUnknown = 4 // tag 100
|
|
4087
|
+
} upb_TaggedAuxType;
|
|
4088
|
+
|
|
4089
|
+
typedef union {
|
|
4090
|
+
upb_Extension* extension;
|
|
4091
|
+
const upb_StringView* unknown_data;
|
|
4092
|
+
} upb_TaggedAux;
|
|
4093
|
+
|
|
4094
|
+
UPB_INLINE upb_TaggedAuxType upb_TaggedAux_Get(upb_TaggedAuxPtr ptr,
|
|
4095
|
+
upb_TaggedAux* data) {
|
|
4096
|
+
uintptr_t untagged = ptr.ptr & ~7ULL;
|
|
4097
|
+
UPB_ASSERT((untagged & 7) == 0);
|
|
4098
|
+
memcpy(data, &untagged, sizeof(*data));
|
|
4099
|
+
return (upb_TaggedAuxType)(ptr.ptr & 7);
|
|
3683
4100
|
}
|
|
3684
4101
|
|
|
3685
4102
|
UPB_INLINE upb_TaggedAuxPtr upb_TaggedAuxPtr_Null(void) {
|
|
@@ -3689,7 +4106,16 @@ UPB_INLINE upb_TaggedAuxPtr upb_TaggedAuxPtr_Null(void) {
|
|
|
3689
4106
|
}
|
|
3690
4107
|
|
|
3691
4108
|
UPB_INLINE upb_TaggedAuxPtr
|
|
3692
|
-
|
|
4109
|
+
upb_TaggedAuxPtr_MakeCanonicalExtension(const upb_Extension* e) {
|
|
4110
|
+
UPB_ASSERT(((uintptr_t)e & 7) == 0);
|
|
4111
|
+
upb_TaggedAuxPtr ptr;
|
|
4112
|
+
ptr.ptr = (uintptr_t)e | 3;
|
|
4113
|
+
return ptr;
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4116
|
+
UPB_INLINE upb_TaggedAuxPtr
|
|
4117
|
+
upb_TaggedAuxPtr_MakeNonCanonicalExtension(const upb_Extension* e) {
|
|
4118
|
+
UPB_ASSERT(((uintptr_t)e & 7) == 0);
|
|
3693
4119
|
upb_TaggedAuxPtr ptr;
|
|
3694
4120
|
ptr.ptr = (uintptr_t)e | 1;
|
|
3695
4121
|
return ptr;
|
|
@@ -3700,6 +4126,7 @@ upb_TaggedAuxPtr_MakeExtension(const upb_Extension* e) {
|
|
|
3700
4126
|
// view.
|
|
3701
4127
|
UPB_INLINE upb_TaggedAuxPtr
|
|
3702
4128
|
upb_TaggedAuxPtr_MakeUnknownData(const upb_StringView* sv) {
|
|
4129
|
+
UPB_ASSERT(((uintptr_t)sv & 7) == 0);
|
|
3703
4130
|
upb_TaggedAuxPtr ptr;
|
|
3704
4131
|
ptr.ptr = (uintptr_t)sv;
|
|
3705
4132
|
return ptr;
|
|
@@ -3709,8 +4136,9 @@ upb_TaggedAuxPtr_MakeUnknownData(const upb_StringView* sv) {
|
|
|
3709
4136
|
// the data it points to.
|
|
3710
4137
|
UPB_INLINE upb_TaggedAuxPtr
|
|
3711
4138
|
upb_TaggedAuxPtr_MakeUnknownDataAliased(const upb_StringView* sv) {
|
|
4139
|
+
UPB_ASSERT(((uintptr_t)sv & 7) == 0);
|
|
3712
4140
|
upb_TaggedAuxPtr ptr;
|
|
3713
|
-
ptr.ptr = (uintptr_t)sv |
|
|
4141
|
+
ptr.ptr = (uintptr_t)sv | 4;
|
|
3714
4142
|
return ptr;
|
|
3715
4143
|
}
|
|
3716
4144
|
|
|
@@ -3729,9 +4157,63 @@ UPB_API void upb_Message_SetNewMessageTraceHandler(
|
|
|
3729
4157
|
void (*handler)(const upb_MiniTable*, const upb_Arena*));
|
|
3730
4158
|
#endif // UPB_TRACING_ENABLED
|
|
3731
4159
|
|
|
4160
|
+
// We want to avoid the PLT and register spills for the many tiny memsets used
|
|
4161
|
+
// to initialize messages; the dedicated memset instructions won't do that
|
|
4162
|
+
#ifdef __ARM_FEAT_MOPS
|
|
4163
|
+
#define UPB_ARM_MOPS __ARM_FEAT_MOPS
|
|
4164
|
+
#else
|
|
4165
|
+
#define UPB_ARM_MOPS 0
|
|
4166
|
+
#endif
|
|
4167
|
+
|
|
4168
|
+
UPB_FORCEINLINE void _upb_Message_AlignedMemsetZero(void* dst, size_t size) {
|
|
4169
|
+
UPB_ASSUME(size % kUpb_Message_Align == 0);
|
|
4170
|
+
UPB_ASSUME(size != 0);
|
|
4171
|
+
UPB_ASSUME((uintptr_t)dst % kUpb_Message_Align == 0);
|
|
4172
|
+
#if UPB_ARM64_ASM && !UPB_ARM_MOPS
|
|
4173
|
+
#if UPB_HAS_BUILTIN(__builtin_constant_p)
|
|
4174
|
+
if (__builtin_constant_p(size)) {
|
|
4175
|
+
// We assume the compiler will do something intelligent with a known-length
|
|
4176
|
+
// memset.
|
|
4177
|
+
memset(dst, 0, size);
|
|
4178
|
+
return;
|
|
4179
|
+
}
|
|
4180
|
+
#endif
|
|
4181
|
+
char* ptr = (char*)dst;
|
|
4182
|
+
char* end = ptr + size;
|
|
4183
|
+
__asm__(
|
|
4184
|
+
// Unconditionally zero the first 8 byte chunk; if the loop runs this is
|
|
4185
|
+
// wasted work, but doing it unconditionally is cheaper than adding
|
|
4186
|
+
// another branch.
|
|
4187
|
+
"str xzr, [%x[ptr]]\n\t"
|
|
4188
|
+
|
|
4189
|
+
// If size == 8, skip the loop.
|
|
4190
|
+
"cmp %x[count], #8\n\t"
|
|
4191
|
+
"b.eq 2f\n\t"
|
|
4192
|
+
|
|
4193
|
+
// Loop for size >= 16.
|
|
4194
|
+
// In each iteration, we zero 16 bytes from the ptr and 16 bytes from the
|
|
4195
|
+
// end. These regions may overlap, which is OK; doing it this way lets us
|
|
4196
|
+
// process two chunks per loop iteration.
|
|
4197
|
+
"1:\n\t"
|
|
4198
|
+
"stp xzr, xzr, [%x[ptr]], #16\n\t" // Store then increment by 16
|
|
4199
|
+
"stp xzr, xzr, [%x[end], #-16]!\n\t" // Decrement by 16 then store
|
|
4200
|
+
// End the loop when pointers cross or meet.
|
|
4201
|
+
"cmp %x[ptr], %x[end]\n\t"
|
|
4202
|
+
"b.lo 1b\n\t"
|
|
4203
|
+
"2:\n\t"
|
|
4204
|
+
: [ptr] "+&r"(ptr), [end] "+&r"(end), "=m"(*(char (*)[])dst)
|
|
4205
|
+
: [count] "r"(size)
|
|
4206
|
+
: "cc");
|
|
4207
|
+
UPB_PRIVATE(upb_Xsan_MarkInitialized)(dst, size);
|
|
4208
|
+
#else
|
|
4209
|
+
memset(dst, 0, size);
|
|
4210
|
+
#endif
|
|
4211
|
+
}
|
|
4212
|
+
#undef UPB_ARM_MOPS
|
|
4213
|
+
|
|
3732
4214
|
// Inline version upb_Message_New(), for internal use.
|
|
3733
|
-
UPB_INLINE struct upb_Message* _upb_Message_New(
|
|
3734
|
-
|
|
4215
|
+
UPB_NODISCARD UPB_INLINE struct upb_Message* _upb_Message_New(
|
|
4216
|
+
const upb_MiniTable* m, upb_Arena* a) {
|
|
3735
4217
|
UPB_PRIVATE(upb_MiniTable_CheckInvariants)(m);
|
|
3736
4218
|
#ifdef UPB_TRACING_ENABLED
|
|
3737
4219
|
upb_Message_LogNewMessage(m, a);
|
|
@@ -3743,14 +4225,14 @@ UPB_INLINE struct upb_Message* _upb_Message_New(const upb_MiniTable* m,
|
|
|
3743
4225
|
UPB_ASSUME(size % kUpb_Message_Align == 0);
|
|
3744
4226
|
struct upb_Message* msg = (struct upb_Message*)upb_Arena_Malloc(a, size);
|
|
3745
4227
|
if (UPB_UNLIKELY(!msg)) return NULL;
|
|
3746
|
-
|
|
4228
|
+
_upb_Message_AlignedMemsetZero(msg, size);
|
|
3747
4229
|
return msg;
|
|
3748
4230
|
}
|
|
3749
4231
|
|
|
3750
4232
|
// Discards the unknown fields for this message only.
|
|
3751
4233
|
void _upb_Message_DiscardUnknown_shallow(struct upb_Message* msg);
|
|
3752
4234
|
|
|
3753
|
-
UPB_NOINLINE bool UPB_PRIVATE(_upb_Message_AddUnknownSlowPath)(
|
|
4235
|
+
UPB_NODISCARD UPB_NOINLINE bool UPB_PRIVATE(_upb_Message_AddUnknownSlowPath)(
|
|
3754
4236
|
struct upb_Message* msg, const char* data, size_t len, upb_Arena* arena,
|
|
3755
4237
|
bool alias);
|
|
3756
4238
|
|
|
@@ -3766,6 +4248,36 @@ typedef enum {
|
|
|
3766
4248
|
kUpb_AddUnknown_AliasAllowMerge = 2,
|
|
3767
4249
|
} upb_AddUnknownMode;
|
|
3768
4250
|
|
|
4251
|
+
UPB_NODISCARD UPB_INLINE bool UPB_PRIVATE(
|
|
4252
|
+
_upb_Message_TryAddUnknownAliasAllowMerge)(struct upb_Message* msg,
|
|
4253
|
+
const char* data, size_t len,
|
|
4254
|
+
upb_Arena* arena,
|
|
4255
|
+
upb_AddUnknownMode mode) {
|
|
4256
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
|
4257
|
+
UPB_ASSERT(mode == kUpb_AddUnknown_AliasAllowMerge);
|
|
4258
|
+
// Aliasing parse of a message with sequential unknown fields is a simple
|
|
4259
|
+
// pointer bump, so inline it.
|
|
4260
|
+
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
|
4261
|
+
if (in && in->size) {
|
|
4262
|
+
upb_TaggedAuxPtr ptr = in->aux_data[in->size - 1];
|
|
4263
|
+
if (upb_TaggedAuxPtr_IsUnknownStringView(ptr)) {
|
|
4264
|
+
upb_StringView* existing = upb_TaggedPtrAux_StringViewRepr(ptr);
|
|
4265
|
+
// Fast path if the field we're adding is immediately after the last
|
|
4266
|
+
// added unknown field.
|
|
4267
|
+
//
|
|
4268
|
+
// The caller has guaranteed to us, by passing
|
|
4269
|
+
// kUpb_AddUnknown_AliasAllowMerge, that there is no risk that these two
|
|
4270
|
+
// regions of memory are from different objects that are contiguous in
|
|
4271
|
+
// memory by coincidence.
|
|
4272
|
+
if (existing->data + existing->size == data) {
|
|
4273
|
+
existing->size += len;
|
|
4274
|
+
return true;
|
|
4275
|
+
}
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4278
|
+
return false;
|
|
4279
|
+
}
|
|
4280
|
+
|
|
3769
4281
|
// Adds unknown data (serialized protobuf data) to the given message. The data
|
|
3770
4282
|
// must represent one or more complete and well formed proto fields.
|
|
3771
4283
|
//
|
|
@@ -3776,33 +4288,14 @@ typedef enum {
|
|
|
3776
4288
|
// to mark the boundary of the buffer, so that we do not inappropriately
|
|
3777
4289
|
// coalesce two buffers that are separate objects but happen to be contiguous
|
|
3778
4290
|
// in memory.
|
|
3779
|
-
UPB_INLINE bool UPB_PRIVATE(_upb_Message_AddUnknown)(
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
upb_Arena* arena,
|
|
3783
|
-
upb_AddUnknownMode mode) {
|
|
4291
|
+
UPB_NODISCARD UPB_INLINE bool UPB_PRIVATE(_upb_Message_AddUnknown)(
|
|
4292
|
+
struct upb_Message* msg, const char* data, size_t len, upb_Arena* arena,
|
|
4293
|
+
upb_AddUnknownMode mode) {
|
|
3784
4294
|
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
|
3785
|
-
if (mode == kUpb_AddUnknown_AliasAllowMerge
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
if (in && in->size) {
|
|
3790
|
-
upb_TaggedAuxPtr ptr = in->aux_data[in->size - 1];
|
|
3791
|
-
if (upb_TaggedAuxPtr_IsUnknown(ptr)) {
|
|
3792
|
-
upb_StringView* existing = upb_TaggedAuxPtr_UnknownData(ptr);
|
|
3793
|
-
// Fast path if the field we're adding is immediately after the last
|
|
3794
|
-
// added unknown field.
|
|
3795
|
-
//
|
|
3796
|
-
// The caller has guaranteed to us, by passing
|
|
3797
|
-
// kUpb_AddUnknown_AliasAllowMerge, that there is no risk that these two
|
|
3798
|
-
// regions of memory are from different objects that are contiguous in
|
|
3799
|
-
// memory by coincidence.
|
|
3800
|
-
if (existing->data + existing->size == data) {
|
|
3801
|
-
existing->size += len;
|
|
3802
|
-
return true;
|
|
3803
|
-
}
|
|
3804
|
-
}
|
|
3805
|
-
}
|
|
4295
|
+
if (mode == kUpb_AddUnknown_AliasAllowMerge &&
|
|
4296
|
+
UPB_PRIVATE(_upb_Message_TryAddUnknownAliasAllowMerge)(msg, data, len,
|
|
4297
|
+
arena, mode)) {
|
|
4298
|
+
return true;
|
|
3806
4299
|
}
|
|
3807
4300
|
return UPB_PRIVATE(_upb_Message_AddUnknownSlowPath)(
|
|
3808
4301
|
msg, data, len, arena, mode != kUpb_AddUnknown_Copy);
|
|
@@ -3812,14 +4305,35 @@ UPB_INLINE bool UPB_PRIVATE(_upb_Message_AddUnknown)(struct upb_Message* msg,
|
|
|
3812
4305
|
// The data is copied into the message instance. Data when concatenated together
|
|
3813
4306
|
// must represent one or more complete and well formed proto fields, but the
|
|
3814
4307
|
// individual spans may point only to partial fields.
|
|
3815
|
-
bool UPB_PRIVATE(_upb_Message_AddUnknownV)(
|
|
3816
|
-
|
|
3817
|
-
|
|
4308
|
+
UPB_NODISCARD bool UPB_PRIVATE(_upb_Message_AddUnknownV)(
|
|
4309
|
+
struct upb_Message* msg, upb_Arena* arena, upb_StringView data[],
|
|
4310
|
+
size_t count);
|
|
3818
4311
|
|
|
3819
4312
|
// Ensures at least one slot is available in the aux_data of this message.
|
|
3820
4313
|
// Returns false if a reallocation is needed to satisfy the request, and fails.
|
|
3821
|
-
bool UPB_PRIVATE(_upb_Message_ReserveSlot)(
|
|
3822
|
-
|
|
4314
|
+
UPB_NODISCARD bool UPB_PRIVATE(_upb_Message_ReserveSlot)(
|
|
4315
|
+
struct upb_Message* msg, upb_Arena* arena);
|
|
4316
|
+
|
|
4317
|
+
typedef enum {
|
|
4318
|
+
kUpb_MessageUnknownType_StringView,
|
|
4319
|
+
kUpb_MessageUnknownType_NonCanonicalExtension,
|
|
4320
|
+
} upb_MessageUnknownType;
|
|
4321
|
+
|
|
4322
|
+
// Represents an unknown field in a message, whether it's in a serialized
|
|
4323
|
+
// (upb_StringView) or parsed non-canonical extension (upb_Extension*) format.
|
|
4324
|
+
typedef struct upb_MessageUnknown {
|
|
4325
|
+
uint8_t type;
|
|
4326
|
+
union {
|
|
4327
|
+
upb_StringView bytes;
|
|
4328
|
+
const upb_Extension* extension;
|
|
4329
|
+
} value;
|
|
4330
|
+
} upb_MessageUnknown;
|
|
4331
|
+
|
|
4332
|
+
typedef enum upb_Message_DeleteUnknownStatus {
|
|
4333
|
+
kUpb_DeleteUnknown_DeletedLast,
|
|
4334
|
+
kUpb_DeleteUnknown_IterUpdated,
|
|
4335
|
+
kUpb_DeleteUnknown_AllocFail,
|
|
4336
|
+
} upb_Message_DeleteUnknownStatus;
|
|
3823
4337
|
|
|
3824
4338
|
#define kUpb_Message_UnknownBegin 0
|
|
3825
4339
|
#define kUpb_Message_ExtensionBegin 0
|
|
@@ -3831,8 +4345,8 @@ UPB_INLINE bool upb_Message_NextUnknown(const struct upb_Message* msg,
|
|
|
3831
4345
|
if (in) {
|
|
3832
4346
|
while (i < in->size) {
|
|
3833
4347
|
upb_TaggedAuxPtr tagged_ptr = in->aux_data[i++];
|
|
3834
|
-
if (
|
|
3835
|
-
*data = *
|
|
4348
|
+
if (upb_TaggedAuxPtr_IsUnknownStringView(tagged_ptr)) {
|
|
4349
|
+
*data = *upb_TaggedPtrAux_StringViewRepr(tagged_ptr);
|
|
3836
4350
|
*iter = i;
|
|
3837
4351
|
return true;
|
|
3838
4352
|
}
|
|
@@ -3844,12 +4358,6 @@ UPB_INLINE bool upb_Message_NextUnknown(const struct upb_Message* msg,
|
|
|
3844
4358
|
return false;
|
|
3845
4359
|
}
|
|
3846
4360
|
|
|
3847
|
-
UPB_INLINE bool upb_Message_HasUnknown(const struct upb_Message* msg) {
|
|
3848
|
-
upb_StringView data;
|
|
3849
|
-
uintptr_t iter = kUpb_Message_UnknownBegin;
|
|
3850
|
-
return upb_Message_NextUnknown(msg, &data, &iter);
|
|
3851
|
-
}
|
|
3852
|
-
|
|
3853
4361
|
UPB_INLINE bool upb_Message_NextExtension(const struct upb_Message* msg,
|
|
3854
4362
|
const upb_MiniTableExtension** out_e,
|
|
3855
4363
|
upb_MessageValue* out_v,
|
|
@@ -3859,8 +4367,9 @@ UPB_INLINE bool upb_Message_NextExtension(const struct upb_Message* msg,
|
|
|
3859
4367
|
if (in) {
|
|
3860
4368
|
while (i < in->size) {
|
|
3861
4369
|
upb_TaggedAuxPtr tagged_ptr = in->aux_data[i++];
|
|
3862
|
-
if (
|
|
3863
|
-
const upb_Extension* ext =
|
|
4370
|
+
if (upb_TaggedAuxPtr_IsCanonicalExtension(tagged_ptr)) {
|
|
4371
|
+
const upb_Extension* ext =
|
|
4372
|
+
upb_TaggedAuxPtr_CanonicalExtension(tagged_ptr);
|
|
3864
4373
|
|
|
3865
4374
|
// Empty repeated fields or maps semantically don't exist.
|
|
3866
4375
|
if (UPB_PRIVATE(_upb_Extension_IsEmpty)(ext)) continue;
|
|
@@ -3887,10 +4396,10 @@ UPB_INLINE bool UPB_PRIVATE(_upb_Message_NextExtensionReverse)(
|
|
|
3887
4396
|
while (i < size) {
|
|
3888
4397
|
upb_TaggedAuxPtr tagged_ptr = in->aux_data[size - 1 - i];
|
|
3889
4398
|
i++;
|
|
3890
|
-
if (!
|
|
4399
|
+
if (!upb_TaggedAuxPtr_IsCanonicalExtension(tagged_ptr)) {
|
|
3891
4400
|
continue;
|
|
3892
4401
|
}
|
|
3893
|
-
const upb_Extension* ext =
|
|
4402
|
+
const upb_Extension* ext = upb_TaggedAuxPtr_CanonicalExtension(tagged_ptr);
|
|
3894
4403
|
|
|
3895
4404
|
// Empty repeated fields or maps semantically don't exist.
|
|
3896
4405
|
if (UPB_PRIVATE(_upb_Extension_IsEmpty)(ext)) continue;
|
|
@@ -4025,6 +4534,7 @@ UPB_INLINE bool UPB_PRIVATE(_upb_Message_IsInitializedShallow)(
|
|
|
4025
4534
|
return (UPB_PRIVATE(_upb_MiniTable_RequiredMask)(m) & ~bits) == 0;
|
|
4026
4535
|
}
|
|
4027
4536
|
|
|
4537
|
+
// LINT.IfChange(message_raw_fields)
|
|
4028
4538
|
UPB_INLINE void* UPB_PRIVATE(_upb_Message_MutableDataPtr)(
|
|
4029
4539
|
struct upb_Message* msg, const upb_MiniTableField* f) {
|
|
4030
4540
|
return (char*)msg + f->UPB_ONLYBITS(offset);
|
|
@@ -4063,6 +4573,7 @@ UPB_INLINE_IF_NOT_GCC void UPB_PRIVATE(_upb_MiniTableField_DataCopy)(
|
|
|
4063
4573
|
}
|
|
4064
4574
|
UPB_UNREACHABLE();
|
|
4065
4575
|
}
|
|
4576
|
+
// LINT.ThenChange(//depot/google3/third_party/upb/bits/golang/message.go:message_raw_fields)
|
|
4066
4577
|
|
|
4067
4578
|
UPB_INLINE_IF_NOT_GCC bool UPB_PRIVATE(_upb_MiniTableField_DataEquals)(
|
|
4068
4579
|
const upb_MiniTableField* f, const void* a, const void* b) {
|
|
@@ -4213,6 +4724,19 @@ UPB_API_INLINE bool upb_Message_SetExtension(struct upb_Message* msg,
|
|
|
4213
4724
|
return true;
|
|
4214
4725
|
}
|
|
4215
4726
|
|
|
4727
|
+
UPB_API_INLINE bool UPB_PRIVATE(_upb_Message_SetNonCanonicalExtension)(
|
|
4728
|
+
struct upb_Message* msg, const upb_MiniTableExtension* e, const void* val,
|
|
4729
|
+
upb_Arena* a) {
|
|
4730
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
|
4731
|
+
UPB_ASSERT(a);
|
|
4732
|
+
upb_Extension* ext =
|
|
4733
|
+
UPB_PRIVATE(_upb_Message_CreateNonCanonicalExtension)(msg, e, a);
|
|
4734
|
+
if (!ext) return false;
|
|
4735
|
+
UPB_PRIVATE(_upb_MiniTableField_DataCopy)
|
|
4736
|
+
(&e->UPB_PRIVATE(field), &ext->data, val);
|
|
4737
|
+
return true;
|
|
4738
|
+
}
|
|
4739
|
+
|
|
4216
4740
|
// Sets the value of the given field in the given msg. The return value is true
|
|
4217
4741
|
// if the operation completed successfully, or false if memory allocation
|
|
4218
4742
|
// failed.
|
|
@@ -4334,14 +4858,15 @@ UPB_API_INLINE struct upb_Message* upb_Message_GetMutableMessage(
|
|
|
4334
4858
|
return (struct upb_Message*)upb_Message_GetMessage(msg, f);
|
|
4335
4859
|
}
|
|
4336
4860
|
|
|
4337
|
-
UPB_API_INLINE upb_Array* upb_Message_GetOrCreateMutableArray(
|
|
4861
|
+
UPB_NODISCARD UPB_API_INLINE upb_Array* upb_Message_GetOrCreateMutableArray(
|
|
4338
4862
|
struct upb_Message* msg, const upb_MiniTableField* f, upb_Arena* arena) {
|
|
4339
4863
|
UPB_ASSERT(arena);
|
|
4340
4864
|
UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(f);
|
|
4341
4865
|
upb_Array* array = upb_Message_GetMutableArray(msg, f);
|
|
4342
4866
|
if (!array) {
|
|
4343
4867
|
array = UPB_PRIVATE(_upb_Array_New)(
|
|
4344
|
-
arena,
|
|
4868
|
+
arena, _UPB_ARRAY_DEFAULT_INITIAL_SIZE,
|
|
4869
|
+
UPB_PRIVATE(_upb_MiniTableField_ElemSizeLg2)(f));
|
|
4345
4870
|
// Check again due to: https://godbolt.org/z/7WfaoKG1r
|
|
4346
4871
|
UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(f);
|
|
4347
4872
|
upb_MessageValue val;
|
|
@@ -4351,7 +4876,7 @@ UPB_API_INLINE upb_Array* upb_Message_GetOrCreateMutableArray(
|
|
|
4351
4876
|
return array;
|
|
4352
4877
|
}
|
|
4353
4878
|
|
|
4354
|
-
UPB_INLINE struct upb_Map* _upb_Message_GetOrCreateMutableMap(
|
|
4879
|
+
UPB_NODISCARD UPB_INLINE struct upb_Map* _upb_Message_GetOrCreateMutableMap(
|
|
4355
4880
|
struct upb_Message* msg, const upb_MiniTableField* field, size_t key_size,
|
|
4356
4881
|
size_t val_size, upb_Arena* arena) {
|
|
4357
4882
|
UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(field);
|
|
@@ -4367,7 +4892,7 @@ UPB_INLINE struct upb_Map* _upb_Message_GetOrCreateMutableMap(
|
|
|
4367
4892
|
return map;
|
|
4368
4893
|
}
|
|
4369
4894
|
|
|
4370
|
-
UPB_API_INLINE struct upb_Map* upb_Message_GetOrCreateMutableMap(
|
|
4895
|
+
UPB_NODISCARD UPB_API_INLINE struct upb_Map* upb_Message_GetOrCreateMutableMap(
|
|
4371
4896
|
struct upb_Message* msg, const upb_MiniTable* map_entry_mini_table,
|
|
4372
4897
|
const upb_MiniTableField* f, upb_Arena* arena) {
|
|
4373
4898
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
|
|
@@ -4381,8 +4906,10 @@ UPB_API_INLINE struct upb_Map* upb_Message_GetOrCreateMutableMap(
|
|
|
4381
4906
|
arena);
|
|
4382
4907
|
}
|
|
4383
4908
|
|
|
4384
|
-
UPB_API_INLINE struct upb_Message*
|
|
4385
|
-
|
|
4909
|
+
UPB_NODISCARD UPB_API_INLINE struct upb_Message*
|
|
4910
|
+
upb_Message_GetOrCreateMutableMessage(struct upb_Message* msg,
|
|
4911
|
+
const upb_MiniTableField* f,
|
|
4912
|
+
upb_Arena* arena) {
|
|
4386
4913
|
UPB_ASSERT(arena);
|
|
4387
4914
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
|
|
4388
4915
|
UPB_ASSUME(!upb_MiniTableField_IsExtension(f));
|
|
@@ -4495,6 +5022,27 @@ UPB_API_INLINE void upb_Message_SetBaseFieldMessage(struct upb_Message* msg,
|
|
|
4495
5022
|
upb_Message_SetBaseField(msg, f, &value);
|
|
4496
5023
|
}
|
|
4497
5024
|
|
|
5025
|
+
UPB_API_INLINE void upb_Message_SetBaseFieldArray(struct upb_Message* msg,
|
|
5026
|
+
const upb_MiniTableField* f,
|
|
5027
|
+
upb_Array* arr,
|
|
5028
|
+
const upb_MiniTable* arr_mt) {
|
|
5029
|
+
UPB_ASSERT(upb_MiniTableField_IsArray(f));
|
|
5030
|
+
UPB_ASSERT(arr_mt == upb_MiniTable_SubMessage(f));
|
|
5031
|
+
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
|
|
5032
|
+
kUpb_FieldRep_NativePointer);
|
|
5033
|
+
upb_Message_SetBaseField(msg, f, &arr);
|
|
5034
|
+
}
|
|
5035
|
+
|
|
5036
|
+
UPB_API_INLINE void upb_Message_SetBaseFieldMap(
|
|
5037
|
+
struct upb_Message* msg, const upb_MiniTableField* f, struct upb_Map* map,
|
|
5038
|
+
const upb_MiniTable* map_entry_mt) {
|
|
5039
|
+
UPB_ASSERT(upb_MiniTableField_IsMap(f));
|
|
5040
|
+
UPB_ASSERT(map_entry_mt == upb_MiniTable_MapEntrySubMessage(f));
|
|
5041
|
+
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
|
|
5042
|
+
kUpb_FieldRep_NativePointer);
|
|
5043
|
+
upb_Message_SetBaseField(msg, f, &map);
|
|
5044
|
+
}
|
|
5045
|
+
|
|
4498
5046
|
UPB_API_INLINE void upb_Message_SetBaseFieldString(struct upb_Message* msg,
|
|
4499
5047
|
const upb_MiniTableField* f,
|
|
4500
5048
|
upb_StringView value) {
|
|
@@ -4536,7 +5084,7 @@ UPB_API_INLINE void upb_Message_SetClosedEnum(struct upb_Message* msg,
|
|
|
4536
5084
|
|
|
4537
5085
|
// Extension Setters ///////////////////////////////////////////////////////////
|
|
4538
5086
|
|
|
4539
|
-
UPB_API_INLINE bool upb_Message_SetExtensionMessage(
|
|
5087
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionMessage(
|
|
4540
5088
|
struct upb_Message* msg, const upb_MiniTableExtension* e,
|
|
4541
5089
|
struct upb_Message* value, upb_Arena* a) {
|
|
4542
5090
|
UPB_ASSERT(value);
|
|
@@ -4546,7 +5094,7 @@ UPB_API_INLINE bool upb_Message_SetExtensionMessage(
|
|
|
4546
5094
|
return upb_Message_SetExtension(msg, e, &value, a);
|
|
4547
5095
|
}
|
|
4548
5096
|
|
|
4549
|
-
UPB_API_INLINE bool upb_Message_SetExtensionBool(
|
|
5097
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionBool(
|
|
4550
5098
|
struct upb_Message* msg, const upb_MiniTableExtension* e, bool value,
|
|
4551
5099
|
upb_Arena* a) {
|
|
4552
5100
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Bool);
|
|
@@ -4555,7 +5103,7 @@ UPB_API_INLINE bool upb_Message_SetExtensionBool(
|
|
|
4555
5103
|
return upb_Message_SetExtension(msg, e, &value, a);
|
|
4556
5104
|
}
|
|
4557
5105
|
|
|
4558
|
-
UPB_API_INLINE bool upb_Message_SetExtensionDouble(
|
|
5106
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionDouble(
|
|
4559
5107
|
struct upb_Message* msg, const upb_MiniTableExtension* e, double value,
|
|
4560
5108
|
upb_Arena* a) {
|
|
4561
5109
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Double);
|
|
@@ -4564,7 +5112,7 @@ UPB_API_INLINE bool upb_Message_SetExtensionDouble(
|
|
|
4564
5112
|
return upb_Message_SetExtension(msg, e, &value, a);
|
|
4565
5113
|
}
|
|
4566
5114
|
|
|
4567
|
-
UPB_API_INLINE bool upb_Message_SetExtensionFloat(
|
|
5115
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionFloat(
|
|
4568
5116
|
struct upb_Message* msg, const upb_MiniTableExtension* e, float value,
|
|
4569
5117
|
upb_Arena* a) {
|
|
4570
5118
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Float);
|
|
@@ -4573,7 +5121,7 @@ UPB_API_INLINE bool upb_Message_SetExtensionFloat(
|
|
|
4573
5121
|
return upb_Message_SetExtension(msg, e, &value, a);
|
|
4574
5122
|
}
|
|
4575
5123
|
|
|
4576
|
-
UPB_API_INLINE bool upb_Message_SetExtensionInt32(
|
|
5124
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionInt32(
|
|
4577
5125
|
struct upb_Message* msg, const upb_MiniTableExtension* e, int32_t value,
|
|
4578
5126
|
upb_Arena* a) {
|
|
4579
5127
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Int32 ||
|
|
@@ -4583,7 +5131,7 @@ UPB_API_INLINE bool upb_Message_SetExtensionInt32(
|
|
|
4583
5131
|
return upb_Message_SetExtension(msg, e, &value, a);
|
|
4584
5132
|
}
|
|
4585
5133
|
|
|
4586
|
-
UPB_API_INLINE bool upb_Message_SetExtensionInt64(
|
|
5134
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionInt64(
|
|
4587
5135
|
struct upb_Message* msg, const upb_MiniTableExtension* e, int64_t value,
|
|
4588
5136
|
upb_Arena* a) {
|
|
4589
5137
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Int64);
|
|
@@ -4592,7 +5140,7 @@ UPB_API_INLINE bool upb_Message_SetExtensionInt64(
|
|
|
4592
5140
|
return upb_Message_SetExtension(msg, e, &value, a);
|
|
4593
5141
|
}
|
|
4594
5142
|
|
|
4595
|
-
UPB_API_INLINE bool upb_Message_SetExtensionString(
|
|
5143
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionString(
|
|
4596
5144
|
struct upb_Message* msg, const upb_MiniTableExtension* e,
|
|
4597
5145
|
upb_StringView value, upb_Arena* a) {
|
|
4598
5146
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_String ||
|
|
@@ -4602,7 +5150,7 @@ UPB_API_INLINE bool upb_Message_SetExtensionString(
|
|
|
4602
5150
|
return upb_Message_SetExtension(msg, e, &value, a);
|
|
4603
5151
|
}
|
|
4604
5152
|
|
|
4605
|
-
UPB_API_INLINE bool upb_Message_SetExtensionUInt32(
|
|
5153
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionUInt32(
|
|
4606
5154
|
struct upb_Message* msg, const upb_MiniTableExtension* e, uint32_t value,
|
|
4607
5155
|
upb_Arena* a) {
|
|
4608
5156
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_UInt32);
|
|
@@ -4611,7 +5159,7 @@ UPB_API_INLINE bool upb_Message_SetExtensionUInt32(
|
|
|
4611
5159
|
return upb_Message_SetExtension(msg, e, &value, a);
|
|
4612
5160
|
}
|
|
4613
5161
|
|
|
4614
|
-
UPB_API_INLINE bool upb_Message_SetExtensionUInt64(
|
|
5162
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionUInt64(
|
|
4615
5163
|
struct upb_Message* msg, const upb_MiniTableExtension* e, uint64_t value,
|
|
4616
5164
|
upb_Arena* a) {
|
|
4617
5165
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_UInt64);
|
|
@@ -4622,45 +5170,45 @@ UPB_API_INLINE bool upb_Message_SetExtensionUInt64(
|
|
|
4622
5170
|
|
|
4623
5171
|
// Universal Setters ///////////////////////////////////////////////////////////
|
|
4624
5172
|
|
|
4625
|
-
UPB_API_INLINE bool upb_Message_SetBool(
|
|
4626
|
-
|
|
4627
|
-
|
|
5173
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetBool(
|
|
5174
|
+
struct upb_Message* msg, const upb_MiniTableField* f, bool value,
|
|
5175
|
+
upb_Arena* a) {
|
|
4628
5176
|
return upb_MiniTableField_IsExtension(f)
|
|
4629
5177
|
? upb_Message_SetExtensionBool(
|
|
4630
5178
|
msg, (const upb_MiniTableExtension*)f, value, a)
|
|
4631
5179
|
: (upb_Message_SetBaseFieldBool(msg, f, value), true);
|
|
4632
5180
|
}
|
|
4633
5181
|
|
|
4634
|
-
UPB_API_INLINE bool upb_Message_SetDouble(
|
|
4635
|
-
|
|
4636
|
-
|
|
5182
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetDouble(
|
|
5183
|
+
struct upb_Message* msg, const upb_MiniTableField* f, double value,
|
|
5184
|
+
upb_Arena* a) {
|
|
4637
5185
|
return upb_MiniTableField_IsExtension(f)
|
|
4638
5186
|
? upb_Message_SetExtensionDouble(
|
|
4639
5187
|
msg, (const upb_MiniTableExtension*)f, value, a)
|
|
4640
5188
|
: (upb_Message_SetBaseFieldDouble(msg, f, value), true);
|
|
4641
5189
|
}
|
|
4642
5190
|
|
|
4643
|
-
UPB_API_INLINE bool upb_Message_SetFloat(
|
|
4644
|
-
|
|
4645
|
-
|
|
5191
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetFloat(
|
|
5192
|
+
struct upb_Message* msg, const upb_MiniTableField* f, float value,
|
|
5193
|
+
upb_Arena* a) {
|
|
4646
5194
|
return upb_MiniTableField_IsExtension(f)
|
|
4647
5195
|
? upb_Message_SetExtensionFloat(
|
|
4648
5196
|
msg, (const upb_MiniTableExtension*)f, value, a)
|
|
4649
5197
|
: (upb_Message_SetBaseFieldFloat(msg, f, value), true);
|
|
4650
5198
|
}
|
|
4651
5199
|
|
|
4652
|
-
UPB_API_INLINE bool upb_Message_SetInt32(
|
|
4653
|
-
|
|
4654
|
-
|
|
5200
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetInt32(
|
|
5201
|
+
struct upb_Message* msg, const upb_MiniTableField* f, int32_t value,
|
|
5202
|
+
upb_Arena* a) {
|
|
4655
5203
|
return upb_MiniTableField_IsExtension(f)
|
|
4656
5204
|
? upb_Message_SetExtensionInt32(
|
|
4657
5205
|
msg, (const upb_MiniTableExtension*)f, value, a)
|
|
4658
5206
|
: (upb_Message_SetBaseFieldInt32(msg, f, value), true);
|
|
4659
5207
|
}
|
|
4660
5208
|
|
|
4661
|
-
UPB_API_INLINE bool upb_Message_SetInt64(
|
|
4662
|
-
|
|
4663
|
-
|
|
5209
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetInt64(
|
|
5210
|
+
struct upb_Message* msg, const upb_MiniTableField* f, int64_t value,
|
|
5211
|
+
upb_Arena* a) {
|
|
4664
5212
|
return upb_MiniTableField_IsExtension(f)
|
|
4665
5213
|
? upb_Message_SetExtensionInt64(
|
|
4666
5214
|
msg, (const upb_MiniTableExtension*)f, value, a)
|
|
@@ -4680,27 +5228,27 @@ UPB_API_INLINE void upb_Message_SetMessage(struct upb_Message* msg,
|
|
|
4680
5228
|
// copied, so it is the caller's responsibility to ensure that they remain valid
|
|
4681
5229
|
// for the lifetime of `msg`. That might be done by copying them into the given
|
|
4682
5230
|
// arena, or by fusing that arena with the arena the bytes live in, for example.
|
|
4683
|
-
UPB_API_INLINE bool upb_Message_SetString(
|
|
4684
|
-
|
|
4685
|
-
|
|
5231
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetString(
|
|
5232
|
+
struct upb_Message* msg, const upb_MiniTableField* f, upb_StringView value,
|
|
5233
|
+
upb_Arena* a) {
|
|
4686
5234
|
return upb_MiniTableField_IsExtension(f)
|
|
4687
5235
|
? upb_Message_SetExtensionString(
|
|
4688
5236
|
msg, (const upb_MiniTableExtension*)f, value, a)
|
|
4689
5237
|
: (upb_Message_SetBaseFieldString(msg, f, value), true);
|
|
4690
5238
|
}
|
|
4691
5239
|
|
|
4692
|
-
UPB_API_INLINE bool upb_Message_SetUInt32(
|
|
4693
|
-
|
|
4694
|
-
|
|
5240
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetUInt32(
|
|
5241
|
+
struct upb_Message* msg, const upb_MiniTableField* f, uint32_t value,
|
|
5242
|
+
upb_Arena* a) {
|
|
4695
5243
|
return upb_MiniTableField_IsExtension(f)
|
|
4696
5244
|
? upb_Message_SetExtensionUInt32(
|
|
4697
5245
|
msg, (const upb_MiniTableExtension*)f, value, a)
|
|
4698
5246
|
: (upb_Message_SetBaseFieldUInt32(msg, f, value), true);
|
|
4699
5247
|
}
|
|
4700
5248
|
|
|
4701
|
-
UPB_API_INLINE bool upb_Message_SetUInt64(
|
|
4702
|
-
|
|
4703
|
-
|
|
5249
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetUInt64(
|
|
5250
|
+
struct upb_Message* msg, const upb_MiniTableField* f, uint64_t value,
|
|
5251
|
+
upb_Arena* a) {
|
|
4704
5252
|
return upb_MiniTableField_IsExtension(f)
|
|
4705
5253
|
? upb_Message_SetExtensionUInt64(
|
|
4706
5254
|
msg, (const upb_MiniTableExtension*)f, value, a)
|
|
@@ -4740,8 +5288,9 @@ UPB_API_INLINE void upb_Message_ClearExtension(
|
|
|
4740
5288
|
if (!in) return;
|
|
4741
5289
|
for (size_t i = 0; i < in->size; i++) {
|
|
4742
5290
|
upb_TaggedAuxPtr tagged_ptr = in->aux_data[i];
|
|
4743
|
-
if (
|
|
4744
|
-
const upb_Extension* ext =
|
|
5291
|
+
if (upb_TaggedAuxPtr_IsCanonicalExtension(tagged_ptr)) {
|
|
5292
|
+
const upb_Extension* ext =
|
|
5293
|
+
upb_TaggedAuxPtr_CanonicalExtension(tagged_ptr);
|
|
4745
5294
|
if (ext->ext == e) {
|
|
4746
5295
|
in->aux_data[i] = upb_TaggedAuxPtr_Null();
|
|
4747
5296
|
return;
|
|
@@ -4765,7 +5314,7 @@ UPB_API_INLINE void upb_Message_ClearOneof(struct upb_Message* msg,
|
|
|
4765
5314
|
upb_Message_ClearBaseField(msg, field);
|
|
4766
5315
|
}
|
|
4767
5316
|
|
|
4768
|
-
UPB_API_INLINE void* upb_Message_ResizeArrayUninitialized(
|
|
5317
|
+
UPB_NODISCARD UPB_API_INLINE void* upb_Message_ResizeArrayUninitialized(
|
|
4769
5318
|
struct upb_Message* msg, const upb_MiniTableField* f, size_t size,
|
|
4770
5319
|
upb_Arena* arena) {
|
|
4771
5320
|
UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(f);
|
|
@@ -4929,8 +5478,8 @@ extern "C" {
|
|
|
4929
5478
|
#endif
|
|
4930
5479
|
|
|
4931
5480
|
// Creates a new map on the given arena with the given key/value size.
|
|
4932
|
-
UPB_API upb_Map* upb_Map_New(upb_Arena* a, upb_CType key_type,
|
|
4933
|
-
|
|
5481
|
+
UPB_NODISCARD UPB_API upb_Map* upb_Map_New(upb_Arena* a, upb_CType key_type,
|
|
5482
|
+
upb_CType value_type);
|
|
4934
5483
|
|
|
4935
5484
|
// Returns the number of entries in the map.
|
|
4936
5485
|
UPB_API size_t upb_Map_Size(const upb_Map* map);
|
|
@@ -4953,15 +5502,18 @@ UPB_API void upb_Map_Clear(upb_Map* map);
|
|
|
4953
5502
|
// Sets the given key to the given value, returning whether the key was inserted
|
|
4954
5503
|
// or replaced. If the key was inserted, then any existing iterators will be
|
|
4955
5504
|
// invalidated.
|
|
4956
|
-
UPB_API upb_MapInsertStatus upb_Map_Insert(upb_Map* map,
|
|
4957
|
-
|
|
4958
|
-
|
|
5505
|
+
UPB_NODISCARD UPB_API upb_MapInsertStatus upb_Map_Insert(upb_Map* map,
|
|
5506
|
+
upb_MessageValue key,
|
|
5507
|
+
upb_MessageValue val,
|
|
5508
|
+
upb_Arena* arena);
|
|
4959
5509
|
|
|
4960
5510
|
// Sets the given key to the given value. Returns false if memory allocation
|
|
4961
5511
|
// failed. If the key is newly inserted, then any existing iterators will be
|
|
4962
5512
|
// invalidated.
|
|
4963
|
-
UPB_API_INLINE bool upb_Map_Set(upb_Map* map,
|
|
4964
|
-
|
|
5513
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Map_Set(upb_Map* map,
|
|
5514
|
+
upb_MessageValue key,
|
|
5515
|
+
upb_MessageValue val,
|
|
5516
|
+
upb_Arena* arena) {
|
|
4965
5517
|
return upb_Map_Insert(map, key, val, arena) !=
|
|
4966
5518
|
kUpb_MapInsertStatus_OutOfMemory;
|
|
4967
5519
|
}
|
|
@@ -5049,7 +5601,8 @@ extern "C" {
|
|
|
5049
5601
|
#endif
|
|
5050
5602
|
|
|
5051
5603
|
// Creates a new message with the given mini_table on the given arena.
|
|
5052
|
-
UPB_API upb_Message* upb_Message_New(const upb_MiniTable* m,
|
|
5604
|
+
UPB_NODISCARD UPB_API upb_Message* upb_Message_New(const upb_MiniTable* m,
|
|
5605
|
+
upb_Arena* arena);
|
|
5053
5606
|
|
|
5054
5607
|
//
|
|
5055
5608
|
// Unknown data may be stored non-contiguously. Each segment stores a block of
|
|
@@ -5065,10 +5618,24 @@ UPB_API upb_Message* upb_Message_New(const upb_MiniTable* m, upb_Arena* arena);
|
|
|
5065
5618
|
#define kUpb_Message_UnknownBegin 0
|
|
5066
5619
|
#define kUpb_Message_ExtensionBegin 0
|
|
5067
5620
|
|
|
5621
|
+
// TODO: b/510055656 - Legacy API that works with messages that only have
|
|
5622
|
+
// unknown data in upb_StringView format. Use `upb_Message_NextUnknown2` for
|
|
5623
|
+
// messages that may have non-canonical extensions.
|
|
5068
5624
|
UPB_INLINE bool upb_Message_NextUnknown(const upb_Message* msg,
|
|
5069
5625
|
upb_StringView* data, uintptr_t* iter);
|
|
5070
5626
|
|
|
5071
|
-
UPB_INLINE bool upb_Message_HasUnknown(const upb_Message* msg)
|
|
5627
|
+
UPB_INLINE bool upb_Message_HasUnknown(const upb_Message* msg) {
|
|
5628
|
+
const upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
|
5629
|
+
if (!in) return false;
|
|
5630
|
+
for (size_t i = 0; i < in->size; i++) {
|
|
5631
|
+
upb_TaggedAuxPtr tagged_ptr = in->aux_data[i];
|
|
5632
|
+
if (tagged_ptr.ptr != 0 &&
|
|
5633
|
+
!upb_TaggedAuxPtr_IsSemanticallyKnown(tagged_ptr)) {
|
|
5634
|
+
return true;
|
|
5635
|
+
}
|
|
5636
|
+
}
|
|
5637
|
+
return false;
|
|
5638
|
+
}
|
|
5072
5639
|
|
|
5073
5640
|
// Removes a segment of unknown data from the message, advancing to the next
|
|
5074
5641
|
// segment. Returns false if the removed segment was at the end of the last
|
|
@@ -5096,15 +5663,12 @@ UPB_INLINE bool upb_Message_HasUnknown(const upb_Message* msg);
|
|
|
5096
5663
|
//
|
|
5097
5664
|
// The range given in `data` must be contained inside the most recently
|
|
5098
5665
|
// returned region.
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
upb_StringView* data,
|
|
5106
|
-
uintptr_t* iter,
|
|
5107
|
-
upb_Arena* arena);
|
|
5666
|
+
//
|
|
5667
|
+
// TODO: b/510055656 - Legacy API that works with messages that only have
|
|
5668
|
+
// unknown data in upb_StringView format. Use `upb_Message_DeleteUnknown2` for
|
|
5669
|
+
// messages that may have non-canonical extensions.
|
|
5670
|
+
UPB_NODISCARD upb_Message_DeleteUnknownStatus upb_Message_DeleteUnknown(
|
|
5671
|
+
upb_Message* msg, upb_StringView* data, uintptr_t* iter, upb_Arena* arena);
|
|
5108
5672
|
|
|
5109
5673
|
// Returns the number of extensions present in this message.
|
|
5110
5674
|
size_t upb_Message_ExtensionCount(const upb_Message* msg);
|
|
@@ -5213,14 +5777,14 @@ UPB_API_INLINE upb_Map* upb_Message_GetMutableMap(upb_Message* msg,
|
|
|
5213
5777
|
UPB_API_INLINE upb_Message* upb_Message_GetMutableMessage(
|
|
5214
5778
|
upb_Message* msg, const upb_MiniTableField* f);
|
|
5215
5779
|
|
|
5216
|
-
UPB_API_INLINE upb_Array* upb_Message_GetOrCreateMutableArray(
|
|
5780
|
+
UPB_NODISCARD UPB_API_INLINE upb_Array* upb_Message_GetOrCreateMutableArray(
|
|
5217
5781
|
upb_Message* msg, const upb_MiniTableField* f, upb_Arena* arena);
|
|
5218
5782
|
|
|
5219
|
-
UPB_API_INLINE upb_Map* upb_Message_GetOrCreateMutableMap(
|
|
5783
|
+
UPB_NODISCARD UPB_API_INLINE upb_Map* upb_Message_GetOrCreateMutableMap(
|
|
5220
5784
|
upb_Message* msg, const upb_MiniTable* map_entry_mini_table,
|
|
5221
5785
|
const upb_MiniTableField* f, upb_Arena* arena);
|
|
5222
5786
|
|
|
5223
|
-
UPB_API_INLINE upb_Message* upb_Message_GetOrCreateMutableMessage(
|
|
5787
|
+
UPB_NODISCARD UPB_API_INLINE upb_Message* upb_Message_GetOrCreateMutableMessage(
|
|
5224
5788
|
upb_Message* msg, const upb_MiniTableField* f, upb_Arena* arena);
|
|
5225
5789
|
|
|
5226
5790
|
UPB_API_INLINE upb_StringView
|
|
@@ -5269,6 +5833,15 @@ UPB_API_INLINE void upb_Message_SetBaseFieldMessage(struct upb_Message* msg,
|
|
|
5269
5833
|
const upb_MiniTableField* f,
|
|
5270
5834
|
upb_Message* value);
|
|
5271
5835
|
|
|
5836
|
+
UPB_API_INLINE void upb_Message_SetBaseFieldArray(struct upb_Message* msg,
|
|
5837
|
+
const upb_MiniTableField* f,
|
|
5838
|
+
upb_Array* arr,
|
|
5839
|
+
const upb_MiniTable* arr_mt);
|
|
5840
|
+
|
|
5841
|
+
UPB_API_INLINE void upb_Message_SetBaseFieldMap(
|
|
5842
|
+
struct upb_Message* msg, const upb_MiniTableField* f, struct upb_Map* map,
|
|
5843
|
+
const upb_MiniTable* map_entry_mt);
|
|
5844
|
+
|
|
5272
5845
|
UPB_API_INLINE void upb_Message_SetBaseFieldString(struct upb_Message* msg,
|
|
5273
5846
|
const upb_MiniTableField* f,
|
|
5274
5847
|
upb_StringView value);
|
|
@@ -5324,67 +5897,62 @@ UPB_API_INLINE upb_Array* upb_Message_GetExtensionMutableArray(
|
|
|
5324
5897
|
|
|
5325
5898
|
// Extension Setters ///////////////////////////////////////////////////////////
|
|
5326
5899
|
|
|
5327
|
-
UPB_API_INLINE bool upb_Message_SetExtension(
|
|
5328
|
-
|
|
5329
|
-
|
|
5900
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtension(
|
|
5901
|
+
upb_Message* msg, const upb_MiniTableExtension* e, const void* value,
|
|
5902
|
+
upb_Arena* a);
|
|
5330
5903
|
|
|
5331
|
-
UPB_API_INLINE bool upb_Message_SetExtensionMessage(
|
|
5904
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionMessage(
|
|
5332
5905
|
struct upb_Message* msg, const upb_MiniTableExtension* e,
|
|
5333
5906
|
struct upb_Message* value, upb_Arena* a);
|
|
5334
5907
|
|
|
5335
|
-
UPB_API_INLINE bool upb_Message_SetExtensionBool(
|
|
5908
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionBool(
|
|
5336
5909
|
struct upb_Message* msg, const upb_MiniTableExtension* e, bool value,
|
|
5337
5910
|
upb_Arena* a);
|
|
5338
5911
|
|
|
5339
|
-
UPB_API_INLINE bool upb_Message_SetExtensionDouble(
|
|
5912
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionDouble(
|
|
5340
5913
|
struct upb_Message* msg, const upb_MiniTableExtension* e, double value,
|
|
5341
5914
|
upb_Arena* a);
|
|
5342
5915
|
|
|
5343
|
-
UPB_API_INLINE bool upb_Message_SetExtensionFloat(
|
|
5916
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionFloat(
|
|
5344
5917
|
struct upb_Message* msg, const upb_MiniTableExtension* e, float value,
|
|
5345
5918
|
upb_Arena* a);
|
|
5346
5919
|
|
|
5347
|
-
UPB_API_INLINE bool upb_Message_SetExtensionInt32(
|
|
5920
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionInt32(
|
|
5348
5921
|
struct upb_Message* msg, const upb_MiniTableExtension* e, int32_t value,
|
|
5349
5922
|
upb_Arena* a);
|
|
5350
5923
|
|
|
5351
|
-
UPB_API_INLINE bool upb_Message_SetExtensionInt64(
|
|
5924
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionInt64(
|
|
5352
5925
|
struct upb_Message* msg, const upb_MiniTableExtension* e, int64_t value,
|
|
5353
5926
|
upb_Arena* a);
|
|
5354
5927
|
|
|
5355
|
-
UPB_API_INLINE bool upb_Message_SetExtensionString(
|
|
5928
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionString(
|
|
5356
5929
|
struct upb_Message* msg, const upb_MiniTableExtension* e,
|
|
5357
5930
|
upb_StringView value, upb_Arena* a);
|
|
5358
5931
|
|
|
5359
|
-
UPB_API_INLINE bool upb_Message_SetExtensionUInt32(
|
|
5932
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionUInt32(
|
|
5360
5933
|
struct upb_Message* msg, const upb_MiniTableExtension* e, uint32_t value,
|
|
5361
5934
|
upb_Arena* a);
|
|
5362
5935
|
|
|
5363
|
-
UPB_API_INLINE bool upb_Message_SetExtensionUInt64(
|
|
5936
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetExtensionUInt64(
|
|
5364
5937
|
struct upb_Message* msg, const upb_MiniTableExtension* e, uint64_t value,
|
|
5365
5938
|
upb_Arena* a);
|
|
5366
5939
|
|
|
5367
5940
|
// Universal Setters ///////////////////////////////////////////////////////////
|
|
5368
5941
|
|
|
5369
|
-
UPB_API_INLINE bool upb_Message_SetBool(
|
|
5370
|
-
|
|
5371
|
-
upb_Arena* a);
|
|
5942
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetBool(
|
|
5943
|
+
upb_Message* msg, const upb_MiniTableField* f, bool value, upb_Arena* a);
|
|
5372
5944
|
|
|
5373
|
-
UPB_API_INLINE bool upb_Message_SetDouble(
|
|
5374
|
-
|
|
5375
|
-
double value, upb_Arena* a);
|
|
5945
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetDouble(
|
|
5946
|
+
upb_Message* msg, const upb_MiniTableField* f, double value, upb_Arena* a);
|
|
5376
5947
|
|
|
5377
|
-
UPB_API_INLINE bool upb_Message_SetFloat(
|
|
5378
|
-
|
|
5379
|
-
float value, upb_Arena* a);
|
|
5948
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetFloat(
|
|
5949
|
+
upb_Message* msg, const upb_MiniTableField* f, float value, upb_Arena* a);
|
|
5380
5950
|
|
|
5381
|
-
UPB_API_INLINE bool upb_Message_SetInt32(
|
|
5382
|
-
|
|
5383
|
-
int32_t value, upb_Arena* a);
|
|
5951
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetInt32(
|
|
5952
|
+
upb_Message* msg, const upb_MiniTableField* f, int32_t value, upb_Arena* a);
|
|
5384
5953
|
|
|
5385
|
-
UPB_API_INLINE bool upb_Message_SetInt64(
|
|
5386
|
-
|
|
5387
|
-
int64_t value, upb_Arena* a);
|
|
5954
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetInt64(
|
|
5955
|
+
upb_Message* msg, const upb_MiniTableField* f, int64_t value, upb_Arena* a);
|
|
5388
5956
|
|
|
5389
5957
|
// Unlike the other similarly-named setters, this function can only be
|
|
5390
5958
|
// called on base fields. Prefer upb_Message_SetBaseFieldMessage().
|
|
@@ -5392,21 +5960,21 @@ UPB_API_INLINE void upb_Message_SetMessage(upb_Message* msg,
|
|
|
5392
5960
|
const upb_MiniTableField* f,
|
|
5393
5961
|
upb_Message* value);
|
|
5394
5962
|
|
|
5395
|
-
UPB_API_INLINE bool upb_Message_SetString(
|
|
5396
|
-
|
|
5397
|
-
|
|
5963
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetString(
|
|
5964
|
+
upb_Message* msg, const upb_MiniTableField* f, upb_StringView value,
|
|
5965
|
+
upb_Arena* a);
|
|
5398
5966
|
|
|
5399
|
-
UPB_API_INLINE bool upb_Message_SetUInt32(
|
|
5400
|
-
|
|
5401
|
-
|
|
5967
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetUInt32(
|
|
5968
|
+
upb_Message* msg, const upb_MiniTableField* f, uint32_t value,
|
|
5969
|
+
upb_Arena* a);
|
|
5402
5970
|
|
|
5403
|
-
UPB_API_INLINE bool upb_Message_SetUInt64(
|
|
5404
|
-
|
|
5405
|
-
|
|
5971
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_Message_SetUInt64(
|
|
5972
|
+
upb_Message* msg, const upb_MiniTableField* f, uint64_t value,
|
|
5973
|
+
upb_Arena* a);
|
|
5406
5974
|
|
|
5407
5975
|
////////////////////////////////////////////////////////////////////////////////
|
|
5408
5976
|
|
|
5409
|
-
UPB_API_INLINE void* upb_Message_ResizeArrayUninitialized(
|
|
5977
|
+
UPB_NODISCARD UPB_API_INLINE void* upb_Message_ResizeArrayUninitialized(
|
|
5410
5978
|
upb_Message* msg, const upb_MiniTableField* f, size_t size,
|
|
5411
5979
|
upb_Arena* arena);
|
|
5412
5980
|
|
|
@@ -5420,8 +5988,10 @@ UPB_API_INLINE const upb_MiniTableField* upb_Message_WhichOneof(
|
|
|
5420
5988
|
const upb_MiniTableField* f);
|
|
5421
5989
|
|
|
5422
5990
|
// Updates a map entry given an entry message.
|
|
5423
|
-
bool upb_Message_SetMapEntry(upb_Map* map,
|
|
5424
|
-
|
|
5991
|
+
UPB_NODISCARD bool upb_Message_SetMapEntry(upb_Map* map,
|
|
5992
|
+
const upb_MiniTableField* field,
|
|
5993
|
+
upb_Message* map_entry_message,
|
|
5994
|
+
upb_Arena* arena);
|
|
5425
5995
|
|
|
5426
5996
|
#ifdef __cplusplus
|
|
5427
5997
|
} /* extern "C" */
|
|
@@ -5430,7 +6000,7 @@ bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTableField* field,
|
|
|
5430
6000
|
#if defined(__cplusplus)
|
|
5431
6001
|
// Temporary overloads for functions whose signature has recently changed.
|
|
5432
6002
|
UPB_DEPRECATE_AND_INLINE()
|
|
5433
|
-
inline upb_Message* upb_Message_GetOrCreateMutableMessage(
|
|
6003
|
+
UPB_NODISCARD inline upb_Message* upb_Message_GetOrCreateMutableMessage(
|
|
5434
6004
|
upb_Message* msg, const upb_MiniTable* mini_table,
|
|
5435
6005
|
const upb_MiniTableField* f, upb_Arena* arena) {
|
|
5436
6006
|
return upb_Message_GetOrCreateMutableMessage(msg, f, arena);
|
|
@@ -5445,6 +6015,7 @@ inline void upb_Message_SetClosedEnum(upb_Message* msg,
|
|
|
5445
6015
|
}
|
|
5446
6016
|
|
|
5447
6017
|
UPB_DEPRECATE_AND_INLINE()
|
|
6018
|
+
UPB_NODISCARD
|
|
5448
6019
|
inline bool upb_Message_SetMapEntry(upb_Map* map,
|
|
5449
6020
|
const upb_MiniTable* mini_table,
|
|
5450
6021
|
const upb_MiniTableField* field,
|
|
@@ -5562,9 +6133,8 @@ extern "C" {
|
|
|
5562
6133
|
|
|
5563
6134
|
// Builds a upb_MiniTableEnum from an enum mini descriptor.
|
|
5564
6135
|
// The mini descriptor must be for an enum, not a message.
|
|
5565
|
-
UPB_API upb_MiniTableEnum* upb_MiniTableEnum_Build(
|
|
5566
|
-
|
|
5567
|
-
upb_Status* status);
|
|
6136
|
+
UPB_NODISCARD UPB_API upb_MiniTableEnum* upb_MiniTableEnum_Build(
|
|
6137
|
+
const char* data, size_t len, upb_Arena* arena, upb_Status* status);
|
|
5568
6138
|
|
|
5569
6139
|
#ifdef __cplusplus
|
|
5570
6140
|
} /* extern "C" */
|
|
@@ -5598,16 +6168,15 @@ extern "C" {
|
|
|
5598
6168
|
// as unknown. However there is no synchronization for this operation, which
|
|
5599
6169
|
// means parallel mutation requires external synchronization.
|
|
5600
6170
|
// Returns success/failure.
|
|
5601
|
-
UPB_API bool upb_MiniTable_SetSubMessage(
|
|
5602
|
-
|
|
5603
|
-
const upb_MiniTable* sub);
|
|
6171
|
+
UPB_NODISCARD UPB_API bool upb_MiniTable_SetSubMessage(
|
|
6172
|
+
upb_MiniTable* table, upb_MiniTableField* field, const upb_MiniTable* sub);
|
|
5604
6173
|
|
|
5605
6174
|
// Links an enum field to a MiniTable for that enum.
|
|
5606
6175
|
// All enum fields must be linked prior to parsing.
|
|
5607
6176
|
// Returns success/failure.
|
|
5608
|
-
UPB_API bool upb_MiniTable_SetSubEnum(
|
|
5609
|
-
|
|
5610
|
-
|
|
6177
|
+
UPB_NODISCARD UPB_API bool upb_MiniTable_SetSubEnum(
|
|
6178
|
+
upb_MiniTable* table, upb_MiniTableField* field,
|
|
6179
|
+
const upb_MiniTableEnum* sub);
|
|
5611
6180
|
|
|
5612
6181
|
// Returns a list of fields that require linking at runtime, to connect the
|
|
5613
6182
|
// MiniTable to its sub-messages and sub-enums. The list of fields will be
|
|
@@ -5630,11 +6199,9 @@ UPB_API uint32_t upb_MiniTable_GetSubList(const upb_MiniTable* mt,
|
|
|
5630
6199
|
//
|
|
5631
6200
|
// Returns false if either array is too short, or if any of the tables fails
|
|
5632
6201
|
// to link.
|
|
5633
|
-
UPB_API bool upb_MiniTable_Link(
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
const upb_MiniTableEnum** sub_enums,
|
|
5637
|
-
size_t sub_enum_count);
|
|
6202
|
+
UPB_NODISCARD UPB_API bool upb_MiniTable_Link(
|
|
6203
|
+
upb_MiniTable* mt, const upb_MiniTable** sub_tables, size_t sub_table_count,
|
|
6204
|
+
const upb_MiniTableEnum** sub_enums, size_t sub_enum_count);
|
|
5638
6205
|
|
|
5639
6206
|
#ifdef __cplusplus
|
|
5640
6207
|
} /* extern "C" */
|
|
@@ -5661,13 +6228,12 @@ extern "C" {
|
|
|
5661
6228
|
// errors occur, returns NULL and sets a status message. In the success case,
|
|
5662
6229
|
// the caller must call upb_MiniTable_SetSub*() for all message or proto2 enum
|
|
5663
6230
|
// fields to link the table to the appropriate sub-tables.
|
|
5664
|
-
upb_MiniTable* _upb_MiniTable_Build(
|
|
5665
|
-
|
|
5666
|
-
|
|
6231
|
+
UPB_NODISCARD upb_MiniTable* _upb_MiniTable_Build(
|
|
6232
|
+
const char* data, size_t len, upb_MiniTablePlatform platform,
|
|
6233
|
+
upb_Arena* arena, upb_Status* status);
|
|
5667
6234
|
|
|
5668
|
-
UPB_API_INLINE upb_MiniTable* upb_MiniTable_Build(
|
|
5669
|
-
|
|
5670
|
-
upb_Status* status) {
|
|
6235
|
+
UPB_NODISCARD UPB_API_INLINE upb_MiniTable* upb_MiniTable_Build(
|
|
6236
|
+
const char* data, size_t len, upb_Arena* arena, upb_Status* status) {
|
|
5671
6237
|
return _upb_MiniTable_Build(data, len, kUpb_MiniTablePlatform_Native, arena,
|
|
5672
6238
|
status);
|
|
5673
6239
|
}
|
|
@@ -5675,44 +6241,47 @@ UPB_API_INLINE upb_MiniTable* upb_MiniTable_Build(const char* data, size_t len,
|
|
|
5675
6241
|
// Initializes a MiniTableExtension buffer that has already been allocated.
|
|
5676
6242
|
// This is needed by upb_FileDef and upb_MessageDef, which allocate all of the
|
|
5677
6243
|
// extensions together in a single contiguous array.
|
|
5678
|
-
const char* _upb_MiniTableExtension_Init(
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
UPB_API_INLINE const char* upb_MiniTableExtension_Init(
|
|
6244
|
+
UPB_NODISCARD const char* _upb_MiniTableExtension_Init(
|
|
6245
|
+
const char* data, size_t len, upb_MiniTableExtension* ext,
|
|
6246
|
+
const upb_MiniTable* extendee, upb_MiniTableSub sub,
|
|
6247
|
+
upb_MiniTablePlatform platform, upb_Status* status);
|
|
6248
|
+
|
|
6249
|
+
UPB_NODISCARD UPB_API_INLINE const char* upb_MiniTableExtension_Init(
|
|
5686
6250
|
const char* data, size_t len, upb_MiniTableExtension* ext,
|
|
5687
6251
|
const upb_MiniTable* extendee, upb_MiniTableSub sub, upb_Status* status) {
|
|
5688
6252
|
return _upb_MiniTableExtension_Init(data, len, ext, extendee, sub,
|
|
5689
6253
|
kUpb_MiniTablePlatform_Native, status);
|
|
5690
6254
|
}
|
|
5691
6255
|
|
|
5692
|
-
UPB_API upb_MiniTableExtension* _upb_MiniTableExtension_Build(
|
|
6256
|
+
UPB_NODISCARD UPB_API upb_MiniTableExtension* _upb_MiniTableExtension_Build(
|
|
5693
6257
|
const char* data, size_t len, const upb_MiniTable* extendee,
|
|
5694
6258
|
upb_MiniTableSub sub, upb_MiniTablePlatform platform, upb_Arena* arena,
|
|
5695
6259
|
upb_Status* status);
|
|
5696
6260
|
|
|
5697
|
-
UPB_API_INLINE upb_MiniTableExtension*
|
|
5698
|
-
|
|
5699
|
-
|
|
6261
|
+
UPB_NODISCARD UPB_API_INLINE upb_MiniTableExtension*
|
|
6262
|
+
upb_MiniTableExtension_Build(const char* data, size_t len,
|
|
6263
|
+
const upb_MiniTable* extendee, upb_Arena* arena,
|
|
6264
|
+
upb_Status* status) {
|
|
5700
6265
|
upb_MiniTableSub sub = upb_MiniTableSub_FromMessage(NULL);
|
|
5701
6266
|
return _upb_MiniTableExtension_Build(
|
|
5702
6267
|
data, len, extendee, sub, kUpb_MiniTablePlatform_Native, arena, status);
|
|
5703
6268
|
}
|
|
5704
6269
|
|
|
5705
|
-
UPB_API_INLINE upb_MiniTableExtension*
|
|
5706
|
-
|
|
5707
|
-
|
|
6270
|
+
UPB_NODISCARD UPB_API_INLINE upb_MiniTableExtension*
|
|
6271
|
+
upb_MiniTableExtension_BuildMessage(const char* data, size_t len,
|
|
6272
|
+
const upb_MiniTable* extendee,
|
|
6273
|
+
const upb_MiniTable* submsg,
|
|
6274
|
+
upb_Arena* arena, upb_Status* status) {
|
|
5708
6275
|
upb_MiniTableSub sub = upb_MiniTableSub_FromMessage(submsg);
|
|
5709
6276
|
return _upb_MiniTableExtension_Build(
|
|
5710
6277
|
data, len, extendee, sub, kUpb_MiniTablePlatform_Native, arena, status);
|
|
5711
6278
|
}
|
|
5712
6279
|
|
|
5713
|
-
UPB_API_INLINE upb_MiniTableExtension*
|
|
5714
|
-
|
|
5715
|
-
|
|
6280
|
+
UPB_NODISCARD UPB_API_INLINE upb_MiniTableExtension*
|
|
6281
|
+
upb_MiniTableExtension_BuildEnum(const char* data, size_t len,
|
|
6282
|
+
const upb_MiniTable* extendee,
|
|
6283
|
+
const upb_MiniTableEnum* subenum,
|
|
6284
|
+
upb_Arena* arena, upb_Status* status) {
|
|
5716
6285
|
upb_MiniTableSub sub = upb_MiniTableSub_FromEnum(subenum);
|
|
5717
6286
|
return _upb_MiniTableExtension_Build(
|
|
5718
6287
|
data, len, extendee, sub, kUpb_MiniTablePlatform_Native, arena, status);
|
|
@@ -5725,10 +6294,9 @@ UPB_API_INLINE upb_MiniTableExtension* upb_MiniTableExtension_BuildEnum(
|
|
|
5725
6294
|
// The caller owns `*buf` both before and after the call, and must upb_gfree()
|
|
5726
6295
|
// it when it is no longer in use. The function will upb_grealloc() `*buf` as
|
|
5727
6296
|
// necessary, updating `*size` accordingly.
|
|
5728
|
-
upb_MiniTable* upb_MiniTable_BuildWithBuf(
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
size_t* buf_size, upb_Status* status);
|
|
6297
|
+
UPB_NODISCARD upb_MiniTable* upb_MiniTable_BuildWithBuf(
|
|
6298
|
+
const char* data, size_t len, upb_MiniTablePlatform platform,
|
|
6299
|
+
upb_Arena* arena, void** buf, size_t* buf_size, upb_Status* status);
|
|
5732
6300
|
|
|
5733
6301
|
#ifdef __cplusplus
|
|
5734
6302
|
} /* extern "C" */
|
|
@@ -5791,22 +6359,22 @@ typedef enum {
|
|
|
5791
6359
|
kUpb_ExtensionRegistryStatus_Ok = 0,
|
|
5792
6360
|
kUpb_ExtensionRegistryStatus_DuplicateEntry = 1,
|
|
5793
6361
|
kUpb_ExtensionRegistryStatus_OutOfMemory = 2,
|
|
5794
|
-
kUpb_ExtensionRegistryStatus_InvalidExtension = 3,
|
|
5795
6362
|
} upb_ExtensionRegistryStatus;
|
|
5796
6363
|
// LINT.ThenChange(//depot/google3/third_party/upb/rust/sys/mini_table/extension_registry.rs)
|
|
5797
6364
|
|
|
5798
6365
|
// Creates a upb_ExtensionRegistry in the given arena.
|
|
5799
6366
|
// The arena must outlive any use of the extreg.
|
|
5800
|
-
UPB_API upb_ExtensionRegistry* upb_ExtensionRegistry_New(
|
|
6367
|
+
UPB_NODISCARD UPB_API upb_ExtensionRegistry* upb_ExtensionRegistry_New(
|
|
6368
|
+
upb_Arena* arena);
|
|
5801
6369
|
|
|
5802
|
-
UPB_API upb_ExtensionRegistryStatus upb_ExtensionRegistry_Add(
|
|
6370
|
+
UPB_NODISCARD UPB_API upb_ExtensionRegistryStatus upb_ExtensionRegistry_Add(
|
|
5803
6371
|
upb_ExtensionRegistry* r, const upb_MiniTableExtension* e);
|
|
5804
6372
|
|
|
5805
6373
|
// Adds the given extension info for the array |e| of size |count| into the
|
|
5806
6374
|
// registry. If there are any errors, the entire array is backed out.
|
|
5807
6375
|
// The extensions must outlive the registry.
|
|
5808
6376
|
// Possible errors include OOM or an extension number that already exists.
|
|
5809
|
-
upb_ExtensionRegistryStatus upb_ExtensionRegistry_AddArray(
|
|
6377
|
+
UPB_NODISCARD upb_ExtensionRegistryStatus upb_ExtensionRegistry_AddArray(
|
|
5810
6378
|
upb_ExtensionRegistry* r, const upb_MiniTableExtension** e, size_t count);
|
|
5811
6379
|
|
|
5812
6380
|
// Looks up the extension (if any) defined for message type |t| and field
|
|
@@ -5953,6 +6521,78 @@ struct upb_GeneratedRegistryRef {
|
|
|
5953
6521
|
#include <stdint.h>
|
|
5954
6522
|
|
|
5955
6523
|
|
|
6524
|
+
#ifndef GOOGLE_UPB_UPB_BASE_ERROR_HANDLER_H__
|
|
6525
|
+
#define GOOGLE_UPB_UPB_BASE_ERROR_HANDLER_H__
|
|
6526
|
+
|
|
6527
|
+
#include <setjmp.h>
|
|
6528
|
+
|
|
6529
|
+
// Must be last.
|
|
6530
|
+
|
|
6531
|
+
// upb_ErrorHandler is a standard longjmp()-based exception handler for UPB.
|
|
6532
|
+
// It is used for efficient error handling in cases where longjmp() is safe to
|
|
6533
|
+
// use, such as in highly performance-sensitive C parsing code.
|
|
6534
|
+
//
|
|
6535
|
+
// This structure contains both a jmp_buf and an error code; the error code is
|
|
6536
|
+
// stored in the structure prior to calling longjmp(). This is necessary because
|
|
6537
|
+
// per the C standard, it is not possible to store the result of setjmp(), so
|
|
6538
|
+
// the error code must be passed out-of-band.
|
|
6539
|
+
//
|
|
6540
|
+
// upb_ErrorHandler is generally not C++-compatible, because longjmp() does not
|
|
6541
|
+
// run C++ destructors. So any library that supports upb_ErrorHandler should
|
|
6542
|
+
// also support a regular return-based error handling mechanism. (Note: we
|
|
6543
|
+
// could conceivably extend this to take a callback, which could either call
|
|
6544
|
+
// longjmp() or throw a C++ exception. But since C++ exceptions are forbidden
|
|
6545
|
+
// by the C++ style guide, there's not likely to be a demand for this.)
|
|
6546
|
+
//
|
|
6547
|
+
// To support both cases (longjmp() or return-based status) efficiently, code
|
|
6548
|
+
// can be written like this:
|
|
6549
|
+
//
|
|
6550
|
+
// UPB_ATTR_CONST bool upb_Arena_HasErrHandler(const upb_Arena* a);
|
|
6551
|
+
//
|
|
6552
|
+
// INLINE void* upb_Arena_Malloc(upb_Arena* a, size_t size) {
|
|
6553
|
+
// if (UPB_UNLIKELY(a->end - a->ptr < size)) {
|
|
6554
|
+
// void* ret = upb_Arena_MallocFallback(a, size);
|
|
6555
|
+
// UPB_MAYBE_ASSUME(upb_Arena_HasErrHandler(a), ret != NULL);
|
|
6556
|
+
// return ret;
|
|
6557
|
+
// }
|
|
6558
|
+
// void* ret = a->ptr;
|
|
6559
|
+
// a->ptr += size;
|
|
6560
|
+
// UPB_ASSUME(ret != NULL);
|
|
6561
|
+
// return ret;
|
|
6562
|
+
// }
|
|
6563
|
+
//
|
|
6564
|
+
// If the optimizer can prove that an error handler is present, it can assume
|
|
6565
|
+
// that upb_Arena_Malloc() will not return NULL.
|
|
6566
|
+
|
|
6567
|
+
// We need to standardize on any error code that might be thrown by an error
|
|
6568
|
+
// handler.
|
|
6569
|
+
|
|
6570
|
+
typedef enum {
|
|
6571
|
+
kUpb_ErrorCode_Ok = 0,
|
|
6572
|
+
kUpb_ErrorCode_OutOfMemory = 1,
|
|
6573
|
+
kUpb_ErrorCode_Malformed = 2,
|
|
6574
|
+
kUpb_ErrorCode_MaxDepthExceeded = 3,
|
|
6575
|
+
} upb_ErrorCode;
|
|
6576
|
+
|
|
6577
|
+
typedef struct {
|
|
6578
|
+
int code;
|
|
6579
|
+
jmp_buf buf;
|
|
6580
|
+
} upb_ErrorHandler;
|
|
6581
|
+
|
|
6582
|
+
UPB_INLINE void upb_ErrorHandler_Init(upb_ErrorHandler* e) {
|
|
6583
|
+
e->code = kUpb_ErrorCode_Ok;
|
|
6584
|
+
}
|
|
6585
|
+
|
|
6586
|
+
UPB_INLINE UPB_NORETURN void upb_ErrorHandler_ThrowError(upb_ErrorHandler* e,
|
|
6587
|
+
int code) {
|
|
6588
|
+
UPB_ASSERT(code != kUpb_ErrorCode_Ok);
|
|
6589
|
+
e->code = code;
|
|
6590
|
+
UPB_LONGJMP(e->buf, 1);
|
|
6591
|
+
}
|
|
6592
|
+
|
|
6593
|
+
|
|
6594
|
+
#endif // GOOGLE_UPB_UPB_BASE_ERROR_HANDLER_H__
|
|
6595
|
+
|
|
5956
6596
|
// Must be last.
|
|
5957
6597
|
|
|
5958
6598
|
#ifdef __cplusplus
|
|
@@ -6017,34 +6657,36 @@ UPB_INLINE int upb_Decode_LimitDepth(uint32_t decode_options, uint32_t limit) {
|
|
|
6017
6657
|
|
|
6018
6658
|
// LINT.IfChange
|
|
6019
6659
|
typedef enum {
|
|
6020
|
-
kUpb_DecodeStatus_Ok =
|
|
6021
|
-
kUpb_DecodeStatus_OutOfMemory =
|
|
6022
|
-
|
|
6023
|
-
|
|
6660
|
+
kUpb_DecodeStatus_Ok = kUpb_ErrorCode_Ok,
|
|
6661
|
+
kUpb_DecodeStatus_OutOfMemory =
|
|
6662
|
+
kUpb_ErrorCode_OutOfMemory, // Arena alloc failed
|
|
6663
|
+
kUpb_DecodeStatus_Malformed =
|
|
6664
|
+
kUpb_ErrorCode_Malformed, // Wire format was corrupt
|
|
6024
6665
|
kUpb_DecodeStatus_MaxDepthExceeded =
|
|
6025
|
-
|
|
6666
|
+
kUpb_ErrorCode_MaxDepthExceeded, // Exceeded upb_DecodeOptions_MaxDepth
|
|
6667
|
+
|
|
6668
|
+
kUpb_DecodeStatus_BadUtf8 = 10, // String field had bad UTF-8
|
|
6026
6669
|
|
|
6027
6670
|
// kUpb_DecodeOption_CheckRequired failed (see above), but the parse otherwise
|
|
6028
6671
|
// succeeded.
|
|
6029
|
-
kUpb_DecodeStatus_MissingRequired =
|
|
6672
|
+
kUpb_DecodeStatus_MissingRequired = 11,
|
|
6030
6673
|
} upb_DecodeStatus;
|
|
6031
6674
|
// LINT.ThenChange(//depot/google3/third_party/upb/rust/sys/wire/wire.rs:decode_status)
|
|
6032
6675
|
|
|
6033
|
-
UPB_API upb_DecodeStatus upb_Decode(
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
int options, upb_Arena* arena);
|
|
6676
|
+
UPB_NODISCARD UPB_API upb_DecodeStatus upb_Decode(
|
|
6677
|
+
const char* buf, size_t size, upb_Message* msg, const upb_MiniTable* mt,
|
|
6678
|
+
const upb_ExtensionRegistry* extreg, int options, upb_Arena* arena);
|
|
6037
6679
|
|
|
6038
6680
|
// Same as upb_Decode but with a varint-encoded length prepended.
|
|
6039
6681
|
// On success 'num_bytes_read' will be set to the how many bytes were read,
|
|
6040
6682
|
// on failure the contents of num_bytes_read is undefined.
|
|
6041
|
-
UPB_API upb_DecodeStatus upb_DecodeLengthPrefixed(
|
|
6683
|
+
UPB_NODISCARD UPB_API upb_DecodeStatus upb_DecodeLengthPrefixed(
|
|
6042
6684
|
const char* buf, size_t size, upb_Message* msg, size_t* num_bytes_read,
|
|
6043
6685
|
const upb_MiniTable* mt, const upb_ExtensionRegistry* extreg, int options,
|
|
6044
6686
|
upb_Arena* arena);
|
|
6045
6687
|
|
|
6046
6688
|
// For testing: decode with tracing.
|
|
6047
|
-
UPB_API upb_DecodeStatus upb_DecodeWithTrace(
|
|
6689
|
+
UPB_NODISCARD UPB_API upb_DecodeStatus upb_DecodeWithTrace(
|
|
6048
6690
|
const char* buf, size_t size, upb_Message* msg, const upb_MiniTable* mt,
|
|
6049
6691
|
const upb_ExtensionRegistry* extreg, int options, upb_Arena* arena,
|
|
6050
6692
|
char* trace_buf, size_t trace_size);
|
|
@@ -6068,6 +6710,27 @@ UPB_API const char* upb_DecodeStatus_String(upb_DecodeStatus status);
|
|
|
6068
6710
|
#include <stdint.h>
|
|
6069
6711
|
|
|
6070
6712
|
|
|
6713
|
+
#ifndef UPB_WIRE_INTERNAL_CONSTANTS_H_
|
|
6714
|
+
#define UPB_WIRE_INTERNAL_CONSTANTS_H_
|
|
6715
|
+
|
|
6716
|
+
#define kUpb_WireFormat_DefaultDepthLimit 100
|
|
6717
|
+
|
|
6718
|
+
// MessageSet wire format is:
|
|
6719
|
+
// message MessageSet {
|
|
6720
|
+
// repeated group Item = 1 {
|
|
6721
|
+
// required int32 type_id = 2;
|
|
6722
|
+
// required bytes message = 3;
|
|
6723
|
+
// }
|
|
6724
|
+
// }
|
|
6725
|
+
|
|
6726
|
+
enum {
|
|
6727
|
+
kUpb_MsgSet_Item = 1,
|
|
6728
|
+
kUpb_MsgSet_TypeId = 2,
|
|
6729
|
+
kUpb_MsgSet_Message = 3,
|
|
6730
|
+
};
|
|
6731
|
+
|
|
6732
|
+
#endif /* UPB_WIRE_INTERNAL_CONSTANTS_H_ */
|
|
6733
|
+
|
|
6071
6734
|
// Must be last.
|
|
6072
6735
|
|
|
6073
6736
|
#ifdef __cplusplus
|
|
@@ -6092,16 +6755,16 @@ enum {
|
|
|
6092
6755
|
|
|
6093
6756
|
// LINT.IfChange
|
|
6094
6757
|
typedef enum {
|
|
6095
|
-
kUpb_EncodeStatus_Ok =
|
|
6096
|
-
kUpb_EncodeStatus_OutOfMemory =
|
|
6097
|
-
|
|
6098
|
-
|
|
6758
|
+
kUpb_EncodeStatus_Ok = kUpb_ErrorCode_Ok,
|
|
6759
|
+
kUpb_EncodeStatus_OutOfMemory =
|
|
6760
|
+
kUpb_ErrorCode_OutOfMemory, // Arena alloc failed
|
|
6099
6761
|
// One or more required fields are missing. Only returned if
|
|
6100
6762
|
// kUpb_EncodeOption_CheckRequired is set.
|
|
6101
|
-
|
|
6763
|
+
kUpb_EncodeStatus_MaxDepthExceeded = kUpb_ErrorCode_MaxDepthExceeded,
|
|
6102
6764
|
|
|
6765
|
+
kUpb_EncodeStatus_MissingRequired = 10,
|
|
6103
6766
|
// The message is larger than protobuf's 2GB size limit.
|
|
6104
|
-
kUpb_EncodeStatus_MaxSizeExceeded =
|
|
6767
|
+
kUpb_EncodeStatus_MaxSizeExceeded = 11,
|
|
6105
6768
|
} upb_EncodeStatus;
|
|
6106
6769
|
// LINT.ThenChange(//depot/google3/third_party/upb/rust/sys/wire/wire.rs:encode_status)
|
|
6107
6770
|
|
|
@@ -6109,7 +6772,14 @@ UPB_INLINE uint32_t upb_EncodeOptions_MaxDepth(uint16_t depth) {
|
|
|
6109
6772
|
return (uint32_t)depth << 16;
|
|
6110
6773
|
}
|
|
6111
6774
|
|
|
6112
|
-
uint16_t
|
|
6775
|
+
UPB_INLINE uint16_t upb_EncodeOptions_GetMaxDepth(uint32_t options) {
|
|
6776
|
+
return options >> 16;
|
|
6777
|
+
}
|
|
6778
|
+
|
|
6779
|
+
UPB_INLINE uint16_t upb_EncodeOptions_GetEffectiveMaxDepth(uint32_t options) {
|
|
6780
|
+
uint16_t max_depth = upb_EncodeOptions_GetMaxDepth(options);
|
|
6781
|
+
return max_depth ? max_depth : kUpb_WireFormat_DefaultDepthLimit;
|
|
6782
|
+
}
|
|
6113
6783
|
|
|
6114
6784
|
// Enforce an upper bound on recursion depth.
|
|
6115
6785
|
UPB_INLINE int upb_Encode_LimitDepth(uint32_t encode_options, uint32_t limit) {
|
|
@@ -6119,15 +6789,15 @@ UPB_INLINE int upb_Encode_LimitDepth(uint32_t encode_options, uint32_t limit) {
|
|
|
6119
6789
|
(encode_options & 0xffff));
|
|
6120
6790
|
}
|
|
6121
6791
|
|
|
6122
|
-
UPB_API upb_EncodeStatus upb_Encode(const upb_Message* msg,
|
|
6123
|
-
const upb_MiniTable* l, int options,
|
|
6124
|
-
upb_Arena* arena, char** buf, size_t* size);
|
|
6125
|
-
|
|
6126
|
-
// Encodes the message prepended by a varint of the serialized length.
|
|
6127
|
-
UPB_API upb_EncodeStatus upb_EncodeLengthPrefixed(const upb_Message* msg,
|
|
6792
|
+
UPB_NODISCARD UPB_API upb_EncodeStatus upb_Encode(const upb_Message* msg,
|
|
6128
6793
|
const upb_MiniTable* l,
|
|
6129
6794
|
int options, upb_Arena* arena,
|
|
6130
6795
|
char** buf, size_t* size);
|
|
6796
|
+
|
|
6797
|
+
// Encodes the message prepended by a varint of the serialized length.
|
|
6798
|
+
UPB_NODISCARD UPB_API upb_EncodeStatus upb_EncodeLengthPrefixed(
|
|
6799
|
+
const upb_Message* msg, const upb_MiniTable* l, int options,
|
|
6800
|
+
upb_Arena* arena, char** buf, size_t* size);
|
|
6131
6801
|
// Utility function for wrapper languages to get an error string from a
|
|
6132
6802
|
// upb_EncodeStatus.
|
|
6133
6803
|
UPB_API const char* upb_EncodeStatus_String(upb_EncodeStatus status);
|
|
@@ -6191,6 +6861,7 @@ extern const upb_MiniTable google__protobuf__UninterpretedOption_msg_init;
|
|
|
6191
6861
|
extern const upb_MiniTable google__protobuf__UninterpretedOption__NamePart_msg_init;
|
|
6192
6862
|
extern const upb_MiniTable google__protobuf__FeatureSet_msg_init;
|
|
6193
6863
|
extern const upb_MiniTable google__protobuf__FeatureSet__VisibilityFeature_msg_init;
|
|
6864
|
+
extern const upb_MiniTable google__protobuf__FeatureSet__ProtoLimitsFeature_msg_init;
|
|
6194
6865
|
extern const upb_MiniTable google__protobuf__FeatureSetDefaults_msg_init;
|
|
6195
6866
|
extern const upb_MiniTable google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init;
|
|
6196
6867
|
extern const upb_MiniTable google__protobuf__SourceCodeInfo_msg_init;
|
|
@@ -6205,6 +6876,7 @@ extern const upb_MiniTableEnum google__protobuf__FeatureSet__EnumType_enum_init;
|
|
|
6205
6876
|
extern const upb_MiniTableEnum google__protobuf__FeatureSet__FieldPresence_enum_init;
|
|
6206
6877
|
extern const upb_MiniTableEnum google__protobuf__FeatureSet__JsonFormat_enum_init;
|
|
6207
6878
|
extern const upb_MiniTableEnum google__protobuf__FeatureSet__MessageEncoding_enum_init;
|
|
6879
|
+
extern const upb_MiniTableEnum google__protobuf__FeatureSet__ProtoLimitsFeature__EnforceProtoLimits_enum_init;
|
|
6208
6880
|
extern const upb_MiniTableEnum google__protobuf__FeatureSet__RepeatedFieldEncoding_enum_init;
|
|
6209
6881
|
extern const upb_MiniTableEnum google__protobuf__FeatureSet__Utf8Validation_enum_init;
|
|
6210
6882
|
extern const upb_MiniTableEnum google__protobuf__FeatureSet__VisibilityFeature__DefaultSymbolVisibility_enum_init;
|
|
@@ -6226,6 +6898,35 @@ extern const upb_MiniTableFile google_protobuf_descriptor_proto_upb_file_layout;
|
|
|
6226
6898
|
|
|
6227
6899
|
|
|
6228
6900
|
#endif /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H__UPB_MINITABLE_H_ */
|
|
6901
|
+
/* This file was generated by upb_generator from the input file:
|
|
6902
|
+
*
|
|
6903
|
+
* google/protobuf/json_enumvalue_options.proto
|
|
6904
|
+
*
|
|
6905
|
+
* Do not edit -- your changes will be discarded when the file is
|
|
6906
|
+
* regenerated.
|
|
6907
|
+
* NO CHECKED-IN PROTOBUF GENCODE */
|
|
6908
|
+
|
|
6909
|
+
#ifndef GOOGLE_PROTOBUF_JSON_ENUMVALUE_OPTIONS_PROTO_UPB_H__UPB_MINITABLE_H_
|
|
6910
|
+
#define GOOGLE_PROTOBUF_JSON_ENUMVALUE_OPTIONS_PROTO_UPB_H__UPB_MINITABLE_H_
|
|
6911
|
+
|
|
6912
|
+
|
|
6913
|
+
// Must be last.
|
|
6914
|
+
|
|
6915
|
+
#ifdef __cplusplus
|
|
6916
|
+
extern "C" {
|
|
6917
|
+
#endif
|
|
6918
|
+
|
|
6919
|
+
extern const upb_MiniTable pb__enumvalue__JsonEnumValueOptions_msg_init;
|
|
6920
|
+
extern const upb_MiniTableExtension* pb_enumvalue_json_ext;
|
|
6921
|
+
|
|
6922
|
+
extern const upb_MiniTableFile google_protobuf_json_enumvalue_options_proto_upb_file_layout;
|
|
6923
|
+
|
|
6924
|
+
#ifdef __cplusplus
|
|
6925
|
+
} /* extern "C" */
|
|
6926
|
+
#endif
|
|
6927
|
+
|
|
6928
|
+
|
|
6929
|
+
#endif /* GOOGLE_PROTOBUF_JSON_ENUMVALUE_OPTIONS_PROTO_UPB_H__UPB_MINITABLE_H_ */
|
|
6229
6930
|
|
|
6230
6931
|
#ifndef UPB_BASE_INTERNAL_LOG2_H_
|
|
6231
6932
|
#define UPB_BASE_INTERNAL_LOG2_H_
|
|
@@ -6251,7 +6952,7 @@ UPB_INLINE int upb_Log2Ceiling(size_t x) {
|
|
|
6251
6952
|
#else
|
|
6252
6953
|
if (x > SIZE_MAX / 2) return sizeof(size_t) * CHAR_BIT;
|
|
6253
6954
|
int lg2 = 0;
|
|
6254
|
-
while ((1 << lg2) < x) lg2++;
|
|
6955
|
+
while (((size_t)1 << lg2) < x) lg2++;
|
|
6255
6956
|
return lg2;
|
|
6256
6957
|
#endif
|
|
6257
6958
|
}
|
|
@@ -6301,7 +7002,8 @@ extern "C" {
|
|
|
6301
7002
|
|
|
6302
7003
|
// Initialize a table. If memory allocation failed, false is returned and
|
|
6303
7004
|
// the table is uninitialized.
|
|
6304
|
-
bool upb_exttable_init(upb_exttable* table, size_t expected_size,
|
|
7005
|
+
UPB_NODISCARD bool upb_exttable_init(upb_exttable* table, size_t expected_size,
|
|
7006
|
+
upb_Arena* a);
|
|
6305
7007
|
|
|
6306
7008
|
// Returns the number of values in the table.
|
|
6307
7009
|
UPB_INLINE size_t upb_exttable_count(const upb_exttable* t) {
|
|
@@ -6315,8 +7017,8 @@ void upb_exttable_clear(upb_exttable* t);
|
|
|
6315
7017
|
//
|
|
6316
7018
|
// If a table resize was required but memory allocation failed, false is
|
|
6317
7019
|
// returned and the table is unchanged.
|
|
6318
|
-
bool upb_exttable_insert(upb_exttable* t, const void* k,
|
|
6319
|
-
|
|
7020
|
+
UPB_NODISCARD bool upb_exttable_insert(upb_exttable* t, const void* k,
|
|
7021
|
+
const uint32_t* v, upb_Arena* a);
|
|
6320
7022
|
|
|
6321
7023
|
// Looks up key and ext_number in this table, returning the value if the key was
|
|
6322
7024
|
// found, or NULL otherwise.
|
|
@@ -6353,6 +7055,9 @@ size_t upb_exttable_size(const upb_exttable* t);
|
|
|
6353
7055
|
#ifndef UPB_REFLECTION_DEF_POOL_H_
|
|
6354
7056
|
#define UPB_REFLECTION_DEF_POOL_H_
|
|
6355
7057
|
|
|
7058
|
+
#include <stddef.h>
|
|
7059
|
+
#include <stdint.h>
|
|
7060
|
+
|
|
6356
7061
|
|
|
6357
7062
|
// IWYU pragma: private, include "upb/reflection/def.h"
|
|
6358
7063
|
|
|
@@ -6501,6 +7206,10 @@ typedef struct google_protobuf_FeatureSet_VisibilityFeature {
|
|
|
6501
7206
|
upb_Message UPB_PRIVATE(base);
|
|
6502
7207
|
} google_protobuf_FeatureSet_VisibilityFeature;
|
|
6503
7208
|
|
|
7209
|
+
typedef struct google_protobuf_FeatureSet_ProtoLimitsFeature {
|
|
7210
|
+
upb_Message UPB_PRIVATE(base);
|
|
7211
|
+
} google_protobuf_FeatureSet_ProtoLimitsFeature;
|
|
7212
|
+
|
|
6504
7213
|
typedef struct google_protobuf_FeatureSetDefaults {
|
|
6505
7214
|
upb_Message UPB_PRIVATE(base);
|
|
6506
7215
|
} google_protobuf_FeatureSetDefaults;
|
|
@@ -6580,6 +7289,12 @@ typedef enum {
|
|
|
6580
7289
|
google_protobuf_FeatureSet_DELIMITED = 2
|
|
6581
7290
|
} google_protobuf_FeatureSet_MessageEncoding;
|
|
6582
7291
|
|
|
7292
|
+
typedef enum {
|
|
7293
|
+
google_protobuf_FeatureSet_ProtoLimitsFeature_PROTO_LIMITS_UNKNOWN = 0,
|
|
7294
|
+
google_protobuf_FeatureSet_ProtoLimitsFeature_LEGACY_NO_EXPLICIT_LIMITS = 1,
|
|
7295
|
+
google_protobuf_FeatureSet_ProtoLimitsFeature_PROTO_LIMITS2026 = 2
|
|
7296
|
+
} google_protobuf_FeatureSet_ProtoLimitsFeature_EnforceProtoLimits;
|
|
7297
|
+
|
|
6583
7298
|
typedef enum {
|
|
6584
7299
|
google_protobuf_FeatureSet_REPEATED_FIELD_ENCODING_UNKNOWN = 0,
|
|
6585
7300
|
google_protobuf_FeatureSet_PACKED = 1,
|
|
@@ -12971,164 +13686,184 @@ UPB_INLINE char* google_protobuf_FeatureSet_serialize_ex(const google_protobuf_F
|
|
|
12971
13686
|
return ptr;
|
|
12972
13687
|
}
|
|
12973
13688
|
UPB_INLINE void google_protobuf_FeatureSet_clear_field_presence(google_protobuf_FeatureSet* msg) {
|
|
12974
|
-
const upb_MiniTableField field = {1, 12, 64,
|
|
13689
|
+
const upb_MiniTableField field = {1, 12, 64, UPB_SIZE(27, 28), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
12975
13690
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
|
12976
13691
|
}
|
|
12977
13692
|
UPB_INLINE int32_t google_protobuf_FeatureSet_field_presence(const google_protobuf_FeatureSet* msg) {
|
|
12978
13693
|
int32_t default_val = 0;
|
|
12979
13694
|
int32_t ret;
|
|
12980
|
-
const upb_MiniTableField field = {1, 12, 64,
|
|
13695
|
+
const upb_MiniTableField field = {1, 12, 64, UPB_SIZE(27, 28), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
12981
13696
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
|
12982
13697
|
&default_val, &ret);
|
|
12983
13698
|
return ret;
|
|
12984
13699
|
}
|
|
12985
13700
|
UPB_INLINE bool google_protobuf_FeatureSet_has_field_presence(const google_protobuf_FeatureSet* msg) {
|
|
12986
|
-
const upb_MiniTableField field = {1, 12, 64,
|
|
13701
|
+
const upb_MiniTableField field = {1, 12, 64, UPB_SIZE(27, 28), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
12987
13702
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
|
12988
13703
|
}
|
|
12989
13704
|
UPB_INLINE void google_protobuf_FeatureSet_clear_enum_type(google_protobuf_FeatureSet* msg) {
|
|
12990
|
-
const upb_MiniTableField field = {2, 16, 65, UPB_SIZE(
|
|
13705
|
+
const upb_MiniTableField field = {2, 16, 65, UPB_SIZE(25, 27), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
12991
13706
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
|
12992
13707
|
}
|
|
12993
13708
|
UPB_INLINE int32_t google_protobuf_FeatureSet_enum_type(const google_protobuf_FeatureSet* msg) {
|
|
12994
13709
|
int32_t default_val = 0;
|
|
12995
13710
|
int32_t ret;
|
|
12996
|
-
const upb_MiniTableField field = {2, 16, 65, UPB_SIZE(
|
|
13711
|
+
const upb_MiniTableField field = {2, 16, 65, UPB_SIZE(25, 27), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
12997
13712
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
|
12998
13713
|
&default_val, &ret);
|
|
12999
13714
|
return ret;
|
|
13000
13715
|
}
|
|
13001
13716
|
UPB_INLINE bool google_protobuf_FeatureSet_has_enum_type(const google_protobuf_FeatureSet* msg) {
|
|
13002
|
-
const upb_MiniTableField field = {2, 16, 65, UPB_SIZE(
|
|
13717
|
+
const upb_MiniTableField field = {2, 16, 65, UPB_SIZE(25, 27), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13003
13718
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
|
13004
13719
|
}
|
|
13005
13720
|
UPB_INLINE void google_protobuf_FeatureSet_clear_repeated_field_encoding(google_protobuf_FeatureSet* msg) {
|
|
13006
|
-
const upb_MiniTableField field = {3, 20, 66, UPB_SIZE(
|
|
13721
|
+
const upb_MiniTableField field = {3, 20, 66, UPB_SIZE(23, 26), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13007
13722
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
|
13008
13723
|
}
|
|
13009
13724
|
UPB_INLINE int32_t google_protobuf_FeatureSet_repeated_field_encoding(const google_protobuf_FeatureSet* msg) {
|
|
13010
13725
|
int32_t default_val = 0;
|
|
13011
13726
|
int32_t ret;
|
|
13012
|
-
const upb_MiniTableField field = {3, 20, 66, UPB_SIZE(
|
|
13727
|
+
const upb_MiniTableField field = {3, 20, 66, UPB_SIZE(23, 26), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13013
13728
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
|
13014
13729
|
&default_val, &ret);
|
|
13015
13730
|
return ret;
|
|
13016
13731
|
}
|
|
13017
13732
|
UPB_INLINE bool google_protobuf_FeatureSet_has_repeated_field_encoding(const google_protobuf_FeatureSet* msg) {
|
|
13018
|
-
const upb_MiniTableField field = {3, 20, 66, UPB_SIZE(
|
|
13733
|
+
const upb_MiniTableField field = {3, 20, 66, UPB_SIZE(23, 26), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13019
13734
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
|
13020
13735
|
}
|
|
13021
13736
|
UPB_INLINE void google_protobuf_FeatureSet_clear_utf8_validation(google_protobuf_FeatureSet* msg) {
|
|
13022
|
-
const upb_MiniTableField field = {4, 24, 67, UPB_SIZE(
|
|
13737
|
+
const upb_MiniTableField field = {4, 24, 67, UPB_SIZE(21, 25), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13023
13738
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
|
13024
13739
|
}
|
|
13025
13740
|
UPB_INLINE int32_t google_protobuf_FeatureSet_utf8_validation(const google_protobuf_FeatureSet* msg) {
|
|
13026
13741
|
int32_t default_val = 0;
|
|
13027
13742
|
int32_t ret;
|
|
13028
|
-
const upb_MiniTableField field = {4, 24, 67, UPB_SIZE(
|
|
13743
|
+
const upb_MiniTableField field = {4, 24, 67, UPB_SIZE(21, 25), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13029
13744
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
|
13030
13745
|
&default_val, &ret);
|
|
13031
13746
|
return ret;
|
|
13032
13747
|
}
|
|
13033
13748
|
UPB_INLINE bool google_protobuf_FeatureSet_has_utf8_validation(const google_protobuf_FeatureSet* msg) {
|
|
13034
|
-
const upb_MiniTableField field = {4, 24, 67, UPB_SIZE(
|
|
13749
|
+
const upb_MiniTableField field = {4, 24, 67, UPB_SIZE(21, 25), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13035
13750
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
|
13036
13751
|
}
|
|
13037
13752
|
UPB_INLINE void google_protobuf_FeatureSet_clear_message_encoding(google_protobuf_FeatureSet* msg) {
|
|
13038
|
-
const upb_MiniTableField field = {5, 28, 68, UPB_SIZE(
|
|
13753
|
+
const upb_MiniTableField field = {5, 28, 68, UPB_SIZE(19, 24), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13039
13754
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
|
13040
13755
|
}
|
|
13041
13756
|
UPB_INLINE int32_t google_protobuf_FeatureSet_message_encoding(const google_protobuf_FeatureSet* msg) {
|
|
13042
13757
|
int32_t default_val = 0;
|
|
13043
13758
|
int32_t ret;
|
|
13044
|
-
const upb_MiniTableField field = {5, 28, 68, UPB_SIZE(
|
|
13759
|
+
const upb_MiniTableField field = {5, 28, 68, UPB_SIZE(19, 24), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13045
13760
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
|
13046
13761
|
&default_val, &ret);
|
|
13047
13762
|
return ret;
|
|
13048
13763
|
}
|
|
13049
13764
|
UPB_INLINE bool google_protobuf_FeatureSet_has_message_encoding(const google_protobuf_FeatureSet* msg) {
|
|
13050
|
-
const upb_MiniTableField field = {5, 28, 68, UPB_SIZE(
|
|
13765
|
+
const upb_MiniTableField field = {5, 28, 68, UPB_SIZE(19, 24), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13051
13766
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
|
13052
13767
|
}
|
|
13053
13768
|
UPB_INLINE void google_protobuf_FeatureSet_clear_json_format(google_protobuf_FeatureSet* msg) {
|
|
13054
|
-
const upb_MiniTableField field = {6, 32, 69, UPB_SIZE(
|
|
13769
|
+
const upb_MiniTableField field = {6, 32, 69, UPB_SIZE(17, 23), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13055
13770
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
|
13056
13771
|
}
|
|
13057
13772
|
UPB_INLINE int32_t google_protobuf_FeatureSet_json_format(const google_protobuf_FeatureSet* msg) {
|
|
13058
13773
|
int32_t default_val = 0;
|
|
13059
13774
|
int32_t ret;
|
|
13060
|
-
const upb_MiniTableField field = {6, 32, 69, UPB_SIZE(
|
|
13775
|
+
const upb_MiniTableField field = {6, 32, 69, UPB_SIZE(17, 23), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13061
13776
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
|
13062
13777
|
&default_val, &ret);
|
|
13063
13778
|
return ret;
|
|
13064
13779
|
}
|
|
13065
13780
|
UPB_INLINE bool google_protobuf_FeatureSet_has_json_format(const google_protobuf_FeatureSet* msg) {
|
|
13066
|
-
const upb_MiniTableField field = {6, 32, 69, UPB_SIZE(
|
|
13781
|
+
const upb_MiniTableField field = {6, 32, 69, UPB_SIZE(17, 23), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13067
13782
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
|
13068
13783
|
}
|
|
13069
13784
|
UPB_INLINE void google_protobuf_FeatureSet_clear_enforce_naming_style(google_protobuf_FeatureSet* msg) {
|
|
13070
|
-
const upb_MiniTableField field = {7, 36, 70, UPB_SIZE(
|
|
13785
|
+
const upb_MiniTableField field = {7, 36, 70, UPB_SIZE(15, 22), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13071
13786
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
|
13072
13787
|
}
|
|
13073
13788
|
UPB_INLINE int32_t google_protobuf_FeatureSet_enforce_naming_style(const google_protobuf_FeatureSet* msg) {
|
|
13074
13789
|
int32_t default_val = 0;
|
|
13075
13790
|
int32_t ret;
|
|
13076
|
-
const upb_MiniTableField field = {7, 36, 70, UPB_SIZE(
|
|
13791
|
+
const upb_MiniTableField field = {7, 36, 70, UPB_SIZE(15, 22), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13077
13792
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
|
13078
13793
|
&default_val, &ret);
|
|
13079
13794
|
return ret;
|
|
13080
13795
|
}
|
|
13081
13796
|
UPB_INLINE bool google_protobuf_FeatureSet_has_enforce_naming_style(const google_protobuf_FeatureSet* msg) {
|
|
13082
|
-
const upb_MiniTableField field = {7, 36, 70, UPB_SIZE(
|
|
13797
|
+
const upb_MiniTableField field = {7, 36, 70, UPB_SIZE(15, 22), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13083
13798
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
|
13084
13799
|
}
|
|
13085
13800
|
UPB_INLINE void google_protobuf_FeatureSet_clear_default_symbol_visibility(google_protobuf_FeatureSet* msg) {
|
|
13086
|
-
const upb_MiniTableField field = {8, 40, 71, UPB_SIZE(
|
|
13801
|
+
const upb_MiniTableField field = {8, 40, 71, UPB_SIZE(13, 21), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13087
13802
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
|
13088
13803
|
}
|
|
13089
13804
|
UPB_INLINE int32_t google_protobuf_FeatureSet_default_symbol_visibility(const google_protobuf_FeatureSet* msg) {
|
|
13090
13805
|
int32_t default_val = 0;
|
|
13091
13806
|
int32_t ret;
|
|
13092
|
-
const upb_MiniTableField field = {8, 40, 71, UPB_SIZE(
|
|
13807
|
+
const upb_MiniTableField field = {8, 40, 71, UPB_SIZE(13, 21), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13093
13808
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
|
13094
13809
|
&default_val, &ret);
|
|
13095
13810
|
return ret;
|
|
13096
13811
|
}
|
|
13097
13812
|
UPB_INLINE bool google_protobuf_FeatureSet_has_default_symbol_visibility(const google_protobuf_FeatureSet* msg) {
|
|
13098
|
-
const upb_MiniTableField field = {8, 40, 71, UPB_SIZE(
|
|
13813
|
+
const upb_MiniTableField field = {8, 40, 71, UPB_SIZE(13, 21), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13814
|
+
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
|
13815
|
+
}
|
|
13816
|
+
UPB_INLINE void google_protobuf_FeatureSet_clear_enforce_proto_limits(google_protobuf_FeatureSet* msg) {
|
|
13817
|
+
const upb_MiniTableField field = {9, 44, 72, UPB_SIZE(11, 20), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13818
|
+
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
|
13819
|
+
}
|
|
13820
|
+
UPB_INLINE int32_t google_protobuf_FeatureSet_enforce_proto_limits(const google_protobuf_FeatureSet* msg) {
|
|
13821
|
+
int32_t default_val = 0;
|
|
13822
|
+
int32_t ret;
|
|
13823
|
+
const upb_MiniTableField field = {9, 44, 72, UPB_SIZE(11, 20), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13824
|
+
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
|
13825
|
+
&default_val, &ret);
|
|
13826
|
+
return ret;
|
|
13827
|
+
}
|
|
13828
|
+
UPB_INLINE bool google_protobuf_FeatureSet_has_enforce_proto_limits(const google_protobuf_FeatureSet* msg) {
|
|
13829
|
+
const upb_MiniTableField field = {9, 44, 72, UPB_SIZE(11, 20), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13099
13830
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
|
13100
13831
|
}
|
|
13101
13832
|
|
|
13102
13833
|
UPB_INLINE void google_protobuf_FeatureSet_set_field_presence(google_protobuf_FeatureSet* msg, int32_t value) {
|
|
13103
|
-
const upb_MiniTableField field = {1, 12, 64,
|
|
13834
|
+
const upb_MiniTableField field = {1, 12, 64, UPB_SIZE(27, 28), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13104
13835
|
upb_Message_SetBaseField((upb_Message*)msg, &field, &value);
|
|
13105
13836
|
}
|
|
13106
13837
|
UPB_INLINE void google_protobuf_FeatureSet_set_enum_type(google_protobuf_FeatureSet* msg, int32_t value) {
|
|
13107
|
-
const upb_MiniTableField field = {2, 16, 65, UPB_SIZE(
|
|
13838
|
+
const upb_MiniTableField field = {2, 16, 65, UPB_SIZE(25, 27), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13108
13839
|
upb_Message_SetBaseField((upb_Message*)msg, &field, &value);
|
|
13109
13840
|
}
|
|
13110
13841
|
UPB_INLINE void google_protobuf_FeatureSet_set_repeated_field_encoding(google_protobuf_FeatureSet* msg, int32_t value) {
|
|
13111
|
-
const upb_MiniTableField field = {3, 20, 66, UPB_SIZE(
|
|
13842
|
+
const upb_MiniTableField field = {3, 20, 66, UPB_SIZE(23, 26), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13112
13843
|
upb_Message_SetBaseField((upb_Message*)msg, &field, &value);
|
|
13113
13844
|
}
|
|
13114
13845
|
UPB_INLINE void google_protobuf_FeatureSet_set_utf8_validation(google_protobuf_FeatureSet* msg, int32_t value) {
|
|
13115
|
-
const upb_MiniTableField field = {4, 24, 67, UPB_SIZE(
|
|
13846
|
+
const upb_MiniTableField field = {4, 24, 67, UPB_SIZE(21, 25), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13116
13847
|
upb_Message_SetBaseField((upb_Message*)msg, &field, &value);
|
|
13117
13848
|
}
|
|
13118
13849
|
UPB_INLINE void google_protobuf_FeatureSet_set_message_encoding(google_protobuf_FeatureSet* msg, int32_t value) {
|
|
13119
|
-
const upb_MiniTableField field = {5, 28, 68, UPB_SIZE(
|
|
13850
|
+
const upb_MiniTableField field = {5, 28, 68, UPB_SIZE(19, 24), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13120
13851
|
upb_Message_SetBaseField((upb_Message*)msg, &field, &value);
|
|
13121
13852
|
}
|
|
13122
13853
|
UPB_INLINE void google_protobuf_FeatureSet_set_json_format(google_protobuf_FeatureSet* msg, int32_t value) {
|
|
13123
|
-
const upb_MiniTableField field = {6, 32, 69, UPB_SIZE(
|
|
13854
|
+
const upb_MiniTableField field = {6, 32, 69, UPB_SIZE(17, 23), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13124
13855
|
upb_Message_SetBaseField((upb_Message*)msg, &field, &value);
|
|
13125
13856
|
}
|
|
13126
13857
|
UPB_INLINE void google_protobuf_FeatureSet_set_enforce_naming_style(google_protobuf_FeatureSet* msg, int32_t value) {
|
|
13127
|
-
const upb_MiniTableField field = {7, 36, 70, UPB_SIZE(
|
|
13858
|
+
const upb_MiniTableField field = {7, 36, 70, UPB_SIZE(15, 22), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13128
13859
|
upb_Message_SetBaseField((upb_Message*)msg, &field, &value);
|
|
13129
13860
|
}
|
|
13130
13861
|
UPB_INLINE void google_protobuf_FeatureSet_set_default_symbol_visibility(google_protobuf_FeatureSet* msg, int32_t value) {
|
|
13131
|
-
const upb_MiniTableField field = {8, 40, 71, UPB_SIZE(
|
|
13862
|
+
const upb_MiniTableField field = {8, 40, 71, UPB_SIZE(13, 21), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13863
|
+
upb_Message_SetBaseField((upb_Message*)msg, &field, &value);
|
|
13864
|
+
}
|
|
13865
|
+
UPB_INLINE void google_protobuf_FeatureSet_set_enforce_proto_limits(google_protobuf_FeatureSet* msg, int32_t value) {
|
|
13866
|
+
const upb_MiniTableField field = {9, 44, 72, UPB_SIZE(11, 20), 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
|
13132
13867
|
upb_Message_SetBaseField((upb_Message*)msg, &field, &value);
|
|
13133
13868
|
}
|
|
13134
13869
|
|
|
@@ -13172,6 +13907,46 @@ UPB_INLINE char* google_protobuf_FeatureSet_VisibilityFeature_serialize_ex(const
|
|
|
13172
13907
|
}
|
|
13173
13908
|
|
|
13174
13909
|
|
|
13910
|
+
/* google.protobuf.FeatureSet.ProtoLimitsFeature */
|
|
13911
|
+
UPB_INLINE google_protobuf_FeatureSet_ProtoLimitsFeature* google_protobuf_FeatureSet_ProtoLimitsFeature_new(upb_Arena* arena) {
|
|
13912
|
+
return (google_protobuf_FeatureSet_ProtoLimitsFeature*)_upb_Message_New(&google__protobuf__FeatureSet__ProtoLimitsFeature_msg_init, arena);
|
|
13913
|
+
}
|
|
13914
|
+
UPB_INLINE google_protobuf_FeatureSet_ProtoLimitsFeature* google_protobuf_FeatureSet_ProtoLimitsFeature_parse(const char* buf, size_t size,
|
|
13915
|
+
upb_Arena* arena) {
|
|
13916
|
+
google_protobuf_FeatureSet_ProtoLimitsFeature* ret = google_protobuf_FeatureSet_ProtoLimitsFeature_new(arena);
|
|
13917
|
+
if (!ret) return NULL;
|
|
13918
|
+
if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FeatureSet__ProtoLimitsFeature_msg_init, NULL, 0,
|
|
13919
|
+
arena) != kUpb_DecodeStatus_Ok) {
|
|
13920
|
+
return NULL;
|
|
13921
|
+
}
|
|
13922
|
+
return ret;
|
|
13923
|
+
}
|
|
13924
|
+
UPB_INLINE google_protobuf_FeatureSet_ProtoLimitsFeature* google_protobuf_FeatureSet_ProtoLimitsFeature_parse_ex(
|
|
13925
|
+
const char* buf, size_t size, const upb_ExtensionRegistry* extreg,
|
|
13926
|
+
int options, upb_Arena* arena) {
|
|
13927
|
+
google_protobuf_FeatureSet_ProtoLimitsFeature* ret = google_protobuf_FeatureSet_ProtoLimitsFeature_new(arena);
|
|
13928
|
+
if (!ret) return NULL;
|
|
13929
|
+
if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FeatureSet__ProtoLimitsFeature_msg_init, extreg,
|
|
13930
|
+
options, arena) != kUpb_DecodeStatus_Ok) {
|
|
13931
|
+
return NULL;
|
|
13932
|
+
}
|
|
13933
|
+
return ret;
|
|
13934
|
+
}
|
|
13935
|
+
UPB_INLINE char* google_protobuf_FeatureSet_ProtoLimitsFeature_serialize(const google_protobuf_FeatureSet_ProtoLimitsFeature* msg,
|
|
13936
|
+
upb_Arena* arena, size_t* len) {
|
|
13937
|
+
char* ptr;
|
|
13938
|
+
(void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FeatureSet__ProtoLimitsFeature_msg_init, 0, arena, &ptr, len);
|
|
13939
|
+
return ptr;
|
|
13940
|
+
}
|
|
13941
|
+
UPB_INLINE char* google_protobuf_FeatureSet_ProtoLimitsFeature_serialize_ex(const google_protobuf_FeatureSet_ProtoLimitsFeature* msg,
|
|
13942
|
+
int options, upb_Arena* arena,
|
|
13943
|
+
size_t* len) {
|
|
13944
|
+
char* ptr;
|
|
13945
|
+
(void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FeatureSet__ProtoLimitsFeature_msg_init, options, arena, &ptr, len);
|
|
13946
|
+
return ptr;
|
|
13947
|
+
}
|
|
13948
|
+
|
|
13949
|
+
|
|
13175
13950
|
/* google.protobuf.FeatureSetDefaults */
|
|
13176
13951
|
UPB_INLINE google_protobuf_FeatureSetDefaults* google_protobuf_FeatureSetDefaults_new(upb_Arena* arena) {
|
|
13177
13952
|
return (google_protobuf_FeatureSetDefaults*)_upb_Message_New(&google__protobuf__FeatureSetDefaults_msg_init, arena);
|
|
@@ -14213,60 +14988,6 @@ typedef struct upb_DefBuilder upb_DefBuilder;
|
|
|
14213
14988
|
|
|
14214
14989
|
#endif /* UPB_REFLECTION_COMMON_H_ */
|
|
14215
14990
|
|
|
14216
|
-
#ifndef UPB_REFLECTION_DEF_TYPE_H_
|
|
14217
|
-
#define UPB_REFLECTION_DEF_TYPE_H_
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
// Must be last.
|
|
14221
|
-
|
|
14222
|
-
// Inside a symtab we store tagged pointers to specific def types.
|
|
14223
|
-
typedef enum {
|
|
14224
|
-
UPB_DEFTYPE_MASK = 7,
|
|
14225
|
-
|
|
14226
|
-
// Only inside symtab table.
|
|
14227
|
-
UPB_DEFTYPE_EXT = 0,
|
|
14228
|
-
UPB_DEFTYPE_MSG = 1,
|
|
14229
|
-
UPB_DEFTYPE_ENUM = 2,
|
|
14230
|
-
UPB_DEFTYPE_ENUMVAL = 3,
|
|
14231
|
-
UPB_DEFTYPE_SERVICE = 4,
|
|
14232
|
-
|
|
14233
|
-
// Only inside message table.
|
|
14234
|
-
UPB_DEFTYPE_FIELD = 0,
|
|
14235
|
-
UPB_DEFTYPE_ONEOF = 1,
|
|
14236
|
-
|
|
14237
|
-
// Only inside service table.
|
|
14238
|
-
UPB_DEFTYPE_METHOD = 0,
|
|
14239
|
-
} upb_deftype_t;
|
|
14240
|
-
|
|
14241
|
-
#ifdef __cplusplus
|
|
14242
|
-
extern "C" {
|
|
14243
|
-
#endif
|
|
14244
|
-
|
|
14245
|
-
// Our 3-bit pointer tagging requires all pointers to be multiples of 8.
|
|
14246
|
-
// The arena will always yield 8-byte-aligned addresses, however we put
|
|
14247
|
-
// the defs into arrays. For each element in the array to be 8-byte-aligned,
|
|
14248
|
-
// the sizes of each def type must also be a multiple of 8.
|
|
14249
|
-
//
|
|
14250
|
-
// If any of these asserts fail, we need to add or remove padding on 32-bit
|
|
14251
|
-
// machines (64-bit machines will have 8-byte alignment already due to
|
|
14252
|
-
// pointers, which all of these structs have).
|
|
14253
|
-
UPB_INLINE void _upb_DefType_CheckPadding(size_t size) {
|
|
14254
|
-
UPB_ASSERT((size & UPB_DEFTYPE_MASK) == 0);
|
|
14255
|
-
}
|
|
14256
|
-
|
|
14257
|
-
upb_deftype_t _upb_DefType_Type(upb_value v);
|
|
14258
|
-
|
|
14259
|
-
upb_value _upb_DefType_Pack(const void* ptr, upb_deftype_t type);
|
|
14260
|
-
|
|
14261
|
-
const void* _upb_DefType_Unpack(upb_value v, upb_deftype_t type);
|
|
14262
|
-
|
|
14263
|
-
#ifdef __cplusplus
|
|
14264
|
-
} /* extern "C" */
|
|
14265
|
-
#endif
|
|
14266
|
-
|
|
14267
|
-
|
|
14268
|
-
#endif /* UPB_REFLECTION_DEF_TYPE_H_ */
|
|
14269
|
-
|
|
14270
14991
|
// Must be last.
|
|
14271
14992
|
|
|
14272
14993
|
#ifdef __cplusplus
|
|
@@ -14275,15 +14996,14 @@ extern "C" {
|
|
|
14275
14996
|
|
|
14276
14997
|
UPB_API void upb_DefPool_Free(upb_DefPool* s);
|
|
14277
14998
|
|
|
14278
|
-
UPB_API upb_DefPool* upb_DefPool_New(void);
|
|
14999
|
+
UPB_NODISCARD UPB_API upb_DefPool* upb_DefPool_New(void);
|
|
14279
15000
|
|
|
14280
15001
|
UPB_API const google_protobuf_FeatureSetDefaults* upb_DefPool_FeatureSetDefaults(
|
|
14281
15002
|
const upb_DefPool* s);
|
|
14282
15003
|
|
|
14283
|
-
UPB_API bool upb_DefPool_SetFeatureSetDefaults(
|
|
14284
|
-
|
|
14285
|
-
|
|
14286
|
-
upb_Status* status);
|
|
15004
|
+
UPB_NODISCARD UPB_API bool upb_DefPool_SetFeatureSetDefaults(
|
|
15005
|
+
upb_DefPool* s, const char* serialized_defaults, size_t serialized_len,
|
|
15006
|
+
upb_Status* status);
|
|
14287
15007
|
|
|
14288
15008
|
UPB_API const upb_MessageDef* upb_DefPool_FindMessageByName(
|
|
14289
15009
|
const upb_DefPool* s, const char* sym);
|
|
@@ -14332,7 +15052,7 @@ const upb_ServiceDef* upb_DefPool_FindServiceByNameWithSize(
|
|
|
14332
15052
|
const upb_FileDef* upb_DefPool_FindFileContainingSymbol(const upb_DefPool* s,
|
|
14333
15053
|
const char* name);
|
|
14334
15054
|
|
|
14335
|
-
UPB_API const upb_FileDef* upb_DefPool_AddFile(
|
|
15055
|
+
UPB_NODISCARD UPB_API const upb_FileDef* upb_DefPool_AddFile(
|
|
14336
15056
|
upb_DefPool* s, const google_protobuf_FileDescriptorProto* file_proto,
|
|
14337
15057
|
upb_Status* status);
|
|
14338
15058
|
|
|
@@ -14381,6 +15101,7 @@ bool upb_DefPool_ImplicitFieldPresenceDisabled(const upb_DefPool* s);
|
|
|
14381
15101
|
|
|
14382
15102
|
#include <stddef.h>
|
|
14383
15103
|
#include <stdint.h>
|
|
15104
|
+
#include <string.h>
|
|
14384
15105
|
|
|
14385
15106
|
|
|
14386
15107
|
// Must be last.
|
|
@@ -14393,6 +15114,12 @@ bool upb_EnumDef_CheckNumber(const upb_EnumDef* e, int32_t num);
|
|
|
14393
15114
|
const upb_MessageDef* upb_EnumDef_ContainingType(const upb_EnumDef* e);
|
|
14394
15115
|
int32_t upb_EnumDef_Default(const upb_EnumDef* e);
|
|
14395
15116
|
UPB_API const upb_FileDef* upb_EnumDef_File(const upb_EnumDef* e);
|
|
15117
|
+
UPB_API const upb_EnumValueDef* upb_EnumDef_FindByJsonNameWithSize(
|
|
15118
|
+
const upb_EnumDef* e, const char* name, size_t size);
|
|
15119
|
+
UPB_INLINE const upb_EnumValueDef* upb_EnumDef_FindByJsonName(
|
|
15120
|
+
const upb_EnumDef* e, const char* name) {
|
|
15121
|
+
return upb_EnumDef_FindByJsonNameWithSize(e, name, strlen(name));
|
|
15122
|
+
}
|
|
14396
15123
|
const upb_EnumValueDef* upb_EnumDef_FindValueByName(const upb_EnumDef* e,
|
|
14397
15124
|
const char* name);
|
|
14398
15125
|
UPB_API const upb_EnumValueDef* upb_EnumDef_FindValueByNameWithSize(
|
|
@@ -14404,8 +15131,9 @@ bool upb_EnumDef_HasOptions(const upb_EnumDef* e);
|
|
|
14404
15131
|
bool upb_EnumDef_IsClosed(const upb_EnumDef* e);
|
|
14405
15132
|
|
|
14406
15133
|
// Creates a mini descriptor string for an enum, returns true on success.
|
|
14407
|
-
bool upb_EnumDef_MiniDescriptorEncode(const upb_EnumDef* e,
|
|
14408
|
-
|
|
15134
|
+
UPB_NODISCARD bool upb_EnumDef_MiniDescriptorEncode(const upb_EnumDef* e,
|
|
15135
|
+
upb_Arena* a,
|
|
15136
|
+
upb_StringView* out);
|
|
14409
15137
|
|
|
14410
15138
|
const char* upb_EnumDef_Name(const upb_EnumDef* e);
|
|
14411
15139
|
const google_protobuf_EnumOptions* upb_EnumDef_Options(const upb_EnumDef* e);
|
|
@@ -14434,6 +15162,8 @@ UPB_API int upb_EnumDef_ValueCount(const upb_EnumDef* e);
|
|
|
14434
15162
|
#ifndef UPB_REFLECTION_ENUM_VALUE_DEF_H_
|
|
14435
15163
|
#define UPB_REFLECTION_ENUM_VALUE_DEF_H_
|
|
14436
15164
|
|
|
15165
|
+
#include <stdint.h>
|
|
15166
|
+
|
|
14437
15167
|
|
|
14438
15168
|
// Must be last.
|
|
14439
15169
|
|
|
@@ -14445,6 +15175,7 @@ const upb_EnumDef* upb_EnumValueDef_Enum(const upb_EnumValueDef* v);
|
|
|
14445
15175
|
const char* upb_EnumValueDef_FullName(const upb_EnumValueDef* v);
|
|
14446
15176
|
bool upb_EnumValueDef_HasOptions(const upb_EnumValueDef* v);
|
|
14447
15177
|
uint32_t upb_EnumValueDef_Index(const upb_EnumValueDef* v);
|
|
15178
|
+
UPB_API const char* upb_EnumValueDef_JsonName(const upb_EnumValueDef* v);
|
|
14448
15179
|
UPB_API const char* upb_EnumValueDef_Name(const upb_EnumValueDef* v);
|
|
14449
15180
|
UPB_API int32_t upb_EnumValueDef_Number(const upb_EnumValueDef* v);
|
|
14450
15181
|
const google_protobuf_EnumValueOptions* upb_EnumValueDef_Options(
|
|
@@ -14541,8 +15272,9 @@ bool _upb_FieldDef_ValidateUtf8(const upb_FieldDef* f);
|
|
|
14541
15272
|
bool _upb_FieldDef_IsGroupLike(const upb_FieldDef* f);
|
|
14542
15273
|
|
|
14543
15274
|
// Creates a mini descriptor string for a field, returns true on success.
|
|
14544
|
-
bool upb_FieldDef_MiniDescriptorEncode(const upb_FieldDef* f,
|
|
14545
|
-
|
|
15275
|
+
UPB_NODISCARD bool upb_FieldDef_MiniDescriptorEncode(const upb_FieldDef* f,
|
|
15276
|
+
upb_Arena* a,
|
|
15277
|
+
upb_StringView* out);
|
|
14546
15278
|
|
|
14547
15279
|
const upb_MiniTableField* upb_FieldDef_MiniTable(const upb_FieldDef* f);
|
|
14548
15280
|
const upb_MiniTableExtension* upb_FieldDef_MiniTableExtension(
|
|
@@ -14719,8 +15451,9 @@ bool upb_MessageDef_IsMapEntry(const upb_MessageDef* m);
|
|
|
14719
15451
|
bool upb_MessageDef_IsMessageSet(const upb_MessageDef* m);
|
|
14720
15452
|
|
|
14721
15453
|
// Creates a mini descriptor string for a message, returns true on success.
|
|
14722
|
-
bool upb_MessageDef_MiniDescriptorEncode(const upb_MessageDef* m,
|
|
14723
|
-
|
|
15454
|
+
UPB_NODISCARD bool upb_MessageDef_MiniDescriptorEncode(const upb_MessageDef* m,
|
|
15455
|
+
upb_Arena* a,
|
|
15456
|
+
upb_StringView* out);
|
|
14724
15457
|
|
|
14725
15458
|
UPB_API const upb_MiniTable* upb_MessageDef_MiniTable(const upb_MessageDef* m);
|
|
14726
15459
|
const char* upb_MessageDef_Name(const upb_MessageDef* m);
|
|
@@ -14888,17 +15621,17 @@ enum {
|
|
|
14888
15621
|
kUpb_JsonDecodeResult_Error = 2,
|
|
14889
15622
|
};
|
|
14890
15623
|
|
|
14891
|
-
UPB_API int upb_JsonDecodeDetectingNonconformance(
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
int options, upb_Arena* arena,
|
|
14896
|
-
upb_Status* status);
|
|
15624
|
+
UPB_NODISCARD UPB_API int upb_JsonDecodeDetectingNonconformance(
|
|
15625
|
+
const char* buf, size_t size, upb_Message* msg, const upb_MessageDef* m,
|
|
15626
|
+
const upb_DefPool* symtab, int options, upb_Arena* arena,
|
|
15627
|
+
upb_Status* status);
|
|
14897
15628
|
|
|
14898
|
-
UPB_API_INLINE bool upb_JsonDecode(const char* buf, size_t size,
|
|
14899
|
-
|
|
14900
|
-
|
|
14901
|
-
|
|
15629
|
+
UPB_NODISCARD UPB_API_INLINE bool upb_JsonDecode(const char* buf, size_t size,
|
|
15630
|
+
upb_Message* msg,
|
|
15631
|
+
const upb_MessageDef* m,
|
|
15632
|
+
const upb_DefPool* symtab,
|
|
15633
|
+
int options, upb_Arena* arena,
|
|
15634
|
+
upb_Status* status) {
|
|
14902
15635
|
return upb_JsonDecodeDetectingNonconformance(buf, size, msg, m, symtab,
|
|
14903
15636
|
options, arena, status) ==
|
|
14904
15637
|
kUpb_JsonDecodeResult_Ok;
|
|
@@ -15004,9 +15737,8 @@ extern "C" {
|
|
|
15004
15737
|
// Returns a mutable pointer to a map, array, or submessage value. If the given
|
|
15005
15738
|
// arena is non-NULL this will construct a new object if it was not previously
|
|
15006
15739
|
// present. May not be called for primitive fields.
|
|
15007
|
-
UPB_API upb_MutableMessageValue
|
|
15008
|
-
|
|
15009
|
-
upb_Arena* a);
|
|
15740
|
+
UPB_NODISCARD UPB_API upb_MutableMessageValue
|
|
15741
|
+
upb_Message_Mutable(upb_Message* msg, const upb_FieldDef* f, upb_Arena* a);
|
|
15010
15742
|
|
|
15011
15743
|
// Returns the field that is set in the oneof, or NULL if none are set.
|
|
15012
15744
|
UPB_API const upb_FieldDef* upb_Message_WhichOneofByDef(const upb_Message* msg,
|
|
@@ -15032,8 +15764,10 @@ UPB_API upb_MessageValue upb_Message_GetFieldByDef(const upb_Message* msg,
|
|
|
15032
15764
|
// the same arena or a different arena that outlives it).
|
|
15033
15765
|
//
|
|
15034
15766
|
// Returns false if allocation fails.
|
|
15035
|
-
UPB_API bool upb_Message_SetFieldByDef(upb_Message* msg,
|
|
15036
|
-
|
|
15767
|
+
UPB_NODISCARD UPB_API bool upb_Message_SetFieldByDef(upb_Message* msg,
|
|
15768
|
+
const upb_FieldDef* f,
|
|
15769
|
+
upb_MessageValue val,
|
|
15770
|
+
upb_Arena* a);
|
|
15037
15771
|
|
|
15038
15772
|
// Iterate over present fields.
|
|
15039
15773
|
//
|
|
@@ -15158,24 +15892,6 @@ UPB_INLINE int _upb_vsnprintf(char* buf, size_t size, const char* fmt,
|
|
|
15158
15892
|
|
|
15159
15893
|
#endif // UPB_PORT_VSNPRINTF_COMPAT_H_
|
|
15160
15894
|
|
|
15161
|
-
#ifndef UPB_LEX_STRTOD_H_
|
|
15162
|
-
#define UPB_LEX_STRTOD_H_
|
|
15163
|
-
|
|
15164
|
-
// Must be last.
|
|
15165
|
-
|
|
15166
|
-
#ifdef __cplusplus
|
|
15167
|
-
extern "C" {
|
|
15168
|
-
#endif
|
|
15169
|
-
|
|
15170
|
-
double _upb_NoLocaleStrtod(const char *str, char **endptr);
|
|
15171
|
-
|
|
15172
|
-
#ifdef __cplusplus
|
|
15173
|
-
} /* extern "C" */
|
|
15174
|
-
#endif
|
|
15175
|
-
|
|
15176
|
-
|
|
15177
|
-
#endif /* UPB_LEX_STRTOD_H_ */
|
|
15178
|
-
|
|
15179
15895
|
#ifndef UPB_PORT_ATOMIC_H_
|
|
15180
15896
|
#define UPB_PORT_ATOMIC_H_
|
|
15181
15897
|
|
|
@@ -15633,130 +16349,115 @@ bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Message_Internal* in,
|
|
|
15633
16349
|
|
|
15634
16350
|
#endif /* UPB_MESSAGE_INTERNAL_MAP_SORTER_H_ */
|
|
15635
16351
|
|
|
15636
|
-
#ifndef
|
|
15637
|
-
#define
|
|
16352
|
+
#ifndef UPB_MESSAGE_UNKNOWN_FIELDS_H_
|
|
16353
|
+
#define UPB_MESSAGE_UNKNOWN_FIELDS_H_
|
|
15638
16354
|
|
|
15639
16355
|
#include <stddef.h>
|
|
16356
|
+
#include <stdint.h>
|
|
15640
16357
|
|
|
15641
16358
|
|
|
15642
16359
|
// Must be last.
|
|
15643
16360
|
|
|
15644
|
-
enum {
|
|
15645
|
-
// If set, upb_Message_IsEqual() will attempt to compare unknown fields.
|
|
15646
|
-
// By its very nature this comparison is inexact.
|
|
15647
|
-
kUpb_CompareOption_IncludeUnknownFields = (1 << 0)
|
|
15648
|
-
};
|
|
15649
|
-
|
|
15650
16361
|
#ifdef __cplusplus
|
|
15651
16362
|
extern "C" {
|
|
15652
16363
|
#endif
|
|
15653
16364
|
|
|
15654
|
-
//
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
|
|
15661
|
-
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
15667
|
-
|
|
15668
|
-
|
|
15669
|
-
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
|
|
15675
|
-
|
|
15676
|
-
|
|
15677
|
-
|
|
15678
|
-
case kUpb_CType_Double:
|
|
15679
|
-
case kUpb_CType_Int64:
|
|
15680
|
-
case kUpb_CType_UInt64:
|
|
15681
|
-
return val1.int64_val == val2.int64_val;
|
|
15682
|
-
|
|
15683
|
-
case kUpb_CType_String:
|
|
15684
|
-
case kUpb_CType_Bytes:
|
|
15685
|
-
return upb_StringView_IsEqual(val1.str_val, val2.str_val);
|
|
15686
|
-
|
|
15687
|
-
case kUpb_CType_Message:
|
|
15688
|
-
return upb_Message_IsEqual(val1.msg_val, val2.msg_val, m, options);
|
|
15689
|
-
|
|
15690
|
-
default:
|
|
15691
|
-
UPB_UNREACHABLE();
|
|
15692
|
-
return false;
|
|
16365
|
+
// Support iteration over unknown (upb_MessageUnknown*), including unknown
|
|
16366
|
+
// upb_StringView and non-canonical extensions (upb_Extension*).
|
|
16367
|
+
UPB_INLINE bool upb_Message_NextUnknown2(const struct upb_Message* msg,
|
|
16368
|
+
struct upb_MessageUnknown* data,
|
|
16369
|
+
uintptr_t* iter) {
|
|
16370
|
+
const upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
|
16371
|
+
size_t i = *iter;
|
|
16372
|
+
if (in) {
|
|
16373
|
+
while (i < in->size) {
|
|
16374
|
+
upb_TaggedAuxPtr tagged_ptr = in->aux_data[i++];
|
|
16375
|
+
if (upb_TaggedAuxPtr_IsUnknownStringView(tagged_ptr)) {
|
|
16376
|
+
data->type = kUpb_MessageUnknownType_StringView;
|
|
16377
|
+
data->value.bytes = *upb_TaggedPtrAux_StringViewRepr(tagged_ptr);
|
|
16378
|
+
*iter = i;
|
|
16379
|
+
return true;
|
|
16380
|
+
} else if (upb_TaggedAuxPtr_IsNonCanonicalExtension(tagged_ptr)) {
|
|
16381
|
+
data->type = kUpb_MessageUnknownType_NonCanonicalExtension;
|
|
16382
|
+
data->value.extension =
|
|
16383
|
+
upb_TaggedAuxPtr_NonCanonicalExtension(tagged_ptr);
|
|
16384
|
+
*iter = i;
|
|
16385
|
+
return true;
|
|
16386
|
+
}
|
|
16387
|
+
}
|
|
15693
16388
|
}
|
|
16389
|
+
data->type = kUpb_MessageUnknownType_StringView;
|
|
16390
|
+
data->value.bytes.size = 0;
|
|
16391
|
+
data->value.bytes.data = NULL;
|
|
16392
|
+
*iter = i;
|
|
16393
|
+
return false;
|
|
15694
16394
|
}
|
|
15695
16395
|
|
|
15696
|
-
|
|
15697
|
-
|
|
15698
|
-
|
|
15699
|
-
|
|
15700
|
-
|
|
15701
|
-
#endif // UPB_MESSAGE_COMPARE_H_
|
|
15702
|
-
|
|
15703
|
-
#ifndef UPB_MESSAGE_INTERNAL_COMPARE_UNKNOWN_H_
|
|
15704
|
-
#define UPB_MESSAGE_INTERNAL_COMPARE_UNKNOWN_H_
|
|
15705
|
-
|
|
15706
|
-
#include <stddef.h>
|
|
15707
|
-
|
|
15708
|
-
// Must be last.
|
|
15709
|
-
|
|
15710
|
-
#ifdef __cplusplus
|
|
15711
|
-
extern "C" {
|
|
15712
|
-
#endif
|
|
16396
|
+
typedef enum {
|
|
16397
|
+
kUpb_FindUnknown_Ok,
|
|
16398
|
+
kUpb_FindUnknown_NotPresent,
|
|
16399
|
+
kUpb_FindUnknown_ParseError,
|
|
16400
|
+
} upb_FindUnknown_Status;
|
|
15713
16401
|
|
|
15714
|
-
|
|
15715
|
-
|
|
16402
|
+
typedef struct {
|
|
16403
|
+
upb_FindUnknown_Status status;
|
|
16404
|
+
struct upb_MessageUnknown unknown;
|
|
16405
|
+
uintptr_t iter;
|
|
16406
|
+
} upb_FindUnknownRet2;
|
|
16407
|
+
|
|
16408
|
+
// Finds first occurrence of unknown data (upb_MessageUnknown) by tag id in
|
|
16409
|
+
// message, including unknown upb_StringView and non-canonical extensions
|
|
16410
|
+
// (upb_Extension*).
|
|
15716
16411
|
//
|
|
15717
|
-
//
|
|
15718
|
-
//
|
|
16412
|
+
// If multiple matching entries exist for the same field number (e.g. both a
|
|
16413
|
+
// raw unknown upb_StringView and a non-canonical extension), this function
|
|
16414
|
+
// returns the one encountered first in internal iteration order (which follows
|
|
16415
|
+
// the order they were added or parsed).
|
|
15719
16416
|
//
|
|
15720
|
-
//
|
|
15721
|
-
|
|
15722
|
-
|
|
15723
|
-
|
|
15724
|
-
// discard every value except the last.
|
|
15725
|
-
|
|
15726
|
-
typedef enum {
|
|
15727
|
-
kUpb_UnknownCompareResult_Equal = 0,
|
|
15728
|
-
kUpb_UnknownCompareResult_NotEqual = 1,
|
|
15729
|
-
kUpb_UnknownCompareResult_OutOfMemory = 2,
|
|
15730
|
-
kUpb_UnknownCompareResult_MaxDepthExceeded = 3,
|
|
15731
|
-
} upb_UnknownCompareResult;
|
|
16417
|
+
// A depth_limit of zero means to just use the upb default depth limit.
|
|
16418
|
+
upb_FindUnknownRet2 upb_Message_FindUnknown2(const struct upb_Message* msg,
|
|
16419
|
+
uint32_t field_number,
|
|
16420
|
+
int depth_limit);
|
|
15732
16421
|
|
|
15733
|
-
|
|
15734
|
-
|
|
16422
|
+
// Removes a segment of unknown data from the message, advancing to the next
|
|
16423
|
+
// segment. Returns false if the removed segment was at the end of the last
|
|
16424
|
+
// chunk.
|
|
16425
|
+
//
|
|
16426
|
+
// This must be done while iterating:
|
|
16427
|
+
//
|
|
16428
|
+
// uintptr_t iter = kUpb_Message_UnknownBegin;
|
|
16429
|
+
// upb_MessageUnknown data;
|
|
16430
|
+
// // Iterate chunks
|
|
16431
|
+
// while (upb_Message_NextUnknown2(msg, &data, &iter)) {
|
|
16432
|
+
// // Iterate within a chunk, deleting ranges
|
|
16433
|
+
// while (ShouldDeleteSubSegment(&data)) {
|
|
16434
|
+
// // Data now points to the region to be deleted
|
|
16435
|
+
// switch (upb_Message_DeleteUnknown2(msg, &data, &iter)) {
|
|
16436
|
+
// case kUpb_Message_DeleteUnknown_DeletedLast: return ok;
|
|
16437
|
+
// case kUpb_Message_DeleteUnknown_IterUpdated: break;
|
|
16438
|
+
// // If DeleteUnknown returned kUpb_Message_DeleteUnknown_IterUpdated,
|
|
16439
|
+
// // then data now points to the remaining unknown fields after the
|
|
16440
|
+
// // region that was just deleted.
|
|
16441
|
+
// case kUpb_Message_DeleteUnknown_AllocFail: return err;
|
|
16442
|
+
// }
|
|
16443
|
+
// }
|
|
16444
|
+
// }
|
|
16445
|
+
//
|
|
16446
|
+
// The range given in `data` must be contained inside the most recently
|
|
16447
|
+
// returned region.
|
|
16448
|
+
//
|
|
16449
|
+
// Support deletion of unknown (upb_MessageUnknown*), including unknown
|
|
16450
|
+
// upb_StringView and non-canonical extensions (upb_Extension*).
|
|
16451
|
+
UPB_NODISCARD upb_Message_DeleteUnknownStatus upb_Message_DeleteUnknown2(
|
|
16452
|
+
struct upb_Message* msg, struct upb_MessageUnknown* data, uintptr_t* iter,
|
|
16453
|
+
struct upb_Arena* arena);
|
|
15735
16454
|
|
|
15736
16455
|
#ifdef __cplusplus
|
|
15737
16456
|
} /* extern "C" */
|
|
15738
16457
|
#endif
|
|
15739
16458
|
|
|
15740
16459
|
|
|
15741
|
-
#endif /*
|
|
15742
|
-
|
|
15743
|
-
#ifndef GOOGLE_UPB_UPB_MESSAGE_INTERNAL_ITERATOR_H__
|
|
15744
|
-
#define GOOGLE_UPB_UPB_MESSAGE_INTERNAL_ITERATOR_H__
|
|
15745
|
-
|
|
15746
|
-
#include <stddef.h>
|
|
15747
|
-
#include <stdint.h>
|
|
15748
|
-
|
|
15749
|
-
|
|
15750
|
-
// Must be last.
|
|
15751
|
-
|
|
15752
|
-
#define kUpb_BaseField_Begin ((size_t)-1)
|
|
15753
|
-
bool UPB_PRIVATE(_upb_Message_NextBaseField)(const upb_Message* msg,
|
|
15754
|
-
const upb_MiniTable* m,
|
|
15755
|
-
const upb_MiniTableField** out_f,
|
|
15756
|
-
upb_MessageValue* out_v,
|
|
15757
|
-
uintptr_t* iter);
|
|
15758
|
-
|
|
15759
|
-
#endif // GOOGLE_UPB_UPB_MESSAGE_INTERNAL_ITERATOR_H__
|
|
16460
|
+
#endif /* UPB_MESSAGE_UNKNOWN_FIELDS_H_ */
|
|
15760
16461
|
|
|
15761
16462
|
#ifndef UPB_WIRE_EPS_COPY_INPUT_STREAM_H_
|
|
15762
16463
|
#define UPB_WIRE_EPS_COPY_INPUT_STREAM_H_
|
|
@@ -15765,77 +16466,6 @@ bool UPB_PRIVATE(_upb_Message_NextBaseField)(const upb_Message* msg,
|
|
|
15765
16466
|
#include <stdint.h>
|
|
15766
16467
|
|
|
15767
16468
|
|
|
15768
|
-
#ifndef GOOGLE_UPB_UPB_BASE_ERROR_HANDLER_H__
|
|
15769
|
-
#define GOOGLE_UPB_UPB_BASE_ERROR_HANDLER_H__
|
|
15770
|
-
|
|
15771
|
-
#include <setjmp.h>
|
|
15772
|
-
|
|
15773
|
-
// Must be last.
|
|
15774
|
-
|
|
15775
|
-
// upb_ErrorHandler is a standard longjmp()-based exception handler for UPB.
|
|
15776
|
-
// It is used for efficient error handling in cases where longjmp() is safe to
|
|
15777
|
-
// use, such as in highly performance-sensitive C parsing code.
|
|
15778
|
-
//
|
|
15779
|
-
// This structure contains both a jmp_buf and an error code; the error code is
|
|
15780
|
-
// stored in the structure prior to calling longjmp(). This is necessary because
|
|
15781
|
-
// per the C standard, it is not possible to store the result of setjmp(), so
|
|
15782
|
-
// the error code must be passed out-of-band.
|
|
15783
|
-
//
|
|
15784
|
-
// upb_ErrorHandler is generally not C++-compatible, because longjmp() does not
|
|
15785
|
-
// run C++ destructors. So any library that supports upb_ErrorHandler should
|
|
15786
|
-
// also support a regular return-based error handling mechanism. (Note: we
|
|
15787
|
-
// could conceivably extend this to take a callback, which could either call
|
|
15788
|
-
// longjmp() or throw a C++ exception. But since C++ exceptions are forbidden
|
|
15789
|
-
// by the C++ style guide, there's not likely to be a demand for this.)
|
|
15790
|
-
//
|
|
15791
|
-
// To support both cases (longjmp() or return-based status) efficiently, code
|
|
15792
|
-
// can be written like this:
|
|
15793
|
-
//
|
|
15794
|
-
// UPB_ATTR_CONST bool upb_Arena_HasErrHandler(const upb_Arena* a);
|
|
15795
|
-
//
|
|
15796
|
-
// INLINE void* upb_Arena_Malloc(upb_Arena* a, size_t size) {
|
|
15797
|
-
// if (UPB_UNLIKELY(a->end - a->ptr < size)) {
|
|
15798
|
-
// void* ret = upb_Arena_MallocFallback(a, size);
|
|
15799
|
-
// UPB_MAYBE_ASSUME(upb_Arena_HasErrHandler(a), ret != NULL);
|
|
15800
|
-
// return ret;
|
|
15801
|
-
// }
|
|
15802
|
-
// void* ret = a->ptr;
|
|
15803
|
-
// a->ptr += size;
|
|
15804
|
-
// UPB_ASSUME(ret != NULL);
|
|
15805
|
-
// return ret;
|
|
15806
|
-
// }
|
|
15807
|
-
//
|
|
15808
|
-
// If the optimizer can prove that an error handler is present, it can assume
|
|
15809
|
-
// that upb_Arena_Malloc() will not return NULL.
|
|
15810
|
-
|
|
15811
|
-
// We need to standardize on any error code that might be thrown by an error
|
|
15812
|
-
// handler.
|
|
15813
|
-
|
|
15814
|
-
typedef enum {
|
|
15815
|
-
kUpb_ErrorCode_Ok = 0,
|
|
15816
|
-
kUpb_ErrorCode_OutOfMemory = 1,
|
|
15817
|
-
kUpb_ErrorCode_Malformed = 2,
|
|
15818
|
-
} upb_ErrorCode;
|
|
15819
|
-
|
|
15820
|
-
typedef struct {
|
|
15821
|
-
int code;
|
|
15822
|
-
jmp_buf buf;
|
|
15823
|
-
} upb_ErrorHandler;
|
|
15824
|
-
|
|
15825
|
-
UPB_INLINE void upb_ErrorHandler_Init(upb_ErrorHandler* e) {
|
|
15826
|
-
e->code = kUpb_ErrorCode_Ok;
|
|
15827
|
-
}
|
|
15828
|
-
|
|
15829
|
-
UPB_INLINE UPB_NORETURN void upb_ErrorHandler_ThrowError(upb_ErrorHandler* e,
|
|
15830
|
-
int code) {
|
|
15831
|
-
UPB_ASSERT(code != kUpb_ErrorCode_Ok);
|
|
15832
|
-
e->code = code;
|
|
15833
|
-
UPB_LONGJMP(e->buf, 1);
|
|
15834
|
-
}
|
|
15835
|
-
|
|
15836
|
-
|
|
15837
|
-
#endif // GOOGLE_UPB_UPB_BASE_ERROR_HANDLER_H__
|
|
15838
|
-
|
|
15839
16469
|
#ifndef UPB_WIRE_INTERNAL_EPS_COPY_INPUT_STREAM_H_
|
|
15840
16470
|
#define UPB_WIRE_INTERNAL_EPS_COPY_INPUT_STREAM_H_
|
|
15841
16471
|
|
|
@@ -15860,15 +16490,18 @@ extern "C" {
|
|
|
15860
16490
|
// efficient fixed size copies.
|
|
15861
16491
|
#define kUpb_EpsCopyInputStream_SlopBytes 16
|
|
15862
16492
|
|
|
16493
|
+
struct upb_EpsCopyCapture {
|
|
16494
|
+
const char* start; // Pointer to the beginning of the captured region.
|
|
16495
|
+
};
|
|
16496
|
+
|
|
15863
16497
|
struct upb_EpsCopyInputStream {
|
|
15864
16498
|
const char* end; // Can read up to SlopBytes bytes beyond this.
|
|
15865
16499
|
const char* limit_ptr; // For bounds checks, = end + UPB_MIN(limit, 0)
|
|
15866
16500
|
uintptr_t input_delta; // Diff between the original input pointer and patch
|
|
15867
|
-
const char* buffer_start;
|
|
15868
|
-
|
|
15869
|
-
|
|
15870
|
-
|
|
15871
|
-
bool error; // To distinguish between EOF and error.
|
|
16501
|
+
const char* buffer_start; // Pointer to the original input buffer
|
|
16502
|
+
ptrdiff_t limit; // Submessage limit relative to end
|
|
16503
|
+
upb_ErrorHandler* err; // Error handler to use when things go wrong.
|
|
16504
|
+
bool error; // To distinguish between EOF and error.
|
|
15872
16505
|
#ifndef NDEBUG
|
|
15873
16506
|
int guaranteed_bytes;
|
|
15874
16507
|
#endif
|
|
@@ -15890,7 +16523,6 @@ UPB_INLINE void upb_EpsCopyInputStream_InitWithErrorHandler(
|
|
|
15890
16523
|
struct upb_EpsCopyInputStream* e, const char** ptr, size_t size,
|
|
15891
16524
|
upb_ErrorHandler* err) {
|
|
15892
16525
|
e->buffer_start = *ptr;
|
|
15893
|
-
e->capture_start = NULL;
|
|
15894
16526
|
e->err = err;
|
|
15895
16527
|
if (size <= kUpb_EpsCopyInputStream_SlopBytes) {
|
|
15896
16528
|
memset(&e->patch, 0, 32);
|
|
@@ -15920,11 +16552,21 @@ UPB_INLINE bool upb_EpsCopyInputStream_HasErrorHandler(
|
|
|
15920
16552
|
return e && e->err != NULL;
|
|
15921
16553
|
}
|
|
15922
16554
|
|
|
16555
|
+
UPB_NORETURN UPB_NOINLINE void UPB_PRIVATE(
|
|
16556
|
+
upb_EpsCopyInputStream_ThrowMalformed)(struct upb_EpsCopyInputStream* e);
|
|
16557
|
+
|
|
15923
16558
|
// Call this function to signal an error. If an error handler is set, it will be
|
|
15924
16559
|
// called and the function will never return. Otherwise, returns NULL to
|
|
15925
16560
|
// indicate an error.
|
|
15926
|
-
const char* UPB_PRIVATE(upb_EpsCopyInputStream_ReturnError)(
|
|
15927
|
-
struct upb_EpsCopyInputStream* e)
|
|
16561
|
+
UPB_INLINE const char* UPB_PRIVATE(upb_EpsCopyInputStream_ReturnError)(
|
|
16562
|
+
struct upb_EpsCopyInputStream* e) {
|
|
16563
|
+
if (e->err) {
|
|
16564
|
+
UPB_PRIVATE(upb_EpsCopyInputStream_ThrowMalformed)(e);
|
|
16565
|
+
} else {
|
|
16566
|
+
e->error = true;
|
|
16567
|
+
}
|
|
16568
|
+
return NULL;
|
|
16569
|
+
}
|
|
15928
16570
|
|
|
15929
16571
|
UPB_INLINE const char* UPB_PRIVATE(upb_EpsCopyInputStream_AssumeResult)(
|
|
15930
16572
|
struct upb_EpsCopyInputStream* e, const char* ptr) {
|
|
@@ -16044,22 +16686,21 @@ UPB_INLINE const char* UPB_PRIVATE(upb_EpsCopyInputStream_GetInputPtr)(
|
|
|
16044
16686
|
return e->buffer_start + position;
|
|
16045
16687
|
}
|
|
16046
16688
|
|
|
16047
|
-
UPB_INLINE void
|
|
16048
|
-
|
|
16049
|
-
|
|
16050
|
-
|
|
16689
|
+
UPB_INLINE void upb_EpsCopyCapture_Start(struct upb_EpsCopyCapture* c,
|
|
16690
|
+
struct upb_EpsCopyInputStream* e,
|
|
16691
|
+
const char* ptr) {
|
|
16692
|
+
c->start = UPB_PRIVATE(upb_EpsCopyInputStream_GetInputPtr)(e, ptr);
|
|
16051
16693
|
}
|
|
16052
16694
|
|
|
16053
|
-
UPB_INLINE bool
|
|
16054
|
-
|
|
16055
|
-
|
|
16695
|
+
UPB_INLINE bool upb_EpsCopyCapture_End(struct upb_EpsCopyCapture* c,
|
|
16696
|
+
struct upb_EpsCopyInputStream* e,
|
|
16697
|
+
const char* ptr, upb_StringView* sv) {
|
|
16056
16698
|
if (ptr - e->end > e->limit) {
|
|
16057
16699
|
return UPB_PRIVATE(upb_EpsCopyInputStream_ReturnError)(e);
|
|
16058
16700
|
}
|
|
16059
16701
|
const char* end = UPB_PRIVATE(upb_EpsCopyInputStream_GetInputPtr)(e, ptr);
|
|
16060
|
-
sv->data =
|
|
16702
|
+
sv->data = c->start;
|
|
16061
16703
|
sv->size = end - sv->data;
|
|
16062
|
-
e->capture_start = NULL;
|
|
16063
16704
|
return true;
|
|
16064
16705
|
}
|
|
16065
16706
|
|
|
@@ -16147,7 +16788,7 @@ UPB_FORCEINLINE bool upb_EpsCopyInputStream_TryParseDelimitedFast(
|
|
|
16147
16788
|
// Fast case: Sub-message is <128 bytes and fits in the current buffer.
|
|
16148
16789
|
// This means we can preserve limit/limit_ptr verbatim.
|
|
16149
16790
|
const char* saved_limit_ptr = e->limit_ptr;
|
|
16150
|
-
|
|
16791
|
+
ptrdiff_t saved_limit = e->limit;
|
|
16151
16792
|
e->limit_ptr = *ptr + size;
|
|
16152
16793
|
e->limit = e->limit_ptr - e->end;
|
|
16153
16794
|
UPB_ASSERT(e->limit_ptr == e->end + UPB_MIN(0, e->limit));
|
|
@@ -16171,6 +16812,7 @@ UPB_FORCEINLINE bool upb_EpsCopyInputStream_TryParseDelimitedFast(
|
|
|
16171
16812
|
extern "C" {
|
|
16172
16813
|
#endif
|
|
16173
16814
|
|
|
16815
|
+
typedef struct upb_EpsCopyCapture upb_EpsCopyCapture;
|
|
16174
16816
|
typedef struct upb_EpsCopyInputStream upb_EpsCopyInputStream;
|
|
16175
16817
|
|
|
16176
16818
|
// Initializes a upb_EpsCopyInputStream using the contents of the buffer
|
|
@@ -16224,19 +16866,19 @@ UPB_INLINE bool upb_EpsCopyInputStream_IsDone(upb_EpsCopyInputStream* e,
|
|
|
16224
16866
|
UPB_INLINE bool upb_EpsCopyInputStream_CheckSize(
|
|
16225
16867
|
const upb_EpsCopyInputStream* e, const char* ptr, int size);
|
|
16226
16868
|
|
|
16227
|
-
// Marks the start of a capture operation.
|
|
16228
|
-
//
|
|
16229
|
-
//
|
|
16230
|
-
|
|
16231
|
-
|
|
16232
|
-
|
|
16869
|
+
// Marks the start of a capture operation. The capture operation will be
|
|
16870
|
+
// finalized by a call to upb_EpsCopyCapture_End(). The captured string will
|
|
16871
|
+
// be returned in sv, and will point to the original input buffer if possible.
|
|
16872
|
+
UPB_INLINE void upb_EpsCopyCapture_Start(upb_EpsCopyCapture* c,
|
|
16873
|
+
upb_EpsCopyInputStream* e,
|
|
16874
|
+
const char* ptr);
|
|
16233
16875
|
|
|
16234
|
-
// Ends a capture operation and returns the captured string.
|
|
16235
|
-
//
|
|
16236
|
-
//
|
|
16237
|
-
UPB_INLINE bool
|
|
16238
|
-
|
|
16239
|
-
|
|
16876
|
+
// Ends a capture operation and returns the captured string. Returns false if
|
|
16877
|
+
// the capture operation was invalid (the parsing pointer extends beyond the
|
|
16878
|
+
// end of the stream).
|
|
16879
|
+
UPB_INLINE bool upb_EpsCopyCapture_End(upb_EpsCopyCapture* c,
|
|
16880
|
+
upb_EpsCopyInputStream* e,
|
|
16881
|
+
const char* ptr, upb_StringView* sv);
|
|
16240
16882
|
|
|
16241
16883
|
// Reads a string from the stream and advances the pointer accordingly. The
|
|
16242
16884
|
// returned string view will always alias the input buffer.
|
|
@@ -16471,8 +17113,14 @@ UPB_FORCEINLINE const char* upb_WireReader_ReadVarint(
|
|
|
16471
17113
|
// by calling upb_EpsCopyInputStream_IsDone().
|
|
16472
17114
|
UPB_INLINE const char* upb_WireReader_SkipVarint(
|
|
16473
17115
|
const char* ptr, upb_EpsCopyInputStream* stream) {
|
|
16474
|
-
|
|
16475
|
-
|
|
17116
|
+
UPB_PRIVATE(upb_EpsCopyInputStream_ConsumeBytes)(stream, 10);
|
|
17117
|
+
const char* bound = ptr + 10;
|
|
17118
|
+
do {
|
|
17119
|
+
if ((*(ptr++) & 0x80) == 0) {
|
|
17120
|
+
return ptr;
|
|
17121
|
+
}
|
|
17122
|
+
} while (ptr != bound);
|
|
17123
|
+
return UPB_PRIVATE(upb_EpsCopyInputStream_ReturnError)(stream);
|
|
16476
17124
|
}
|
|
16477
17125
|
|
|
16478
17126
|
// Reads a varint indicating the size of a delimited field into `size`, or
|
|
@@ -16534,7 +17182,7 @@ UPB_INLINE const char* upb_WireReader_SkipGroup(
|
|
|
16534
17182
|
return UPB_PRIVATE(upb_EpsCopyInputStream_AssumeResult)(stream, ret);
|
|
16535
17183
|
}
|
|
16536
17184
|
|
|
16537
|
-
|
|
17185
|
+
UPB_FORCEINLINE const char* _upb_WireReader_SkipValueForceInline(
|
|
16538
17186
|
const char* ptr, uint32_t tag, int depth_limit,
|
|
16539
17187
|
upb_EpsCopyInputStream* stream) {
|
|
16540
17188
|
switch (upb_WireReader_GetWireType(tag)) {
|
|
@@ -16566,6 +17214,12 @@ UPB_INLINE const char* _upb_WireReader_SkipValue(
|
|
|
16566
17214
|
}
|
|
16567
17215
|
}
|
|
16568
17216
|
|
|
17217
|
+
UPB_INLINE const char* _upb_WireReader_SkipValue(
|
|
17218
|
+
const char* ptr, uint32_t tag, int depth_limit,
|
|
17219
|
+
upb_EpsCopyInputStream* stream) {
|
|
17220
|
+
return _upb_WireReader_SkipValueForceInline(ptr, tag, depth_limit, stream);
|
|
17221
|
+
}
|
|
17222
|
+
|
|
16569
17223
|
// Skips data for a wire value of any type, returning a pointer past the end of
|
|
16570
17224
|
// the data, or NULL if there was an error parsing the group. The `tag` argument
|
|
16571
17225
|
// should be the tag that was just parsed. The `depth_limit` argument indicates
|
|
@@ -16590,41 +17244,178 @@ UPB_INLINE const char* upb_WireReader_SkipValue(
|
|
|
16590
17244
|
|
|
16591
17245
|
#endif // UPB_WIRE_READER_H_
|
|
16592
17246
|
|
|
16593
|
-
#ifndef
|
|
16594
|
-
#define
|
|
17247
|
+
#ifndef UPB_MESSAGE_COMPARE_H_
|
|
17248
|
+
#define UPB_MESSAGE_COMPARE_H_
|
|
16595
17249
|
|
|
17250
|
+
#include <stddef.h>
|
|
16596
17251
|
|
|
16597
|
-
// Must be last.
|
|
16598
17252
|
|
|
16599
|
-
|
|
16600
|
-
|
|
16601
|
-
|
|
17253
|
+
// Must be last.
|
|
17254
|
+
|
|
17255
|
+
enum {
|
|
17256
|
+
// If set, upb_Message_IsEqual() will attempt to compare unknown fields.
|
|
17257
|
+
// By its very nature this comparison is inexact.
|
|
17258
|
+
kUpb_CompareOption_IncludeUnknownFields = (1 << 0)
|
|
17259
|
+
};
|
|
17260
|
+
|
|
17261
|
+
#ifdef __cplusplus
|
|
17262
|
+
extern "C" {
|
|
17263
|
+
#endif
|
|
17264
|
+
|
|
17265
|
+
// Returns true if no known fields or extensions are set in the message.
|
|
17266
|
+
UPB_API bool upb_Message_IsEmpty(const upb_Message* msg,
|
|
17267
|
+
const upb_MiniTable* m);
|
|
17268
|
+
|
|
17269
|
+
UPB_API bool upb_Message_IsEqual(const upb_Message* msg1,
|
|
17270
|
+
const upb_Message* msg2,
|
|
17271
|
+
const upb_MiniTable* m, int options);
|
|
17272
|
+
|
|
17273
|
+
// If |ctype| is a message then |m| must point to its minitable.
|
|
17274
|
+
UPB_API_INLINE bool upb_MessageValue_IsEqual(upb_MessageValue val1,
|
|
17275
|
+
upb_MessageValue val2,
|
|
17276
|
+
upb_CType ctype,
|
|
17277
|
+
const upb_MiniTable* m,
|
|
17278
|
+
int options) {
|
|
17279
|
+
switch (ctype) {
|
|
17280
|
+
case kUpb_CType_Bool:
|
|
17281
|
+
return val1.bool_val == val2.bool_val;
|
|
17282
|
+
|
|
17283
|
+
case kUpb_CType_Float:
|
|
17284
|
+
case kUpb_CType_Int32:
|
|
17285
|
+
case kUpb_CType_UInt32:
|
|
17286
|
+
case kUpb_CType_Enum:
|
|
17287
|
+
return val1.int32_val == val2.int32_val;
|
|
17288
|
+
|
|
17289
|
+
case kUpb_CType_Double:
|
|
17290
|
+
case kUpb_CType_Int64:
|
|
17291
|
+
case kUpb_CType_UInt64:
|
|
17292
|
+
return val1.int64_val == val2.int64_val;
|
|
17293
|
+
|
|
17294
|
+
case kUpb_CType_String:
|
|
17295
|
+
case kUpb_CType_Bytes:
|
|
17296
|
+
return upb_StringView_IsEqual(val1.str_val, val2.str_val);
|
|
17297
|
+
|
|
17298
|
+
case kUpb_CType_Message:
|
|
17299
|
+
return upb_Message_IsEqual(val1.msg_val, val2.msg_val, m, options);
|
|
17300
|
+
|
|
17301
|
+
default:
|
|
17302
|
+
UPB_UNREACHABLE();
|
|
17303
|
+
return false;
|
|
17304
|
+
}
|
|
17305
|
+
}
|
|
17306
|
+
|
|
17307
|
+
#ifdef __cplusplus
|
|
17308
|
+
} /* extern "C" */
|
|
17309
|
+
#endif
|
|
17310
|
+
|
|
17311
|
+
|
|
17312
|
+
#endif // UPB_MESSAGE_COMPARE_H_
|
|
17313
|
+
|
|
17314
|
+
#ifndef UPB_MESSAGE_INTERNAL_COMPARE_UNKNOWN_H_
|
|
17315
|
+
#define UPB_MESSAGE_INTERNAL_COMPARE_UNKNOWN_H_
|
|
17316
|
+
|
|
17317
|
+
#include <stddef.h>
|
|
17318
|
+
|
|
17319
|
+
// Must be last.
|
|
17320
|
+
|
|
17321
|
+
#ifdef __cplusplus
|
|
17322
|
+
extern "C" {
|
|
17323
|
+
#endif
|
|
17324
|
+
|
|
17325
|
+
// Returns true if unknown fields from the two messages are equal when sorted
|
|
17326
|
+
// and varints are made canonical.
|
|
17327
|
+
//
|
|
17328
|
+
// This function is discouraged, as the comparison is inherently lossy without
|
|
17329
|
+
// schema data:
|
|
17330
|
+
//
|
|
17331
|
+
// 1. We don't know whether delimited fields are sub-messages. Unknown
|
|
17332
|
+
// sub-messages will therefore not have their fields sorted and varints
|
|
17333
|
+
// canonicalized.
|
|
17334
|
+
// 2. We don't know about oneof/non-repeated fields, which should semantically
|
|
17335
|
+
// discard every value except the last.
|
|
17336
|
+
|
|
17337
|
+
typedef enum {
|
|
17338
|
+
kUpb_UnknownCompareResult_Equal = 0,
|
|
17339
|
+
kUpb_UnknownCompareResult_NotEqual = 1,
|
|
17340
|
+
kUpb_UnknownCompareResult_OutOfMemory = 2,
|
|
17341
|
+
kUpb_UnknownCompareResult_MaxDepthExceeded = 3,
|
|
17342
|
+
} upb_UnknownCompareResult;
|
|
17343
|
+
|
|
17344
|
+
upb_UnknownCompareResult UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)(
|
|
17345
|
+
const upb_Message* msg1, const upb_Message* msg2, int max_depth);
|
|
17346
|
+
|
|
17347
|
+
#ifdef __cplusplus
|
|
17348
|
+
} /* extern "C" */
|
|
17349
|
+
#endif
|
|
17350
|
+
|
|
17351
|
+
|
|
17352
|
+
#endif /* UPB_MESSAGE_INTERNAL_COMPARE_UNKNOWN_H_ */
|
|
17353
|
+
|
|
17354
|
+
#ifndef GOOGLE_UPB_UPB_MESSAGE_INTERNAL_ITERATOR_H__
|
|
17355
|
+
#define GOOGLE_UPB_UPB_MESSAGE_INTERNAL_ITERATOR_H__
|
|
17356
|
+
|
|
17357
|
+
#include <stddef.h>
|
|
17358
|
+
#include <stdint.h>
|
|
17359
|
+
|
|
17360
|
+
|
|
17361
|
+
// Must be last.
|
|
17362
|
+
|
|
17363
|
+
#define kUpb_BaseField_Begin ((size_t)-1)
|
|
17364
|
+
bool UPB_PRIVATE(_upb_Message_NextBaseField)(const upb_Message* msg,
|
|
17365
|
+
const upb_MiniTable* m,
|
|
17366
|
+
const upb_MiniTableField** out_f,
|
|
17367
|
+
upb_MessageValue* out_v,
|
|
17368
|
+
uintptr_t* iter);
|
|
17369
|
+
|
|
17370
|
+
#endif // GOOGLE_UPB_UPB_MESSAGE_INTERNAL_ITERATOR_H__
|
|
17371
|
+
|
|
17372
|
+
#ifndef UPB_MESSAGE_COPY_H_
|
|
17373
|
+
#define UPB_MESSAGE_COPY_H_
|
|
17374
|
+
|
|
17375
|
+
|
|
17376
|
+
// Must be last.
|
|
17377
|
+
|
|
17378
|
+
#ifdef __cplusplus
|
|
17379
|
+
extern "C" {
|
|
17380
|
+
#endif
|
|
16602
17381
|
|
|
16603
17382
|
// Deep clones a message using the provided target arena.
|
|
16604
|
-
upb_Message* upb_Message_DeepClone(const upb_Message* msg,
|
|
16605
|
-
|
|
17383
|
+
UPB_NODISCARD upb_Message* upb_Message_DeepClone(const upb_Message* msg,
|
|
17384
|
+
const upb_MiniTable* m,
|
|
17385
|
+
upb_Arena* arena);
|
|
16606
17386
|
|
|
16607
17387
|
// Shallow clones a message using the provided target arena.
|
|
16608
|
-
|
|
16609
|
-
|
|
17388
|
+
// `msg` must outlive the returned message since all strings, repeated fields,
|
|
17389
|
+
// maps, and unknown fields will alias the original message.
|
|
17390
|
+
UPB_NODISCARD upb_Message* upb_Message_ShallowClone(const upb_Message* msg,
|
|
17391
|
+
const upb_MiniTable* m,
|
|
17392
|
+
upb_Arena* arena);
|
|
16610
17393
|
|
|
16611
17394
|
// Deep clones array contents.
|
|
16612
|
-
upb_Array* upb_Array_DeepClone(const upb_Array* array,
|
|
16613
|
-
|
|
17395
|
+
UPB_NODISCARD upb_Array* upb_Array_DeepClone(const upb_Array* array,
|
|
17396
|
+
upb_CType value_type,
|
|
17397
|
+
const upb_MiniTable* sub,
|
|
17398
|
+
upb_Arena* arena);
|
|
16614
17399
|
|
|
16615
17400
|
// Deep clones map contents.
|
|
16616
|
-
upb_Map* upb_Map_DeepClone(const upb_Map* map, upb_CType key_type,
|
|
16617
|
-
|
|
16618
|
-
|
|
16619
|
-
|
|
17401
|
+
UPB_NODISCARD upb_Map* upb_Map_DeepClone(const upb_Map* map, upb_CType key_type,
|
|
17402
|
+
upb_CType value_type,
|
|
17403
|
+
const upb_MiniTable* map_entry_table,
|
|
17404
|
+
upb_Arena* arena);
|
|
16620
17405
|
|
|
16621
17406
|
// Deep copies the message from src to dst.
|
|
16622
|
-
bool upb_Message_DeepCopy(upb_Message* dst,
|
|
16623
|
-
|
|
17407
|
+
UPB_NODISCARD bool upb_Message_DeepCopy(upb_Message* dst,
|
|
17408
|
+
const upb_Message* src,
|
|
17409
|
+
const upb_MiniTable* m,
|
|
17410
|
+
upb_Arena* arena);
|
|
16624
17411
|
|
|
16625
17412
|
// Shallow copies the message from src to dst.
|
|
16626
|
-
|
|
16627
|
-
|
|
17413
|
+
// `src` must outlive `dst` since all strings, repeated fields, maps, and
|
|
17414
|
+
// unknown fields will alias the original message.
|
|
17415
|
+
UPB_NODISCARD UPB_API bool upb_Message_ShallowCopy(upb_Message* dst,
|
|
17416
|
+
const upb_Message* src,
|
|
17417
|
+
const upb_MiniTable* m,
|
|
17418
|
+
upb_Arena* arena);
|
|
16628
17419
|
|
|
16629
17420
|
#ifdef __cplusplus
|
|
16630
17421
|
} /* extern "C" */
|
|
@@ -16642,10 +17433,9 @@ void upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src,
|
|
|
16642
17433
|
extern "C" {
|
|
16643
17434
|
#endif
|
|
16644
17435
|
|
|
16645
|
-
UPB_API bool upb_Message_MergeFrom(
|
|
16646
|
-
|
|
16647
|
-
|
|
16648
|
-
upb_Arena* arena);
|
|
17436
|
+
UPB_NODISCARD UPB_API bool upb_Message_MergeFrom(
|
|
17437
|
+
upb_Message* dst, const upb_Message* src, const upb_MiniTable* mt,
|
|
17438
|
+
const upb_ExtensionRegistry* extreg, upb_Arena* arena);
|
|
16649
17439
|
|
|
16650
17440
|
#ifdef __cplusplus
|
|
16651
17441
|
} /* extern "C" */
|
|
@@ -17026,6 +17816,60 @@ const upb_ExtensionRegistry* _upb_DefPool_GeneratedExtensionRegistry(
|
|
|
17026
17816
|
|
|
17027
17817
|
#endif /* UPB_REFLECTION_DEF_POOL_INTERNAL_H_ */
|
|
17028
17818
|
|
|
17819
|
+
#ifndef UPB_REFLECTION_DEF_TYPE_H_
|
|
17820
|
+
#define UPB_REFLECTION_DEF_TYPE_H_
|
|
17821
|
+
|
|
17822
|
+
|
|
17823
|
+
// Must be last.
|
|
17824
|
+
|
|
17825
|
+
// Inside a symtab we store tagged pointers to specific def types.
|
|
17826
|
+
typedef enum {
|
|
17827
|
+
UPB_DEFTYPE_MASK = 7,
|
|
17828
|
+
|
|
17829
|
+
// Only inside symtab table.
|
|
17830
|
+
UPB_DEFTYPE_EXT = 0,
|
|
17831
|
+
UPB_DEFTYPE_MSG = 1,
|
|
17832
|
+
UPB_DEFTYPE_ENUM = 2,
|
|
17833
|
+
UPB_DEFTYPE_ENUMVAL = 3,
|
|
17834
|
+
UPB_DEFTYPE_SERVICE = 4,
|
|
17835
|
+
|
|
17836
|
+
// Only inside message table.
|
|
17837
|
+
UPB_DEFTYPE_FIELD = 0,
|
|
17838
|
+
UPB_DEFTYPE_ONEOF = 1,
|
|
17839
|
+
|
|
17840
|
+
// Only inside service table.
|
|
17841
|
+
UPB_DEFTYPE_METHOD = 0,
|
|
17842
|
+
} upb_deftype_t;
|
|
17843
|
+
|
|
17844
|
+
#ifdef __cplusplus
|
|
17845
|
+
extern "C" {
|
|
17846
|
+
#endif
|
|
17847
|
+
|
|
17848
|
+
// Our 3-bit pointer tagging requires all pointers to be multiples of 8.
|
|
17849
|
+
// The arena will always yield 8-byte-aligned addresses, however we put
|
|
17850
|
+
// the defs into arrays. For each element in the array to be 8-byte-aligned,
|
|
17851
|
+
// the sizes of each def type must also be a multiple of 8.
|
|
17852
|
+
//
|
|
17853
|
+
// If any of these asserts fail, we need to add or remove padding on 32-bit
|
|
17854
|
+
// machines (64-bit machines will have 8-byte alignment already due to
|
|
17855
|
+
// pointers, which all of these structs have).
|
|
17856
|
+
UPB_INLINE void _upb_DefType_CheckPadding(size_t size) {
|
|
17857
|
+
UPB_ASSERT((size & UPB_DEFTYPE_MASK) == 0);
|
|
17858
|
+
}
|
|
17859
|
+
|
|
17860
|
+
upb_deftype_t _upb_DefType_Type(upb_value v);
|
|
17861
|
+
|
|
17862
|
+
upb_value _upb_DefType_Pack(const void* ptr, upb_deftype_t type);
|
|
17863
|
+
|
|
17864
|
+
const void* _upb_DefType_Unpack(upb_value v, upb_deftype_t type);
|
|
17865
|
+
|
|
17866
|
+
#ifdef __cplusplus
|
|
17867
|
+
} /* extern "C" */
|
|
17868
|
+
#endif
|
|
17869
|
+
|
|
17870
|
+
|
|
17871
|
+
#endif /* UPB_REFLECTION_DEF_TYPE_H_ */
|
|
17872
|
+
|
|
17029
17873
|
#ifndef UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_
|
|
17030
17874
|
#define UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_
|
|
17031
17875
|
|
|
@@ -17039,6 +17883,9 @@ const upb_ExtensionRegistry* _upb_DefPool_GeneratedExtensionRegistry(
|
|
|
17039
17883
|
|
|
17040
17884
|
// We want to copy the options verbatim into the destination options proto.
|
|
17041
17885
|
// We use serialize+parse as our deep copy.
|
|
17886
|
+
#define _UPB_FREEZE_OPTIONS(target, options_type) \
|
|
17887
|
+
upb_Message_Freeze((upb_Message*)target, UPB_DESC_MINITABLE(options_type))
|
|
17888
|
+
|
|
17042
17889
|
#define UPB_DEF_SET_OPTIONS(target, desc_type, options_type, proto) \
|
|
17043
17890
|
if (google_protobuf_##desc_type##_has_options(proto)) { \
|
|
17044
17891
|
size_t size; \
|
|
@@ -17049,6 +17896,7 @@ const upb_ExtensionRegistry* _upb_DefPool_GeneratedExtensionRegistry(
|
|
|
17049
17896
|
pb, size, _upb_DefPool_GeneratedExtensionRegistry(ctx->symtab), 0, \
|
|
17050
17897
|
_upb_DefBuilder_Arena(ctx)); \
|
|
17051
17898
|
if (!target) _upb_DefBuilder_OomErr(ctx); \
|
|
17899
|
+
_UPB_FREEZE_OPTIONS(target, options_type); \
|
|
17052
17900
|
} else { \
|
|
17053
17901
|
target = (const google_protobuf_##options_type*)kUpbDefOptDefault; \
|
|
17054
17902
|
}
|
|
@@ -17275,7 +18123,7 @@ upb_MessageDef* _upb_MessageDefs_New(
|
|
|
17275
18123
|
// features. This is used for feature resolution under Editions.
|
|
17276
18124
|
// NOLINTBEGIN
|
|
17277
18125
|
// clang-format off
|
|
17278
|
-
#define UPB_INTERNAL_UPB_EDITION_DEFAULTS "\n\
|
|
18126
|
+
#define UPB_INTERNAL_UPB_EDITION_DEFAULTS "\n\031\030\204\007\"\000*\022\010\001\020\002\030\002 \003(\0010\0028\002@\001H\001\n\031\030\347\007\"\000*\022\010\002\020\001\030\001 \002(\0010\0018\002@\001H\001\n\031\030\350\007\"\014\010\001\020\001\030\001 \002(\0010\001*\0068\002@\001H\001\n\031\030\351\007\"\020\010\001\020\001\030\001 \002(\0010\0018\001@\002*\002H\001\n\031\030\352\007\"\022\010\001\020\001\030\001 \002(\0010\0018\003@\004H\002*\000 \346\007(\352\007"
|
|
17279
18127
|
// clang-format on
|
|
17280
18128
|
// NOLINTEND
|
|
17281
18129
|
|
|
@@ -17326,7 +18174,8 @@ extern "C" {
|
|
|
17326
18174
|
#endif
|
|
17327
18175
|
|
|
17328
18176
|
upb_EnumDef* _upb_EnumDef_At(const upb_EnumDef* e, int i);
|
|
17329
|
-
|
|
18177
|
+
void _upb_EnumDef_Insert(upb_DefBuilder* ctx, upb_EnumDef* e,
|
|
18178
|
+
upb_EnumValueDef* v);
|
|
17330
18179
|
const upb_MiniTableEnum* _upb_EnumDef_MiniTable(const upb_EnumDef* e);
|
|
17331
18180
|
|
|
17332
18181
|
// Allocate and initialize an array of |n| enum defs.
|
|
@@ -17420,6 +18269,151 @@ char* upb_strdup2(const char* s, size_t len, upb_Arena* a);
|
|
|
17420
18269
|
|
|
17421
18270
|
|
|
17422
18271
|
#endif /* UPB_REFLECTION_INTERNAL_STRDUP2_H_ */
|
|
18272
|
+
#ifndef GOOGLE_UPB_UPB_REFLECTION_JSON_ENUMVALUE_OPTIONS_BOOTSTRAP_H__
|
|
18273
|
+
#define GOOGLE_UPB_UPB_REFLECTION_JSON_ENUMVALUE_OPTIONS_BOOTSTRAP_H__
|
|
18274
|
+
|
|
18275
|
+
// IWYU pragma: begin_exports
|
|
18276
|
+
|
|
18277
|
+
#if defined(UPB_BOOTSTRAP_STAGE) && UPB_BOOTSTRAP_STAGE == 0
|
|
18278
|
+
// This header is checked in.
|
|
18279
|
+
#elif defined(UPB_BOOTSTRAP_STAGE) && UPB_BOOTSTRAP_STAGE == 1
|
|
18280
|
+
// This header is generated at build time by the bootstrapping process.
|
|
18281
|
+
#else
|
|
18282
|
+
// This is the normal header, generated by upb_c_proto_library().
|
|
18283
|
+
/* This file was generated by upb_generator from the input file:
|
|
18284
|
+
*
|
|
18285
|
+
* google/protobuf/json_enumvalue_options.proto
|
|
18286
|
+
*
|
|
18287
|
+
* Do not edit -- your changes will be discarded when the file is
|
|
18288
|
+
* regenerated.
|
|
18289
|
+
* NO CHECKED-IN PROTOBUF GENCODE */
|
|
18290
|
+
|
|
18291
|
+
#ifndef GOOGLE_PROTOBUF_JSON_ENUMVALUE_OPTIONS_PROTO_UPB_H__UPB_H_
|
|
18292
|
+
#define GOOGLE_PROTOBUF_JSON_ENUMVALUE_OPTIONS_PROTO_UPB_H__UPB_H_
|
|
18293
|
+
|
|
18294
|
+
|
|
18295
|
+
// Must be last.
|
|
18296
|
+
|
|
18297
|
+
#ifdef __cplusplus
|
|
18298
|
+
extern "C" {
|
|
18299
|
+
#endif
|
|
18300
|
+
typedef struct pb_enumvalue_JsonEnumValueOptions {
|
|
18301
|
+
upb_Message UPB_PRIVATE(base);
|
|
18302
|
+
} pb_enumvalue_JsonEnumValueOptions;
|
|
18303
|
+
|
|
18304
|
+
struct google_protobuf_EnumValueOptions;
|
|
18305
|
+
|
|
18306
|
+
|
|
18307
|
+
|
|
18308
|
+
/* pb.enumvalue.JsonEnumValueOptions */
|
|
18309
|
+
UPB_INLINE pb_enumvalue_JsonEnumValueOptions* pb_enumvalue_JsonEnumValueOptions_new(upb_Arena* arena) {
|
|
18310
|
+
return (pb_enumvalue_JsonEnumValueOptions*)_upb_Message_New(&pb__enumvalue__JsonEnumValueOptions_msg_init, arena);
|
|
18311
|
+
}
|
|
18312
|
+
UPB_INLINE pb_enumvalue_JsonEnumValueOptions* pb_enumvalue_JsonEnumValueOptions_parse(const char* buf, size_t size,
|
|
18313
|
+
upb_Arena* arena) {
|
|
18314
|
+
pb_enumvalue_JsonEnumValueOptions* ret = pb_enumvalue_JsonEnumValueOptions_new(arena);
|
|
18315
|
+
if (!ret) return NULL;
|
|
18316
|
+
if (upb_Decode(buf, size, UPB_UPCAST(ret), &pb__enumvalue__JsonEnumValueOptions_msg_init, NULL, 0,
|
|
18317
|
+
arena) != kUpb_DecodeStatus_Ok) {
|
|
18318
|
+
return NULL;
|
|
18319
|
+
}
|
|
18320
|
+
return ret;
|
|
18321
|
+
}
|
|
18322
|
+
UPB_INLINE pb_enumvalue_JsonEnumValueOptions* pb_enumvalue_JsonEnumValueOptions_parse_ex(
|
|
18323
|
+
const char* buf, size_t size, const upb_ExtensionRegistry* extreg,
|
|
18324
|
+
int options, upb_Arena* arena) {
|
|
18325
|
+
pb_enumvalue_JsonEnumValueOptions* ret = pb_enumvalue_JsonEnumValueOptions_new(arena);
|
|
18326
|
+
if (!ret) return NULL;
|
|
18327
|
+
if (upb_Decode(buf, size, UPB_UPCAST(ret), &pb__enumvalue__JsonEnumValueOptions_msg_init, extreg,
|
|
18328
|
+
options, arena) != kUpb_DecodeStatus_Ok) {
|
|
18329
|
+
return NULL;
|
|
18330
|
+
}
|
|
18331
|
+
return ret;
|
|
18332
|
+
}
|
|
18333
|
+
UPB_INLINE char* pb_enumvalue_JsonEnumValueOptions_serialize(const pb_enumvalue_JsonEnumValueOptions* msg,
|
|
18334
|
+
upb_Arena* arena, size_t* len) {
|
|
18335
|
+
char* ptr;
|
|
18336
|
+
(void)upb_Encode(UPB_UPCAST(msg), &pb__enumvalue__JsonEnumValueOptions_msg_init, 0, arena, &ptr, len);
|
|
18337
|
+
return ptr;
|
|
18338
|
+
}
|
|
18339
|
+
UPB_INLINE char* pb_enumvalue_JsonEnumValueOptions_serialize_ex(const pb_enumvalue_JsonEnumValueOptions* msg,
|
|
18340
|
+
int options, upb_Arena* arena,
|
|
18341
|
+
size_t* len) {
|
|
18342
|
+
char* ptr;
|
|
18343
|
+
(void)upb_Encode(UPB_UPCAST(msg), &pb__enumvalue__JsonEnumValueOptions_msg_init, options, arena, &ptr, len);
|
|
18344
|
+
return ptr;
|
|
18345
|
+
}
|
|
18346
|
+
UPB_INLINE void pb_enumvalue_JsonEnumValueOptions_clear_string(pb_enumvalue_JsonEnumValueOptions* msg) {
|
|
18347
|
+
const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 64, kUpb_NoSub, 9, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
|
18348
|
+
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
|
18349
|
+
}
|
|
18350
|
+
UPB_INLINE upb_StringView pb_enumvalue_JsonEnumValueOptions_string(const pb_enumvalue_JsonEnumValueOptions* msg) {
|
|
18351
|
+
upb_StringView default_val = upb_StringView_FromString("");
|
|
18352
|
+
upb_StringView ret;
|
|
18353
|
+
const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 64, kUpb_NoSub, 9, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
|
18354
|
+
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
|
18355
|
+
&default_val, &ret);
|
|
18356
|
+
return ret;
|
|
18357
|
+
}
|
|
18358
|
+
UPB_INLINE bool pb_enumvalue_JsonEnumValueOptions_has_string(const pb_enumvalue_JsonEnumValueOptions* msg) {
|
|
18359
|
+
const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 64, kUpb_NoSub, 9, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
|
18360
|
+
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
|
18361
|
+
}
|
|
18362
|
+
|
|
18363
|
+
UPB_INLINE void pb_enumvalue_JsonEnumValueOptions_set_string(pb_enumvalue_JsonEnumValueOptions* msg, upb_StringView value) {
|
|
18364
|
+
const upb_MiniTableField field = {1, UPB_SIZE(12, 16), 64, kUpb_NoSub, 9, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
|
18365
|
+
upb_Message_SetBaseField((upb_Message*)msg, &field, &value);
|
|
18366
|
+
}
|
|
18367
|
+
|
|
18368
|
+
UPB_INLINE bool pb_enumvalue_has_json(const struct google_protobuf_EnumValueOptions* msg) {
|
|
18369
|
+
return upb_Message_HasExtension((upb_Message*)msg, pb_enumvalue_json_ext);
|
|
18370
|
+
}
|
|
18371
|
+
|
|
18372
|
+
UPB_INLINE void pb_enumvalue_clear_json(struct google_protobuf_EnumValueOptions* msg) {
|
|
18373
|
+
upb_Message_ClearExtension((upb_Message*)msg, pb_enumvalue_json_ext);
|
|
18374
|
+
}
|
|
18375
|
+
UPB_INLINE const pb_enumvalue_JsonEnumValueOptions*
|
|
18376
|
+
pb_enumvalue_json(const struct google_protobuf_EnumValueOptions* msg) {
|
|
18377
|
+
const upb_MiniTableExtension* ext = pb_enumvalue_json_ext;
|
|
18378
|
+
UPB_ASSUME(upb_MiniTableField_IsScalar(&ext->UPB_PRIVATE(field)));
|
|
18379
|
+
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(
|
|
18380
|
+
&ext->UPB_PRIVATE(field)) == UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
|
|
18381
|
+
const pb_enumvalue_JsonEnumValueOptions* default_val = NULL;
|
|
18382
|
+
const pb_enumvalue_JsonEnumValueOptions* ret;
|
|
18383
|
+
_upb_Message_GetExtensionField((upb_Message*)msg, ext, &default_val, &ret);
|
|
18384
|
+
return ret;
|
|
18385
|
+
}
|
|
18386
|
+
|
|
18387
|
+
UPB_INLINE void pb_enumvalue_set_json(struct google_protobuf_EnumValueOptions* msg,
|
|
18388
|
+
const pb_enumvalue_JsonEnumValueOptions* val,
|
|
18389
|
+
upb_Arena* arena) {
|
|
18390
|
+
const upb_MiniTableExtension* ext = pb_enumvalue_json_ext;
|
|
18391
|
+
UPB_ASSUME(upb_MiniTableField_IsScalar(&ext->UPB_PRIVATE(field)));
|
|
18392
|
+
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(
|
|
18393
|
+
&ext->UPB_PRIVATE(field)) == UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
|
|
18394
|
+
bool ok = upb_Message_SetExtension((upb_Message*)msg, ext, &val, arena);
|
|
18395
|
+
UPB_ASSERT(ok);
|
|
18396
|
+
}
|
|
18397
|
+
UPB_INLINE struct pb_enumvalue_JsonEnumValueOptions* pb_enumvalue_mutable_json(
|
|
18398
|
+
struct google_protobuf_EnumValueOptions* msg, upb_Arena* arena) {
|
|
18399
|
+
struct pb_enumvalue_JsonEnumValueOptions* sub = (struct pb_enumvalue_JsonEnumValueOptions*)pb_enumvalue_json(msg);
|
|
18400
|
+
if (sub == NULL) {
|
|
18401
|
+
sub = (struct pb_enumvalue_JsonEnumValueOptions*)_upb_Message_New(&pb__enumvalue__JsonEnumValueOptions_msg_init, arena);
|
|
18402
|
+
if (sub) pb_enumvalue_set_json(msg, sub, arena);
|
|
18403
|
+
}
|
|
18404
|
+
return sub;
|
|
18405
|
+
}
|
|
18406
|
+
#ifdef __cplusplus
|
|
18407
|
+
} /* extern "C" */
|
|
18408
|
+
#endif
|
|
18409
|
+
|
|
18410
|
+
|
|
18411
|
+
#endif /* GOOGLE_PROTOBUF_JSON_ENUMVALUE_OPTIONS_PROTO_UPB_H__UPB_H_ */
|
|
18412
|
+
#endif
|
|
18413
|
+
|
|
18414
|
+
// IWYU pragma: end_exports
|
|
18415
|
+
|
|
18416
|
+
#endif // GOOGLE_UPB_UPB_REFLECTION_JSON_ENUMVALUE_OPTIONS_BOOTSTRAP_H__
|
|
17423
18417
|
|
|
17424
18418
|
#ifndef UPB_REFLECTION_EXTENSION_RANGE_INTERNAL_H_
|
|
17425
18419
|
#define UPB_REFLECTION_EXTENSION_RANGE_INTERNAL_H_
|
|
@@ -17633,27 +18627,30 @@ upb_MethodDef* _upb_MethodDefs_New(
|
|
|
17633
18627
|
extern "C" {
|
|
17634
18628
|
#endif
|
|
17635
18629
|
|
|
18630
|
+
// Must be last
|
|
18631
|
+
|
|
17636
18632
|
// Functions for converting defs back to the equivalent descriptor proto.
|
|
17637
18633
|
// Ultimately the goal is that a round-trip proto->def->proto is lossless. Each
|
|
17638
18634
|
// function returns a new proto created in arena `a`, or NULL if memory
|
|
17639
18635
|
// allocation failed.
|
|
17640
|
-
google_protobuf_DescriptorProto* upb_MessageDef_ToProto(
|
|
17641
|
-
|
|
17642
|
-
google_protobuf_EnumDescriptorProto* upb_EnumDef_ToProto(
|
|
17643
|
-
|
|
17644
|
-
google_protobuf_EnumValueDescriptorProto* upb_EnumValueDef_ToProto(
|
|
18636
|
+
UPB_NODISCARD google_protobuf_DescriptorProto* upb_MessageDef_ToProto(
|
|
18637
|
+
const upb_MessageDef* m, upb_Arena* a);
|
|
18638
|
+
UPB_NODISCARD google_protobuf_EnumDescriptorProto* upb_EnumDef_ToProto(
|
|
18639
|
+
const upb_EnumDef* e, upb_Arena* a);
|
|
18640
|
+
UPB_NODISCARD google_protobuf_EnumValueDescriptorProto* upb_EnumValueDef_ToProto(
|
|
17645
18641
|
const upb_EnumValueDef* e, upb_Arena* a);
|
|
17646
|
-
google_protobuf_FieldDescriptorProto* upb_FieldDef_ToProto(
|
|
18642
|
+
UPB_NODISCARD google_protobuf_FieldDescriptorProto* upb_FieldDef_ToProto(
|
|
17647
18643
|
const upb_FieldDef* f, upb_Arena* a);
|
|
17648
|
-
google_protobuf_OneofDescriptorProto* upb_OneofDef_ToProto(
|
|
18644
|
+
UPB_NODISCARD google_protobuf_OneofDescriptorProto* upb_OneofDef_ToProto(
|
|
17649
18645
|
const upb_OneofDef* o, upb_Arena* a);
|
|
17650
|
-
google_protobuf_FileDescriptorProto* upb_FileDef_ToProto(
|
|
17651
|
-
|
|
17652
|
-
google_protobuf_MethodDescriptorProto* upb_MethodDef_ToProto(
|
|
18646
|
+
UPB_NODISCARD google_protobuf_FileDescriptorProto* upb_FileDef_ToProto(
|
|
18647
|
+
const upb_FileDef* f, upb_Arena* a);
|
|
18648
|
+
UPB_NODISCARD google_protobuf_MethodDescriptorProto* upb_MethodDef_ToProto(
|
|
17653
18649
|
const upb_MethodDef* m, upb_Arena* a);
|
|
17654
|
-
google_protobuf_ServiceDescriptorProto* upb_ServiceDef_ToProto(
|
|
18650
|
+
UPB_NODISCARD google_protobuf_ServiceDescriptorProto* upb_ServiceDef_ToProto(
|
|
17655
18651
|
const upb_ServiceDef* s, upb_Arena* a);
|
|
17656
18652
|
|
|
18653
|
+
|
|
17657
18654
|
#ifdef __cplusplus
|
|
17658
18655
|
} /* extern "C" */
|
|
17659
18656
|
#endif
|
|
@@ -17682,27 +18679,6 @@ int32_t upb_EnumReservedRange_End(const upb_EnumReservedRange* r);
|
|
|
17682
18679
|
|
|
17683
18680
|
#endif /* UPB_REFLECTION_ENUM_RESERVED_RANGE_H_ */
|
|
17684
18681
|
|
|
17685
|
-
#ifndef UPB_WIRE_INTERNAL_CONSTANTS_H_
|
|
17686
|
-
#define UPB_WIRE_INTERNAL_CONSTANTS_H_
|
|
17687
|
-
|
|
17688
|
-
#define kUpb_WireFormat_DefaultDepthLimit 100
|
|
17689
|
-
|
|
17690
|
-
// MessageSet wire format is:
|
|
17691
|
-
// message MessageSet {
|
|
17692
|
-
// repeated group Item = 1 {
|
|
17693
|
-
// required int32 type_id = 2;
|
|
17694
|
-
// required bytes message = 3;
|
|
17695
|
-
// }
|
|
17696
|
-
// }
|
|
17697
|
-
|
|
17698
|
-
enum {
|
|
17699
|
-
kUpb_MsgSet_Item = 1,
|
|
17700
|
-
kUpb_MsgSet_TypeId = 2,
|
|
17701
|
-
kUpb_MsgSet_Message = 3,
|
|
17702
|
-
};
|
|
17703
|
-
|
|
17704
|
-
#endif /* UPB_WIRE_INTERNAL_CONSTANTS_H_ */
|
|
17705
|
-
|
|
17706
18682
|
/*
|
|
17707
18683
|
* Internal implementation details of the decoder that are shared between
|
|
17708
18684
|
* decode.c and decode_fast.c.
|
|
@@ -17711,7 +18687,6 @@ enum {
|
|
|
17711
18687
|
#ifndef UPB_WIRE_INTERNAL_DECODER_H_
|
|
17712
18688
|
#define UPB_WIRE_INTERNAL_DECODER_H_
|
|
17713
18689
|
|
|
17714
|
-
#include <setjmp.h>
|
|
17715
18690
|
#include <stddef.h>
|
|
17716
18691
|
#include <stdint.h>
|
|
17717
18692
|
#include <string.h>
|
|
@@ -17721,6 +18696,14 @@ enum {
|
|
|
17721
18696
|
// Must be last.
|
|
17722
18697
|
|
|
17723
18698
|
#define DECODE_NOGROUP (uint32_t)-1
|
|
18699
|
+
#define kUpb_Decoder_EncodeVarint32MaxSize 5
|
|
18700
|
+
|
|
18701
|
+
typedef union {
|
|
18702
|
+
bool bool_val;
|
|
18703
|
+
uint32_t uint32_val;
|
|
18704
|
+
uint64_t uint64_val;
|
|
18705
|
+
uint32_t size;
|
|
18706
|
+
} wireval;
|
|
17724
18707
|
|
|
17725
18708
|
typedef struct upb_Decoder {
|
|
17726
18709
|
upb_EpsCopyInputStream input;
|
|
@@ -17735,7 +18718,7 @@ typedef struct upb_Decoder {
|
|
|
17735
18718
|
upb_Arena arena;
|
|
17736
18719
|
void* foo[UPB_ARENA_SIZE_HACK / sizeof(void*)];
|
|
17737
18720
|
};
|
|
17738
|
-
upb_ErrorHandler err;
|
|
18721
|
+
upb_ErrorHandler* err;
|
|
17739
18722
|
|
|
17740
18723
|
#ifndef NDEBUG
|
|
17741
18724
|
char* trace_buf;
|
|
@@ -17744,13 +18727,20 @@ typedef struct upb_Decoder {
|
|
|
17744
18727
|
#endif
|
|
17745
18728
|
} upb_Decoder;
|
|
17746
18729
|
|
|
18730
|
+
UPB_INLINE void _upb_Decoder_AssumeEpsHasErrorHandler(upb_Decoder* d) {
|
|
18731
|
+
UPB_ASSUME(upb_EpsCopyInputStream_HasErrorHandler(&d->input));
|
|
18732
|
+
}
|
|
18733
|
+
|
|
18734
|
+
#define EPS(d) (_upb_Decoder_AssumeEpsHasErrorHandler(d), &(d)->input)
|
|
18735
|
+
|
|
17747
18736
|
UPB_INLINE const char* upb_Decoder_Init(upb_Decoder* d, const char* buf,
|
|
17748
18737
|
size_t size,
|
|
17749
18738
|
const upb_ExtensionRegistry* extreg,
|
|
17750
18739
|
int options, upb_Arena* arena,
|
|
17751
|
-
char* trace_buf,
|
|
17752
|
-
|
|
17753
|
-
|
|
18740
|
+
upb_ErrorHandler* err, char* trace_buf,
|
|
18741
|
+
size_t trace_size) {
|
|
18742
|
+
d->err = err;
|
|
18743
|
+
upb_EpsCopyInputStream_InitWithErrorHandler(&d->input, &buf, size, d->err);
|
|
17754
18744
|
|
|
17755
18745
|
UPB_STATIC_ASSERT((int)kUpb_DecodeStatus_Ok == (int)kUpb_ErrorCode_Ok,
|
|
17756
18746
|
"mismatched error codes");
|
|
@@ -17791,22 +18781,36 @@ UPB_INLINE const char* upb_Decoder_Init(upb_Decoder* d, const char* buf,
|
|
|
17791
18781
|
UPB_INLINE upb_DecodeStatus upb_Decoder_Destroy(upb_Decoder* d,
|
|
17792
18782
|
upb_Arena* arena) {
|
|
17793
18783
|
UPB_PRIVATE(_upb_Arena_SwapOut)(arena, &d->arena);
|
|
17794
|
-
return (upb_DecodeStatus)d->err
|
|
18784
|
+
return (upb_DecodeStatus)d->err->code;
|
|
17795
18785
|
}
|
|
17796
18786
|
|
|
17797
|
-
|
|
17798
|
-
|
|
17799
|
-
|
|
18787
|
+
// Resets decoder fields in preparation for decoding a new message.
|
|
18788
|
+
//
|
|
18789
|
+
// Some decoder fields (arena, extreg, err) are preserved so they can be
|
|
18790
|
+
// reused across messages.
|
|
18791
|
+
// NOTE: The input stream is NOT reset. If a new input buffer is being used,
|
|
18792
|
+
// upb_EpsCopyInputStream_InitWithErrorHandler() must be called separately.
|
|
18793
|
+
UPB_INLINE void upb_Decoder_Reset(upb_Decoder* d, int options,
|
|
18794
|
+
upb_Message* msg) {
|
|
18795
|
+
d->depth = upb_DecodeOptions_GetEffectiveMaxDepth(options);
|
|
18796
|
+
d->options = options;
|
|
18797
|
+
d->end_group = DECODE_NOGROUP;
|
|
18798
|
+
d->missing_required = false;
|
|
18799
|
+
d->message_is_done = false;
|
|
18800
|
+
d->original_msg = msg;
|
|
17800
18801
|
}
|
|
17801
18802
|
|
|
17802
|
-
|
|
17803
|
-
|
|
18803
|
+
#ifndef NDEBUG
|
|
18804
|
+
UPB_INLINE bool _upb_Decoder_TraceBufferHasBytesAvailable(upb_Decoder* d,
|
|
18805
|
+
int n) {
|
|
18806
|
+
return d->trace_ptr && d->trace_end && d->trace_end - d->trace_ptr > n;
|
|
17804
18807
|
}
|
|
17805
18808
|
#endif
|
|
17806
18809
|
|
|
17807
18810
|
UPB_INLINE char* _upb_Decoder_TraceNext(upb_Decoder* d) {
|
|
17808
18811
|
#ifndef NDEBUG
|
|
17809
|
-
return
|
|
18812
|
+
return _upb_Decoder_TraceBufferHasBytesAvailable(d, 2) ? d->trace_ptr + 1
|
|
18813
|
+
: NULL;
|
|
17810
18814
|
#else
|
|
17811
18815
|
return NULL;
|
|
17812
18816
|
#endif
|
|
@@ -17827,10 +18831,20 @@ UPB_INLINE char* _upb_Decoder_TracePtr(upb_Decoder* d) {
|
|
|
17827
18831
|
// '<' Fallback to MiniTable parser.
|
|
17828
18832
|
// 'M' Field successfully parsed with MiniTable.
|
|
17829
18833
|
// 'X' Truncated -- trace buffer is full, further events were discarded.
|
|
18834
|
+
// 'U' Unknown field parsed fast
|
|
18835
|
+
//
|
|
18836
|
+
// Lower-case letters indicate events that are more subtle and therefore
|
|
18837
|
+
// difficult to assert on, but may be useful information for debugging:
|
|
18838
|
+
// 'r' Refresh buffer.
|
|
18839
|
+
// 's' Fall back to unknown fast path
|
|
18840
|
+
// 'm' Fall back to minitable lookup fast path
|
|
17830
18841
|
UPB_INLINE void _upb_Decoder_Trace(upb_Decoder* d, char event) {
|
|
17831
18842
|
#ifndef NDEBUG
|
|
18843
|
+
#ifdef UPB_TRACE_FASTDECODER
|
|
18844
|
+
fprintf(stderr, "Fasttable trace event: %c\n", event);
|
|
18845
|
+
#endif
|
|
17832
18846
|
if (d->trace_ptr == NULL) return;
|
|
17833
|
-
if (
|
|
18847
|
+
if (!_upb_Decoder_TraceBufferHasBytesAvailable(d, 1)) {
|
|
17834
18848
|
d->trace_ptr[-1] = 'X'; // Truncated.
|
|
17835
18849
|
return;
|
|
17836
18850
|
}
|
|
@@ -17845,20 +18859,29 @@ bool _upb_Decoder_VerifyUtf8Inline(const char* ptr, int len) {
|
|
|
17845
18859
|
return utf8_range_IsValid(ptr, len);
|
|
17846
18860
|
}
|
|
17847
18861
|
|
|
18862
|
+
UPB_INLINE void _upb_Decoder_VerifyOneofUnlinked(
|
|
18863
|
+
const upb_MiniTable* mt, const upb_MiniTableField* field) {
|
|
18864
|
+
#ifndef NDEBUG
|
|
18865
|
+
const upb_MiniTableField* oneof = upb_MiniTable_GetOneof(mt, field);
|
|
18866
|
+
if (oneof) {
|
|
18867
|
+
// All other members of the oneof must be message fields that are also
|
|
18868
|
+
// unlinked.
|
|
18869
|
+
do {
|
|
18870
|
+
UPB_ASSERT(upb_MiniTableField_CType(oneof) == kUpb_CType_Message);
|
|
18871
|
+
const upb_MiniTable* oneof_sub = upb_MiniTable_GetSubMessageTable(oneof);
|
|
18872
|
+
UPB_ASSERT(!oneof_sub);
|
|
18873
|
+
} while (upb_MiniTable_NextOneofField(mt, &oneof));
|
|
18874
|
+
}
|
|
18875
|
+
#endif // NDEBUG
|
|
18876
|
+
}
|
|
18877
|
+
|
|
17848
18878
|
const char* _upb_Decoder_CheckRequired(upb_Decoder* d, const char* ptr,
|
|
17849
18879
|
const upb_Message* msg,
|
|
17850
18880
|
const upb_MiniTable* m);
|
|
17851
18881
|
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
return ((intptr_t)tablep << 8) | tablep->UPB_PRIVATE(table_mask);
|
|
17856
|
-
}
|
|
17857
|
-
|
|
17858
|
-
UPB_INLINE const upb_MiniTable* decode_totablep(intptr_t table) {
|
|
17859
|
-
return (const upb_MiniTable*)(table >> 8);
|
|
17860
|
-
}
|
|
17861
|
-
|
|
18882
|
+
#if UPB_FASTTABLE
|
|
18883
|
+
UPB_PRESERVE_NONE
|
|
18884
|
+
#endif
|
|
17862
18885
|
const char* _upb_Decoder_DecodeMessage(upb_Decoder* d, const char* ptr,
|
|
17863
18886
|
upb_Message* msg,
|
|
17864
18887
|
const upb_MiniTable* layout);
|
|
@@ -17884,7 +18907,7 @@ UPB_INLINE bool _upb_Decoder_ReadString(upb_Decoder* d, const char** ptr,
|
|
|
17884
18907
|
upb_EpsCopyInputStream_ReadStringAlwaysAlias(&d->input, *ptr, size, &tmp);
|
|
17885
18908
|
if (*ptr == NULL) return false;
|
|
17886
18909
|
if (validate_utf8 && !utf8_range_IsValid(tmp.data, tmp.size)) {
|
|
17887
|
-
upb_ErrorHandler_ThrowError(
|
|
18910
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_BadUtf8);
|
|
17888
18911
|
return false;
|
|
17889
18912
|
}
|
|
17890
18913
|
if ((d->options & kUpb_DecodeOption_AliasString) == 0) {
|
|
@@ -17897,8 +18920,236 @@ UPB_INLINE bool _upb_Decoder_ReadString(upb_Decoder* d, const char** ptr,
|
|
|
17897
18920
|
return true;
|
|
17898
18921
|
}
|
|
17899
18922
|
|
|
18923
|
+
UPB_INLINE char* upb_Decoder_EncodeVarint32(uint32_t val, char* ptr) {
|
|
18924
|
+
do {
|
|
18925
|
+
uint8_t byte = val & 0x7fU;
|
|
18926
|
+
val >>= 7;
|
|
18927
|
+
if (val) byte |= 0x80U;
|
|
18928
|
+
*(ptr++) = byte;
|
|
18929
|
+
} while (val);
|
|
18930
|
+
return ptr;
|
|
18931
|
+
}
|
|
18932
|
+
|
|
18933
|
+
UPB_FORCEINLINE
|
|
18934
|
+
void _upb_Decoder_AddEnumValueToUnknown(upb_Decoder* d, upb_Message* msg,
|
|
18935
|
+
const upb_MiniTableField* field,
|
|
18936
|
+
uint64_t val) {
|
|
18937
|
+
// Unrecognized enum goes into unknown fields.
|
|
18938
|
+
// For packed fields the tag could be arbitrarily far in the past,
|
|
18939
|
+
// so we just re-encode the tag and value here.
|
|
18940
|
+
const uint32_t tag =
|
|
18941
|
+
((uint32_t)field->UPB_PRIVATE(number) << 3) | kUpb_WireType_Varint;
|
|
18942
|
+
upb_Message* unknown_msg =
|
|
18943
|
+
field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsExtension ? d->original_msg
|
|
18944
|
+
: msg;
|
|
18945
|
+
char buf[2 * kUpb_Decoder_EncodeVarint32MaxSize];
|
|
18946
|
+
char* end = buf;
|
|
18947
|
+
end = upb_Decoder_EncodeVarint32(tag, end);
|
|
18948
|
+
end = upb_Decoder_EncodeVarint32(val, end);
|
|
18949
|
+
|
|
18950
|
+
if (!UPB_PRIVATE(_upb_Message_AddUnknown)(unknown_msg, buf, end - buf,
|
|
18951
|
+
&d->arena, kUpb_AddUnknown_Copy)) {
|
|
18952
|
+
upb_ErrorHandler_ThrowError(d->err, kUpb_DecodeStatus_OutOfMemory);
|
|
18953
|
+
}
|
|
18954
|
+
}
|
|
18955
|
+
|
|
17900
18956
|
|
|
17901
18957
|
#endif /* UPB_WIRE_INTERNAL_DECODER_H_ */
|
|
18958
|
+
|
|
18959
|
+
#ifndef UPB_WIRE_INTERNAL_ENCODE_H_
|
|
18960
|
+
#define UPB_WIRE_INTERNAL_ENCODE_H_
|
|
18961
|
+
|
|
18962
|
+
#include <setjmp.h>
|
|
18963
|
+
#include <stddef.h>
|
|
18964
|
+
#include <stdint.h>
|
|
18965
|
+
|
|
18966
|
+
|
|
18967
|
+
#ifndef GOOGLE_UPB_UPB_WIRE_INTERNAL_BACK_ALLOC_H__
|
|
18968
|
+
#define GOOGLE_UPB_UPB_WIRE_INTERNAL_BACK_ALLOC_H__
|
|
18969
|
+
|
|
18970
|
+
#include <stddef.h>
|
|
18971
|
+
|
|
18972
|
+
|
|
18973
|
+
// Must be last.
|
|
18974
|
+
|
|
18975
|
+
#ifdef __cplusplus
|
|
18976
|
+
extern "C" {
|
|
18977
|
+
#endif
|
|
18978
|
+
|
|
18979
|
+
// Allocates memory from the back of the arena.
|
|
18980
|
+
typedef struct {
|
|
18981
|
+
upb_Arena* arena;
|
|
18982
|
+
char *buf, *limit;
|
|
18983
|
+
bool standalone;
|
|
18984
|
+
} upb_BackAlloc;
|
|
18985
|
+
|
|
18986
|
+
// Needed because C doesn't allow NULL - NULL.
|
|
18987
|
+
extern char upb_BackAlloc_sentinel;
|
|
18988
|
+
|
|
18989
|
+
char* upb_BackAlloc_Grow(upb_BackAlloc* a, char* ptr, size_t need);
|
|
18990
|
+
|
|
18991
|
+
UPB_INLINE char* upb_BackAlloc_Init(upb_BackAlloc* a, upb_Arena* arena) {
|
|
18992
|
+
a->arena = arena;
|
|
18993
|
+
// This could eagerly steal whatever's in the arena, since stealing with a
|
|
18994
|
+
// minimum of 0 can't fail.
|
|
18995
|
+
a->buf = &upb_BackAlloc_sentinel;
|
|
18996
|
+
a->limit = &upb_BackAlloc_sentinel;
|
|
18997
|
+
a->standalone = false;
|
|
18998
|
+
return a->limit;
|
|
18999
|
+
}
|
|
19000
|
+
|
|
19001
|
+
UPB_INLINE void upb_BackAlloc_Abort(upb_BackAlloc* a) {
|
|
19002
|
+
if (a->standalone) {
|
|
19003
|
+
UPB_PRIVATE(_upb_Arena_FreeBlock)(a->arena, a->buf);
|
|
19004
|
+
} else if (a->limit != a->buf) {
|
|
19005
|
+
UPB_PRIVATE(_upb_Arena_UseBlock)(a->arena, a->buf, a->limit - a->buf);
|
|
19006
|
+
}
|
|
19007
|
+
}
|
|
19008
|
+
|
|
19009
|
+
UPB_INLINE size_t upb_BackAlloc_Finish(upb_BackAlloc* a, const char* ptr) {
|
|
19010
|
+
if (a->standalone) {
|
|
19011
|
+
UPB_PRIVATE(_upb_Arena_AddBlock)(a->arena, a->buf);
|
|
19012
|
+
}
|
|
19013
|
+
if (ptr != a->buf) {
|
|
19014
|
+
UPB_PRIVATE(_upb_Arena_UseBlock)(a->arena, a->buf, ptr - a->buf);
|
|
19015
|
+
}
|
|
19016
|
+
return a->limit - ptr;
|
|
19017
|
+
}
|
|
19018
|
+
|
|
19019
|
+
UPB_FORCEINLINE bool upb_BackAlloc_HasBytes(const upb_BackAlloc* a,
|
|
19020
|
+
const char* ptr, size_t need) {
|
|
19021
|
+
size_t have = ptr - a->buf;
|
|
19022
|
+
return have >= need;
|
|
19023
|
+
}
|
|
19024
|
+
|
|
19025
|
+
UPB_FORCEINLINE char* upb_BackAlloc_Reserve(upb_BackAlloc* a, char* ptr,
|
|
19026
|
+
size_t need) {
|
|
19027
|
+
return upb_BackAlloc_HasBytes(a, ptr, need)
|
|
19028
|
+
? ptr - need
|
|
19029
|
+
: upb_BackAlloc_Grow(a, ptr, need);
|
|
19030
|
+
}
|
|
19031
|
+
|
|
19032
|
+
UPB_INLINE size_t upb_BackAlloc_Size(const upb_BackAlloc* a, const char* ptr) {
|
|
19033
|
+
return a->limit - ptr;
|
|
19034
|
+
}
|
|
19035
|
+
|
|
19036
|
+
#ifdef __cplusplus
|
|
19037
|
+
} /* extern "C" */
|
|
19038
|
+
#endif
|
|
19039
|
+
|
|
19040
|
+
|
|
19041
|
+
#endif // GOOGLE_UPB_UPB_WIRE_INTERNAL_BACK_ALLOC_H__
|
|
19042
|
+
|
|
19043
|
+
// Must be last.
|
|
19044
|
+
|
|
19045
|
+
#ifdef __cplusplus
|
|
19046
|
+
extern "C" {
|
|
19047
|
+
#endif
|
|
19048
|
+
|
|
19049
|
+
typedef struct {
|
|
19050
|
+
upb_BackAlloc alloc;
|
|
19051
|
+
int options;
|
|
19052
|
+
int depth;
|
|
19053
|
+
upb_EncodeStatus status;
|
|
19054
|
+
_upb_mapsorter sorter;
|
|
19055
|
+
jmp_buf* err;
|
|
19056
|
+
} upb_encstate;
|
|
19057
|
+
|
|
19058
|
+
UPB_INLINE char* UPB_PRIVATE(_upb_encstate_init)(upb_encstate* e, jmp_buf* err,
|
|
19059
|
+
upb_Arena* arena) {
|
|
19060
|
+
e->status = kUpb_EncodeStatus_Ok;
|
|
19061
|
+
char* ptr = upb_BackAlloc_Init(&e->alloc, arena);
|
|
19062
|
+
e->options = 0;
|
|
19063
|
+
e->depth = 0;
|
|
19064
|
+
e->err = err;
|
|
19065
|
+
_upb_mapsorter_init(&e->sorter);
|
|
19066
|
+
return ptr;
|
|
19067
|
+
}
|
|
19068
|
+
|
|
19069
|
+
UPB_INLINE void UPB_PRIVATE(_upb_encstate_destroy)(upb_encstate* e) {
|
|
19070
|
+
_upb_mapsorter_destroy(&e->sorter);
|
|
19071
|
+
}
|
|
19072
|
+
|
|
19073
|
+
// Internal version of upb_Encode that encodes a single field.
|
|
19074
|
+
//
|
|
19075
|
+
// The caller must clean up the `upb_encstate` by calling
|
|
19076
|
+
// `_upb_encstate_destroy(e)` when done.
|
|
19077
|
+
upb_EncodeStatus UPB_PRIVATE(_upb_Encode_Field)(upb_encstate* e,
|
|
19078
|
+
const upb_Message* msg,
|
|
19079
|
+
const upb_MiniTableField* field,
|
|
19080
|
+
char** buf, size_t* size,
|
|
19081
|
+
int options);
|
|
19082
|
+
|
|
19083
|
+
// Internal version of upb_Encode that encodes a single extension.
|
|
19084
|
+
//
|
|
19085
|
+
// The caller must clean up the `upb_encstate` by calling
|
|
19086
|
+
// `_upb_encstate_destroy(e)` when done.
|
|
19087
|
+
upb_EncodeStatus UPB_PRIVATE(_upb_Encode_Extension)(
|
|
19088
|
+
upb_encstate* e, const upb_MiniTableExtension* ext,
|
|
19089
|
+
upb_MessageValue ext_val, bool is_message_set, char** buf, size_t* size,
|
|
19090
|
+
int options);
|
|
19091
|
+
|
|
19092
|
+
char* encode_message(char* ptr, upb_encstate* e, const upb_Message* msg,
|
|
19093
|
+
const upb_MiniTable* m, size_t* size);
|
|
19094
|
+
|
|
19095
|
+
#define kUpb_Encoder_EncodeVarint32MaxSize 5
|
|
19096
|
+
#define kUpb_Encoder_EncodeVarint64MaxSize 10
|
|
19097
|
+
|
|
19098
|
+
static char* upb_Encoder_EncodeVarint32(uint32_t val, char* ptr) {
|
|
19099
|
+
do {
|
|
19100
|
+
uint8_t byte = val & 0x7fU;
|
|
19101
|
+
val >>= 7;
|
|
19102
|
+
if (val) byte |= 0x80U;
|
|
19103
|
+
*(ptr++) = byte;
|
|
19104
|
+
} while (val);
|
|
19105
|
+
return ptr;
|
|
19106
|
+
}
|
|
19107
|
+
|
|
19108
|
+
static char* upb_Encoder_EncodeVarint64(uint64_t val, char* ptr) {
|
|
19109
|
+
do {
|
|
19110
|
+
uint8_t byte = val & 0x7fU;
|
|
19111
|
+
val >>= 7;
|
|
19112
|
+
if (val) byte |= 0x80U;
|
|
19113
|
+
*(ptr++) = byte;
|
|
19114
|
+
} while (val);
|
|
19115
|
+
return ptr;
|
|
19116
|
+
}
|
|
19117
|
+
|
|
19118
|
+
UPB_INLINE
|
|
19119
|
+
bool _upb_Encoder_AddEnumValueToUnknown(upb_Message* msg,
|
|
19120
|
+
const upb_MiniTableField* field,
|
|
19121
|
+
uint64_t val, upb_Arena* arena) {
|
|
19122
|
+
// Unrecognized enum goes into unknown fields.
|
|
19123
|
+
// For packed fields the tag could be arbitrarily far in the past,
|
|
19124
|
+
// so we just re-encode the tag and value here.
|
|
19125
|
+
const uint32_t tag =
|
|
19126
|
+
((uint32_t)field->UPB_PRIVATE(number) << 3) | kUpb_WireType_Varint;
|
|
19127
|
+
char buf[kUpb_Encoder_EncodeVarint32MaxSize +
|
|
19128
|
+
kUpb_Encoder_EncodeVarint64MaxSize];
|
|
19129
|
+
char* end = buf;
|
|
19130
|
+
end = upb_Encoder_EncodeVarint32(tag, end);
|
|
19131
|
+
end = upb_Encoder_EncodeVarint64(val, end);
|
|
19132
|
+
|
|
19133
|
+
return UPB_PRIVATE(_upb_Message_AddUnknown)(msg, buf, end - buf, arena,
|
|
19134
|
+
kUpb_AddUnknown_Copy);
|
|
19135
|
+
}
|
|
19136
|
+
|
|
19137
|
+
bool _upb_Encoder_AddMapEntryUnknown(upb_Message* msg,
|
|
19138
|
+
const upb_MiniTableField* field,
|
|
19139
|
+
upb_Message* ent_msg,
|
|
19140
|
+
const upb_MiniTable* entry,
|
|
19141
|
+
upb_Arena* arena);
|
|
19142
|
+
|
|
19143
|
+
upb_EncodeStatus _upb_Encode(const upb_Message* msg, const upb_MiniTable* l,
|
|
19144
|
+
int options, upb_Arena* arena, char** buf,
|
|
19145
|
+
size_t* size, bool prepend_len);
|
|
19146
|
+
|
|
19147
|
+
#ifdef __cplusplus
|
|
19148
|
+
} /* extern "C" */
|
|
19149
|
+
#endif
|
|
19150
|
+
|
|
19151
|
+
|
|
19152
|
+
#endif /* UPB_WIRE_INTERNAL_ENCODE_H_ */
|
|
17902
19153
|
#ifndef GOOGLE_UPB_UPB_WIRE_WRITER_H__
|
|
17903
19154
|
#define GOOGLE_UPB_UPB_WIRE_WRITER_H__
|
|
17904
19155
|
|
|
@@ -17947,12 +19198,15 @@ UPB_PRIVATE(upb_WireWriter_VarintUnusedSizeFromLeadingZeros64)(uint64_t clz) {
|
|
|
17947
19198
|
#undef UPB_NORETURN
|
|
17948
19199
|
#undef UPB_PRINTF
|
|
17949
19200
|
#undef UPB_NODEREF
|
|
19201
|
+
#undef UPB_NODISCARD
|
|
17950
19202
|
#undef UPB_MAX
|
|
17951
19203
|
#undef UPB_MIN
|
|
17952
19204
|
#undef UPB_UNUSED
|
|
17953
19205
|
#undef UPB_ASSUME
|
|
17954
19206
|
#undef UPB_ASSERT
|
|
17955
19207
|
#undef UPB_UNREACHABLE
|
|
19208
|
+
#undef UPB_UNREACHABLE_FAILURE
|
|
19209
|
+
#undef UPB_PRETTY_FUNCTION
|
|
17956
19210
|
#undef UPB_DEFAULT_MAX_BLOCK_SIZE
|
|
17957
19211
|
#undef UPB_SETJMP
|
|
17958
19212
|
#undef UPB_LONGJMP
|
|
@@ -17974,6 +19228,7 @@ UPB_PRIVATE(upb_WireWriter_VarintUnusedSizeFromLeadingZeros64)(uint64_t clz) {
|
|
|
17974
19228
|
#undef UPB_TSAN
|
|
17975
19229
|
#undef UPB_DEPRECATED
|
|
17976
19230
|
#undef UPB_GNUC_MIN
|
|
19231
|
+
#undef UPB_CLANG_MIN
|
|
17977
19232
|
#undef UPB_DESCRIPTOR_UPB_H_FILENAME
|
|
17978
19233
|
#undef UPB_DESC_MINITABLE
|
|
17979
19234
|
#undef UPB_IS_GOOGLE3
|
|
@@ -17986,7 +19241,6 @@ UPB_PRIVATE(upb_WireWriter_VarintUnusedSizeFromLeadingZeros64)(uint64_t clz) {
|
|
|
17986
19241
|
#undef UPB_LINKARR_APPEND
|
|
17987
19242
|
#undef UPB_LINKARR_START
|
|
17988
19243
|
#undef UPB_LINKARR_STOP
|
|
17989
|
-
#undef UPB_FUTURE_BREAKING_CHANGES
|
|
17990
19244
|
#undef UPB_HAS_ATTRIBUTE
|
|
17991
19245
|
#undef UPB_HAS_CPP_ATTRIBUTE
|
|
17992
19246
|
#undef UPB_HAS_BUILTIN
|
|
@@ -18001,3 +19255,6 @@ UPB_PRIVATE(upb_WireWriter_VarintUnusedSizeFromLeadingZeros64)(uint64_t clz) {
|
|
|
18001
19255
|
#undef UPB_DEPRECATE_AND_INLINE
|
|
18002
19256
|
#undef UPB_MAYBE_ASSUME
|
|
18003
19257
|
#undef UPB_ATTR_CONST
|
|
19258
|
+
#undef _UPB_STRINGIFY
|
|
19259
|
+
#undef _UPB_STRINGIFY2
|
|
19260
|
+
#undef UPB_CONSTRUCTOR
|