google-protobuf 4.30.2 → 4.31.0.rc.1
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/defs.c +32 -0
- data/ext/google/protobuf_c/extconf.rb +6 -2
- data/ext/google/protobuf_c/map.c +2 -2
- data/ext/google/protobuf_c/message.c +2 -2
- data/ext/google/protobuf_c/protobuf.h +0 -6
- data/ext/google/protobuf_c/ruby-upb.c +1013 -478
- data/ext/google/protobuf_c/ruby-upb.h +787 -385
- data/lib/google/protobuf/any_pb.rb +1 -1
- data/lib/google/protobuf/api_pb.rb +1 -1
- data/lib/google/protobuf/descriptor_pb.rb +5 -2
- data/lib/google/protobuf/duration_pb.rb +1 -1
- data/lib/google/protobuf/empty_pb.rb +1 -1
- data/lib/google/protobuf/ffi/descriptor_pool.rb +3 -1
- data/lib/google/protobuf/ffi/field_descriptor.rb +6 -0
- data/lib/google/protobuf/ffi/file_descriptor.rb +26 -0
- data/lib/google/protobuf/ffi/internal/pointer_helper.rb +2 -1
- data/lib/google/protobuf/ffi/map.rb +2 -2
- data/lib/google/protobuf/field_mask_pb.rb +1 -1
- data/lib/google/protobuf/message_exts.rb +4 -0
- data/lib/google/protobuf/plugin_pb.rb +1 -1
- data/lib/google/protobuf/source_context_pb.rb +1 -1
- data/lib/google/protobuf/struct_pb.rb +1 -1
- data/lib/google/protobuf/timestamp_pb.rb +1 -1
- data/lib/google/protobuf/type_pb.rb +1 -1
- data/lib/google/protobuf/wrappers_pb.rb +1 -1
- data/lib/google/protobuf_ffi.rb +1 -1
- metadata +20 -20
@@ -68,6 +68,10 @@ Error, UINTPTR_MAX is undefined
|
|
68
68
|
#define UPB_SIZEOF_FLEX(type, member, count) \
|
69
69
|
UPB_MAX(sizeof(type), offsetof(type, member[count]))
|
70
70
|
|
71
|
+
#define UPB_SIZEOF_FLEX_WOULD_OVERFLOW(type, member, count) \
|
72
|
+
(((SIZE_MAX - offsetof(type, member[0])) / \
|
73
|
+
(offsetof(type, member[1]) - offsetof(type, member[0]))) < (size_t)count)
|
74
|
+
|
71
75
|
#define UPB_MAPTYPE_STRING 0
|
72
76
|
|
73
77
|
// UPB_EXPORT: always generate a public symbol.
|
@@ -126,6 +130,8 @@ Error, UINTPTR_MAX is undefined
|
|
126
130
|
#ifdef _MSC_VER
|
127
131
|
// Some versions of our Windows compiler don't support the C11 syntax.
|
128
132
|
#define UPB_ALIGN_AS(x) __declspec(align(x))
|
133
|
+
#elif defined(__GNUC__)
|
134
|
+
#define UPB_ALIGN_AS(x) __attribute__((aligned(x)))
|
129
135
|
#else
|
130
136
|
#define UPB_ALIGN_AS(x) _Alignas(x)
|
131
137
|
#endif
|
@@ -444,6 +450,10 @@ Error, UINTPTR_MAX is undefined
|
|
444
450
|
(!defined(UPB_BOOTSTRAP_STAGE) || UPB_BOOTSTRAP_STAGE != 0)
|
445
451
|
#define UPB_DESC(sym) proto2_##sym
|
446
452
|
#define UPB_DESC_MINITABLE(sym) &proto2__##sym##_msg_init
|
453
|
+
#elif defined(UPB_IS_GOOGLE3) && defined(UPB_BOOTSTRAP_STAGE) && \
|
454
|
+
UPB_BOOTSTRAP_STAGE == 0
|
455
|
+
#define UPB_DESC(sym) proto2_##sym
|
456
|
+
#define UPB_DESC_MINITABLE(sym) proto2__##sym##_msg_init()
|
447
457
|
#elif defined(UPB_BOOTSTRAP_STAGE) && UPB_BOOTSTRAP_STAGE == 0
|
448
458
|
#define UPB_DESC(sym) google_protobuf_##sym
|
449
459
|
#define UPB_DESC_MINITABLE(sym) google__protobuf__##sym##_msg_init()
|
@@ -454,6 +464,12 @@ Error, UINTPTR_MAX is undefined
|
|
454
464
|
|
455
465
|
#undef UPB_IS_GOOGLE3
|
456
466
|
|
467
|
+
#ifdef __clang__
|
468
|
+
#define UPB_NO_SANITIZE_ADDRESS __attribute__((no_sanitize("address")))
|
469
|
+
#else
|
470
|
+
#define UPB_NO_SANITIZE_ADDRESS
|
471
|
+
#endif
|
472
|
+
|
457
473
|
// Linker arrays combine elements from multiple translation units into a single
|
458
474
|
// array that can be iterated over at runtime.
|
459
475
|
//
|
@@ -480,12 +496,12 @@ Error, UINTPTR_MAX is undefined
|
|
480
496
|
|
481
497
|
#if defined(__ELF__) || defined(__wasm__)
|
482
498
|
|
483
|
-
#define UPB_LINKARR_APPEND(name)
|
484
|
-
__attribute__((retain, used,
|
485
|
-
|
486
|
-
#define UPB_LINKARR_DECLARE(name, type)
|
487
|
-
extern type
|
488
|
-
extern type
|
499
|
+
#define UPB_LINKARR_APPEND(name) \
|
500
|
+
__attribute__((retain, used, \
|
501
|
+
section("linkarr_" #name))) UPB_NO_SANITIZE_ADDRESS
|
502
|
+
#define UPB_LINKARR_DECLARE(name, type) \
|
503
|
+
extern type __start_linkarr_##name; \
|
504
|
+
extern type __stop_linkarr_##name; \
|
489
505
|
UPB_LINKARR_APPEND(name) type UPB_linkarr_internal_empty_##name[1]
|
490
506
|
#define UPB_LINKARR_START(name) (&__start_linkarr_##name)
|
491
507
|
#define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
|
@@ -493,15 +509,15 @@ Error, UINTPTR_MAX is undefined
|
|
493
509
|
#elif defined(__MACH__)
|
494
510
|
|
495
511
|
/* As described in: https://stackoverflow.com/a/22366882 */
|
496
|
-
#define UPB_LINKARR_APPEND(name)
|
497
|
-
__attribute__((retain, used,
|
498
|
-
|
499
|
-
#define UPB_LINKARR_DECLARE(name, type)
|
500
|
-
extern type
|
501
|
-
"section$start$__DATA$__la_" #name);
|
502
|
-
extern type
|
503
|
-
"section$end$__DATA$"
|
504
|
-
"__la_" #name);
|
512
|
+
#define UPB_LINKARR_APPEND(name) \
|
513
|
+
__attribute__((retain, used, \
|
514
|
+
section("__DATA,__la_" #name))) UPB_NO_SANITIZE_ADDRESS
|
515
|
+
#define UPB_LINKARR_DECLARE(name, type) \
|
516
|
+
extern type __start_linkarr_##name __asm( \
|
517
|
+
"section$start$__DATA$__la_" #name); \
|
518
|
+
extern type __stop_linkarr_##name __asm( \
|
519
|
+
"section$end$__DATA$" \
|
520
|
+
"__la_" #name); \
|
505
521
|
UPB_LINKARR_APPEND(name) type UPB_linkarr_internal_empty_##name[1]
|
506
522
|
#define UPB_LINKARR_START(name) (&__start_linkarr_##name)
|
507
523
|
#define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
|
@@ -517,7 +533,7 @@ Error, UINTPTR_MAX is undefined
|
|
517
533
|
// not work on MSVC.
|
518
534
|
#define UPB_LINKARR_APPEND(name) \
|
519
535
|
__declspec(allocate("la_" #name "$j")) \
|
520
|
-
__attribute__((retain, used
|
536
|
+
__attribute__((retain, used)) UPB_NO_SANITIZE_ADDRESS
|
521
537
|
#define UPB_LINKARR_DECLARE(name, type) \
|
522
538
|
__declspec(allocate("la_" #name "$a")) type __start_linkarr_##name; \
|
523
539
|
__declspec(allocate("la_" #name "$z")) type __stop_linkarr_##name; \
|
@@ -738,45 +754,83 @@ UPB_API_INLINE void* upb_Arena_Malloc(struct upb_Arena* a, size_t size) {
|
|
738
754
|
return ret;
|
739
755
|
}
|
740
756
|
|
757
|
+
UPB_API_INLINE void upb_Arena_ShrinkLast(struct upb_Arena* a, void* ptr,
|
758
|
+
size_t oldsize, size_t size) {
|
759
|
+
UPB_TSAN_CHECK_WRITE(a->UPB_ONLYBITS(ptr));
|
760
|
+
UPB_ASSERT(ptr);
|
761
|
+
UPB_ASSERT(size <= oldsize);
|
762
|
+
size = UPB_ALIGN_MALLOC(size) + UPB_ASAN_GUARD_SIZE;
|
763
|
+
oldsize = UPB_ALIGN_MALLOC(oldsize) + UPB_ASAN_GUARD_SIZE;
|
764
|
+
if (size == oldsize) {
|
765
|
+
return;
|
766
|
+
}
|
767
|
+
char* arena_ptr = a->UPB_ONLYBITS(ptr);
|
768
|
+
// If it's the last alloc in the last block, we can resize.
|
769
|
+
if ((char*)ptr + oldsize == arena_ptr) {
|
770
|
+
a->UPB_ONLYBITS(ptr) = (char*)ptr + size;
|
771
|
+
} else {
|
772
|
+
// If not, verify that it could have been a full-block alloc that did not
|
773
|
+
// replace the last block.
|
774
|
+
#ifndef NDEBUG
|
775
|
+
bool _upb_Arena_WasLastAlloc(struct upb_Arena * a, void* ptr,
|
776
|
+
size_t oldsize);
|
777
|
+
UPB_ASSERT(_upb_Arena_WasLastAlloc(a, ptr, oldsize));
|
778
|
+
#endif
|
779
|
+
}
|
780
|
+
UPB_POISON_MEMORY_REGION((char*)ptr + (size - UPB_ASAN_GUARD_SIZE),
|
781
|
+
oldsize - size);
|
782
|
+
}
|
783
|
+
|
784
|
+
UPB_API_INLINE bool upb_Arena_TryExtend(struct upb_Arena* a, void* ptr,
|
785
|
+
size_t oldsize, size_t size) {
|
786
|
+
UPB_TSAN_CHECK_WRITE(a->UPB_ONLYBITS(ptr));
|
787
|
+
UPB_ASSERT(ptr);
|
788
|
+
UPB_ASSERT(size > oldsize);
|
789
|
+
size = UPB_ALIGN_MALLOC(size) + UPB_ASAN_GUARD_SIZE;
|
790
|
+
oldsize = UPB_ALIGN_MALLOC(oldsize) + UPB_ASAN_GUARD_SIZE;
|
791
|
+
if (size == oldsize) {
|
792
|
+
return true;
|
793
|
+
}
|
794
|
+
size_t extend = size - oldsize;
|
795
|
+
if ((char*)ptr + oldsize == a->UPB_ONLYBITS(ptr) &&
|
796
|
+
UPB_PRIVATE(_upb_ArenaHas)(a) >= extend) {
|
797
|
+
a->UPB_ONLYBITS(ptr) += extend;
|
798
|
+
UPB_UNPOISON_MEMORY_REGION((char*)ptr + (oldsize - UPB_ASAN_GUARD_SIZE),
|
799
|
+
extend);
|
800
|
+
return true;
|
801
|
+
}
|
802
|
+
return false;
|
803
|
+
}
|
804
|
+
|
741
805
|
UPB_API_INLINE void* upb_Arena_Realloc(struct upb_Arena* a, void* ptr,
|
742
806
|
size_t oldsize, size_t size) {
|
743
807
|
UPB_TSAN_CHECK_WRITE(a->UPB_ONLYBITS(ptr));
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
808
|
+
if (ptr) {
|
809
|
+
if (size == oldsize) {
|
810
|
+
return ptr;
|
811
|
+
}
|
812
|
+
if (size > oldsize) {
|
813
|
+
if (upb_Arena_TryExtend(a, ptr, oldsize, size)) return ptr;
|
814
|
+
} else {
|
815
|
+
if ((char*)ptr + (UPB_ALIGN_MALLOC(oldsize) + UPB_ASAN_GUARD_SIZE) ==
|
816
|
+
a->UPB_ONLYBITS(ptr)) {
|
817
|
+
upb_Arena_ShrinkLast(a, ptr, oldsize, size);
|
818
|
+
} else {
|
819
|
+
UPB_POISON_MEMORY_REGION((char*)ptr + size, oldsize - size);
|
820
|
+
}
|
753
821
|
return ptr;
|
754
822
|
}
|
755
|
-
} else if (size <= oldsize) {
|
756
|
-
return ptr;
|
757
823
|
}
|
758
|
-
|
759
824
|
void* ret = upb_Arena_Malloc(a, size);
|
760
825
|
|
761
826
|
if (ret && oldsize > 0) {
|
762
827
|
memcpy(ret, ptr, UPB_MIN(oldsize, size));
|
828
|
+
UPB_POISON_MEMORY_REGION(ptr, oldsize);
|
763
829
|
}
|
764
830
|
|
765
831
|
return ret;
|
766
832
|
}
|
767
833
|
|
768
|
-
UPB_API_INLINE void upb_Arena_ShrinkLast(struct upb_Arena* a, void* ptr,
|
769
|
-
size_t oldsize, size_t size) {
|
770
|
-
UPB_TSAN_CHECK_WRITE(a->UPB_ONLYBITS(ptr));
|
771
|
-
oldsize = UPB_ALIGN_MALLOC(oldsize);
|
772
|
-
size = UPB_ALIGN_MALLOC(size);
|
773
|
-
// Must be the last alloc.
|
774
|
-
UPB_ASSERT((char*)ptr + oldsize ==
|
775
|
-
a->UPB_ONLYBITS(ptr) - UPB_ASAN_GUARD_SIZE);
|
776
|
-
UPB_ASSERT(size <= oldsize);
|
777
|
-
a->UPB_ONLYBITS(ptr) = (char*)ptr + size;
|
778
|
-
}
|
779
|
-
|
780
834
|
#ifdef __cplusplus
|
781
835
|
} /* extern "C" */
|
782
836
|
#endif
|
@@ -866,6 +920,16 @@ void upb_Arena_SetMaxBlockSize(size_t max);
|
|
866
920
|
UPB_API_INLINE void upb_Arena_ShrinkLast(upb_Arena* a, void* ptr,
|
867
921
|
size_t oldsize, size_t size);
|
868
922
|
|
923
|
+
// Attempts to extend the given alloc from arena, in place. Is generally
|
924
|
+
// only likely to succeed for the most recent allocation from this arena. If it
|
925
|
+
// succeeds, returns true and `ptr`'s allocation is now `size` rather than
|
926
|
+
// `oldsize`. Returns false if the allocation cannot be extended; `ptr`'s
|
927
|
+
// allocation is unmodified. See also upb_Arena_Realloc.
|
928
|
+
// REQUIRES: `size > oldsize`; to shrink, use `upb_Arena_Realloc` or
|
929
|
+
// `upb_Arena_ShrinkLast`.
|
930
|
+
UPB_API_INLINE bool upb_Arena_TryExtend(upb_Arena* a, void* ptr, size_t oldsize,
|
931
|
+
size_t size);
|
932
|
+
|
869
933
|
#ifdef UPB_TRACING_ENABLED
|
870
934
|
void upb_Arena_SetTraceHandler(void (*initArenaTraceHandler)(const upb_Arena*,
|
871
935
|
size_t size),
|
@@ -1592,16 +1656,6 @@ UPB_API_INLINE size_t upb_Array_Size(const struct upb_Array* arr) {
|
|
1592
1656
|
|
1593
1657
|
#endif /* UPB_MESSAGE_INTERNAL_ARRAY_H_ */
|
1594
1658
|
|
1595
|
-
// Users should include array.h or map.h instead.
|
1596
|
-
// IWYU pragma: private, include "upb/message/array.h"
|
1597
|
-
|
1598
|
-
#ifndef UPB_MESSAGE_VALUE_H_
|
1599
|
-
#define UPB_MESSAGE_VALUE_H_
|
1600
|
-
|
1601
|
-
#include <stdint.h>
|
1602
|
-
#include <string.h>
|
1603
|
-
|
1604
|
-
|
1605
1659
|
#ifndef UPB_MESSAGE_INTERNAL_TYPES_H_
|
1606
1660
|
#define UPB_MESSAGE_INTERNAL_TYPES_H_
|
1607
1661
|
|
@@ -1652,6 +1706,16 @@ UPB_INLINE void UPB_PRIVATE(_upb_Message_SetInternal)(
|
|
1652
1706
|
|
1653
1707
|
#endif /* UPB_MESSAGE_INTERNAL_TYPES_H_ */
|
1654
1708
|
|
1709
|
+
// Users should include array.h or map.h instead.
|
1710
|
+
// IWYU pragma: private, include "upb/message/array.h"
|
1711
|
+
|
1712
|
+
#ifndef UPB_MESSAGE_VALUE_H_
|
1713
|
+
#define UPB_MESSAGE_VALUE_H_
|
1714
|
+
|
1715
|
+
#include <stdint.h>
|
1716
|
+
#include <string.h>
|
1717
|
+
|
1718
|
+
|
1655
1719
|
// Must be last.
|
1656
1720
|
|
1657
1721
|
#ifdef __cplusplus
|
@@ -1711,6 +1775,84 @@ UPB_API_INLINE upb_MutableMessageValue upb_MutableMessageValue_Zero(void) {
|
|
1711
1775
|
|
1712
1776
|
#endif /* UPB_MESSAGE_VALUE_H_ */
|
1713
1777
|
|
1778
|
+
#ifndef UPB_MINI_TABLE_MESSAGE_H_
|
1779
|
+
#define UPB_MINI_TABLE_MESSAGE_H_
|
1780
|
+
|
1781
|
+
|
1782
|
+
#ifndef UPB_MINI_TABLE_ENUM_H_
|
1783
|
+
#define UPB_MINI_TABLE_ENUM_H_
|
1784
|
+
|
1785
|
+
#include <stdint.h>
|
1786
|
+
|
1787
|
+
|
1788
|
+
#ifndef UPB_MINI_TABLE_INTERNAL_ENUM_H_
|
1789
|
+
#define UPB_MINI_TABLE_INTERNAL_ENUM_H_
|
1790
|
+
|
1791
|
+
#include <stdint.h>
|
1792
|
+
|
1793
|
+
// Must be last.
|
1794
|
+
|
1795
|
+
struct upb_MiniTableEnum {
|
1796
|
+
uint32_t UPB_PRIVATE(mask_limit); // Highest that can be tested with mask.
|
1797
|
+
uint32_t UPB_PRIVATE(value_count); // Number of values after the bitfield.
|
1798
|
+
uint32_t UPB_PRIVATE(data)[]; // Bitmask + enumerated values follow.
|
1799
|
+
};
|
1800
|
+
|
1801
|
+
#ifdef __cplusplus
|
1802
|
+
extern "C" {
|
1803
|
+
#endif
|
1804
|
+
|
1805
|
+
UPB_API_INLINE bool upb_MiniTableEnum_CheckValue(
|
1806
|
+
const struct upb_MiniTableEnum* e, uint32_t val) {
|
1807
|
+
if (UPB_LIKELY(val < 64)) {
|
1808
|
+
const uint64_t mask =
|
1809
|
+
e->UPB_PRIVATE(data)[0] | ((uint64_t)e->UPB_PRIVATE(data)[1] << 32);
|
1810
|
+
const uint64_t bit = 1ULL << val;
|
1811
|
+
return (mask & bit) != 0;
|
1812
|
+
}
|
1813
|
+
if (UPB_LIKELY(val < e->UPB_PRIVATE(mask_limit))) {
|
1814
|
+
const uint32_t mask = e->UPB_PRIVATE(data)[val / 32];
|
1815
|
+
const uint32_t bit = 1U << (val % 32);
|
1816
|
+
return (mask & bit) != 0;
|
1817
|
+
}
|
1818
|
+
|
1819
|
+
// OPT: binary search long lists?
|
1820
|
+
const uint32_t* start =
|
1821
|
+
&e->UPB_PRIVATE(data)[e->UPB_PRIVATE(mask_limit) / 32];
|
1822
|
+
const uint32_t* limit = &e->UPB_PRIVATE(
|
1823
|
+
data)[e->UPB_PRIVATE(mask_limit) / 32 + e->UPB_PRIVATE(value_count)];
|
1824
|
+
for (const uint32_t* p = start; p < limit; p++) {
|
1825
|
+
if (*p == val) return true;
|
1826
|
+
}
|
1827
|
+
return false;
|
1828
|
+
}
|
1829
|
+
|
1830
|
+
#ifdef __cplusplus
|
1831
|
+
} /* extern "C" */
|
1832
|
+
#endif
|
1833
|
+
|
1834
|
+
|
1835
|
+
#endif /* UPB_MINI_TABLE_INTERNAL_ENUM_H_ */
|
1836
|
+
|
1837
|
+
// Must be last
|
1838
|
+
|
1839
|
+
typedef struct upb_MiniTableEnum upb_MiniTableEnum;
|
1840
|
+
|
1841
|
+
#ifdef __cplusplus
|
1842
|
+
extern "C" {
|
1843
|
+
#endif
|
1844
|
+
|
1845
|
+
// Validates enum value against range defined by enum mini table.
|
1846
|
+
UPB_API_INLINE bool upb_MiniTableEnum_CheckValue(const upb_MiniTableEnum* e,
|
1847
|
+
uint32_t val);
|
1848
|
+
|
1849
|
+
#ifdef __cplusplus
|
1850
|
+
} /* extern "C" */
|
1851
|
+
#endif
|
1852
|
+
|
1853
|
+
|
1854
|
+
#endif /* UPB_MINI_TABLE_ENUM_H_ */
|
1855
|
+
|
1714
1856
|
#ifndef UPB_MINI_TABLE_FIELD_H_
|
1715
1857
|
#define UPB_MINI_TABLE_FIELD_H_
|
1716
1858
|
|
@@ -1809,7 +1951,7 @@ struct upb_MiniTableField {
|
|
1809
1951
|
uint8_t UPB_ONLYBITS(mode);
|
1810
1952
|
};
|
1811
1953
|
|
1812
|
-
#define kUpb_NoSub ((uint16_t)
|
1954
|
+
#define kUpb_NoSub ((uint16_t)-1)
|
1813
1955
|
|
1814
1956
|
typedef enum {
|
1815
1957
|
kUpb_FieldMode_Map = 0,
|
@@ -1914,14 +2056,14 @@ UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(
|
|
1914
2056
|
UPB_INLINE char UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(
|
1915
2057
|
const struct upb_MiniTableField* f) {
|
1916
2058
|
UPB_ASSERT(UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f));
|
1917
|
-
const
|
2059
|
+
const uint16_t index = f->presence;
|
1918
2060
|
return 1 << (index % 8);
|
1919
2061
|
}
|
1920
2062
|
|
1921
|
-
UPB_INLINE
|
2063
|
+
UPB_INLINE uint16_t UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(
|
1922
2064
|
const struct upb_MiniTableField* f) {
|
1923
2065
|
UPB_ASSERT(UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f));
|
1924
|
-
const
|
2066
|
+
const uint16_t index = f->presence;
|
1925
2067
|
return index / 8;
|
1926
2068
|
}
|
1927
2069
|
|
@@ -2039,84 +2181,6 @@ upb_MiniTableField_Type(const upb_MiniTableField* f);
|
|
2039
2181
|
|
2040
2182
|
#endif /* UPB_MINI_TABLE_FIELD_H_ */
|
2041
2183
|
|
2042
|
-
#ifndef UPB_MINI_TABLE_MESSAGE_H_
|
2043
|
-
#define UPB_MINI_TABLE_MESSAGE_H_
|
2044
|
-
|
2045
|
-
|
2046
|
-
#ifndef UPB_MINI_TABLE_ENUM_H_
|
2047
|
-
#define UPB_MINI_TABLE_ENUM_H_
|
2048
|
-
|
2049
|
-
#include <stdint.h>
|
2050
|
-
|
2051
|
-
|
2052
|
-
#ifndef UPB_MINI_TABLE_INTERNAL_ENUM_H_
|
2053
|
-
#define UPB_MINI_TABLE_INTERNAL_ENUM_H_
|
2054
|
-
|
2055
|
-
#include <stdint.h>
|
2056
|
-
|
2057
|
-
// Must be last.
|
2058
|
-
|
2059
|
-
struct upb_MiniTableEnum {
|
2060
|
-
uint32_t UPB_PRIVATE(mask_limit); // Highest that can be tested with mask.
|
2061
|
-
uint32_t UPB_PRIVATE(value_count); // Number of values after the bitfield.
|
2062
|
-
uint32_t UPB_PRIVATE(data)[]; // Bitmask + enumerated values follow.
|
2063
|
-
};
|
2064
|
-
|
2065
|
-
#ifdef __cplusplus
|
2066
|
-
extern "C" {
|
2067
|
-
#endif
|
2068
|
-
|
2069
|
-
UPB_API_INLINE bool upb_MiniTableEnum_CheckValue(
|
2070
|
-
const struct upb_MiniTableEnum* e, uint32_t val) {
|
2071
|
-
if (UPB_LIKELY(val < 64)) {
|
2072
|
-
const uint64_t mask =
|
2073
|
-
e->UPB_PRIVATE(data)[0] | ((uint64_t)e->UPB_PRIVATE(data)[1] << 32);
|
2074
|
-
const uint64_t bit = 1ULL << val;
|
2075
|
-
return (mask & bit) != 0;
|
2076
|
-
}
|
2077
|
-
if (UPB_LIKELY(val < e->UPB_PRIVATE(mask_limit))) {
|
2078
|
-
const uint32_t mask = e->UPB_PRIVATE(data)[val / 32];
|
2079
|
-
const uint32_t bit = 1ULL << (val % 32);
|
2080
|
-
return (mask & bit) != 0;
|
2081
|
-
}
|
2082
|
-
|
2083
|
-
// OPT: binary search long lists?
|
2084
|
-
const uint32_t* start =
|
2085
|
-
&e->UPB_PRIVATE(data)[e->UPB_PRIVATE(mask_limit) / 32];
|
2086
|
-
const uint32_t* limit = &e->UPB_PRIVATE(
|
2087
|
-
data)[e->UPB_PRIVATE(mask_limit) / 32 + e->UPB_PRIVATE(value_count)];
|
2088
|
-
for (const uint32_t* p = start; p < limit; p++) {
|
2089
|
-
if (*p == val) return true;
|
2090
|
-
}
|
2091
|
-
return false;
|
2092
|
-
}
|
2093
|
-
|
2094
|
-
#ifdef __cplusplus
|
2095
|
-
} /* extern "C" */
|
2096
|
-
#endif
|
2097
|
-
|
2098
|
-
|
2099
|
-
#endif /* UPB_MINI_TABLE_INTERNAL_ENUM_H_ */
|
2100
|
-
|
2101
|
-
// Must be last
|
2102
|
-
|
2103
|
-
typedef struct upb_MiniTableEnum upb_MiniTableEnum;
|
2104
|
-
|
2105
|
-
#ifdef __cplusplus
|
2106
|
-
extern "C" {
|
2107
|
-
#endif
|
2108
|
-
|
2109
|
-
// Validates enum value against range defined by enum mini table.
|
2110
|
-
UPB_API_INLINE bool upb_MiniTableEnum_CheckValue(const upb_MiniTableEnum* e,
|
2111
|
-
uint32_t val);
|
2112
|
-
|
2113
|
-
#ifdef __cplusplus
|
2114
|
-
} /* extern "C" */
|
2115
|
-
#endif
|
2116
|
-
|
2117
|
-
|
2118
|
-
#endif /* UPB_MINI_TABLE_ENUM_H_ */
|
2119
|
-
|
2120
2184
|
#ifndef UPB_MINI_TABLE_INTERNAL_MESSAGE_H_
|
2121
2185
|
#define UPB_MINI_TABLE_INTERNAL_MESSAGE_H_
|
2122
2186
|
|
@@ -2222,7 +2286,7 @@ struct upb_MiniTable {
|
|
2222
2286
|
const char* UPB_PRIVATE(full_name);
|
2223
2287
|
#endif
|
2224
2288
|
|
2225
|
-
#ifdef
|
2289
|
+
#ifdef UPB_FASTTABLE
|
2226
2290
|
// To statically initialize the tables of variable length, we need a flexible
|
2227
2291
|
// array member, and we need to compile in gnu99 mode (constant initialization
|
2228
2292
|
// of flexible array members is a GNU extension, not in C99 unfortunately.
|
@@ -2456,9 +2520,9 @@ UPB_API_INLINE size_t upb_Array_Size(const upb_Array* arr);
|
|
2456
2520
|
// Returns the given element, which must be within the array's current size.
|
2457
2521
|
UPB_API upb_MessageValue upb_Array_Get(const upb_Array* arr, size_t i);
|
2458
2522
|
|
2459
|
-
// Returns a mutating pointer to the given element
|
2460
|
-
// array's current size.
|
2461
|
-
UPB_API
|
2523
|
+
// Returns a non-null mutating pointer to the given element. `arr` must be an
|
2524
|
+
// array of a message type, and `i` must be within the array's current size.
|
2525
|
+
UPB_API struct upb_Message* upb_Array_GetMutable(upb_Array* arr, size_t i);
|
2462
2526
|
|
2463
2527
|
// Sets the given element, which must be within the array's current size.
|
2464
2528
|
UPB_API void upb_Array_Set(upb_Array* arr, size_t i, upb_MessageValue val);
|
@@ -2523,13 +2587,10 @@ UPB_API_INLINE bool upb_Array_IsFrozen(const upb_Array* arr);
|
|
2523
2587
|
#define UPB_MESSAGE_INTERNAL_MAP_H_
|
2524
2588
|
|
2525
2589
|
#include <stddef.h>
|
2590
|
+
#include <stdint.h>
|
2526
2591
|
#include <string.h>
|
2527
2592
|
|
2528
2593
|
|
2529
|
-
#ifndef UPB_HASH_STR_TABLE_H_
|
2530
|
-
#define UPB_HASH_STR_TABLE_H_
|
2531
|
-
|
2532
|
-
|
2533
2594
|
/*
|
2534
2595
|
* upb_table
|
2535
2596
|
*
|
@@ -2552,6 +2613,7 @@ UPB_API_INLINE bool upb_Array_IsFrozen(const upb_Array* arr);
|
|
2552
2613
|
#ifndef UPB_HASH_COMMON_H_
|
2553
2614
|
#define UPB_HASH_COMMON_H_
|
2554
2615
|
|
2616
|
+
#include <stdint.h>
|
2555
2617
|
#include <string.h>
|
2556
2618
|
|
2557
2619
|
|
@@ -2567,8 +2629,6 @@ typedef struct {
|
|
2567
2629
|
uint64_t val;
|
2568
2630
|
} upb_value;
|
2569
2631
|
|
2570
|
-
UPB_INLINE void _upb_value_setval(upb_value* v, uint64_t val) { v->val = val; }
|
2571
|
-
|
2572
2632
|
/* For each value ctype, define the following set of functions:
|
2573
2633
|
*
|
2574
2634
|
* // Get/set an int32 from a upb_value.
|
@@ -2579,7 +2639,7 @@ UPB_INLINE void _upb_value_setval(upb_value* v, uint64_t val) { v->val = val; }
|
|
2579
2639
|
* upb_value upb_value_int32(int32_t val); */
|
2580
2640
|
#define FUNCS(name, membername, type_t, converter) \
|
2581
2641
|
UPB_INLINE void upb_value_set##name(upb_value* val, type_t cval) { \
|
2582
|
-
val->val = (
|
2642
|
+
val->val = (uint64_t)cval; \
|
2583
2643
|
} \
|
2584
2644
|
UPB_INLINE upb_value upb_value_##name(type_t val) { \
|
2585
2645
|
upb_value ret; \
|
@@ -2622,45 +2682,33 @@ UPB_INLINE upb_value upb_value_double(double cval) {
|
|
2622
2682
|
return ret;
|
2623
2683
|
}
|
2624
2684
|
|
2625
|
-
/*
|
2685
|
+
/* upb_key *****************************************************************/
|
2686
|
+
|
2687
|
+
// A uint32 size followed by that number of bytes stored contiguously.
|
2688
|
+
typedef struct {
|
2689
|
+
uint32_t size;
|
2690
|
+
const char data[];
|
2691
|
+
} upb_SizePrefixString;
|
2626
2692
|
|
2627
2693
|
/* Either:
|
2628
|
-
* 1. an actual integer key
|
2629
|
-
* 2. a
|
2694
|
+
* 1. an actual integer key
|
2695
|
+
* 2. a SizePrefixString*, owned by us.
|
2630
2696
|
*
|
2631
|
-
* ...depending on whether this is a string table or an int table.
|
2632
|
-
|
2633
|
-
|
2634
|
-
|
2635
|
-
|
2636
|
-
UPB_INLINE char* upb_tabstr(upb_tabkey key, uint32_t* len) {
|
2637
|
-
char* mem = (char*)key;
|
2638
|
-
if (len) memcpy(len, mem, sizeof(*len));
|
2639
|
-
return mem + sizeof(*len);
|
2640
|
-
}
|
2697
|
+
* ...depending on whether this is a string table or an int table. */
|
2698
|
+
typedef union {
|
2699
|
+
uintptr_t num;
|
2700
|
+
const upb_SizePrefixString* str;
|
2701
|
+
} upb_key;
|
2641
2702
|
|
2642
|
-
UPB_INLINE upb_StringView
|
2643
|
-
|
2644
|
-
uint32_t len;
|
2645
|
-
ret.data = upb_tabstr(key, &len);
|
2646
|
-
ret.size = len;
|
2647
|
-
return ret;
|
2703
|
+
UPB_INLINE upb_StringView upb_key_strview(upb_key key) {
|
2704
|
+
return upb_StringView_FromDataAndSize(key.str->data, key.str->size);
|
2648
2705
|
}
|
2649
2706
|
|
2650
|
-
/* upb_tabval *****************************************************************/
|
2651
|
-
|
2652
|
-
typedef struct upb_tabval {
|
2653
|
-
uint64_t val;
|
2654
|
-
} upb_tabval;
|
2655
|
-
|
2656
|
-
#define UPB_TABVALUE_EMPTY_INIT \
|
2657
|
-
{ -1 }
|
2658
|
-
|
2659
2707
|
/* upb_table ******************************************************************/
|
2660
2708
|
|
2661
2709
|
typedef struct _upb_tabent {
|
2662
|
-
|
2663
|
-
|
2710
|
+
upb_value val;
|
2711
|
+
upb_key key;
|
2664
2712
|
|
2665
2713
|
/* Internal chaining. This is const so we can create static initializers for
|
2666
2714
|
* tables. We cast away const sometimes, but *only* when the containing
|
@@ -2670,20 +2718,35 @@ typedef struct _upb_tabent {
|
|
2670
2718
|
} upb_tabent;
|
2671
2719
|
|
2672
2720
|
typedef struct {
|
2673
|
-
size_t count; /* Number of entries in the hash part. */
|
2674
|
-
uint32_t mask; /* Mask to turn hash value -> bucket. */
|
2675
|
-
uint32_t max_count; /* Max count before we hit our load limit. */
|
2676
|
-
uint8_t size_lg2; /* Size of the hashtable part is 2^size_lg2 entries. */
|
2677
2721
|
upb_tabent* entries;
|
2722
|
+
/* Number of entries in the hash part. */
|
2723
|
+
uint32_t count;
|
2724
|
+
|
2725
|
+
/* Mask to turn hash value -> bucket. The map's allocated size is mask + 1.*/
|
2726
|
+
uint32_t mask;
|
2678
2727
|
} upb_table;
|
2679
2728
|
|
2680
|
-
UPB_INLINE size_t upb_table_size(const upb_table* t) {
|
2681
|
-
return t->size_lg2 ? 1 << t->size_lg2 : 0;
|
2682
|
-
}
|
2729
|
+
UPB_INLINE size_t upb_table_size(const upb_table* t) { return t->mask + 1; }
|
2683
2730
|
|
2684
2731
|
// Internal-only functions, in .h file only out of necessity.
|
2685
2732
|
|
2686
|
-
UPB_INLINE
|
2733
|
+
UPB_INLINE upb_key upb_key_empty(void) {
|
2734
|
+
upb_key ret;
|
2735
|
+
memset(&ret, 0, sizeof(upb_key));
|
2736
|
+
return ret;
|
2737
|
+
}
|
2738
|
+
|
2739
|
+
UPB_INLINE bool upb_tabent_isempty(const upb_tabent* e) {
|
2740
|
+
upb_key key = e->key;
|
2741
|
+
UPB_ASSERT(sizeof(key.num) == sizeof(key.str));
|
2742
|
+
uintptr_t val;
|
2743
|
+
memcpy(&val, &key, sizeof(val));
|
2744
|
+
// Note: for upb_inttables a tab_key is a true integer key value, but the
|
2745
|
+
// inttable maintains the invariant that 0 value is always stored in the
|
2746
|
+
// compact table and never as a upb_tabent* so we can always use the 0
|
2747
|
+
// key value to identify an empty tabent.
|
2748
|
+
return val == 0;
|
2749
|
+
}
|
2687
2750
|
|
2688
2751
|
uint32_t _upb_Hash(const void* p, size_t n, uint64_t seed);
|
2689
2752
|
|
@@ -2694,6 +2757,110 @@ uint32_t _upb_Hash(const void* p, size_t n, uint64_t seed);
|
|
2694
2757
|
|
2695
2758
|
#endif /* UPB_HASH_COMMON_H_ */
|
2696
2759
|
|
2760
|
+
#ifndef UPB_HASH_INT_TABLE_H_
|
2761
|
+
#define UPB_HASH_INT_TABLE_H_
|
2762
|
+
|
2763
|
+
#include <stddef.h>
|
2764
|
+
#include <stdint.h>
|
2765
|
+
|
2766
|
+
|
2767
|
+
// Must be last.
|
2768
|
+
|
2769
|
+
typedef struct {
|
2770
|
+
upb_table t; // For entries that don't fit in the array part.
|
2771
|
+
// Array part of the table.
|
2772
|
+
// Pointers on this table are const so we can create static initializers for
|
2773
|
+
// tables. We cast away const sometimes, but *only* when the containing
|
2774
|
+
// upb_table is known to be non-const. This requires a bit of care, but
|
2775
|
+
// the subtlety is confined to table.c.
|
2776
|
+
const upb_value* array;
|
2777
|
+
// Track presence in the array part. Each bit at index (key % 8) at the
|
2778
|
+
// presence_mask[key/8] indicates if the element is present in the array part.
|
2779
|
+
const uint8_t* presence_mask;
|
2780
|
+
uint32_t array_size; // Array part size.
|
2781
|
+
uint32_t array_count; // Array part number of elements.
|
2782
|
+
} upb_inttable;
|
2783
|
+
|
2784
|
+
#ifdef __cplusplus
|
2785
|
+
extern "C" {
|
2786
|
+
#endif
|
2787
|
+
|
2788
|
+
// Initialize a table. If memory allocation failed, false is returned and
|
2789
|
+
// the table is uninitialized.
|
2790
|
+
bool upb_inttable_init(upb_inttable* table, upb_Arena* a);
|
2791
|
+
|
2792
|
+
// Returns the number of values in the table.
|
2793
|
+
size_t upb_inttable_count(const upb_inttable* t);
|
2794
|
+
|
2795
|
+
// Inserts the given key into the hashtable with the given value.
|
2796
|
+
// The key must not already exist in the hash table.
|
2797
|
+
// The value must not be UINTPTR_MAX.
|
2798
|
+
//
|
2799
|
+
// If a table resize was required but memory allocation failed, false is
|
2800
|
+
// returned and the table is unchanged.
|
2801
|
+
bool upb_inttable_insert(upb_inttable* t, uintptr_t key, upb_value val,
|
2802
|
+
upb_Arena* a);
|
2803
|
+
|
2804
|
+
// Looks up key in this table, returning "true" if the key was found.
|
2805
|
+
// If v is non-NULL, copies the value for this key into *v.
|
2806
|
+
bool upb_inttable_lookup(const upb_inttable* t, uintptr_t key, upb_value* v);
|
2807
|
+
|
2808
|
+
// Removes an item from the table. Returns true if the remove was successful,
|
2809
|
+
// and stores the removed item in *val if non-NULL.
|
2810
|
+
bool upb_inttable_remove(upb_inttable* t, uintptr_t key, upb_value* val);
|
2811
|
+
|
2812
|
+
// Updates an existing entry in an inttable.
|
2813
|
+
// If the entry does not exist, returns false and does nothing.
|
2814
|
+
// Unlike insert/remove, this does not invalidate iterators.
|
2815
|
+
bool upb_inttable_replace(upb_inttable* t, uintptr_t key, upb_value val);
|
2816
|
+
|
2817
|
+
// Optimizes the table for the current set of entries, for both memory use and
|
2818
|
+
// lookup time. Client should call this after all entries have been inserted;
|
2819
|
+
// inserting more entries is legal, but will likely require a table resize.
|
2820
|
+
// Returns false if reallocation fails.
|
2821
|
+
bool upb_inttable_compact(upb_inttable* t, upb_Arena* a);
|
2822
|
+
|
2823
|
+
// Clears the table.
|
2824
|
+
void upb_inttable_clear(upb_inttable* t);
|
2825
|
+
|
2826
|
+
// Iteration over inttable:
|
2827
|
+
//
|
2828
|
+
// intptr_t iter = UPB_INTTABLE_BEGIN;
|
2829
|
+
// uintptr_t key;
|
2830
|
+
// upb_value val;
|
2831
|
+
// while (upb_inttable_next(t, &key, &val, &iter)) {
|
2832
|
+
// // ...
|
2833
|
+
// }
|
2834
|
+
|
2835
|
+
#define UPB_INTTABLE_BEGIN -1
|
2836
|
+
|
2837
|
+
bool upb_inttable_next(const upb_inttable* t, uintptr_t* key, upb_value* val,
|
2838
|
+
intptr_t* iter);
|
2839
|
+
void upb_inttable_removeiter(upb_inttable* t, intptr_t* iter);
|
2840
|
+
void upb_inttable_setentryvalue(upb_inttable* t, intptr_t iter, upb_value v);
|
2841
|
+
bool upb_inttable_done(const upb_inttable* t, intptr_t i);
|
2842
|
+
uintptr_t upb_inttable_iter_key(const upb_inttable* t, intptr_t iter);
|
2843
|
+
upb_value upb_inttable_iter_value(const upb_inttable* t, intptr_t iter);
|
2844
|
+
|
2845
|
+
UPB_INLINE bool upb_inttable_arrhas(const upb_inttable* t, uintptr_t key) {
|
2846
|
+
return (t->presence_mask[key / 8] & (1 << (key % 8))) != 0;
|
2847
|
+
}
|
2848
|
+
|
2849
|
+
#ifdef __cplusplus
|
2850
|
+
} /* extern "C" */
|
2851
|
+
#endif
|
2852
|
+
|
2853
|
+
|
2854
|
+
#endif /* UPB_HASH_INT_TABLE_H_ */
|
2855
|
+
|
2856
|
+
#ifndef UPB_HASH_STR_TABLE_H_
|
2857
|
+
#define UPB_HASH_STR_TABLE_H_
|
2858
|
+
|
2859
|
+
#include <stddef.h>
|
2860
|
+
#include <stdint.h>
|
2861
|
+
#include <string.h>
|
2862
|
+
|
2863
|
+
|
2697
2864
|
// Must be last.
|
2698
2865
|
|
2699
2866
|
typedef struct {
|
@@ -2833,14 +3000,20 @@ typedef enum {
|
|
2833
3000
|
|
2834
3001
|
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
|
2835
3002
|
|
3003
|
+
union upb_Map_Table {
|
3004
|
+
upb_strtable strtable;
|
3005
|
+
upb_inttable inttable;
|
3006
|
+
};
|
3007
|
+
|
2836
3008
|
struct upb_Map {
|
2837
3009
|
// Size of key and val, based on the map type.
|
2838
3010
|
// Strings are represented as '0' because they must be handled specially.
|
2839
3011
|
char key_size;
|
2840
3012
|
char val_size;
|
2841
3013
|
bool UPB_PRIVATE(is_frozen);
|
3014
|
+
bool UPB_PRIVATE(is_strtable);
|
2842
3015
|
|
2843
|
-
|
3016
|
+
union upb_Map_Table t;
|
2844
3017
|
};
|
2845
3018
|
|
2846
3019
|
#ifdef __cplusplus
|
@@ -2871,6 +3044,12 @@ UPB_INLINE upb_StringView _upb_map_tokey(const void* key, size_t size) {
|
|
2871
3044
|
}
|
2872
3045
|
}
|
2873
3046
|
|
3047
|
+
UPB_INLINE uintptr_t _upb_map_tointkey(const void* key, size_t key_size) {
|
3048
|
+
uintptr_t intkey = 0;
|
3049
|
+
memcpy(&intkey, key, key_size);
|
3050
|
+
return intkey;
|
3051
|
+
}
|
3052
|
+
|
2874
3053
|
UPB_INLINE void _upb_map_fromkey(upb_StringView key, void* out, size_t size) {
|
2875
3054
|
if (size == UPB_MAPTYPE_STRING) {
|
2876
3055
|
memcpy(out, &key, sizeof(key));
|
@@ -2902,33 +3081,58 @@ UPB_INLINE void _upb_map_fromvalue(upb_value val, void* out, size_t size) {
|
|
2902
3081
|
}
|
2903
3082
|
|
2904
3083
|
UPB_INLINE bool _upb_map_next(const struct upb_Map* map, size_t* iter) {
|
2905
|
-
|
2906
|
-
|
2907
|
-
|
2908
|
-
|
2909
|
-
|
2910
|
-
|
3084
|
+
if (map->UPB_PRIVATE(is_strtable)) {
|
3085
|
+
upb_strtable_iter it;
|
3086
|
+
it.t = &map->t.strtable;
|
3087
|
+
it.index = *iter;
|
3088
|
+
upb_strtable_next(&it);
|
3089
|
+
*iter = it.index;
|
3090
|
+
return !upb_strtable_done(&it);
|
3091
|
+
} else {
|
3092
|
+
uintptr_t key;
|
3093
|
+
upb_value val;
|
3094
|
+
intptr_t int_iter = 0;
|
3095
|
+
memcpy(&int_iter, iter, sizeof(intptr_t));
|
3096
|
+
upb_inttable_next(&map->t.inttable, &key, &val, &int_iter);
|
3097
|
+
memcpy(iter, &int_iter, sizeof(size_t));
|
3098
|
+
return !upb_inttable_done(&map->t.inttable, int_iter);
|
3099
|
+
}
|
2911
3100
|
}
|
2912
3101
|
|
2913
3102
|
UPB_INLINE void _upb_Map_Clear(struct upb_Map* map) {
|
2914
3103
|
UPB_ASSERT(!upb_Map_IsFrozen(map));
|
2915
3104
|
|
2916
|
-
|
3105
|
+
if (map->UPB_PRIVATE(is_strtable)) {
|
3106
|
+
upb_strtable_clear(&map->t.strtable);
|
3107
|
+
} else {
|
3108
|
+
upb_inttable_clear(&map->t.inttable);
|
3109
|
+
}
|
2917
3110
|
}
|
2918
3111
|
|
2919
3112
|
UPB_INLINE bool _upb_Map_Delete(struct upb_Map* map, const void* key,
|
2920
3113
|
size_t key_size, upb_value* val) {
|
2921
3114
|
UPB_ASSERT(!upb_Map_IsFrozen(map));
|
2922
3115
|
|
2923
|
-
|
2924
|
-
|
3116
|
+
if (map->UPB_PRIVATE(is_strtable)) {
|
3117
|
+
upb_StringView k = _upb_map_tokey(key, key_size);
|
3118
|
+
return upb_strtable_remove2(&map->t.strtable, k.data, k.size, val);
|
3119
|
+
} else {
|
3120
|
+
uintptr_t intkey = _upb_map_tointkey(key, key_size);
|
3121
|
+
return upb_inttable_remove(&map->t.inttable, intkey, val);
|
3122
|
+
}
|
2925
3123
|
}
|
2926
3124
|
|
2927
3125
|
UPB_INLINE bool _upb_Map_Get(const struct upb_Map* map, const void* key,
|
2928
3126
|
size_t key_size, void* val, size_t val_size) {
|
2929
|
-
upb_value tabval;
|
2930
|
-
|
2931
|
-
|
3127
|
+
upb_value tabval = {0};
|
3128
|
+
bool ret;
|
3129
|
+
if (map->UPB_PRIVATE(is_strtable)) {
|
3130
|
+
upb_StringView k = _upb_map_tokey(key, key_size);
|
3131
|
+
ret = upb_strtable_lookup2(&map->t.strtable, k.data, k.size, &tabval);
|
3132
|
+
} else {
|
3133
|
+
uintptr_t intkey = _upb_map_tointkey(key, key_size);
|
3134
|
+
ret = upb_inttable_lookup(&map->t.inttable, intkey, &tabval);
|
3135
|
+
}
|
2932
3136
|
if (ret && val) {
|
2933
3137
|
_upb_map_fromvalue(tabval, val, val_size);
|
2934
3138
|
}
|
@@ -2941,24 +3145,39 @@ UPB_INLINE upb_MapInsertStatus _upb_Map_Insert(struct upb_Map* map,
|
|
2941
3145
|
upb_Arena* a) {
|
2942
3146
|
UPB_ASSERT(!upb_Map_IsFrozen(map));
|
2943
3147
|
|
2944
|
-
|
3148
|
+
// Prep the value.
|
2945
3149
|
upb_value tabval = {0};
|
2946
3150
|
if (!_upb_map_tovalue(val, val_size, &tabval, a)) {
|
2947
3151
|
return kUpb_MapInsertStatus_OutOfMemory;
|
2948
3152
|
}
|
2949
3153
|
|
2950
|
-
|
2951
|
-
|
2952
|
-
|
2953
|
-
|
2954
|
-
|
3154
|
+
bool removed;
|
3155
|
+
if (map->UPB_PRIVATE(is_strtable)) {
|
3156
|
+
upb_StringView strkey = _upb_map_tokey(key, key_size);
|
3157
|
+
// TODO: add overwrite operation to minimize number of lookups.
|
3158
|
+
removed =
|
3159
|
+
upb_strtable_remove2(&map->t.strtable, strkey.data, strkey.size, NULL);
|
3160
|
+
if (!upb_strtable_insert(&map->t.strtable, strkey.data, strkey.size, tabval,
|
3161
|
+
a)) {
|
3162
|
+
return kUpb_MapInsertStatus_OutOfMemory;
|
3163
|
+
}
|
3164
|
+
} else {
|
3165
|
+
uintptr_t intkey = _upb_map_tointkey(key, key_size);
|
3166
|
+
removed = upb_inttable_remove(&map->t.inttable, intkey, NULL);
|
3167
|
+
if (!upb_inttable_insert(&map->t.inttable, intkey, tabval, a)) {
|
3168
|
+
return kUpb_MapInsertStatus_OutOfMemory;
|
3169
|
+
}
|
2955
3170
|
}
|
2956
3171
|
return removed ? kUpb_MapInsertStatus_Replaced
|
2957
3172
|
: kUpb_MapInsertStatus_Inserted;
|
2958
3173
|
}
|
2959
3174
|
|
2960
3175
|
UPB_INLINE size_t _upb_Map_Size(const struct upb_Map* map) {
|
2961
|
-
|
3176
|
+
if (map->UPB_PRIVATE(is_strtable)) {
|
3177
|
+
return map->t.strtable.t.count;
|
3178
|
+
} else {
|
3179
|
+
return upb_inttable_count(&map->t.inttable);
|
3180
|
+
}
|
2962
3181
|
}
|
2963
3182
|
|
2964
3183
|
// Strings/bytes are special-cased in maps.
|
@@ -3023,9 +3242,32 @@ UPB_API_INLINE const struct upb_MiniTable* upb_MiniTableExtension_GetSubMessage(
|
|
3023
3242
|
return upb_MiniTableSub_Message(e->UPB_PRIVATE(sub));
|
3024
3243
|
}
|
3025
3244
|
|
3026
|
-
UPB_API_INLINE
|
3245
|
+
UPB_API_INLINE const struct upb_MiniTableEnum*
|
3246
|
+
upb_MiniTableExtension_GetSubEnum(const struct upb_MiniTableExtension* e) {
|
3247
|
+
if (upb_MiniTableExtension_CType(e) != kUpb_CType_Enum) {
|
3248
|
+
return NULL;
|
3249
|
+
}
|
3250
|
+
return upb_MiniTableSub_Enum(e->UPB_PRIVATE(sub));
|
3251
|
+
}
|
3252
|
+
|
3253
|
+
UPB_API_INLINE bool upb_MiniTableExtension_SetSubMessage(
|
3027
3254
|
struct upb_MiniTableExtension* e, const struct upb_MiniTable* m) {
|
3255
|
+
if (e->UPB_PRIVATE(field).UPB_PRIVATE(descriptortype) !=
|
3256
|
+
kUpb_FieldType_Message) {
|
3257
|
+
return false;
|
3258
|
+
}
|
3028
3259
|
e->UPB_PRIVATE(sub).UPB_PRIVATE(submsg) = m;
|
3260
|
+
return true;
|
3261
|
+
}
|
3262
|
+
|
3263
|
+
UPB_API_INLINE bool upb_MiniTableExtension_SetSubEnum(
|
3264
|
+
struct upb_MiniTableExtension* e, const struct upb_MiniTableEnum* en) {
|
3265
|
+
if (e->UPB_PRIVATE(field).UPB_PRIVATE(descriptortype) !=
|
3266
|
+
kUpb_FieldType_Enum) {
|
3267
|
+
return false;
|
3268
|
+
}
|
3269
|
+
e->UPB_PRIVATE(sub).UPB_PRIVATE(subenum) = en;
|
3270
|
+
return true;
|
3029
3271
|
}
|
3030
3272
|
|
3031
3273
|
UPB_INLINE upb_FieldRep UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(
|
@@ -3057,9 +3299,15 @@ upb_MiniTableExtension_Number(const upb_MiniTableExtension* e);
|
|
3057
3299
|
UPB_API_INLINE const upb_MiniTable* upb_MiniTableExtension_GetSubMessage(
|
3058
3300
|
const upb_MiniTableExtension* e);
|
3059
3301
|
|
3060
|
-
UPB_API_INLINE
|
3302
|
+
UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTableExtension_GetSubEnum(
|
3303
|
+
const upb_MiniTableExtension* e);
|
3304
|
+
|
3305
|
+
UPB_API_INLINE bool upb_MiniTableExtension_SetSubMessage(
|
3061
3306
|
upb_MiniTableExtension* e, const upb_MiniTable* m);
|
3062
3307
|
|
3308
|
+
UPB_API_INLINE bool upb_MiniTableExtension_SetSubEnum(
|
3309
|
+
upb_MiniTableExtension* e, const upb_MiniTableEnum* m);
|
3310
|
+
|
3063
3311
|
#ifdef __cplusplus
|
3064
3312
|
} /* extern "C" */
|
3065
3313
|
#endif
|
@@ -3111,10 +3359,6 @@ UPB_INLINE bool UPB_PRIVATE(_upb_Extension_IsEmpty)(const upb_Extension* ext) {
|
|
3111
3359
|
UPB_UNREACHABLE();
|
3112
3360
|
}
|
3113
3361
|
|
3114
|
-
// Replaces the unknown field at iter with the provided extension.
|
3115
|
-
void upb_Message_ReplaceUnknownWithExtension(struct upb_Message* msg,
|
3116
|
-
uintptr_t iter,
|
3117
|
-
const upb_Extension* ext);
|
3118
3362
|
#ifdef __cplusplus
|
3119
3363
|
} /* extern "C" */
|
3120
3364
|
#endif
|
@@ -3151,6 +3395,10 @@ extern const double kUpb_NaN;
|
|
3151
3395
|
// extensions. We can change this without breaking binary compatibility.
|
3152
3396
|
|
3153
3397
|
typedef struct upb_TaggedAuxPtr {
|
3398
|
+
// Two lowest bits form a tag:
|
3399
|
+
// 00 - non-aliased unknown data
|
3400
|
+
// 10 - aliased unknown data
|
3401
|
+
// 01 - extension
|
3154
3402
|
uintptr_t ptr;
|
3155
3403
|
} upb_TaggedAuxPtr;
|
3156
3404
|
|
@@ -3166,14 +3414,18 @@ UPB_INLINE bool upb_TaggedAuxPtr_IsUnknown(upb_TaggedAuxPtr ptr) {
|
|
3166
3414
|
return (ptr.ptr != 0) && ((ptr.ptr & 1) == 0);
|
3167
3415
|
}
|
3168
3416
|
|
3417
|
+
UPB_INLINE bool upb_TaggedAuxPtr_IsUnknownAliased(upb_TaggedAuxPtr ptr) {
|
3418
|
+
return (ptr.ptr != 0) && ((ptr.ptr & 2) == 2);
|
3419
|
+
}
|
3420
|
+
|
3169
3421
|
UPB_INLINE upb_Extension* upb_TaggedAuxPtr_Extension(upb_TaggedAuxPtr ptr) {
|
3170
3422
|
UPB_ASSERT(upb_TaggedAuxPtr_IsExtension(ptr));
|
3171
|
-
return (upb_Extension*)(ptr.ptr & ~
|
3423
|
+
return (upb_Extension*)(ptr.ptr & ~3ULL);
|
3172
3424
|
}
|
3173
3425
|
|
3174
3426
|
UPB_INLINE upb_StringView* upb_TaggedAuxPtr_UnknownData(upb_TaggedAuxPtr ptr) {
|
3175
3427
|
UPB_ASSERT(!upb_TaggedAuxPtr_IsExtension(ptr));
|
3176
|
-
return (upb_StringView*)(ptr.ptr);
|
3428
|
+
return (upb_StringView*)(ptr.ptr & ~3ULL);
|
3177
3429
|
}
|
3178
3430
|
|
3179
3431
|
UPB_INLINE upb_TaggedAuxPtr upb_TaggedAuxPtr_Null(void) {
|
@@ -3189,6 +3441,9 @@ upb_TaggedAuxPtr_MakeExtension(const upb_Extension* e) {
|
|
3189
3441
|
return ptr;
|
3190
3442
|
}
|
3191
3443
|
|
3444
|
+
// This tag means that the original allocation for this field starts with the
|
3445
|
+
// string view and ends with the end of the content referenced by the string
|
3446
|
+
// view.
|
3192
3447
|
UPB_INLINE upb_TaggedAuxPtr
|
3193
3448
|
upb_TaggedAuxPtr_MakeUnknownData(const upb_StringView* sv) {
|
3194
3449
|
upb_TaggedAuxPtr ptr;
|
@@ -3196,6 +3451,15 @@ upb_TaggedAuxPtr_MakeUnknownData(const upb_StringView* sv) {
|
|
3196
3451
|
return ptr;
|
3197
3452
|
}
|
3198
3453
|
|
3454
|
+
// This tag implies no guarantee between the relationship of the string view and
|
3455
|
+
// the data it points to.
|
3456
|
+
UPB_INLINE upb_TaggedAuxPtr
|
3457
|
+
upb_TaggedAuxPtr_MakeUnknownDataAliased(const upb_StringView* sv) {
|
3458
|
+
upb_TaggedAuxPtr ptr;
|
3459
|
+
ptr.ptr = (uintptr_t)sv | 2;
|
3460
|
+
return ptr;
|
3461
|
+
}
|
3462
|
+
|
3199
3463
|
typedef struct upb_Message_Internal {
|
3200
3464
|
// Total number of entries set in aux_data
|
3201
3465
|
uint32_t size;
|
@@ -3228,13 +3492,41 @@ UPB_INLINE struct upb_Message* _upb_Message_New(const upb_MiniTable* m,
|
|
3228
3492
|
// Discards the unknown fields for this message only.
|
3229
3493
|
void _upb_Message_DiscardUnknown_shallow(struct upb_Message* msg);
|
3230
3494
|
|
3495
|
+
UPB_NOINLINE bool UPB_PRIVATE(_upb_Message_AddUnknownSlowPath)(
|
3496
|
+
struct upb_Message* msg, const char* data, size_t len, upb_Arena* arena,
|
3497
|
+
bool alias);
|
3498
|
+
|
3231
3499
|
// Adds unknown data (serialized protobuf data) to the given message. The data
|
3232
3500
|
// must represent one or more complete and well formed proto fields.
|
3233
3501
|
// If alias is set, will keep a view to the provided data; otherwise a copy is
|
3234
3502
|
// made.
|
3235
|
-
bool UPB_PRIVATE(_upb_Message_AddUnknown)(struct upb_Message* msg,
|
3236
|
-
|
3237
|
-
|
3503
|
+
UPB_INLINE bool UPB_PRIVATE(_upb_Message_AddUnknown)(struct upb_Message* msg,
|
3504
|
+
const char* data,
|
3505
|
+
size_t len,
|
3506
|
+
upb_Arena* arena,
|
3507
|
+
bool alias) {
|
3508
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
3509
|
+
if (alias) {
|
3510
|
+
// Aliasing parse of a message with sequential unknown fields is a simple
|
3511
|
+
// pointer bump, so inline it.
|
3512
|
+
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
3513
|
+
if (in && in->size) {
|
3514
|
+
upb_TaggedAuxPtr ptr = in->aux_data[in->size - 1];
|
3515
|
+
if (upb_TaggedAuxPtr_IsUnknown(ptr)) {
|
3516
|
+
upb_StringView* existing = upb_TaggedAuxPtr_UnknownData(ptr);
|
3517
|
+
bool was_aliased = upb_TaggedAuxPtr_IsUnknownAliased(ptr);
|
3518
|
+
// Fast path if the field we're adding is immediately after the last
|
3519
|
+
// added unknown field.
|
3520
|
+
if (was_aliased && existing->data + existing->size == data) {
|
3521
|
+
existing->size += len;
|
3522
|
+
return true;
|
3523
|
+
}
|
3524
|
+
}
|
3525
|
+
}
|
3526
|
+
}
|
3527
|
+
return UPB_PRIVATE(_upb_Message_AddUnknownSlowPath)(msg, data, len, arena,
|
3528
|
+
alias);
|
3529
|
+
}
|
3238
3530
|
|
3239
3531
|
// Adds unknown data (serialized protobuf data) to the given message.
|
3240
3532
|
// The data is copied into the message instance. Data when concatenated together
|
@@ -3369,9 +3661,6 @@ UPB_INLINE bool upb_Message_NextUnknown(const upb_Message* msg,
|
|
3369
3661
|
|
3370
3662
|
UPB_INLINE bool upb_Message_HasUnknown(const upb_Message* msg);
|
3371
3663
|
|
3372
|
-
// Returns a reference to the message's unknown data.
|
3373
|
-
const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len);
|
3374
|
-
|
3375
3664
|
// Removes a segment of unknown data from the message, advancing to the next
|
3376
3665
|
// segment. Returns false if the removed segment was at the end of the last
|
3377
3666
|
// chunk.
|
@@ -3385,16 +3674,28 @@ const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len);
|
|
3385
3674
|
// // Iterate within a chunk, deleting ranges
|
3386
3675
|
// while (ShouldDeleteSubSegment(&data)) {
|
3387
3676
|
// // Data now points to the region to be deleted
|
3388
|
-
//
|
3389
|
-
//
|
3390
|
-
//
|
3677
|
+
// switch (upb_Message_DeleteUnknown(msg, &data, &iter)) {
|
3678
|
+
// case kUpb_Message_DeleteUnknown_DeletedLast: return ok;
|
3679
|
+
// case kUpb_Message_DeleteUnknown_IterUpdated: break;
|
3680
|
+
// // If DeleteUnknown returned kUpb_Message_DeleteUnknown_IterUpdated,
|
3681
|
+
// // then data now points to the remaining unknown fields after the
|
3682
|
+
// // region that was just deleted.
|
3683
|
+
// case kUpb_Message_DeleteUnknown_AllocFail: return err;
|
3684
|
+
// }
|
3391
3685
|
// }
|
3392
3686
|
// }
|
3393
3687
|
//
|
3394
3688
|
// The range given in `data` must be contained inside the most recently
|
3395
3689
|
// returned region.
|
3396
|
-
|
3397
|
-
|
3690
|
+
typedef enum upb_Message_DeleteUnknownStatus {
|
3691
|
+
kUpb_DeleteUnknown_DeletedLast,
|
3692
|
+
kUpb_DeleteUnknown_IterUpdated,
|
3693
|
+
kUpb_DeleteUnknown_AllocFail,
|
3694
|
+
} upb_Message_DeleteUnknownStatus;
|
3695
|
+
upb_Message_DeleteUnknownStatus upb_Message_DeleteUnknown(upb_Message* msg,
|
3696
|
+
upb_StringView* data,
|
3697
|
+
uintptr_t* iter,
|
3698
|
+
upb_Arena* arena);
|
3398
3699
|
|
3399
3700
|
// Returns the number of extensions present in this message.
|
3400
3701
|
size_t upb_Message_ExtensionCount(const upb_Message* msg);
|
@@ -3449,8 +3750,8 @@ UPB_API void upb_Message_SetNewMessageTraceHandler(
|
|
3449
3750
|
#ifndef UPB_REFLECTION_COMMON_H_
|
3450
3751
|
#define UPB_REFLECTION_COMMON_H_
|
3451
3752
|
|
3452
|
-
#ifndef
|
3453
|
-
#define
|
3753
|
+
#ifndef GOOGLE_UPB_UPB_REFLECTION_DESCRIPTOR_BOOTSTRAP_H__
|
3754
|
+
#define GOOGLE_UPB_UPB_REFLECTION_DESCRIPTOR_BOOTSTRAP_H__
|
3454
3755
|
|
3455
3756
|
// IWYU pragma: begin_exports
|
3456
3757
|
|
@@ -3627,7 +3928,7 @@ extern "C" {
|
|
3627
3928
|
|
3628
3929
|
UPB_INLINE bool UPB_PRIVATE(_upb_Message_GetHasbit)(
|
3629
3930
|
const struct upb_Message* msg, const upb_MiniTableField* f) {
|
3630
|
-
const
|
3931
|
+
const uint16_t offset = UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(f);
|
3631
3932
|
const char mask = UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(f);
|
3632
3933
|
|
3633
3934
|
return (*UPB_PTR_AT(msg, offset, const char) & mask) != 0;
|
@@ -3635,7 +3936,7 @@ UPB_INLINE bool UPB_PRIVATE(_upb_Message_GetHasbit)(
|
|
3635
3936
|
|
3636
3937
|
UPB_INLINE void UPB_PRIVATE(_upb_Message_SetHasbit)(
|
3637
3938
|
const struct upb_Message* msg, const upb_MiniTableField* f) {
|
3638
|
-
const
|
3939
|
+
const uint16_t offset = UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(f);
|
3639
3940
|
const char mask = UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(f);
|
3640
3941
|
|
3641
3942
|
(*UPB_PTR_AT(msg, offset, char)) |= mask;
|
@@ -3643,7 +3944,7 @@ UPB_INLINE void UPB_PRIVATE(_upb_Message_SetHasbit)(
|
|
3643
3944
|
|
3644
3945
|
UPB_INLINE void UPB_PRIVATE(_upb_Message_ClearHasbit)(
|
3645
3946
|
const struct upb_Message* msg, const upb_MiniTableField* f) {
|
3646
|
-
const
|
3947
|
+
const uint16_t offset = UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(f);
|
3647
3948
|
const char mask = UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(f);
|
3648
3949
|
|
3649
3950
|
(*UPB_PTR_AT(msg, offset, char)) &= ~mask;
|
@@ -4650,6 +4951,12 @@ UPB_API size_t upb_Map_Size(const upb_Map* map);
|
|
4650
4951
|
UPB_API bool upb_Map_Get(const upb_Map* map, upb_MessageValue key,
|
4651
4952
|
upb_MessageValue* val);
|
4652
4953
|
|
4954
|
+
// Returns a mutable pointer to the value for the given key. Returns NULL if the
|
4955
|
+
// key is not present.
|
4956
|
+
// This function is only legal to call for maps that contain messages.
|
4957
|
+
UPB_API struct upb_Message* upb_Map_GetMutable(upb_Map* map,
|
4958
|
+
upb_MessageValue key);
|
4959
|
+
|
4653
4960
|
// Removes all entries in the map.
|
4654
4961
|
UPB_API void upb_Map_Clear(upb_Map* map);
|
4655
4962
|
|
@@ -4682,7 +4989,7 @@ UPB_API bool upb_Map_Delete(upb_Map* map, upb_MessageValue key,
|
|
4682
4989
|
// ...
|
4683
4990
|
// }
|
4684
4991
|
|
4685
|
-
#define kUpb_Map_Begin ((size_t)
|
4992
|
+
#define kUpb_Map_Begin ((size_t)-1)
|
4686
4993
|
|
4687
4994
|
// Advances to the next entry. Returns false if no more entries are present.
|
4688
4995
|
// Otherwise returns true and populates both *key and *value.
|
@@ -5066,48 +5373,9 @@ bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* mini_table,
|
|
5066
5373
|
#ifndef UPB_MESSAGE_MAP_GENCODE_UTIL_H_
|
5067
5374
|
#define UPB_MESSAGE_MAP_GENCODE_UTIL_H_
|
5068
5375
|
|
5069
|
-
|
5070
|
-
//
|
5071
|
-
|
5072
|
-
#ifdef __cplusplus
|
5073
|
-
extern "C" {
|
5074
|
-
#endif
|
5075
|
-
|
5076
|
-
// Message map operations, these get the map from the message first.
|
5077
|
-
|
5078
|
-
UPB_INLINE void _upb_msg_map_key(const void* msg, void* key, size_t size) {
|
5079
|
-
const upb_tabent* ent = (const upb_tabent*)msg;
|
5080
|
-
uint32_t u32len;
|
5081
|
-
upb_StringView k;
|
5082
|
-
k.data = upb_tabstr(ent->key, &u32len);
|
5083
|
-
k.size = u32len;
|
5084
|
-
_upb_map_fromkey(k, key, size);
|
5085
|
-
}
|
5086
|
-
|
5087
|
-
UPB_INLINE void _upb_msg_map_value(const void* msg, void* val, size_t size) {
|
5088
|
-
const upb_tabent* ent = (const upb_tabent*)msg;
|
5089
|
-
upb_value v = {ent->val.val};
|
5090
|
-
_upb_map_fromvalue(v, val, size);
|
5091
|
-
}
|
5092
|
-
|
5093
|
-
UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val,
|
5094
|
-
size_t size) {
|
5095
|
-
upb_tabent* ent = (upb_tabent*)msg;
|
5096
|
-
// This is like _upb_map_tovalue() except the entry already exists
|
5097
|
-
// so we can reuse the allocated upb_StringView for string fields.
|
5098
|
-
if (size == UPB_MAPTYPE_STRING) {
|
5099
|
-
upb_StringView* strp = (upb_StringView*)(uintptr_t)ent->val.val;
|
5100
|
-
memcpy(strp, val, sizeof(*strp));
|
5101
|
-
} else {
|
5102
|
-
memcpy(&ent->val.val, val, size);
|
5103
|
-
}
|
5104
|
-
}
|
5105
|
-
|
5106
|
-
#ifdef __cplusplus
|
5107
|
-
} /* extern "C" */
|
5108
|
-
#endif
|
5109
|
-
|
5110
|
-
|
5376
|
+
// This header file is referenced by multiple files. Leave it empty.
|
5377
|
+
// TODO: b/399481227 - Remove this header file, after all the references are
|
5378
|
+
// cleaned up.
|
5111
5379
|
#endif /* UPB_MESSAGE_MAP_GENCODE_UTIL_H_ */
|
5112
5380
|
|
5113
5381
|
#ifndef UPB_MINI_TABLE_DECODE_H_
|
@@ -5794,6 +6062,8 @@ UPB_API const char* upb_EncodeStatus_String(upb_EncodeStatus status);
|
|
5794
6062
|
|
5795
6063
|
// Must be last.
|
5796
6064
|
|
6065
|
+
#if UPB_FASTTABLE
|
6066
|
+
|
5797
6067
|
#ifdef __cplusplus
|
5798
6068
|
extern "C" {
|
5799
6069
|
#endif
|
@@ -5890,6 +6160,8 @@ TAGBYTES(r)
|
|
5890
6160
|
} /* extern "C" */
|
5891
6161
|
#endif
|
5892
6162
|
|
6163
|
+
#endif /* UPB_FASTTABLE */
|
6164
|
+
|
5893
6165
|
|
5894
6166
|
#endif /* UPB_WIRE_INTERNAL_DECODE_FAST_H_ */
|
5895
6167
|
// IWYU pragma: end_exports
|
@@ -5968,6 +6240,8 @@ extern const upb_MiniTable google__protobuf__UninterpretedOption__NamePart_msg_i
|
|
5968
6240
|
extern const upb_MiniTable* google__protobuf__UninterpretedOption__NamePart_msg_init_ptr;
|
5969
6241
|
extern const upb_MiniTable google__protobuf__FeatureSet_msg_init;
|
5970
6242
|
extern const upb_MiniTable* google__protobuf__FeatureSet_msg_init_ptr;
|
6243
|
+
extern const upb_MiniTable google__protobuf__FeatureSet__VisibilityFeature_msg_init;
|
6244
|
+
extern const upb_MiniTable* google__protobuf__FeatureSet__VisibilityFeature_msg_init_ptr;
|
5971
6245
|
extern const upb_MiniTable google__protobuf__FeatureSetDefaults_msg_init;
|
5972
6246
|
extern const upb_MiniTable* google__protobuf__FeatureSetDefaults_msg_init_ptr;
|
5973
6247
|
extern const upb_MiniTable google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init;
|
@@ -5990,6 +6264,7 @@ extern const upb_MiniTableEnum google__protobuf__FeatureSet__JsonFormat_enum_ini
|
|
5990
6264
|
extern const upb_MiniTableEnum google__protobuf__FeatureSet__MessageEncoding_enum_init;
|
5991
6265
|
extern const upb_MiniTableEnum google__protobuf__FeatureSet__RepeatedFieldEncoding_enum_init;
|
5992
6266
|
extern const upb_MiniTableEnum google__protobuf__FeatureSet__Utf8Validation_enum_init;
|
6267
|
+
extern const upb_MiniTableEnum google__protobuf__FeatureSet__VisibilityFeature__DefaultSymbolVisibility_enum_init;
|
5993
6268
|
extern const upb_MiniTableEnum google__protobuf__FieldDescriptorProto__Label_enum_init;
|
5994
6269
|
extern const upb_MiniTableEnum google__protobuf__FieldDescriptorProto__Type_enum_init;
|
5995
6270
|
extern const upb_MiniTableEnum google__protobuf__FieldOptions__CType_enum_init;
|
@@ -5999,6 +6274,7 @@ extern const upb_MiniTableEnum google__protobuf__FieldOptions__OptionTargetType_
|
|
5999
6274
|
extern const upb_MiniTableEnum google__protobuf__FileOptions__OptimizeMode_enum_init;
|
6000
6275
|
extern const upb_MiniTableEnum google__protobuf__GeneratedCodeInfo__Annotation__Semantic_enum_init;
|
6001
6276
|
extern const upb_MiniTableEnum google__protobuf__MethodOptions__IdempotencyLevel_enum_init;
|
6277
|
+
extern const upb_MiniTableEnum google__protobuf__SymbolVisibility_enum_init;
|
6002
6278
|
extern const upb_MiniTableFile google_protobuf_descriptor_proto_upb_file_layout;
|
6003
6279
|
|
6004
6280
|
#ifdef __cplusplus
|
@@ -6042,6 +6318,7 @@ typedef struct google_protobuf_MethodOptions { upb_Message UPB_PRIVATE(base); }
|
|
6042
6318
|
typedef struct google_protobuf_UninterpretedOption { upb_Message UPB_PRIVATE(base); } google_protobuf_UninterpretedOption;
|
6043
6319
|
typedef struct google_protobuf_UninterpretedOption_NamePart { upb_Message UPB_PRIVATE(base); } google_protobuf_UninterpretedOption_NamePart;
|
6044
6320
|
typedef struct google_protobuf_FeatureSet { upb_Message UPB_PRIVATE(base); } google_protobuf_FeatureSet;
|
6321
|
+
typedef struct google_protobuf_FeatureSet_VisibilityFeature { upb_Message UPB_PRIVATE(base); } google_protobuf_FeatureSet_VisibilityFeature;
|
6045
6322
|
typedef struct google_protobuf_FeatureSetDefaults { upb_Message UPB_PRIVATE(base); } google_protobuf_FeatureSetDefaults;
|
6046
6323
|
typedef struct google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault { upb_Message UPB_PRIVATE(base); } google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault;
|
6047
6324
|
typedef struct google_protobuf_SourceCodeInfo { upb_Message UPB_PRIVATE(base); } google_protobuf_SourceCodeInfo;
|
@@ -6112,6 +6389,14 @@ typedef enum {
|
|
6112
6389
|
google_protobuf_FeatureSet_NONE = 3
|
6113
6390
|
} google_protobuf_FeatureSet_Utf8Validation;
|
6114
6391
|
|
6392
|
+
typedef enum {
|
6393
|
+
google_protobuf_FeatureSet_VisibilityFeature_DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0,
|
6394
|
+
google_protobuf_FeatureSet_VisibilityFeature_EXPORT_ALL = 1,
|
6395
|
+
google_protobuf_FeatureSet_VisibilityFeature_EXPORT_TOP_LEVEL = 2,
|
6396
|
+
google_protobuf_FeatureSet_VisibilityFeature_LOCAL_ALL = 3,
|
6397
|
+
google_protobuf_FeatureSet_VisibilityFeature_STRICT = 4
|
6398
|
+
} google_protobuf_FeatureSet_VisibilityFeature_DefaultSymbolVisibility;
|
6399
|
+
|
6115
6400
|
typedef enum {
|
6116
6401
|
google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1,
|
6117
6402
|
google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2,
|
@@ -6188,6 +6473,12 @@ typedef enum {
|
|
6188
6473
|
google_protobuf_MethodOptions_IDEMPOTENT = 2
|
6189
6474
|
} google_protobuf_MethodOptions_IdempotencyLevel;
|
6190
6475
|
|
6476
|
+
typedef enum {
|
6477
|
+
google_protobuf_VISIBILITY_UNSET = 0,
|
6478
|
+
google_protobuf_VISIBILITY_LOCAL = 1,
|
6479
|
+
google_protobuf_VISIBILITY_EXPORT = 2
|
6480
|
+
} google_protobuf_SymbolVisibility;
|
6481
|
+
|
6191
6482
|
|
6192
6483
|
|
6193
6484
|
/* google.protobuf.FileDescriptorSet */
|
@@ -6332,35 +6623,35 @@ UPB_INLINE char* google_protobuf_FileDescriptorProto_serialize_ex(const google_p
|
|
6332
6623
|
return ptr;
|
6333
6624
|
}
|
6334
6625
|
UPB_INLINE void google_protobuf_FileDescriptorProto_clear_name(google_protobuf_FileDescriptorProto* msg) {
|
6335
|
-
const upb_MiniTableField field = {1, UPB_SIZE(
|
6626
|
+
const upb_MiniTableField field = {1, UPB_SIZE(56, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6336
6627
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
6337
6628
|
}
|
6338
6629
|
UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto* msg) {
|
6339
6630
|
upb_StringView default_val = upb_StringView_FromString("");
|
6340
6631
|
upb_StringView ret;
|
6341
|
-
const upb_MiniTableField field = {1, UPB_SIZE(
|
6632
|
+
const upb_MiniTableField field = {1, UPB_SIZE(56, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6342
6633
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
6343
6634
|
&default_val, &ret);
|
6344
6635
|
return ret;
|
6345
6636
|
}
|
6346
6637
|
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto* msg) {
|
6347
|
-
const upb_MiniTableField field = {1, UPB_SIZE(
|
6638
|
+
const upb_MiniTableField field = {1, UPB_SIZE(56, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6348
6639
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
6349
6640
|
}
|
6350
6641
|
UPB_INLINE void google_protobuf_FileDescriptorProto_clear_package(google_protobuf_FileDescriptorProto* msg) {
|
6351
|
-
const upb_MiniTableField field = {2, UPB_SIZE(
|
6642
|
+
const upb_MiniTableField field = {2, UPB_SIZE(64, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6352
6643
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
6353
6644
|
}
|
6354
6645
|
UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto* msg) {
|
6355
6646
|
upb_StringView default_val = upb_StringView_FromString("");
|
6356
6647
|
upb_StringView ret;
|
6357
|
-
const upb_MiniTableField field = {2, UPB_SIZE(
|
6648
|
+
const upb_MiniTableField field = {2, UPB_SIZE(64, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6358
6649
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
6359
6650
|
&default_val, &ret);
|
6360
6651
|
return ret;
|
6361
6652
|
}
|
6362
6653
|
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto* msg) {
|
6363
|
-
const upb_MiniTableField field = {2, UPB_SIZE(
|
6654
|
+
const upb_MiniTableField field = {2, UPB_SIZE(64, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6364
6655
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
6365
6656
|
}
|
6366
6657
|
UPB_INLINE void google_protobuf_FileDescriptorProto_clear_dependency(google_protobuf_FileDescriptorProto* msg) {
|
@@ -6634,19 +6925,19 @@ UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_weak_dependency_mutab
|
|
6634
6925
|
return arr;
|
6635
6926
|
}
|
6636
6927
|
UPB_INLINE void google_protobuf_FileDescriptorProto_clear_syntax(google_protobuf_FileDescriptorProto* msg) {
|
6637
|
-
const upb_MiniTableField field = {12, UPB_SIZE(
|
6928
|
+
const upb_MiniTableField field = {12, UPB_SIZE(72, 48), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6638
6929
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
6639
6930
|
}
|
6640
6931
|
UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto* msg) {
|
6641
6932
|
upb_StringView default_val = upb_StringView_FromString("");
|
6642
6933
|
upb_StringView ret;
|
6643
|
-
const upb_MiniTableField field = {12, UPB_SIZE(
|
6934
|
+
const upb_MiniTableField field = {12, UPB_SIZE(72, 48), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6644
6935
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
6645
6936
|
&default_val, &ret);
|
6646
6937
|
return ret;
|
6647
6938
|
}
|
6648
6939
|
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto* msg) {
|
6649
|
-
const upb_MiniTableField field = {12, UPB_SIZE(
|
6940
|
+
const upb_MiniTableField field = {12, UPB_SIZE(72, 48), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6650
6941
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
6651
6942
|
}
|
6652
6943
|
UPB_INLINE void google_protobuf_FileDescriptorProto_clear_edition(google_protobuf_FileDescriptorProto* msg) {
|
@@ -6665,13 +6956,45 @@ UPB_INLINE bool google_protobuf_FileDescriptorProto_has_edition(const google_pro
|
|
6665
6956
|
const upb_MiniTableField field = {14, UPB_SIZE(48, 12), 69, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
6666
6957
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
6667
6958
|
}
|
6959
|
+
UPB_INLINE void google_protobuf_FileDescriptorProto_clear_option_dependency(google_protobuf_FileDescriptorProto* msg) {
|
6960
|
+
const upb_MiniTableField field = {15, UPB_SIZE(52, 136), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
|
6961
|
+
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
6962
|
+
}
|
6963
|
+
UPB_INLINE upb_StringView const* google_protobuf_FileDescriptorProto_option_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
|
6964
|
+
const upb_MiniTableField field = {15, UPB_SIZE(52, 136), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
|
6965
|
+
const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
|
6966
|
+
if (arr) {
|
6967
|
+
if (size) *size = arr->UPB_PRIVATE(size);
|
6968
|
+
return (upb_StringView const*)upb_Array_DataPtr(arr);
|
6969
|
+
} else {
|
6970
|
+
if (size) *size = 0;
|
6971
|
+
return NULL;
|
6972
|
+
}
|
6973
|
+
}
|
6974
|
+
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_option_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
|
6975
|
+
const upb_MiniTableField field = {15, UPB_SIZE(52, 136), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
|
6976
|
+
const upb_Array* arr = upb_Message_GetArray(UPB_UPCAST(msg), &field);
|
6977
|
+
if (size) {
|
6978
|
+
*size = arr ? arr->UPB_PRIVATE(size) : 0;
|
6979
|
+
}
|
6980
|
+
return arr;
|
6981
|
+
}
|
6982
|
+
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_option_dependency_mutable_upb_array(google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
|
6983
|
+
const upb_MiniTableField field = {15, UPB_SIZE(52, 136), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
|
6984
|
+
upb_Array* arr = upb_Message_GetOrCreateMutableArray(UPB_UPCAST(msg),
|
6985
|
+
&field, arena);
|
6986
|
+
if (size) {
|
6987
|
+
*size = arr ? arr->UPB_PRIVATE(size) : 0;
|
6988
|
+
}
|
6989
|
+
return arr;
|
6990
|
+
}
|
6668
6991
|
|
6669
6992
|
UPB_INLINE void google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto *msg, upb_StringView value) {
|
6670
|
-
const upb_MiniTableField field = {1, UPB_SIZE(
|
6993
|
+
const upb_MiniTableField field = {1, UPB_SIZE(56, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6671
6994
|
upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
|
6672
6995
|
}
|
6673
6996
|
UPB_INLINE void google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto *msg, upb_StringView value) {
|
6674
|
-
const upb_MiniTableField field = {2, UPB_SIZE(
|
6997
|
+
const upb_MiniTableField field = {2, UPB_SIZE(64, 32), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6675
6998
|
upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
|
6676
6999
|
}
|
6677
7000
|
UPB_INLINE upb_StringView* google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto* msg, size_t* size) {
|
@@ -6913,13 +7236,41 @@ UPB_INLINE bool google_protobuf_FileDescriptorProto_add_weak_dependency(google_p
|
|
6913
7236
|
return true;
|
6914
7237
|
}
|
6915
7238
|
UPB_INLINE void google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto *msg, upb_StringView value) {
|
6916
|
-
const upb_MiniTableField field = {12, UPB_SIZE(
|
7239
|
+
const upb_MiniTableField field = {12, UPB_SIZE(72, 48), 68, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6917
7240
|
upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
|
6918
7241
|
}
|
6919
7242
|
UPB_INLINE void google_protobuf_FileDescriptorProto_set_edition(google_protobuf_FileDescriptorProto *msg, int32_t value) {
|
6920
7243
|
const upb_MiniTableField field = {14, UPB_SIZE(48, 12), 69, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
6921
7244
|
upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
|
6922
7245
|
}
|
7246
|
+
UPB_INLINE upb_StringView* google_protobuf_FileDescriptorProto_mutable_option_dependency(google_protobuf_FileDescriptorProto* msg, size_t* size) {
|
7247
|
+
upb_MiniTableField field = {15, UPB_SIZE(52, 136), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
|
7248
|
+
upb_Array* arr = upb_Message_GetMutableArray(UPB_UPCAST(msg), &field);
|
7249
|
+
if (arr) {
|
7250
|
+
if (size) *size = arr->UPB_PRIVATE(size);
|
7251
|
+
return (upb_StringView*)upb_Array_MutableDataPtr(arr);
|
7252
|
+
} else {
|
7253
|
+
if (size) *size = 0;
|
7254
|
+
return NULL;
|
7255
|
+
}
|
7256
|
+
}
|
7257
|
+
UPB_INLINE upb_StringView* google_protobuf_FileDescriptorProto_resize_option_dependency(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) {
|
7258
|
+
upb_MiniTableField field = {15, UPB_SIZE(52, 136), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
|
7259
|
+
return (upb_StringView*)upb_Message_ResizeArrayUninitialized(UPB_UPCAST(msg),
|
7260
|
+
&field, size, arena);
|
7261
|
+
}
|
7262
|
+
UPB_INLINE bool google_protobuf_FileDescriptorProto_add_option_dependency(google_protobuf_FileDescriptorProto* msg, upb_StringView val, upb_Arena* arena) {
|
7263
|
+
upb_MiniTableField field = {15, UPB_SIZE(52, 136), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
|
7264
|
+
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
|
7265
|
+
UPB_UPCAST(msg), &field, arena);
|
7266
|
+
if (!arr || !UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
|
7267
|
+
arr, arr->UPB_PRIVATE(size) + 1, arena)) {
|
7268
|
+
return false;
|
7269
|
+
}
|
7270
|
+
UPB_PRIVATE(_upb_Array_Set)
|
7271
|
+
(arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val));
|
7272
|
+
return true;
|
7273
|
+
}
|
6923
7274
|
|
6924
7275
|
/* google.protobuf.DescriptorProto */
|
6925
7276
|
|
@@ -6958,19 +7309,19 @@ UPB_INLINE char* google_protobuf_DescriptorProto_serialize_ex(const google_proto
|
|
6958
7309
|
return ptr;
|
6959
7310
|
}
|
6960
7311
|
UPB_INLINE void google_protobuf_DescriptorProto_clear_name(google_protobuf_DescriptorProto* msg) {
|
6961
|
-
const upb_MiniTableField field = {1, UPB_SIZE(
|
7312
|
+
const upb_MiniTableField field = {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6962
7313
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
6963
7314
|
}
|
6964
7315
|
UPB_INLINE upb_StringView google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto* msg) {
|
6965
7316
|
upb_StringView default_val = upb_StringView_FromString("");
|
6966
7317
|
upb_StringView ret;
|
6967
|
-
const upb_MiniTableField field = {1, UPB_SIZE(
|
7318
|
+
const upb_MiniTableField field = {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6968
7319
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
6969
7320
|
&default_val, &ret);
|
6970
7321
|
return ret;
|
6971
7322
|
}
|
6972
7323
|
UPB_INLINE bool google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto* msg) {
|
6973
|
-
const upb_MiniTableField field = {1, UPB_SIZE(
|
7324
|
+
const upb_MiniTableField field = {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
6974
7325
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
6975
7326
|
}
|
6976
7327
|
UPB_INLINE void google_protobuf_DescriptorProto_clear_field(google_protobuf_DescriptorProto* msg) {
|
@@ -7267,9 +7618,25 @@ UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_reserved_name_mutable_upb
|
|
7267
7618
|
}
|
7268
7619
|
return arr;
|
7269
7620
|
}
|
7621
|
+
UPB_INLINE void google_protobuf_DescriptorProto_clear_visibility(google_protobuf_DescriptorProto* msg) {
|
7622
|
+
const upb_MiniTableField field = {11, UPB_SIZE(48, 12), 66, 8, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
7623
|
+
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
7624
|
+
}
|
7625
|
+
UPB_INLINE int32_t google_protobuf_DescriptorProto_visibility(const google_protobuf_DescriptorProto* msg) {
|
7626
|
+
int32_t default_val = 0;
|
7627
|
+
int32_t ret;
|
7628
|
+
const upb_MiniTableField field = {11, UPB_SIZE(48, 12), 66, 8, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
7629
|
+
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
7630
|
+
&default_val, &ret);
|
7631
|
+
return ret;
|
7632
|
+
}
|
7633
|
+
UPB_INLINE bool google_protobuf_DescriptorProto_has_visibility(const google_protobuf_DescriptorProto* msg) {
|
7634
|
+
const upb_MiniTableField field = {11, UPB_SIZE(48, 12), 66, 8, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
7635
|
+
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
7636
|
+
}
|
7270
7637
|
|
7271
7638
|
UPB_INLINE void google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto *msg, upb_StringView value) {
|
7272
|
-
const upb_MiniTableField field = {1, UPB_SIZE(
|
7639
|
+
const upb_MiniTableField field = {1, UPB_SIZE(52, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
7273
7640
|
upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
|
7274
7641
|
}
|
7275
7642
|
UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto* msg, size_t* size) {
|
@@ -7537,6 +7904,10 @@ UPB_INLINE bool google_protobuf_DescriptorProto_add_reserved_name(google_protobu
|
|
7537
7904
|
(arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val));
|
7538
7905
|
return true;
|
7539
7906
|
}
|
7907
|
+
UPB_INLINE void google_protobuf_DescriptorProto_set_visibility(google_protobuf_DescriptorProto *msg, int32_t value) {
|
7908
|
+
const upb_MiniTableField field = {11, UPB_SIZE(48, 12), 66, 8, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
7909
|
+
upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
|
7910
|
+
}
|
7540
7911
|
|
7541
7912
|
/* google.protobuf.DescriptorProto.ExtensionRange */
|
7542
7913
|
|
@@ -8477,19 +8848,19 @@ UPB_INLINE char* google_protobuf_EnumDescriptorProto_serialize_ex(const google_p
|
|
8477
8848
|
return ptr;
|
8478
8849
|
}
|
8479
8850
|
UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_name(google_protobuf_EnumDescriptorProto* msg) {
|
8480
|
-
const upb_MiniTableField field = {1, UPB_SIZE(
|
8851
|
+
const upb_MiniTableField field = {1, UPB_SIZE(32, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
8481
8852
|
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
8482
8853
|
}
|
8483
8854
|
UPB_INLINE upb_StringView google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto* msg) {
|
8484
8855
|
upb_StringView default_val = upb_StringView_FromString("");
|
8485
8856
|
upb_StringView ret;
|
8486
|
-
const upb_MiniTableField field = {1, UPB_SIZE(
|
8857
|
+
const upb_MiniTableField field = {1, UPB_SIZE(32, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
8487
8858
|
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
8488
8859
|
&default_val, &ret);
|
8489
8860
|
return ret;
|
8490
8861
|
}
|
8491
8862
|
UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_name(const google_protobuf_EnumDescriptorProto* msg) {
|
8492
|
-
const upb_MiniTableField field = {1, UPB_SIZE(
|
8863
|
+
const upb_MiniTableField field = {1, UPB_SIZE(32, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
8493
8864
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
8494
8865
|
}
|
8495
8866
|
UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_value(google_protobuf_EnumDescriptorProto* msg) {
|
@@ -8611,9 +8982,25 @@ UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_reserved_name_mutable
|
|
8611
8982
|
}
|
8612
8983
|
return arr;
|
8613
8984
|
}
|
8985
|
+
UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_visibility(google_protobuf_EnumDescriptorProto* msg) {
|
8986
|
+
const upb_MiniTableField field = {6, UPB_SIZE(28, 12), 66, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
8987
|
+
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
8988
|
+
}
|
8989
|
+
UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_visibility(const google_protobuf_EnumDescriptorProto* msg) {
|
8990
|
+
int32_t default_val = 0;
|
8991
|
+
int32_t ret;
|
8992
|
+
const upb_MiniTableField field = {6, UPB_SIZE(28, 12), 66, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
8993
|
+
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
8994
|
+
&default_val, &ret);
|
8995
|
+
return ret;
|
8996
|
+
}
|
8997
|
+
UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_visibility(const google_protobuf_EnumDescriptorProto* msg) {
|
8998
|
+
const upb_MiniTableField field = {6, UPB_SIZE(28, 12), 66, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
8999
|
+
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
9000
|
+
}
|
8614
9001
|
|
8615
9002
|
UPB_INLINE void google_protobuf_EnumDescriptorProto_set_name(google_protobuf_EnumDescriptorProto *msg, upb_StringView value) {
|
8616
|
-
const upb_MiniTableField field = {1, UPB_SIZE(
|
9003
|
+
const upb_MiniTableField field = {1, UPB_SIZE(32, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)};
|
8617
9004
|
upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
|
8618
9005
|
}
|
8619
9006
|
UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_mutable_value(google_protobuf_EnumDescriptorProto* msg, size_t* size) {
|
@@ -8721,6 +9108,10 @@ UPB_INLINE bool google_protobuf_EnumDescriptorProto_add_reserved_name(google_pro
|
|
8721
9108
|
(arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val));
|
8722
9109
|
return true;
|
8723
9110
|
}
|
9111
|
+
UPB_INLINE void google_protobuf_EnumDescriptorProto_set_visibility(google_protobuf_EnumDescriptorProto *msg, int32_t value) {
|
9112
|
+
const upb_MiniTableField field = {6, UPB_SIZE(28, 12), 66, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
9113
|
+
upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
|
9114
|
+
}
|
8724
9115
|
|
8725
9116
|
/* google.protobuf.EnumDescriptorProto.EnumReservedRange */
|
8726
9117
|
|
@@ -11965,6 +12356,22 @@ UPB_INLINE bool google_protobuf_FeatureSet_has_enforce_naming_style(const google
|
|
11965
12356
|
const upb_MiniTableField field = {7, 36, 70, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
11966
12357
|
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
11967
12358
|
}
|
12359
|
+
UPB_INLINE void google_protobuf_FeatureSet_clear_default_symbol_visibility(google_protobuf_FeatureSet* msg) {
|
12360
|
+
const upb_MiniTableField field = {8, 40, 71, 7, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
12361
|
+
upb_Message_ClearBaseField(UPB_UPCAST(msg), &field);
|
12362
|
+
}
|
12363
|
+
UPB_INLINE int32_t google_protobuf_FeatureSet_default_symbol_visibility(const google_protobuf_FeatureSet* msg) {
|
12364
|
+
int32_t default_val = 0;
|
12365
|
+
int32_t ret;
|
12366
|
+
const upb_MiniTableField field = {8, 40, 71, 7, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
12367
|
+
_upb_Message_GetNonExtensionField(UPB_UPCAST(msg), &field,
|
12368
|
+
&default_val, &ret);
|
12369
|
+
return ret;
|
12370
|
+
}
|
12371
|
+
UPB_INLINE bool google_protobuf_FeatureSet_has_default_symbol_visibility(const google_protobuf_FeatureSet* msg) {
|
12372
|
+
const upb_MiniTableField field = {8, 40, 71, 7, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
12373
|
+
return upb_Message_HasBaseField(UPB_UPCAST(msg), &field);
|
12374
|
+
}
|
11968
12375
|
|
11969
12376
|
UPB_INLINE void google_protobuf_FeatureSet_set_field_presence(google_protobuf_FeatureSet *msg, int32_t value) {
|
11970
12377
|
const upb_MiniTableField field = {1, 12, 64, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
@@ -11994,6 +12401,48 @@ UPB_INLINE void google_protobuf_FeatureSet_set_enforce_naming_style(google_proto
|
|
11994
12401
|
const upb_MiniTableField field = {7, 36, 70, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
11995
12402
|
upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
|
11996
12403
|
}
|
12404
|
+
UPB_INLINE void google_protobuf_FeatureSet_set_default_symbol_visibility(google_protobuf_FeatureSet *msg, int32_t value) {
|
12405
|
+
const upb_MiniTableField field = {8, 40, 71, 7, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
|
12406
|
+
upb_Message_SetBaseField((upb_Message *)msg, &field, &value);
|
12407
|
+
}
|
12408
|
+
|
12409
|
+
/* google.protobuf.FeatureSet.VisibilityFeature */
|
12410
|
+
|
12411
|
+
UPB_INLINE google_protobuf_FeatureSet_VisibilityFeature* google_protobuf_FeatureSet_VisibilityFeature_new(upb_Arena* arena) {
|
12412
|
+
return (google_protobuf_FeatureSet_VisibilityFeature*)_upb_Message_New(&google__protobuf__FeatureSet__VisibilityFeature_msg_init, arena);
|
12413
|
+
}
|
12414
|
+
UPB_INLINE google_protobuf_FeatureSet_VisibilityFeature* google_protobuf_FeatureSet_VisibilityFeature_parse(const char* buf, size_t size, upb_Arena* arena) {
|
12415
|
+
google_protobuf_FeatureSet_VisibilityFeature* ret = google_protobuf_FeatureSet_VisibilityFeature_new(arena);
|
12416
|
+
if (!ret) return NULL;
|
12417
|
+
if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FeatureSet__VisibilityFeature_msg_init, NULL, 0, arena) !=
|
12418
|
+
kUpb_DecodeStatus_Ok) {
|
12419
|
+
return NULL;
|
12420
|
+
}
|
12421
|
+
return ret;
|
12422
|
+
}
|
12423
|
+
UPB_INLINE google_protobuf_FeatureSet_VisibilityFeature* google_protobuf_FeatureSet_VisibilityFeature_parse_ex(const char* buf, size_t size,
|
12424
|
+
const upb_ExtensionRegistry* extreg,
|
12425
|
+
int options, upb_Arena* arena) {
|
12426
|
+
google_protobuf_FeatureSet_VisibilityFeature* ret = google_protobuf_FeatureSet_VisibilityFeature_new(arena);
|
12427
|
+
if (!ret) return NULL;
|
12428
|
+
if (upb_Decode(buf, size, UPB_UPCAST(ret), &google__protobuf__FeatureSet__VisibilityFeature_msg_init, extreg, options,
|
12429
|
+
arena) != kUpb_DecodeStatus_Ok) {
|
12430
|
+
return NULL;
|
12431
|
+
}
|
12432
|
+
return ret;
|
12433
|
+
}
|
12434
|
+
UPB_INLINE char* google_protobuf_FeatureSet_VisibilityFeature_serialize(const google_protobuf_FeatureSet_VisibilityFeature* msg, upb_Arena* arena, size_t* len) {
|
12435
|
+
char* ptr;
|
12436
|
+
(void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FeatureSet__VisibilityFeature_msg_init, 0, arena, &ptr, len);
|
12437
|
+
return ptr;
|
12438
|
+
}
|
12439
|
+
UPB_INLINE char* google_protobuf_FeatureSet_VisibilityFeature_serialize_ex(const google_protobuf_FeatureSet_VisibilityFeature* msg, int options,
|
12440
|
+
upb_Arena* arena, size_t* len) {
|
12441
|
+
char* ptr;
|
12442
|
+
(void)upb_Encode(UPB_UPCAST(msg), &google__protobuf__FeatureSet__VisibilityFeature_msg_init, options, arena, &ptr, len);
|
12443
|
+
return ptr;
|
12444
|
+
}
|
12445
|
+
|
11997
12446
|
|
11998
12447
|
/* google.protobuf.FeatureSetDefaults */
|
11999
12448
|
|
@@ -12918,7 +13367,7 @@ UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_semantic(google
|
|
12918
13367
|
|
12919
13368
|
// IWYU pragma: end_exports
|
12920
13369
|
|
12921
|
-
#endif //
|
13370
|
+
#endif // GOOGLE_UPB_UPB_REFLECTION_DESCRIPTOR_BOOTSTRAP_H__
|
12922
13371
|
|
12923
13372
|
typedef enum {
|
12924
13373
|
kUpb_Syntax_Proto2 = 2,
|
@@ -13027,8 +13476,8 @@ UPB_API const upb_EnumDef* upb_DefPool_FindEnumByName(const upb_DefPool* s,
|
|
13027
13476
|
const upb_EnumValueDef* upb_DefPool_FindEnumByNameval(const upb_DefPool* s,
|
13028
13477
|
const char* sym);
|
13029
13478
|
|
13030
|
-
const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s,
|
13031
|
-
|
13479
|
+
UPB_API const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s,
|
13480
|
+
const char* name);
|
13032
13481
|
|
13033
13482
|
const upb_FileDef* upb_DefPool_FindFileByNameWithSize(const upb_DefPool* s,
|
13034
13483
|
const char* name,
|
@@ -13224,7 +13673,7 @@ bool upb_FieldDef_IsOptional(const upb_FieldDef* f);
|
|
13224
13673
|
UPB_API bool upb_FieldDef_IsPacked(const upb_FieldDef* f);
|
13225
13674
|
bool upb_FieldDef_IsPrimitive(const upb_FieldDef* f);
|
13226
13675
|
UPB_API bool upb_FieldDef_IsRepeated(const upb_FieldDef* f);
|
13227
|
-
bool upb_FieldDef_IsRequired(const upb_FieldDef* f);
|
13676
|
+
UPB_API bool upb_FieldDef_IsRequired(const upb_FieldDef* f);
|
13228
13677
|
bool upb_FieldDef_IsString(const upb_FieldDef* f);
|
13229
13678
|
UPB_API bool upb_FieldDef_IsSubMessage(const upb_FieldDef* f);
|
13230
13679
|
UPB_API const char* upb_FieldDef_JsonName(const upb_FieldDef* f);
|
@@ -14091,7 +14540,9 @@ const upb_MiniTableExtension* upb_Message_FindExtensionByNumber(
|
|
14091
14540
|
#ifndef UPB_MESSAGE_INTERNAL_MAP_SORTER_H_
|
14092
14541
|
#define UPB_MESSAGE_INTERNAL_MAP_SORTER_H_
|
14093
14542
|
|
14543
|
+
#include <stdint.h>
|
14094
14544
|
#include <stdlib.h>
|
14545
|
+
#include <string.h>
|
14095
14546
|
|
14096
14547
|
|
14097
14548
|
#ifndef UPB_MESSAGE_INTERNAL_MAP_ENTRY_H_
|
@@ -14163,8 +14614,13 @@ UPB_INLINE bool _upb_sortedmap_next(_upb_mapsorter* s,
|
|
14163
14614
|
_upb_sortedmap* sorted, upb_MapEntry* ent) {
|
14164
14615
|
if (sorted->pos == sorted->end) return false;
|
14165
14616
|
const upb_tabent* tabent = (const upb_tabent*)s->entries[sorted->pos++];
|
14166
|
-
|
14167
|
-
|
14617
|
+
if (map->UPB_PRIVATE(is_strtable)) {
|
14618
|
+
upb_StringView key = upb_key_strview(tabent->key);
|
14619
|
+
_upb_map_fromkey(key, &ent->k, map->key_size);
|
14620
|
+
} else {
|
14621
|
+
uintptr_t key = tabent->key.num;
|
14622
|
+
memcpy(&ent->k, &key, map->key_size);
|
14623
|
+
}
|
14168
14624
|
upb_value val = {tabent->val.val};
|
14169
14625
|
_upb_map_fromvalue(val, &ent->v, map->val_size);
|
14170
14626
|
return true;
|
@@ -14334,8 +14790,8 @@ upb_UnknownCompareResult UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)(
|
|
14334
14790
|
|
14335
14791
|
#endif /* UPB_MESSAGE_INTERNAL_COMPARE_UNKNOWN_H_ */
|
14336
14792
|
|
14337
|
-
#ifndef
|
14338
|
-
#define
|
14793
|
+
#ifndef GOOGLE_UPB_UPB_MESSAGE_INTERNAL_ITERATOR_H__
|
14794
|
+
#define GOOGLE_UPB_UPB_MESSAGE_INTERNAL_ITERATOR_H__
|
14339
14795
|
|
14340
14796
|
#include <stddef.h>
|
14341
14797
|
#include <stdint.h>
|
@@ -14350,7 +14806,7 @@ bool UPB_PRIVATE(_upb_Message_NextBaseField)(const upb_Message* msg,
|
|
14350
14806
|
upb_MessageValue* out_v,
|
14351
14807
|
uintptr_t* iter);
|
14352
14808
|
|
14353
|
-
#endif //
|
14809
|
+
#endif // GOOGLE_UPB_UPB_MESSAGE_INTERNAL_ITERATOR_H__
|
14354
14810
|
|
14355
14811
|
#ifndef UPB_WIRE_READER_H_
|
14356
14812
|
#define UPB_WIRE_READER_H_
|
@@ -14624,8 +15080,8 @@ void upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src,
|
|
14624
15080
|
|
14625
15081
|
|
14626
15082
|
#endif // UPB_MESSAGE_COPY_H_
|
14627
|
-
#ifndef
|
14628
|
-
#define
|
15083
|
+
#ifndef GOOGLE_UPB_UPB_MESSAGE_MERGE_H__
|
15084
|
+
#define GOOGLE_UPB_UPB_MESSAGE_MERGE_H__
|
14629
15085
|
|
14630
15086
|
|
14631
15087
|
// Must be last.
|
@@ -14643,7 +15099,7 @@ UPB_API bool upb_Message_MergeFrom(upb_Message* dst, const upb_Message* src,
|
|
14643
15099
|
} /* extern "C" */
|
14644
15100
|
#endif
|
14645
15101
|
|
14646
|
-
#endif //
|
15102
|
+
#endif // GOOGLE_UPB_UPB_MESSAGE_MERGE_H__
|
14647
15103
|
|
14648
15104
|
#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_
|
14649
15105
|
#define UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_
|
@@ -14865,79 +15321,6 @@ upb_MiniTableEquals_Status upb_MiniTable_Equals(const upb_MiniTable* src,
|
|
14865
15321
|
|
14866
15322
|
#endif /* UPB_MINI_TABLE_COMPAT_H_ */
|
14867
15323
|
|
14868
|
-
#ifndef UPB_HASH_INT_TABLE_H_
|
14869
|
-
#define UPB_HASH_INT_TABLE_H_
|
14870
|
-
|
14871
|
-
|
14872
|
-
// Must be last.
|
14873
|
-
|
14874
|
-
typedef struct {
|
14875
|
-
upb_table t; // For entries that don't fit in the array part.
|
14876
|
-
const upb_tabval* array; // Array part of the table. See const note above.
|
14877
|
-
size_t array_size; // Array part size.
|
14878
|
-
size_t array_count; // Array part number of elements.
|
14879
|
-
} upb_inttable;
|
14880
|
-
|
14881
|
-
#ifdef __cplusplus
|
14882
|
-
extern "C" {
|
14883
|
-
#endif
|
14884
|
-
|
14885
|
-
// Initialize a table. If memory allocation failed, false is returned and
|
14886
|
-
// the table is uninitialized.
|
14887
|
-
bool upb_inttable_init(upb_inttable* table, upb_Arena* a);
|
14888
|
-
|
14889
|
-
// Returns the number of values in the table.
|
14890
|
-
size_t upb_inttable_count(const upb_inttable* t);
|
14891
|
-
|
14892
|
-
// Inserts the given key into the hashtable with the given value.
|
14893
|
-
// The key must not already exist in the hash table.
|
14894
|
-
// The value must not be UINTPTR_MAX.
|
14895
|
-
//
|
14896
|
-
// If a table resize was required but memory allocation failed, false is
|
14897
|
-
// returned and the table is unchanged.
|
14898
|
-
bool upb_inttable_insert(upb_inttable* t, uintptr_t key, upb_value val,
|
14899
|
-
upb_Arena* a);
|
14900
|
-
|
14901
|
-
// Looks up key in this table, returning "true" if the key was found.
|
14902
|
-
// If v is non-NULL, copies the value for this key into *v.
|
14903
|
-
bool upb_inttable_lookup(const upb_inttable* t, uintptr_t key, upb_value* v);
|
14904
|
-
|
14905
|
-
// Removes an item from the table. Returns true if the remove was successful,
|
14906
|
-
// and stores the removed item in *val if non-NULL.
|
14907
|
-
bool upb_inttable_remove(upb_inttable* t, uintptr_t key, upb_value* val);
|
14908
|
-
|
14909
|
-
// Updates an existing entry in an inttable.
|
14910
|
-
// If the entry does not exist, returns false and does nothing.
|
14911
|
-
// Unlike insert/remove, this does not invalidate iterators.
|
14912
|
-
bool upb_inttable_replace(upb_inttable* t, uintptr_t key, upb_value val);
|
14913
|
-
|
14914
|
-
// Optimizes the table for the current set of entries, for both memory use and
|
14915
|
-
// lookup time. Client should call this after all entries have been inserted;
|
14916
|
-
// inserting more entries is legal, but will likely require a table resize.
|
14917
|
-
void upb_inttable_compact(upb_inttable* t, upb_Arena* a);
|
14918
|
-
|
14919
|
-
// Iteration over inttable:
|
14920
|
-
//
|
14921
|
-
// intptr_t iter = UPB_INTTABLE_BEGIN;
|
14922
|
-
// uintptr_t key;
|
14923
|
-
// upb_value val;
|
14924
|
-
// while (upb_inttable_next(t, &key, &val, &iter)) {
|
14925
|
-
// // ...
|
14926
|
-
// }
|
14927
|
-
|
14928
|
-
#define UPB_INTTABLE_BEGIN -1
|
14929
|
-
|
14930
|
-
bool upb_inttable_next(const upb_inttable* t, uintptr_t* key, upb_value* val,
|
14931
|
-
intptr_t* iter);
|
14932
|
-
void upb_inttable_removeiter(upb_inttable* t, intptr_t* iter);
|
14933
|
-
|
14934
|
-
#ifdef __cplusplus
|
14935
|
-
} /* extern "C" */
|
14936
|
-
#endif
|
14937
|
-
|
14938
|
-
|
14939
|
-
#endif /* UPB_HASH_INT_TABLE_H_ */
|
14940
|
-
|
14941
15324
|
#ifndef UPB_WIRE_INTERNAL_CONSTANTS_H_
|
14942
15325
|
#define UPB_WIRE_INTERNAL_CONSTANTS_H_
|
14943
15326
|
|
@@ -15218,6 +15601,11 @@ bool _upb_DefPool_LoadDefInitEx(upb_DefPool* s, const _upb_DefPool_Init* init,
|
|
15218
15601
|
#ifndef UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_
|
15219
15602
|
#define UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_
|
15220
15603
|
|
15604
|
+
#include <setjmp.h>
|
15605
|
+
#include <stddef.h>
|
15606
|
+
#include <stdint.h>
|
15607
|
+
#include <string.h>
|
15608
|
+
|
15221
15609
|
|
15222
15610
|
// Must be last.
|
15223
15611
|
|
@@ -15246,16 +15634,16 @@ struct upb_DefBuilder {
|
|
15246
15634
|
UPB_DESC(FeatureSet*) legacy_features; // For computing legacy features.
|
15247
15635
|
char* tmp_buf; // Temporary buffer in tmp_arena.
|
15248
15636
|
size_t tmp_buf_size; // Size of temporary buffer.
|
15249
|
-
upb_FileDef* file;
|
15250
|
-
upb_Arena* arena;
|
15251
|
-
upb_Arena* tmp_arena;
|
15252
|
-
upb_Status* status;
|
15253
|
-
const upb_MiniTableFile* layout;
|
15254
|
-
upb_MiniTablePlatform platform;
|
15255
|
-
int enum_count;
|
15256
|
-
int msg_count;
|
15257
|
-
int ext_count;
|
15258
|
-
jmp_buf err;
|
15637
|
+
upb_FileDef* file; // File we are building.
|
15638
|
+
upb_Arena* arena; // Allocate defs here.
|
15639
|
+
upb_Arena* tmp_arena; // For temporary allocations.
|
15640
|
+
upb_Status* status; // Record errors here.
|
15641
|
+
const upb_MiniTableFile* layout; // NULL if we should build layouts.
|
15642
|
+
upb_MiniTablePlatform platform; // Platform we are targeting.
|
15643
|
+
int enum_count; // Count of enums built so far.
|
15644
|
+
int msg_count; // Count of messages built so far.
|
15645
|
+
int ext_count; // Count of extensions built so far.
|
15646
|
+
jmp_buf err; // longjmp() on error.
|
15259
15647
|
};
|
15260
15648
|
|
15261
15649
|
extern const char* kUpbDefOptDefault;
|
@@ -15294,6 +15682,19 @@ UPB_INLINE void* _upb_DefBuilder_Alloc(upb_DefBuilder* ctx, size_t bytes) {
|
|
15294
15682
|
return ret;
|
15295
15683
|
}
|
15296
15684
|
|
15685
|
+
/* Allocates an array of `count` elements, checking for size_t overflow */
|
15686
|
+
UPB_INLINE void* _upb_DefBuilder_AllocCounted(upb_DefBuilder* ctx, size_t size,
|
15687
|
+
size_t count) {
|
15688
|
+
if (count == 0) return NULL;
|
15689
|
+
if (SIZE_MAX / size < count) {
|
15690
|
+
_upb_DefBuilder_OomErr(ctx);
|
15691
|
+
}
|
15692
|
+
return _upb_DefBuilder_Alloc(ctx, size * count);
|
15693
|
+
}
|
15694
|
+
|
15695
|
+
#define UPB_DEFBUILDER_ALLOCARRAY(ctx, type, count) \
|
15696
|
+
((type*)_upb_DefBuilder_AllocCounted(ctx, sizeof(type), (count)))
|
15697
|
+
|
15297
15698
|
// Adds a symbol |v| to the symtab, which must be a def pointer previously
|
15298
15699
|
// packed with pack_def(). The def's pointer to upb_FileDef* must be set before
|
15299
15700
|
// adding, so we know which entries to remove if building this file fails.
|
@@ -15412,7 +15813,7 @@ upb_EnumValueDef* _upb_EnumValueDefs_New(
|
|
15412
15813
|
bool* is_sorted);
|
15413
15814
|
|
15414
15815
|
const upb_EnumValueDef** _upb_EnumValueDefs_Sorted(const upb_EnumValueDef* v,
|
15415
|
-
|
15816
|
+
size_t n, upb_Arena* a);
|
15416
15817
|
|
15417
15818
|
#ifdef __cplusplus
|
15418
15819
|
} /* extern "C" */
|
@@ -15568,7 +15969,7 @@ upb_ServiceDef* _upb_ServiceDefs_New(upb_DefBuilder* ctx, int n,
|
|
15568
15969
|
// features. This is used for feature resolution under Editions.
|
15569
15970
|
// NOLINTBEGIN
|
15570
15971
|
// clang-format off
|
15571
|
-
#define UPB_INTERNAL_UPB_EDITION_DEFAULTS "\n\
|
15972
|
+
#define UPB_INTERNAL_UPB_EDITION_DEFAULTS "\n\027\030\204\007\"\000*\020\010\001\020\002\030\002 \003(\0010\0028\002@\001\n\027\030\347\007\"\000*\020\010\002\020\001\030\001 \002(\0010\0018\002@\001\n\027\030\350\007\"\014\010\001\020\001\030\001 \002(\0010\001*\0048\002@\001 \346\007(\350\007"
|
15572
15973
|
// clang-format on
|
15573
15974
|
// NOLINTEND
|
15574
15975
|
|
@@ -15848,6 +16249,7 @@ google_protobuf_ServiceDescriptorProto* upb_ServiceDef_ToProto(
|
|
15848
16249
|
#undef UPB_SIZE
|
15849
16250
|
#undef UPB_PTR_AT
|
15850
16251
|
#undef UPB_SIZEOF_FLEX
|
16252
|
+
#undef UPB_SIZEOF_FLEX_WOULD_OVERFLOW
|
15851
16253
|
#undef UPB_MAPTYPE_STRING
|
15852
16254
|
#undef UPB_EXPORT
|
15853
16255
|
#undef UPB_INLINE
|