google-protobuf 3.1.0-x86-linux → 3.2.0-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of google-protobuf might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/defs.c +2 -2
- data/ext/google/protobuf_c/encode_decode.c +4 -4
- data/ext/google/protobuf_c/message.c +44 -0
- data/ext/google/protobuf_c/upb.c +3120 -1982
- data/ext/google/protobuf_c/upb.h +755 -471
- data/lib/google/2.0/protobuf_c.so +0 -0
- data/lib/google/2.1/protobuf_c.so +0 -0
- data/lib/google/2.2/protobuf_c.so +0 -0
- data/lib/google/2.3/protobuf_c.so +0 -0
- data/lib/google/2.4/protobuf_c.so +0 -0
- data/lib/google/protobuf/repeated_field.rb +1 -1
- data/tests/basic.rb +19 -0
- metadata +29 -19
data/ext/google/protobuf_c/upb.h
CHANGED
@@ -55,14 +55,13 @@
|
|
55
55
|
** store pointers or integers of at least 32 bits (upb isn't really useful on
|
56
56
|
** systems where sizeof(void*) < 4).
|
57
57
|
**
|
58
|
-
** The table must be
|
58
|
+
** The table must be homogenous (all values of the same type). In debug
|
59
59
|
** mode, we check this on insert and lookup.
|
60
60
|
*/
|
61
61
|
|
62
62
|
#ifndef UPB_TABLE_H_
|
63
63
|
#define UPB_TABLE_H_
|
64
64
|
|
65
|
-
#include <assert.h>
|
66
65
|
#include <stdint.h>
|
67
66
|
#include <string.h>
|
68
67
|
/*
|
@@ -118,20 +117,21 @@ template <int N> class InlinedEnvironment;
|
|
118
117
|
#define UPB_NORETURN
|
119
118
|
#endif
|
120
119
|
|
120
|
+
#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
|
121
|
+
/* C99/C++11 versions. */
|
122
|
+
#include <stdio.h>
|
123
|
+
#define _upb_snprintf snprintf
|
124
|
+
#define _upb_vsnprintf vsnprintf
|
125
|
+
#define _upb_va_copy(a, b) va_copy(a, b)
|
126
|
+
#elif defined __GNUC__
|
121
127
|
/* A few hacky workarounds for functions not in C89.
|
122
128
|
* For internal use only!
|
123
129
|
* TODO(haberman): fix these by including our own implementations, or finding
|
124
130
|
* another workaround.
|
125
131
|
*/
|
126
|
-
#ifdef __GNUC__
|
127
132
|
#define _upb_snprintf __builtin_snprintf
|
128
133
|
#define _upb_vsnprintf __builtin_vsnprintf
|
129
134
|
#define _upb_va_copy(a, b) __va_copy(a, b)
|
130
|
-
#elif __STDC_VERSION__ >= 199901L
|
131
|
-
/* C99 versions. */
|
132
|
-
#define _upb_snprintf snprintf
|
133
|
-
#define _upb_vsnprintf vsnprintf
|
134
|
-
#define _upb_va_copy(a, b) va_copy(a, b)
|
135
135
|
#else
|
136
136
|
#error Need implementations of [v]snprintf and va_copy
|
137
137
|
#endif
|
@@ -263,10 +263,23 @@ template <int N> class InlinedEnvironment;
|
|
263
263
|
|
264
264
|
#define UPB_UNUSED(var) (void)var
|
265
265
|
|
266
|
-
/*
|
267
|
-
*
|
268
|
-
|
269
|
-
#define
|
266
|
+
/* UPB_ASSERT(): in release mode, we use the expression without letting it be
|
267
|
+
* evaluated. This prevents "unused variable" warnings. */
|
268
|
+
#ifdef NDEBUG
|
269
|
+
#define UPB_ASSERT(expr) do {} while (false && (expr))
|
270
|
+
#else
|
271
|
+
#define UPB_ASSERT(expr) assert(expr)
|
272
|
+
#endif
|
273
|
+
|
274
|
+
/* UPB_ASSERT_DEBUGVAR(): assert that uses functions or variables that only
|
275
|
+
* exist in debug mode. This turns into regular assert. */
|
276
|
+
#define UPB_ASSERT_DEBUGVAR(expr) assert(expr)
|
277
|
+
|
278
|
+
#ifdef __GNUC__
|
279
|
+
#define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0)
|
280
|
+
#else
|
281
|
+
#define UPB_UNREACHABLE() do { assert(0); } while(0)
|
282
|
+
#endif
|
270
283
|
|
271
284
|
/* Generic function type. */
|
272
285
|
typedef void upb_func();
|
@@ -501,17 +514,18 @@ struct upb_alloc {
|
|
501
514
|
};
|
502
515
|
|
503
516
|
UPB_INLINE void *upb_malloc(upb_alloc *alloc, size_t size) {
|
504
|
-
|
517
|
+
UPB_ASSERT(alloc);
|
505
518
|
return alloc->func(alloc, NULL, 0, size);
|
506
519
|
}
|
507
520
|
|
508
521
|
UPB_INLINE void *upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize,
|
509
522
|
size_t size) {
|
510
|
-
|
523
|
+
UPB_ASSERT(alloc);
|
511
524
|
return alloc->func(alloc, ptr, oldsize, size);
|
512
525
|
}
|
513
526
|
|
514
527
|
UPB_INLINE void upb_free(upb_alloc *alloc, void *ptr) {
|
528
|
+
assert(alloc);
|
515
529
|
alloc->func(alloc, ptr, 0, 0);
|
516
530
|
}
|
517
531
|
|
@@ -560,11 +574,11 @@ UPB_BEGIN_EXTERN_C
|
|
560
574
|
void upb_arena_init(upb_arena *a);
|
561
575
|
void upb_arena_init2(upb_arena *a, void *mem, size_t n, upb_alloc *alloc);
|
562
576
|
void upb_arena_uninit(upb_arena *a);
|
563
|
-
upb_alloc *upb_arena_alloc(upb_arena *a);
|
564
577
|
bool upb_arena_addcleanup(upb_arena *a, upb_cleanup_func *func, void *ud);
|
565
578
|
size_t upb_arena_bytesallocated(const upb_arena *a);
|
566
579
|
void upb_arena_setnextblocksize(upb_arena *a, size_t size);
|
567
580
|
void upb_arena_setmaxblocksize(upb_arena *a, size_t size);
|
581
|
+
UPB_INLINE upb_alloc *upb_arena_alloc(upb_arena *a) { return (upb_alloc*)a; }
|
568
582
|
|
569
583
|
UPB_END_EXTERN_C
|
570
584
|
|
@@ -795,7 +809,9 @@ typedef enum {
|
|
795
809
|
UPB_CTYPE_CSTR = 6,
|
796
810
|
UPB_CTYPE_PTR = 7,
|
797
811
|
UPB_CTYPE_CONSTPTR = 8,
|
798
|
-
UPB_CTYPE_FPTR = 9
|
812
|
+
UPB_CTYPE_FPTR = 9,
|
813
|
+
UPB_CTYPE_FLOAT = 10,
|
814
|
+
UPB_CTYPE_DOUBLE = 11
|
799
815
|
} upb_ctype_t;
|
800
816
|
|
801
817
|
typedef struct {
|
@@ -854,7 +870,7 @@ UPB_INLINE upb_value _upb_value_val(uint64_t val, upb_ctype_t ctype) {
|
|
854
870
|
return ret; \
|
855
871
|
} \
|
856
872
|
UPB_INLINE type_t upb_value_get ## name(upb_value val) { \
|
857
|
-
|
873
|
+
UPB_ASSERT_DEBUGVAR(val.ctype == proto_type); \
|
858
874
|
return (type_t)(converter)val.val; \
|
859
875
|
}
|
860
876
|
|
@@ -869,6 +885,29 @@ FUNCS(constptr, constptr, const void*, uintptr_t, UPB_CTYPE_CONSTPTR)
|
|
869
885
|
FUNCS(fptr, fptr, upb_func*, uintptr_t, UPB_CTYPE_FPTR)
|
870
886
|
|
871
887
|
#undef FUNCS
|
888
|
+
|
889
|
+
UPB_INLINE void upb_value_setfloat(upb_value *val, float cval) {
|
890
|
+
memcpy(&val->val, &cval, sizeof(cval));
|
891
|
+
SET_TYPE(val->ctype, UPB_CTYPE_FLOAT);
|
892
|
+
}
|
893
|
+
|
894
|
+
UPB_INLINE void upb_value_setdouble(upb_value *val, double cval) {
|
895
|
+
memcpy(&val->val, &cval, sizeof(cval));
|
896
|
+
SET_TYPE(val->ctype, UPB_CTYPE_DOUBLE);
|
897
|
+
}
|
898
|
+
|
899
|
+
UPB_INLINE upb_value upb_value_float(float cval) {
|
900
|
+
upb_value ret;
|
901
|
+
upb_value_setfloat(&ret, cval);
|
902
|
+
return ret;
|
903
|
+
}
|
904
|
+
|
905
|
+
UPB_INLINE upb_value upb_value_double(double cval) {
|
906
|
+
upb_value ret;
|
907
|
+
upb_value_setdouble(&ret, cval);
|
908
|
+
return ret;
|
909
|
+
}
|
910
|
+
|
872
911
|
#undef SET_TYPE
|
873
912
|
|
874
913
|
|
@@ -1111,6 +1150,13 @@ UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) {
|
|
1111
1150
|
return t->t.count;
|
1112
1151
|
}
|
1113
1152
|
|
1153
|
+
void upb_inttable_packedsize(const upb_inttable *t, size_t *size);
|
1154
|
+
void upb_strtable_packedsize(const upb_strtable *t, size_t *size);
|
1155
|
+
upb_inttable *upb_inttable_pack(const upb_inttable *t, void *p, size_t *ofs,
|
1156
|
+
size_t size);
|
1157
|
+
upb_strtable *upb_strtable_pack(const upb_strtable *t, void *p, size_t *ofs,
|
1158
|
+
size_t size);
|
1159
|
+
|
1114
1160
|
/* Inserts the given key into the hashtable with the given value. The key must
|
1115
1161
|
* not already exist in the hash table. For string tables, the key must be
|
1116
1162
|
* NULL-terminated, and the table will make an internal copy of the key.
|
@@ -1556,7 +1602,7 @@ template <class T> class upb::reffed_ptr {
|
|
1556
1602
|
reffed_ptr(U* val, const void* ref_donor = NULL)
|
1557
1603
|
: ptr_(upb::upcast(val)) {
|
1558
1604
|
if (ref_donor) {
|
1559
|
-
|
1605
|
+
UPB_ASSERT(ptr_);
|
1560
1606
|
ptr_->DonateRef(ref_donor, this);
|
1561
1607
|
} else if (ptr_) {
|
1562
1608
|
ptr_->Ref(this);
|
@@ -1601,12 +1647,12 @@ template <class T> class upb::reffed_ptr {
|
|
1601
1647
|
}
|
1602
1648
|
|
1603
1649
|
T& operator*() const {
|
1604
|
-
|
1650
|
+
UPB_ASSERT(ptr_);
|
1605
1651
|
return *ptr_;
|
1606
1652
|
}
|
1607
1653
|
|
1608
1654
|
T* operator->() const {
|
1609
|
-
|
1655
|
+
UPB_ASSERT(ptr_);
|
1610
1656
|
return ptr_;
|
1611
1657
|
}
|
1612
1658
|
|
@@ -1657,6 +1703,7 @@ class FieldDef;
|
|
1657
1703
|
class FileDef;
|
1658
1704
|
class MessageDef;
|
1659
1705
|
class OneofDef;
|
1706
|
+
class SymbolTable;
|
1660
1707
|
}
|
1661
1708
|
#endif
|
1662
1709
|
|
@@ -1665,6 +1712,8 @@ UPB_DECLARE_DERIVED_TYPE(upb::OneofDef, upb::RefCounted, upb_oneofdef,
|
|
1665
1712
|
upb_refcounted)
|
1666
1713
|
UPB_DECLARE_DERIVED_TYPE(upb::FileDef, upb::RefCounted, upb_filedef,
|
1667
1714
|
upb_refcounted)
|
1715
|
+
UPB_DECLARE_TYPE(upb::SymbolTable, upb_symtab)
|
1716
|
+
|
1668
1717
|
|
1669
1718
|
/* The maximum message depth that the type graph can have. This is a resource
|
1670
1719
|
* limit for the C stack since we sometimes need to recursively traverse the
|
@@ -1698,8 +1747,6 @@ class upb::Def {
|
|
1698
1747
|
public:
|
1699
1748
|
typedef upb_deftype_t Type;
|
1700
1749
|
|
1701
|
-
Def* Dup(const void *owner) const;
|
1702
|
-
|
1703
1750
|
/* upb::RefCounted methods like Ref()/Unref(). */
|
1704
1751
|
UPB_REFCOUNTED_CPPMETHODS
|
1705
1752
|
|
@@ -1745,9 +1792,6 @@ class upb::Def {
|
|
1745
1792
|
|
1746
1793
|
UPB_BEGIN_EXTERN_C
|
1747
1794
|
|
1748
|
-
/* Native C API. */
|
1749
|
-
upb_def *upb_def_dup(const upb_def *def, const void *owner);
|
1750
|
-
|
1751
1795
|
/* Include upb_refcounted methods like upb_def_ref()/upb_def_unref(). */
|
1752
1796
|
UPB_REFCOUNTED_CMETHODS(upb_def, upb_def_upcast)
|
1753
1797
|
|
@@ -1808,7 +1852,7 @@ UPB_END_EXTERN_C
|
|
1808
1852
|
return (upb_##lower *)def; \
|
1809
1853
|
} \
|
1810
1854
|
UPB_INLINE const upb_##lower *upb_downcast_##lower(const upb_def *def) { \
|
1811
|
-
|
1855
|
+
UPB_ASSERT(upb_def_type(def) == UPB_DEF_##upper); \
|
1812
1856
|
return (const upb_##lower *)def; \
|
1813
1857
|
} \
|
1814
1858
|
UPB_INLINE upb_##lower *upb_dyncast_##lower##_mutable(upb_def *def) { \
|
@@ -1844,15 +1888,19 @@ UPB_DECLARE_DEF_TYPE(upb::EnumDef, enumdef, ENUM)
|
|
1844
1888
|
* types defined in descriptor.proto, which gives INT32 and SINT32 separate
|
1845
1889
|
* types (we distinguish the two with the "integer encoding" enum below). */
|
1846
1890
|
typedef enum {
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
UPB_TYPE_ENUM =
|
1854
|
-
|
1855
|
-
|
1891
|
+
/* Types stored in 1 byte. */
|
1892
|
+
UPB_TYPE_BOOL = 1,
|
1893
|
+
/* Types stored in 4 bytes. */
|
1894
|
+
UPB_TYPE_FLOAT = 2,
|
1895
|
+
UPB_TYPE_INT32 = 3,
|
1896
|
+
UPB_TYPE_UINT32 = 4,
|
1897
|
+
UPB_TYPE_ENUM = 5, /* Enum values are int32. */
|
1898
|
+
/* Types stored as pointers (probably 4 or 8 bytes). */
|
1899
|
+
UPB_TYPE_STRING = 6,
|
1900
|
+
UPB_TYPE_BYTES = 7,
|
1901
|
+
UPB_TYPE_MESSAGE = 8,
|
1902
|
+
/* Types stored as 8 bytes. */
|
1903
|
+
UPB_TYPE_DOUBLE = 9,
|
1856
1904
|
UPB_TYPE_INT64 = 10,
|
1857
1905
|
UPB_TYPE_UINT64 = 11
|
1858
1906
|
} upb_fieldtype_t;
|
@@ -1933,13 +1981,6 @@ class upb::FieldDef {
|
|
1933
1981
|
/* Returns NULL if memory allocation failed. */
|
1934
1982
|
static reffed_ptr<FieldDef> New();
|
1935
1983
|
|
1936
|
-
/* Duplicates the given field, returning NULL if memory allocation failed.
|
1937
|
-
* When a fielddef is duplicated, the subdef (if any) is made symbolic if it
|
1938
|
-
* wasn't already. If the subdef is set but has no name (which is possible
|
1939
|
-
* since msgdefs are not required to have a name) the new fielddef's subdef
|
1940
|
-
* will be unset. */
|
1941
|
-
FieldDef* Dup(const void* owner) const;
|
1942
|
-
|
1943
1984
|
/* upb::RefCounted methods like Ref()/Unref(). */
|
1944
1985
|
UPB_REFCOUNTED_CPPMETHODS
|
1945
1986
|
|
@@ -2026,16 +2067,10 @@ class upb::FieldDef {
|
|
2026
2067
|
bool IsPrimitive() const;
|
2027
2068
|
bool IsMap() const;
|
2028
2069
|
|
2029
|
-
/*
|
2070
|
+
/* Returns whether this field explicitly represents presence.
|
2030
2071
|
*
|
2031
|
-
*
|
2032
|
-
*
|
2033
|
-
*
|
2034
|
-
* * This is always true for submessages.
|
2035
|
-
*
|
2036
|
-
* * For other fields, it depends on the message (see
|
2037
|
-
* MessageDef::SetPrimitivesHavePresence())
|
2038
|
-
*/
|
2072
|
+
* For proto2 messages: Returns true for any scalar (non-repeated) field.
|
2073
|
+
* For proto3 messages: Returns true for scalar submessage or oneof fields. */
|
2039
2074
|
bool HasPresence() const;
|
2040
2075
|
|
2041
2076
|
/* How integers are encoded. Only meaningful for integer types.
|
@@ -2194,7 +2229,6 @@ UPB_BEGIN_EXTERN_C
|
|
2194
2229
|
|
2195
2230
|
/* Native C API. */
|
2196
2231
|
upb_fielddef *upb_fielddef_new(const void *owner);
|
2197
|
-
upb_fielddef *upb_fielddef_dup(const upb_fielddef *f, const void *owner);
|
2198
2232
|
|
2199
2233
|
/* Include upb_refcounted methods like upb_fielddef_ref(). */
|
2200
2234
|
UPB_REFCOUNTED_CMETHODS(upb_fielddef, upb_fielddef_upcast2)
|
@@ -2404,16 +2438,6 @@ class upb::MessageDef {
|
|
2404
2438
|
return FindOneofByName(str.c_str(), str.size());
|
2405
2439
|
}
|
2406
2440
|
|
2407
|
-
/* Returns a new msgdef that is a copy of the given msgdef (and a copy of all
|
2408
|
-
* the fields) but with any references to submessages broken and replaced
|
2409
|
-
* with just the name of the submessage. Returns NULL if memory allocation
|
2410
|
-
* failed.
|
2411
|
-
*
|
2412
|
-
* TODO(haberman): which is more useful, keeping fields resolved or
|
2413
|
-
* unresolving them? If there's no obvious answer, Should this functionality
|
2414
|
-
* just be moved into symtab.c? */
|
2415
|
-
MessageDef* Dup(const void* owner) const;
|
2416
|
-
|
2417
2441
|
/* Is this message a map entry? */
|
2418
2442
|
void setmapentry(bool map_entry);
|
2419
2443
|
bool mapentry() const;
|
@@ -2547,7 +2571,6 @@ UPB_REFCOUNTED_CMETHODS(upb_msgdef, upb_msgdef_upcast2)
|
|
2547
2571
|
|
2548
2572
|
bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status);
|
2549
2573
|
|
2550
|
-
upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner);
|
2551
2574
|
const char *upb_msgdef_fullname(const upb_msgdef *m);
|
2552
2575
|
const char *upb_msgdef_name(const upb_msgdef *m);
|
2553
2576
|
int upb_msgdef_numoneofs(const upb_msgdef *m);
|
@@ -2697,10 +2720,6 @@ class upb::EnumDef {
|
|
2697
2720
|
* first one that was added. */
|
2698
2721
|
const char* FindValueByNumber(int32_t num) const;
|
2699
2722
|
|
2700
|
-
/* Returns a new EnumDef with all the same values. The new EnumDef will be
|
2701
|
-
* owned by the given owner. */
|
2702
|
-
EnumDef* Dup(const void* owner) const;
|
2703
|
-
|
2704
2723
|
/* Iteration over name/value pairs. The order is undefined.
|
2705
2724
|
* Adding an enum val invalidates any iterators.
|
2706
2725
|
*
|
@@ -2728,7 +2747,6 @@ UPB_BEGIN_EXTERN_C
|
|
2728
2747
|
|
2729
2748
|
/* Native C API. */
|
2730
2749
|
upb_enumdef *upb_enumdef_new(const void *owner);
|
2731
|
-
upb_enumdef *upb_enumdef_dup(const upb_enumdef *e, const void *owner);
|
2732
2750
|
|
2733
2751
|
/* Include upb_refcounted methods like upb_enumdef_ref(). */
|
2734
2752
|
UPB_REFCOUNTED_CMETHODS(upb_enumdef, upb_enumdef_upcast2)
|
@@ -2773,6 +2791,7 @@ int32_t upb_enum_iter_number(upb_enum_iter *iter);
|
|
2773
2791
|
|
2774
2792
|
UPB_END_EXTERN_C
|
2775
2793
|
|
2794
|
+
|
2776
2795
|
/* upb::OneofDef **************************************************************/
|
2777
2796
|
|
2778
2797
|
typedef upb_inttable_iter upb_oneof_iter;
|
@@ -2837,10 +2856,6 @@ class upb::OneofDef {
|
|
2837
2856
|
/* Looks up by tag number. */
|
2838
2857
|
const FieldDef* FindFieldByNumber(uint32_t num) const;
|
2839
2858
|
|
2840
|
-
/* Returns a new OneofDef with all the same fields. The OneofDef will be owned
|
2841
|
-
* by the given owner. */
|
2842
|
-
OneofDef* Dup(const void* owner) const;
|
2843
|
-
|
2844
2859
|
/* Iteration over fields. The order is undefined. */
|
2845
2860
|
class iterator : public std::iterator<std::forward_iterator_tag, FieldDef*> {
|
2846
2861
|
public:
|
@@ -2886,16 +2901,16 @@ UPB_BEGIN_EXTERN_C
|
|
2886
2901
|
|
2887
2902
|
/* Native C API. */
|
2888
2903
|
upb_oneofdef *upb_oneofdef_new(const void *owner);
|
2889
|
-
upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner);
|
2890
2904
|
|
2891
2905
|
/* Include upb_refcounted methods like upb_oneofdef_ref(). */
|
2892
2906
|
UPB_REFCOUNTED_CMETHODS(upb_oneofdef, upb_oneofdef_upcast)
|
2893
2907
|
|
2894
2908
|
const char *upb_oneofdef_name(const upb_oneofdef *o);
|
2895
|
-
bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s);
|
2896
|
-
|
2897
2909
|
const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o);
|
2898
2910
|
int upb_oneofdef_numfields(const upb_oneofdef *o);
|
2911
|
+
uint32_t upb_oneofdef_index(const upb_oneofdef *o);
|
2912
|
+
|
2913
|
+
bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s);
|
2899
2914
|
bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f,
|
2900
2915
|
const void *ref_donor,
|
2901
2916
|
upb_status *s);
|
@@ -3039,19 +3054,163 @@ UPB_INLINE upb_def *upb_filedef_mutabledef(upb_filedef *f, int i) {
|
|
3039
3054
|
|
3040
3055
|
UPB_END_EXTERN_C
|
3041
3056
|
|
3057
|
+
typedef struct {
|
3058
|
+
UPB_PRIVATE_FOR_CPP
|
3059
|
+
upb_strtable_iter iter;
|
3060
|
+
upb_deftype_t type;
|
3061
|
+
} upb_symtab_iter;
|
3062
|
+
|
3063
|
+
#ifdef __cplusplus
|
3064
|
+
|
3065
|
+
/* Non-const methods in upb::SymbolTable are NOT thread-safe. */
|
3066
|
+
class upb::SymbolTable {
|
3067
|
+
public:
|
3068
|
+
/* Returns a new symbol table with a single ref owned by "owner."
|
3069
|
+
* Returns NULL if memory allocation failed. */
|
3070
|
+
static SymbolTable* New();
|
3071
|
+
static void Free(upb::SymbolTable* table);
|
3072
|
+
|
3073
|
+
/* For all lookup functions, the returned pointer is not owned by the
|
3074
|
+
* caller; it may be invalidated by any non-const call or unref of the
|
3075
|
+
* SymbolTable! To protect against this, take a ref if desired. */
|
3076
|
+
|
3077
|
+
/* Freezes the symbol table: prevents further modification of it.
|
3078
|
+
* After the Freeze() operation is successful, the SymbolTable must only be
|
3079
|
+
* accessed via a const pointer.
|
3080
|
+
*
|
3081
|
+
* Unlike with upb::MessageDef/upb::EnumDef/etc, freezing a SymbolTable is not
|
3082
|
+
* a necessary step in using a SymbolTable. If you have no need for it to be
|
3083
|
+
* immutable, there is no need to freeze it ever. However sometimes it is
|
3084
|
+
* useful, and SymbolTables that are statically compiled into the binary are
|
3085
|
+
* always frozen by nature. */
|
3086
|
+
void Freeze();
|
3087
|
+
|
3088
|
+
/* Resolves the given symbol using the rules described in descriptor.proto,
|
3089
|
+
* namely:
|
3090
|
+
*
|
3091
|
+
* If the name starts with a '.', it is fully-qualified. Otherwise,
|
3092
|
+
* C++-like scoping rules are used to find the type (i.e. first the nested
|
3093
|
+
* types within this message are searched, then within the parent, on up
|
3094
|
+
* to the root namespace).
|
3095
|
+
*
|
3096
|
+
* If not found, returns NULL. */
|
3097
|
+
const Def* Resolve(const char* base, const char* sym) const;
|
3098
|
+
|
3099
|
+
/* Finds an entry in the symbol table with this exact name. If not found,
|
3100
|
+
* returns NULL. */
|
3101
|
+
const Def* Lookup(const char *sym) const;
|
3102
|
+
const MessageDef* LookupMessage(const char *sym) const;
|
3103
|
+
const EnumDef* LookupEnum(const char *sym) const;
|
3104
|
+
|
3105
|
+
/* TODO: introduce a C++ iterator, but make it nice and templated so that if
|
3106
|
+
* you ask for an iterator of MessageDef the iterated elements are strongly
|
3107
|
+
* typed as MessageDef*. */
|
3108
|
+
|
3109
|
+
/* Adds the given mutable defs to the symtab, resolving all symbols (including
|
3110
|
+
* enum default values) and finalizing the defs. Only one def per name may be
|
3111
|
+
* in the list, and the defs may not duplicate any name already in the symtab.
|
3112
|
+
* All defs must have a name -- anonymous defs are not allowed. Anonymous
|
3113
|
+
* defs can still be frozen by calling upb_def_freeze() directly.
|
3114
|
+
*
|
3115
|
+
* The entire operation either succeeds or fails. If the operation fails,
|
3116
|
+
* the symtab is unchanged, false is returned, and status indicates the
|
3117
|
+
* error. The caller passes a ref on all defs to the symtab (even if the
|
3118
|
+
* operation fails).
|
3119
|
+
*
|
3120
|
+
* TODO(haberman): currently failure will leave the symtab unchanged, but may
|
3121
|
+
* leave the defs themselves partially resolved. Does this matter? If so we
|
3122
|
+
* could do a prepass that ensures that all symbols are resolvable and bail
|
3123
|
+
* if not, so we don't mutate anything until we know the operation will
|
3124
|
+
* succeed. */
|
3125
|
+
bool Add(Def*const* defs, size_t n, void* ref_donor, Status* status);
|
3126
|
+
|
3127
|
+
bool Add(const std::vector<Def*>& defs, void *owner, Status* status) {
|
3128
|
+
return Add((Def*const*)&defs[0], defs.size(), owner, status);
|
3129
|
+
}
|
3130
|
+
|
3131
|
+
/* Resolves all subdefs for messages in this file and attempts to freeze the
|
3132
|
+
* file. If this succeeds, adds all the symbols to this SymbolTable
|
3133
|
+
* (replacing any existing ones with the same names). */
|
3134
|
+
bool AddFile(FileDef* file, Status* s);
|
3135
|
+
|
3136
|
+
private:
|
3137
|
+
UPB_DISALLOW_POD_OPS(SymbolTable, upb::SymbolTable)
|
3138
|
+
};
|
3139
|
+
|
3140
|
+
#endif /* __cplusplus */
|
3141
|
+
|
3142
|
+
UPB_BEGIN_EXTERN_C
|
3143
|
+
|
3144
|
+
/* Native C API. */
|
3145
|
+
|
3146
|
+
upb_symtab *upb_symtab_new();
|
3147
|
+
void upb_symtab_free(upb_symtab* s);
|
3148
|
+
const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
|
3149
|
+
const char *sym);
|
3150
|
+
const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym);
|
3151
|
+
const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
|
3152
|
+
const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
|
3153
|
+
bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
|
3154
|
+
void *ref_donor, upb_status *status);
|
3155
|
+
bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status* status);
|
3156
|
+
|
3157
|
+
/* upb_symtab_iter i;
|
3158
|
+
* for(upb_symtab_begin(&i, s, type); !upb_symtab_done(&i);
|
3159
|
+
* upb_symtab_next(&i)) {
|
3160
|
+
* const upb_def *def = upb_symtab_iter_def(&i);
|
3161
|
+
* // ...
|
3162
|
+
* }
|
3163
|
+
*
|
3164
|
+
* For C we don't have separate iterators for const and non-const.
|
3165
|
+
* It is the caller's responsibility to cast the upb_fielddef* to
|
3166
|
+
* const if the upb_msgdef* is const. */
|
3167
|
+
void upb_symtab_begin(upb_symtab_iter *iter, const upb_symtab *s,
|
3168
|
+
upb_deftype_t type);
|
3169
|
+
void upb_symtab_next(upb_symtab_iter *iter);
|
3170
|
+
bool upb_symtab_done(const upb_symtab_iter *iter);
|
3171
|
+
const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter);
|
3172
|
+
|
3173
|
+
UPB_END_EXTERN_C
|
3174
|
+
|
3175
|
+
#ifdef __cplusplus
|
3176
|
+
/* C++ inline wrappers. */
|
3177
|
+
namespace upb {
|
3178
|
+
inline SymbolTable* SymbolTable::New() {
|
3179
|
+
return upb_symtab_new();
|
3180
|
+
}
|
3181
|
+
inline void SymbolTable::Free(SymbolTable* s) {
|
3182
|
+
upb_symtab_free(s);
|
3183
|
+
}
|
3184
|
+
inline const Def *SymbolTable::Resolve(const char *base,
|
3185
|
+
const char *sym) const {
|
3186
|
+
return upb_symtab_resolve(this, base, sym);
|
3187
|
+
}
|
3188
|
+
inline const Def* SymbolTable::Lookup(const char *sym) const {
|
3189
|
+
return upb_symtab_lookup(this, sym);
|
3190
|
+
}
|
3191
|
+
inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const {
|
3192
|
+
return upb_symtab_lookupmsg(this, sym);
|
3193
|
+
}
|
3194
|
+
inline bool SymbolTable::Add(
|
3195
|
+
Def*const* defs, size_t n, void* ref_donor, Status* status) {
|
3196
|
+
return upb_symtab_add(this, (upb_def*const*)defs, n, ref_donor, status);
|
3197
|
+
}
|
3198
|
+
inline bool SymbolTable::AddFile(FileDef* file, Status* s) {
|
3199
|
+
return upb_symtab_addfile(this, file, s);
|
3200
|
+
}
|
3201
|
+
} /* namespace upb */
|
3202
|
+
#endif
|
3203
|
+
|
3042
3204
|
#ifdef __cplusplus
|
3043
3205
|
|
3044
3206
|
UPB_INLINE const char* upb_safecstr(const std::string& str) {
|
3045
|
-
|
3207
|
+
UPB_ASSERT(str.size() == std::strlen(str.c_str()));
|
3046
3208
|
return str.c_str();
|
3047
3209
|
}
|
3048
3210
|
|
3049
3211
|
/* Inline C++ wrappers. */
|
3050
3212
|
namespace upb {
|
3051
3213
|
|
3052
|
-
inline Def* Def::Dup(const void* owner) const {
|
3053
|
-
return upb_def_dup(this, owner);
|
3054
|
-
}
|
3055
3214
|
inline Def::Type Def::def_type() const { return upb_def_type(this); }
|
3056
3215
|
inline const char* Def::full_name() const { return upb_def_fullname(this); }
|
3057
3216
|
inline const char* Def::name() const { return upb_def_name(this); }
|
@@ -3081,19 +3240,19 @@ inline bool FieldDef::CheckIntegerFormat(int32_t val) {
|
|
3081
3240
|
return upb_fielddef_checkintfmt(val);
|
3082
3241
|
}
|
3083
3242
|
inline FieldDef::Type FieldDef::ConvertType(int32_t val) {
|
3084
|
-
|
3243
|
+
UPB_ASSERT(CheckType(val));
|
3085
3244
|
return static_cast<FieldDef::Type>(val);
|
3086
3245
|
}
|
3087
3246
|
inline FieldDef::Label FieldDef::ConvertLabel(int32_t val) {
|
3088
|
-
|
3247
|
+
UPB_ASSERT(CheckLabel(val));
|
3089
3248
|
return static_cast<FieldDef::Label>(val);
|
3090
3249
|
}
|
3091
3250
|
inline FieldDef::DescriptorType FieldDef::ConvertDescriptorType(int32_t val) {
|
3092
|
-
|
3251
|
+
UPB_ASSERT(CheckDescriptorType(val));
|
3093
3252
|
return static_cast<FieldDef::DescriptorType>(val);
|
3094
3253
|
}
|
3095
3254
|
inline FieldDef::IntegerFormat FieldDef::ConvertIntegerFormat(int32_t val) {
|
3096
|
-
|
3255
|
+
UPB_ASSERT(CheckIntegerFormat(val));
|
3097
3256
|
return static_cast<FieldDef::IntegerFormat>(val);
|
3098
3257
|
}
|
3099
3258
|
|
@@ -3101,9 +3260,6 @@ inline reffed_ptr<FieldDef> FieldDef::New() {
|
|
3101
3260
|
upb_fielddef *f = upb_fielddef_new(&f);
|
3102
3261
|
return reffed_ptr<FieldDef>(f, &f);
|
3103
3262
|
}
|
3104
|
-
inline FieldDef* FieldDef::Dup(const void* owner) const {
|
3105
|
-
return upb_fielddef_dup(this, owner);
|
3106
|
-
}
|
3107
3263
|
inline const char* FieldDef::full_name() const {
|
3108
3264
|
return upb_fielddef_fullname(this);
|
3109
3265
|
}
|
@@ -3343,9 +3499,6 @@ inline const OneofDef* MessageDef::FindOneofByName(const char* name,
|
|
3343
3499
|
size_t len) const {
|
3344
3500
|
return upb_msgdef_ntoo(this, name, len);
|
3345
3501
|
}
|
3346
|
-
inline MessageDef* MessageDef::Dup(const void *owner) const {
|
3347
|
-
return upb_msgdef_dup(this, owner);
|
3348
|
-
}
|
3349
3502
|
inline void MessageDef::setmapentry(bool map_entry) {
|
3350
3503
|
upb_msgdef_setmapentry(this, map_entry);
|
3351
3504
|
}
|
@@ -3515,9 +3668,6 @@ inline bool EnumDef::FindValueByName(const char* name, int32_t *num) const {
|
|
3515
3668
|
inline const char* EnumDef::FindValueByNumber(int32_t num) const {
|
3516
3669
|
return upb_enumdef_iton(this, num);
|
3517
3670
|
}
|
3518
|
-
inline EnumDef* EnumDef::Dup(const void* owner) const {
|
3519
|
-
return upb_enumdef_dup(this, owner);
|
3520
|
-
}
|
3521
3671
|
|
3522
3672
|
inline EnumDef::Iterator::Iterator(const EnumDef* e) {
|
3523
3673
|
upb_enum_begin(&iter_, e);
|
@@ -3824,6 +3974,7 @@ extern const struct upb_refcounted_vtbl upb_enumdef_vtbl;
|
|
3824
3974
|
struct upb_oneofdef {
|
3825
3975
|
upb_refcounted base;
|
3826
3976
|
|
3977
|
+
uint32_t index; /* Index within oneofs. */
|
3827
3978
|
const char *name;
|
3828
3979
|
upb_strtable ntof;
|
3829
3980
|
upb_inttable itof;
|
@@ -3833,7 +3984,7 @@ struct upb_oneofdef {
|
|
3833
3984
|
extern const struct upb_refcounted_vtbl upb_oneofdef_vtbl;
|
3834
3985
|
|
3835
3986
|
#define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \
|
3836
|
-
{ UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), name, ntof, itof }
|
3987
|
+
{ UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), 0, name, ntof, itof }
|
3837
3988
|
|
3838
3989
|
|
3839
3990
|
/* upb_symtab *****************************************************************/
|
@@ -4469,7 +4620,7 @@ template <class T> class Handler {
|
|
4469
4620
|
void AddCleanup(Handlers* h) const {
|
4470
4621
|
if (cleanup_func_) {
|
4471
4622
|
bool ok = h->AddCleanup(cleanup_data_, cleanup_func_);
|
4472
|
-
|
4623
|
+
UPB_ASSERT(ok);
|
4473
4624
|
}
|
4474
4625
|
}
|
4475
4626
|
|
@@ -5489,7 +5640,7 @@ struct ConvertParams<BoundFunc5<R, P1, P2, P3, P4, P5, F, I>, T> {
|
|
5489
5640
|
inline bool Handlers::SetValueHandler<vtype>( \
|
5490
5641
|
const FieldDef *f, \
|
5491
5642
|
const Handlers::utype ## Handler& handler) { \
|
5492
|
-
|
5643
|
+
UPB_ASSERT(!handler.registered_); \
|
5493
5644
|
handler.AddCleanup(this); \
|
5494
5645
|
handler.registered_ = true; \
|
5495
5646
|
return upb_handlers_set##ltype(this, f, handler.handler_, &handler.attr_); \
|
@@ -5601,7 +5752,7 @@ inline Handler<T>::Handler(F func)
|
|
5601
5752
|
|
5602
5753
|
template <class T>
|
5603
5754
|
inline Handler<T>::~Handler() {
|
5604
|
-
|
5755
|
+
UPB_ASSERT(registered_);
|
5605
5756
|
}
|
5606
5757
|
|
5607
5758
|
inline HandlerAttributes::HandlerAttributes() { upb_handlerattr_init(this); }
|
@@ -5687,63 +5838,63 @@ inline bool Handlers::AddCleanup(void *p, upb_handlerfree *func) {
|
|
5687
5838
|
}
|
5688
5839
|
inline bool Handlers::SetStartMessageHandler(
|
5689
5840
|
const Handlers::StartMessageHandler &handler) {
|
5690
|
-
|
5841
|
+
UPB_ASSERT(!handler.registered_);
|
5691
5842
|
handler.registered_ = true;
|
5692
5843
|
handler.AddCleanup(this);
|
5693
5844
|
return upb_handlers_setstartmsg(this, handler.handler_, &handler.attr_);
|
5694
5845
|
}
|
5695
5846
|
inline bool Handlers::SetEndMessageHandler(
|
5696
5847
|
const Handlers::EndMessageHandler &handler) {
|
5697
|
-
|
5848
|
+
UPB_ASSERT(!handler.registered_);
|
5698
5849
|
handler.registered_ = true;
|
5699
5850
|
handler.AddCleanup(this);
|
5700
5851
|
return upb_handlers_setendmsg(this, handler.handler_, &handler.attr_);
|
5701
5852
|
}
|
5702
5853
|
inline bool Handlers::SetStartStringHandler(const FieldDef *f,
|
5703
5854
|
const StartStringHandler &handler) {
|
5704
|
-
|
5855
|
+
UPB_ASSERT(!handler.registered_);
|
5705
5856
|
handler.registered_ = true;
|
5706
5857
|
handler.AddCleanup(this);
|
5707
5858
|
return upb_handlers_setstartstr(this, f, handler.handler_, &handler.attr_);
|
5708
5859
|
}
|
5709
5860
|
inline bool Handlers::SetEndStringHandler(const FieldDef *f,
|
5710
5861
|
const EndFieldHandler &handler) {
|
5711
|
-
|
5862
|
+
UPB_ASSERT(!handler.registered_);
|
5712
5863
|
handler.registered_ = true;
|
5713
5864
|
handler.AddCleanup(this);
|
5714
5865
|
return upb_handlers_setendstr(this, f, handler.handler_, &handler.attr_);
|
5715
5866
|
}
|
5716
5867
|
inline bool Handlers::SetStringHandler(const FieldDef *f,
|
5717
5868
|
const StringHandler& handler) {
|
5718
|
-
|
5869
|
+
UPB_ASSERT(!handler.registered_);
|
5719
5870
|
handler.registered_ = true;
|
5720
5871
|
handler.AddCleanup(this);
|
5721
5872
|
return upb_handlers_setstring(this, f, handler.handler_, &handler.attr_);
|
5722
5873
|
}
|
5723
5874
|
inline bool Handlers::SetStartSequenceHandler(
|
5724
5875
|
const FieldDef *f, const StartFieldHandler &handler) {
|
5725
|
-
|
5876
|
+
UPB_ASSERT(!handler.registered_);
|
5726
5877
|
handler.registered_ = true;
|
5727
5878
|
handler.AddCleanup(this);
|
5728
5879
|
return upb_handlers_setstartseq(this, f, handler.handler_, &handler.attr_);
|
5729
5880
|
}
|
5730
5881
|
inline bool Handlers::SetStartSubMessageHandler(
|
5731
5882
|
const FieldDef *f, const StartFieldHandler &handler) {
|
5732
|
-
|
5883
|
+
UPB_ASSERT(!handler.registered_);
|
5733
5884
|
handler.registered_ = true;
|
5734
5885
|
handler.AddCleanup(this);
|
5735
5886
|
return upb_handlers_setstartsubmsg(this, f, handler.handler_, &handler.attr_);
|
5736
5887
|
}
|
5737
5888
|
inline bool Handlers::SetEndSubMessageHandler(const FieldDef *f,
|
5738
5889
|
const EndFieldHandler &handler) {
|
5739
|
-
|
5890
|
+
UPB_ASSERT(!handler.registered_);
|
5740
5891
|
handler.registered_ = true;
|
5741
5892
|
handler.AddCleanup(this);
|
5742
5893
|
return upb_handlers_setendsubmsg(this, f, handler.handler_, &handler.attr_);
|
5743
5894
|
}
|
5744
5895
|
inline bool Handlers::SetEndSequenceHandler(const FieldDef *f,
|
5745
5896
|
const EndFieldHandler &handler) {
|
5746
|
-
|
5897
|
+
UPB_ASSERT(!handler.registered_);
|
5747
5898
|
handler.registered_ = true;
|
5748
5899
|
handler.AddCleanup(this);
|
5749
5900
|
return upb_handlers_setendseq(this, f, handler.handler_, &handler.attr_);
|
@@ -5820,12 +5971,14 @@ inline BytesHandler::~BytesHandler() {}
|
|
5820
5971
|
|
5821
5972
|
#ifdef __cplusplus
|
5822
5973
|
namespace upb {
|
5974
|
+
class BufferSink;
|
5823
5975
|
class BufferSource;
|
5824
5976
|
class BytesSink;
|
5825
5977
|
class Sink;
|
5826
5978
|
}
|
5827
5979
|
#endif
|
5828
5980
|
|
5981
|
+
UPB_DECLARE_TYPE(upb::BufferSink, upb_bufsink)
|
5829
5982
|
UPB_DECLARE_TYPE(upb::BufferSource, upb_bufsrc)
|
5830
5983
|
UPB_DECLARE_TYPE(upb::BytesSink, upb_bytessink)
|
5831
5984
|
UPB_DECLARE_TYPE(upb::Sink, upb_sink)
|
@@ -6012,6 +6165,13 @@ struct upb_bufsrc {
|
|
6012
6165
|
|
6013
6166
|
UPB_BEGIN_EXTERN_C
|
6014
6167
|
|
6168
|
+
/* A class for accumulating output string data in a flat buffer. */
|
6169
|
+
|
6170
|
+
upb_bufsink *upb_bufsink_new(upb_env *env);
|
6171
|
+
void upb_bufsink_free(upb_bufsink *sink);
|
6172
|
+
upb_bytessink *upb_bufsink_sink(upb_bufsink *sink);
|
6173
|
+
const char *upb_bufsink_getdata(const upb_bufsink *sink, size_t *len);
|
6174
|
+
|
6015
6175
|
/* Inline definitions. */
|
6016
6176
|
|
6017
6177
|
UPB_INLINE void upb_bytessink_reset(upb_bytessink *s, const upb_byteshandler *h,
|
@@ -6061,23 +6221,7 @@ UPB_INLINE bool upb_bytessink_end(upb_bytessink *s) {
|
|
6061
6221
|
&s->handler->table[UPB_ENDSTR_SELECTOR].attr));
|
6062
6222
|
}
|
6063
6223
|
|
6064
|
-
|
6065
|
-
upb_bytessink *sink) {
|
6066
|
-
void *subc;
|
6067
|
-
bool ret;
|
6068
|
-
upb_bufhandle handle;
|
6069
|
-
upb_bufhandle_init(&handle);
|
6070
|
-
upb_bufhandle_setbuf(&handle, buf, 0);
|
6071
|
-
ret = upb_bytessink_start(sink, len, &subc);
|
6072
|
-
if (ret && len != 0) {
|
6073
|
-
ret = (upb_bytessink_putbuf(sink, subc, buf, len, &handle) >= len);
|
6074
|
-
}
|
6075
|
-
if (ret) {
|
6076
|
-
ret = upb_bytessink_end(sink);
|
6077
|
-
}
|
6078
|
-
upb_bufhandle_uninit(&handle);
|
6079
|
-
return ret;
|
6080
|
-
}
|
6224
|
+
bool upb_bufsrc_putbuf(const char *buf, size_t len, upb_bytessink *sink);
|
6081
6225
|
|
6082
6226
|
#define PUTVAL(type, ctype) \
|
6083
6227
|
UPB_INLINE bool upb_sink_put##type(upb_sink *s, upb_selector_t sel, \
|
@@ -6325,267 +6469,407 @@ inline bool BufferSource::PutBuffer(const char *buf, size_t len,
|
|
6325
6469
|
|
6326
6470
|
#endif
|
6327
6471
|
/*
|
6328
|
-
**
|
6329
|
-
** overhead of calling a handler can be significant. This file allows the
|
6330
|
-
** user to define handlers that do something very simple like store the value
|
6331
|
-
** to memory and/or set a hasbit. JIT compilers can then special-case these
|
6332
|
-
** handlers and emit specialized code for them instead of actually calling the
|
6333
|
-
** handler.
|
6472
|
+
** upb::Message is a representation for protobuf messages.
|
6334
6473
|
**
|
6335
|
-
**
|
6336
|
-
**
|
6337
|
-
|
6338
|
-
|
6339
|
-
|
6340
|
-
|
6474
|
+
** However it differs from other common representations like
|
6475
|
+
** google::protobuf::Message in one key way: it does not prescribe any
|
6476
|
+
** ownership between messages and submessages, and it relies on the
|
6477
|
+
** client to delete each message/submessage/array/map at the appropriate
|
6478
|
+
** time.
|
6479
|
+
**
|
6480
|
+
** A client can access a upb::Message without knowing anything about
|
6481
|
+
** ownership semantics, but to create or mutate a message a user needs
|
6482
|
+
** to implement the memory management themselves.
|
6483
|
+
**
|
6484
|
+
** Currently all messages, arrays, and maps store a upb_alloc* internally.
|
6485
|
+
** Mutating operations use this when they require dynamically-allocated
|
6486
|
+
** memory. We could potentially eliminate this size overhead later by
|
6487
|
+
** letting the user flip a bit on the factory that prevents this from
|
6488
|
+
** being stored. The user would then need to use separate functions where
|
6489
|
+
** the upb_alloc* is passed explicitly. However for handlers to populate
|
6490
|
+
** such structures, they would need a place to store this upb_alloc* during
|
6491
|
+
** parsing; upb_handlers don't currently have a good way to accommodate this.
|
6492
|
+
**
|
6493
|
+
** TODO: UTF-8 checking?
|
6494
|
+
**/
|
6341
6495
|
|
6496
|
+
#ifndef UPB_MSG_H_
|
6497
|
+
#define UPB_MSG_H_
|
6342
6498
|
|
6343
|
-
typedef struct {
|
6344
|
-
size_t offset;
|
6345
|
-
int32_t hasbit;
|
6346
|
-
} upb_shim_data;
|
6347
6499
|
|
6348
6500
|
#ifdef __cplusplus
|
6349
6501
|
|
6350
6502
|
namespace upb {
|
6503
|
+
class Array;
|
6504
|
+
class Map;
|
6505
|
+
class MapIterator;
|
6506
|
+
class MessageFactory;
|
6507
|
+
class MessageLayout;
|
6508
|
+
class Visitor;
|
6509
|
+
class VisitorPlan;
|
6510
|
+
}
|
6351
6511
|
|
6352
|
-
|
6353
|
-
typedef upb_shim_data Data;
|
6512
|
+
#endif
|
6354
6513
|
|
6355
|
-
|
6356
|
-
|
6357
|
-
|
6358
|
-
|
6514
|
+
UPB_DECLARE_TYPE(upb::MessageFactory, upb_msgfactory)
|
6515
|
+
UPB_DECLARE_TYPE(upb::MessageLayout, upb_msglayout)
|
6516
|
+
UPB_DECLARE_TYPE(upb::Array, upb_array)
|
6517
|
+
UPB_DECLARE_TYPE(upb::Map, upb_map)
|
6518
|
+
UPB_DECLARE_TYPE(upb::MapIterator, upb_mapiter)
|
6519
|
+
UPB_DECLARE_TYPE(upb::Visitor, upb_visitor)
|
6520
|
+
UPB_DECLARE_TYPE(upb::VisitorPlan, upb_visitorplan)
|
6359
6521
|
|
6360
|
-
|
6361
|
-
* stores the type in "type". Otherwise returns NULL. */
|
6362
|
-
static const Data* GetData(const Handlers* h, Handlers::Selector s,
|
6363
|
-
FieldDef::Type* type);
|
6364
|
-
};
|
6522
|
+
/* TODO(haberman): C++ accessors */
|
6365
6523
|
|
6366
|
-
|
6524
|
+
UPB_BEGIN_EXTERN_C
|
6367
6525
|
|
6368
|
-
|
6526
|
+
typedef void upb_msg;
|
6369
6527
|
|
6370
|
-
UPB_BEGIN_EXTERN_C
|
6371
6528
|
|
6372
|
-
|
6373
|
-
bool upb_shim_set(upb_handlers *h, const upb_fielddef *f, size_t offset,
|
6374
|
-
int32_t hasbit);
|
6375
|
-
const upb_shim_data *upb_shim_getdata(const upb_handlers *h, upb_selector_t s,
|
6376
|
-
upb_fieldtype_t *type);
|
6529
|
+
/** upb_msglayout *************************************************************/
|
6377
6530
|
|
6378
|
-
|
6531
|
+
/* upb_msglayout represents the memory layout of a given upb_msgdef. You get
|
6532
|
+
* instances of this from a upb_msgfactory, and the factory always owns the
|
6533
|
+
* msglayout. */
|
6379
6534
|
|
6380
|
-
|
6381
|
-
|
6382
|
-
namespace upb {
|
6383
|
-
inline bool Shim::Set(Handlers* h, const FieldDef* f, size_t ofs,
|
6384
|
-
int32_t hasbit) {
|
6385
|
-
return upb_shim_set(h, f, ofs, hasbit);
|
6386
|
-
}
|
6387
|
-
inline const Shim::Data* Shim::GetData(const Handlers* h, Handlers::Selector s,
|
6388
|
-
FieldDef::Type* type) {
|
6389
|
-
return upb_shim_getdata(h, s, type);
|
6390
|
-
}
|
6391
|
-
} /* namespace upb */
|
6392
|
-
#endif
|
6535
|
+
/* Gets the factory for this layout */
|
6536
|
+
upb_msgfactory *upb_msglayout_factory(const upb_msglayout *l);
|
6393
6537
|
|
6394
|
-
|
6395
|
-
|
6396
|
-
|
6397
|
-
|
6398
|
-
|
6399
|
-
|
6400
|
-
|
6401
|
-
|
6402
|
-
**
|
6403
|
-
** This is a mixed C/C++ interface that offers a full API to both languages.
|
6404
|
-
** See the top-level README for more information.
|
6405
|
-
*/
|
6538
|
+
/* Get the msglayout for a submessage. This requires that this field is a
|
6539
|
+
* submessage, ie. upb_fielddef_issubmsg(upb_msglayout_msgdef(l)) == true.
|
6540
|
+
*
|
6541
|
+
* Since map entry messages don't have layouts, if upb_fielddef_ismap(f) == true
|
6542
|
+
* then this function will return the layout for the map's value. It requires
|
6543
|
+
* that the value type of the map field is a submessage. */
|
6544
|
+
const upb_msglayout *upb_msglayout_sublayout(const upb_msglayout *l,
|
6545
|
+
const upb_fielddef *f);
|
6406
6546
|
|
6407
|
-
|
6408
|
-
|
6547
|
+
/* Returns the msgdef for this msglayout. */
|
6548
|
+
const upb_msgdef *upb_msglayout_msgdef(const upb_msglayout *l);
|
6409
6549
|
|
6410
6550
|
|
6411
|
-
|
6412
|
-
#include <vector>
|
6413
|
-
namespace upb { class SymbolTable; }
|
6414
|
-
#endif
|
6551
|
+
/** upb_visitor ***************************************************************/
|
6415
6552
|
|
6416
|
-
|
6417
|
-
|
6553
|
+
/* upb_visitor will visit all the fields of a message and its submessages. It
|
6554
|
+
* uses a upb_visitorplan which you can obtain from a upb_msgfactory. */
|
6418
6555
|
|
6419
|
-
|
6420
|
-
|
6421
|
-
|
6422
|
-
upb_deftype_t type;
|
6423
|
-
} upb_symtab_iter;
|
6556
|
+
upb_visitor *upb_visitor_create(upb_env *e, const upb_visitorplan *vp,
|
6557
|
+
upb_sink *output);
|
6558
|
+
bool upb_visitor_visitmsg(upb_visitor *v, const upb_msg *msg);
|
6424
6559
|
|
6425
|
-
#ifdef __cplusplus
|
6426
6560
|
|
6427
|
-
|
6428
|
-
class upb::SymbolTable {
|
6429
|
-
public:
|
6430
|
-
/* Returns a new symbol table with a single ref owned by "owner."
|
6431
|
-
* Returns NULL if memory allocation failed. */
|
6432
|
-
static reffed_ptr<SymbolTable> New();
|
6561
|
+
/** upb_msgfactory ************************************************************/
|
6433
6562
|
|
6434
|
-
|
6435
|
-
|
6563
|
+
/* A upb_msgfactory contains a cache of upb_msglayout, upb_handlers, and
|
6564
|
+
* upb_visitorplan objects. These are the objects necessary to represent,
|
6565
|
+
* populate, and and visit upb_msg objects.
|
6566
|
+
*
|
6567
|
+
* These caches are all populated by upb_msgdef, and lazily created on demand.
|
6568
|
+
*/
|
6436
6569
|
|
6437
|
-
|
6438
|
-
|
6439
|
-
|
6570
|
+
/* Creates and destroys a msgfactory, respectively. The messages for this
|
6571
|
+
* msgfactory must come from |symtab| (which should outlive the msgfactory). */
|
6572
|
+
upb_msgfactory *upb_msgfactory_new(const upb_symtab *symtab);
|
6573
|
+
void upb_msgfactory_free(upb_msgfactory *f);
|
6440
6574
|
|
6441
|
-
|
6442
|
-
* After the Freeze() operation is successful, the SymbolTable must only be
|
6443
|
-
* accessed via a const pointer.
|
6444
|
-
*
|
6445
|
-
* Unlike with upb::MessageDef/upb::EnumDef/etc, freezing a SymbolTable is not
|
6446
|
-
* a necessary step in using a SymbolTable. If you have no need for it to be
|
6447
|
-
* immutable, there is no need to freeze it ever. However sometimes it is
|
6448
|
-
* useful, and SymbolTables that are statically compiled into the binary are
|
6449
|
-
* always frozen by nature. */
|
6450
|
-
void Freeze();
|
6575
|
+
const upb_symtab *upb_msgfactory_symtab(const upb_msgfactory *f);
|
6451
6576
|
|
6452
|
-
|
6453
|
-
|
6454
|
-
|
6455
|
-
|
6456
|
-
|
6457
|
-
|
6458
|
-
|
6459
|
-
|
6460
|
-
|
6461
|
-
|
6577
|
+
/* The functions to get cached objects, lazily creating them on demand. These
|
6578
|
+
* all require:
|
6579
|
+
*
|
6580
|
+
* - m is in upb_msgfactory_symtab(f)
|
6581
|
+
* - upb_msgdef_mapentry(m) == false (since map messages can't have layouts).
|
6582
|
+
*
|
6583
|
+
* The returned objects will live for as long as the msgfactory does.
|
6584
|
+
*
|
6585
|
+
* TODO(haberman): consider making this thread-safe and take a const
|
6586
|
+
* upb_msgfactory. */
|
6587
|
+
const upb_msglayout *upb_msgfactory_getlayout(upb_msgfactory *f,
|
6588
|
+
const upb_msgdef *m);
|
6589
|
+
const upb_handlers *upb_msgfactory_getmergehandlers(upb_msgfactory *f,
|
6590
|
+
const upb_msgdef *m);
|
6591
|
+
const upb_visitorplan *upb_msgfactory_getvisitorplan(upb_msgfactory *f,
|
6592
|
+
const upb_handlers *h);
|
6462
6593
|
|
6463
|
-
/* Finds an entry in the symbol table with this exact name. If not found,
|
6464
|
-
* returns NULL. */
|
6465
|
-
const Def* Lookup(const char *sym) const;
|
6466
|
-
const MessageDef* LookupMessage(const char *sym) const;
|
6467
|
-
const EnumDef* LookupEnum(const char *sym) const;
|
6468
6594
|
|
6469
|
-
|
6470
|
-
* you ask for an iterator of MessageDef the iterated elements are strongly
|
6471
|
-
* typed as MessageDef*. */
|
6595
|
+
/** upb_msgval ****************************************************************/
|
6472
6596
|
|
6473
|
-
|
6474
|
-
|
6475
|
-
* name may be in the list, but defs can replace existing defs in the symtab.
|
6476
|
-
* All defs must have a name -- anonymous defs are not allowed. Anonymous
|
6477
|
-
* defs can still be frozen by calling upb_def_freeze() directly.
|
6478
|
-
*
|
6479
|
-
* Any existing defs that can reach defs that are being replaced will
|
6480
|
-
* themselves be replaced also, so that the resulting set of defs is fully
|
6481
|
-
* consistent.
|
6482
|
-
*
|
6483
|
-
* This logic implemented in this method is a convenience; ultimately it
|
6484
|
-
* calls some combination of upb_fielddef_setsubdef(), upb_def_dup(), and
|
6485
|
-
* upb_freeze(), any of which the client could call themself. However, since
|
6486
|
-
* the logic for doing so is nontrivial, we provide it here.
|
6487
|
-
*
|
6488
|
-
* The entire operation either succeeds or fails. If the operation fails,
|
6489
|
-
* the symtab is unchanged, false is returned, and status indicates the
|
6490
|
-
* error. The caller passes a ref on all defs to the symtab (even if the
|
6491
|
-
* operation fails).
|
6492
|
-
*
|
6493
|
-
* TODO(haberman): currently failure will leave the symtab unchanged, but may
|
6494
|
-
* leave the defs themselves partially resolved. Does this matter? If so we
|
6495
|
-
* could do a prepass that ensures that all symbols are resolvable and bail
|
6496
|
-
* if not, so we don't mutate anything until we know the operation will
|
6497
|
-
* succeed.
|
6498
|
-
*
|
6499
|
-
* TODO(haberman): since the defs must be mutable, refining a frozen def
|
6500
|
-
* requires making mutable copies of the entire tree. This is wasteful if
|
6501
|
-
* only a few messages are changing. We may want to add a way of adding a
|
6502
|
-
* tree of frozen defs to the symtab (perhaps an alternate constructor where
|
6503
|
-
* you pass the root of the tree?) */
|
6504
|
-
bool Add(Def*const* defs, size_t n, void* ref_donor, Status* status);
|
6597
|
+
/* A union representing all possible protobuf values. Used for generic get/set
|
6598
|
+
* operations. */
|
6505
6599
|
|
6506
|
-
|
6507
|
-
|
6600
|
+
typedef union {
|
6601
|
+
bool b;
|
6602
|
+
float flt;
|
6603
|
+
double dbl;
|
6604
|
+
int32_t i32;
|
6605
|
+
int64_t i64;
|
6606
|
+
uint32_t u32;
|
6607
|
+
uint64_t u64;
|
6608
|
+
const upb_map* map;
|
6609
|
+
const upb_msg* msg;
|
6610
|
+
const upb_array* arr;
|
6611
|
+
const void* ptr;
|
6612
|
+
struct {
|
6613
|
+
const char *ptr;
|
6614
|
+
size_t len;
|
6615
|
+
} str;
|
6616
|
+
} upb_msgval;
|
6617
|
+
|
6618
|
+
#define ACCESSORS(name, membername, ctype) \
|
6619
|
+
UPB_INLINE ctype upb_msgval_get ## name(upb_msgval v) { \
|
6620
|
+
return v.membername; \
|
6621
|
+
} \
|
6622
|
+
UPB_INLINE void upb_msgval_set ## name(upb_msgval *v, ctype cval) { \
|
6623
|
+
v->membername = cval; \
|
6624
|
+
} \
|
6625
|
+
UPB_INLINE upb_msgval upb_msgval_ ## name(ctype v) { \
|
6626
|
+
upb_msgval ret; \
|
6627
|
+
ret.membername = v; \
|
6628
|
+
return ret; \
|
6508
6629
|
}
|
6509
6630
|
|
6510
|
-
|
6511
|
-
|
6512
|
-
|
6513
|
-
|
6631
|
+
ACCESSORS(bool, b, bool)
|
6632
|
+
ACCESSORS(float, flt, float)
|
6633
|
+
ACCESSORS(double, dbl, double)
|
6634
|
+
ACCESSORS(int32, i32, int32_t)
|
6635
|
+
ACCESSORS(int64, i64, int64_t)
|
6636
|
+
ACCESSORS(uint32, u32, uint32_t)
|
6637
|
+
ACCESSORS(uint64, u64, uint64_t)
|
6638
|
+
ACCESSORS(map, map, const upb_map*)
|
6639
|
+
ACCESSORS(msg, msg, const upb_msg*)
|
6640
|
+
ACCESSORS(ptr, ptr, const void*)
|
6641
|
+
ACCESSORS(arr, arr, const upb_array*)
|
6642
|
+
|
6643
|
+
#undef ACCESSORS
|
6644
|
+
|
6645
|
+
UPB_INLINE upb_msgval upb_msgval_str(const char *ptr, size_t len) {
|
6646
|
+
upb_msgval ret;
|
6647
|
+
ret.str.ptr = ptr;
|
6648
|
+
ret.str.len = len;
|
6649
|
+
return ret;
|
6650
|
+
}
|
6514
6651
|
|
6515
|
-
|
6516
|
-
|
6517
|
-
}
|
6652
|
+
UPB_INLINE const char* upb_msgval_getstr(upb_msgval val) {
|
6653
|
+
return val.str.ptr;
|
6654
|
+
}
|
6518
6655
|
|
6519
|
-
|
6656
|
+
UPB_INLINE size_t upb_msgval_getstrlen(upb_msgval val) {
|
6657
|
+
return val.str.len;
|
6658
|
+
}
|
6520
6659
|
|
6521
|
-
UPB_BEGIN_EXTERN_C
|
6522
6660
|
|
6523
|
-
|
6661
|
+
/** upb_msg *******************************************************************/
|
6524
6662
|
|
6525
|
-
/*
|
6526
|
-
|
6663
|
+
/* A upb_msg represents a protobuf message. It always corresponds to a specific
|
6664
|
+
* upb_msglayout, which describes how it is laid out in memory.
|
6665
|
+
*
|
6666
|
+
* The message will have a fixed size, as returned by upb_msg_sizeof(), which
|
6667
|
+
* will be used to store fixed-length fields. The upb_msg may also allocate
|
6668
|
+
* dynamic memory internally to store data such as:
|
6669
|
+
*
|
6670
|
+
* - extensions
|
6671
|
+
* - unknown fields
|
6672
|
+
*/
|
6527
6673
|
|
6528
|
-
|
6529
|
-
|
6530
|
-
const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
|
6531
|
-
const char *sym);
|
6532
|
-
const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym);
|
6533
|
-
const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
|
6534
|
-
const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
|
6535
|
-
bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
|
6536
|
-
void *ref_donor, upb_status *status);
|
6537
|
-
bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status* status);
|
6674
|
+
/* Returns the size of a message given this layout. */
|
6675
|
+
size_t upb_msg_sizeof(const upb_msglayout *l);
|
6538
6676
|
|
6539
|
-
/*
|
6540
|
-
*
|
6541
|
-
*
|
6542
|
-
*
|
6543
|
-
* // ...
|
6544
|
-
* }
|
6677
|
+
/* upb_msg_init() / upb_msg_uninit() allow the user to use a pre-allocated
|
6678
|
+
* block of memory as a message. The block's size should be upb_msg_sizeof().
|
6679
|
+
* upb_msg_uninit() must be called to release internally-allocated memory
|
6680
|
+
* unless the allocator is an arena that does not require freeing.
|
6545
6681
|
*
|
6546
|
-
*
|
6547
|
-
*
|
6548
|
-
*
|
6549
|
-
void
|
6550
|
-
|
6551
|
-
|
6552
|
-
|
6553
|
-
|
6682
|
+
* Please note that upb_msg_uninit() does *not* free any submessages, maps,
|
6683
|
+
* or arrays referred to by this message's fields. You must free them manually
|
6684
|
+
* yourself. */
|
6685
|
+
void upb_msg_init(upb_msg *msg, const upb_msglayout *l, upb_alloc *a);
|
6686
|
+
void upb_msg_uninit(upb_msg *msg, const upb_msglayout *l);
|
6687
|
+
|
6688
|
+
/* Like upb_msg_init() / upb_msg_uninit(), except the message's memory is
|
6689
|
+
* allocated / freed from the given upb_alloc. */
|
6690
|
+
upb_msg *upb_msg_new(const upb_msglayout *l, upb_alloc *a);
|
6691
|
+
void upb_msg_free(upb_msg *msg, const upb_msglayout *l);
|
6692
|
+
|
6693
|
+
/* Returns the upb_alloc for the given message. */
|
6694
|
+
upb_alloc *upb_msg_alloc(const upb_msg *msg, const upb_msglayout *l);
|
6695
|
+
|
6696
|
+
/* Packs the tree of messages rooted at "msg" into a single hunk of memory,
|
6697
|
+
* allocated from the given allocator. */
|
6698
|
+
void *upb_msg_pack(const upb_msg *msg, const upb_msglayout *l,
|
6699
|
+
void *p, size_t *ofs, size_t size);
|
6700
|
+
|
6701
|
+
/* Read-only message API. Can be safely called by anyone. */
|
6702
|
+
|
6703
|
+
/* Returns the value associated with this field:
|
6704
|
+
* - for scalar fields (including strings), the value directly.
|
6705
|
+
* - return upb_msg*, or upb_map* for msg/map.
|
6706
|
+
* If the field is unset for these field types, returns NULL.
|
6707
|
+
*
|
6708
|
+
* TODO(haberman): should we let users store cached array/map/msg
|
6709
|
+
* pointers here for fields that are unset? Could be useful for the
|
6710
|
+
* strongly-owned submessage model (ie. generated C API that doesn't use
|
6711
|
+
* arenas).
|
6712
|
+
*/
|
6713
|
+
upb_msgval upb_msg_get(const upb_msg *msg,
|
6714
|
+
const upb_fielddef *f,
|
6715
|
+
const upb_msglayout *l);
|
6554
6716
|
|
6555
|
-
|
6717
|
+
/* May only be called for fields where upb_fielddef_haspresence(f) == true. */
|
6718
|
+
bool upb_msg_has(const upb_msg *msg,
|
6719
|
+
const upb_fielddef *f,
|
6720
|
+
const upb_msglayout *l);
|
6556
6721
|
|
6557
|
-
|
6558
|
-
|
6559
|
-
|
6560
|
-
|
6561
|
-
upb_symtab *s = upb_symtab_new(&s);
|
6562
|
-
return reffed_ptr<SymbolTable>(s, &s);
|
6563
|
-
}
|
6722
|
+
/* Returns NULL if no field in the oneof is set. */
|
6723
|
+
const upb_fielddef *upb_msg_getoneofcase(const upb_msg *msg,
|
6724
|
+
const upb_oneofdef *o,
|
6725
|
+
const upb_msglayout *l);
|
6564
6726
|
|
6565
|
-
|
6566
|
-
|
6567
|
-
|
6568
|
-
|
6569
|
-
|
6570
|
-
|
6571
|
-
|
6572
|
-
|
6573
|
-
|
6574
|
-
|
6575
|
-
|
6576
|
-
|
6577
|
-
|
6578
|
-
|
6579
|
-
|
6580
|
-
|
6581
|
-
|
6582
|
-
|
6583
|
-
|
6584
|
-
|
6585
|
-
|
6586
|
-
|
6727
|
+
/* Returns true if any field in the oneof is set. */
|
6728
|
+
bool upb_msg_hasoneof(const upb_msg *msg,
|
6729
|
+
const upb_oneofdef *o,
|
6730
|
+
const upb_msglayout *l);
|
6731
|
+
|
6732
|
+
|
6733
|
+
/* Mutable message API. May only be called by the owner of the message who
|
6734
|
+
* knows its ownership scheme and how to keep it consistent. */
|
6735
|
+
|
6736
|
+
/* Sets the given field to the given value. Does not perform any memory
|
6737
|
+
* management: if you overwrite a pointer to a msg/array/map/string without
|
6738
|
+
* cleaning it up (or using an arena) it will leak.
|
6739
|
+
*/
|
6740
|
+
bool upb_msg_set(upb_msg *msg,
|
6741
|
+
const upb_fielddef *f,
|
6742
|
+
upb_msgval val,
|
6743
|
+
const upb_msglayout *l);
|
6744
|
+
|
6745
|
+
/* For a primitive field, set it back to its default. For repeated, string, and
|
6746
|
+
* submessage fields set it back to NULL. This could involve releasing some
|
6747
|
+
* internal memory (for example, from an extension dictionary), but it is not
|
6748
|
+
* recursive in any way and will not recover any memory that may be used by
|
6749
|
+
* arrays/maps/strings/msgs that this field may have pointed to.
|
6750
|
+
*/
|
6751
|
+
bool upb_msg_clearfield(upb_msg *msg,
|
6752
|
+
const upb_fielddef *f,
|
6753
|
+
const upb_msglayout *l);
|
6754
|
+
|
6755
|
+
/* Clears all fields in the oneof such that none of them are set. */
|
6756
|
+
bool upb_msg_clearoneof(upb_msg *msg,
|
6757
|
+
const upb_oneofdef *o,
|
6758
|
+
const upb_msglayout *l);
|
6759
|
+
|
6760
|
+
/* TODO(haberman): copyfrom()/mergefrom()? */
|
6761
|
+
|
6762
|
+
|
6763
|
+
/** upb_array *****************************************************************/
|
6764
|
+
|
6765
|
+
/* A upb_array stores data for a repeated field. The memory management
|
6766
|
+
* semantics are the same as upb_msg. A upb_array allocates dynamic
|
6767
|
+
* memory internally for the array elements. */
|
6768
|
+
|
6769
|
+
size_t upb_array_sizeof(upb_fieldtype_t type);
|
6770
|
+
void upb_array_init(upb_array *arr, upb_fieldtype_t type, upb_alloc *a);
|
6771
|
+
void upb_array_uninit(upb_array *arr);
|
6772
|
+
upb_array *upb_array_new(upb_fieldtype_t type, upb_alloc *a);
|
6773
|
+
void upb_array_free(upb_array *arr);
|
6774
|
+
|
6775
|
+
/* Read-only interface. Safe for anyone to call. */
|
6776
|
+
|
6777
|
+
size_t upb_array_size(const upb_array *arr);
|
6778
|
+
upb_fieldtype_t upb_array_type(const upb_array *arr);
|
6779
|
+
upb_msgval upb_array_get(const upb_array *arr, size_t i);
|
6780
|
+
|
6781
|
+
/* Write interface. May only be called by the message's owner who can enforce
|
6782
|
+
* its memory management invariants. */
|
6783
|
+
|
6784
|
+
bool upb_array_set(upb_array *arr, size_t i, upb_msgval val);
|
6785
|
+
|
6786
|
+
|
6787
|
+
/** upb_map *******************************************************************/
|
6788
|
+
|
6789
|
+
/* A upb_map stores data for a map field. The memory management semantics are
|
6790
|
+
* the same as upb_msg, with one notable exception. upb_map will internally
|
6791
|
+
* store a copy of all string keys, but *not* any string values or submessages.
|
6792
|
+
* So you must ensure that any string or message values outlive the map, and you
|
6793
|
+
* must delete them manually when they are no longer required. */
|
6794
|
+
|
6795
|
+
size_t upb_map_sizeof(upb_fieldtype_t ktype, upb_fieldtype_t vtype);
|
6796
|
+
bool upb_map_init(upb_map *map, upb_fieldtype_t ktype, upb_fieldtype_t vtype,
|
6797
|
+
upb_alloc *a);
|
6798
|
+
void upb_map_uninit(upb_map *map);
|
6799
|
+
upb_map *upb_map_new(upb_fieldtype_t ktype, upb_fieldtype_t vtype, upb_alloc *a);
|
6800
|
+
void upb_map_free(upb_map *map);
|
6801
|
+
|
6802
|
+
/* Read-only interface. Safe for anyone to call. */
|
6803
|
+
|
6804
|
+
size_t upb_map_size(const upb_map *map);
|
6805
|
+
upb_fieldtype_t upb_map_keytype(const upb_map *map);
|
6806
|
+
upb_fieldtype_t upb_map_valuetype(const upb_map *map);
|
6807
|
+
bool upb_map_get(const upb_map *map, upb_msgval key, upb_msgval *val);
|
6808
|
+
|
6809
|
+
/* Write interface. May only be called by the message's owner who can enforce
|
6810
|
+
* its memory management invariants. */
|
6811
|
+
|
6812
|
+
/* Sets or overwrites an entry in the map. Return value indicates whether
|
6813
|
+
* the operation succeeded or failed with OOM, and also whether an existing
|
6814
|
+
* key was replaced or not. */
|
6815
|
+
bool upb_map_set(upb_map *map,
|
6816
|
+
upb_msgval key, upb_msgval val,
|
6817
|
+
upb_msgval *valremoved);
|
6818
|
+
|
6819
|
+
/* Deletes an entry in the map. Returns true if the key was present. */
|
6820
|
+
bool upb_map_del(upb_map *map, upb_msgval key);
|
6821
|
+
|
6822
|
+
|
6823
|
+
/** upb_mapiter ***************************************************************/
|
6824
|
+
|
6825
|
+
/* For iterating over a map. Map iterators are invalidated by mutations to the
|
6826
|
+
* map, but an invalidated iterator will never return junk or crash the process.
|
6827
|
+
* An invalidated iterator may return entries that were already returned though,
|
6828
|
+
* and if you keep invalidating the iterator during iteration, the program may
|
6829
|
+
* enter an infinite loop. */
|
6830
|
+
|
6831
|
+
size_t upb_mapiter_sizeof();
|
6832
|
+
|
6833
|
+
void upb_mapiter_begin(upb_mapiter *i, const upb_map *t);
|
6834
|
+
upb_mapiter *upb_mapiter_new(const upb_map *t, upb_alloc *a);
|
6835
|
+
void upb_mapiter_free(upb_mapiter *i, upb_alloc *a);
|
6836
|
+
void upb_mapiter_next(upb_mapiter *i);
|
6837
|
+
bool upb_mapiter_done(const upb_mapiter *i);
|
6838
|
+
|
6839
|
+
upb_msgval upb_mapiter_key(const upb_mapiter *i);
|
6840
|
+
upb_msgval upb_mapiter_value(const upb_mapiter *i);
|
6841
|
+
void upb_mapiter_setdone(upb_mapiter *i);
|
6842
|
+
bool upb_mapiter_isequal(const upb_mapiter *i1, const upb_mapiter *i2);
|
6843
|
+
|
6844
|
+
|
6845
|
+
/** Handlers ******************************************************************/
|
6846
|
+
|
6847
|
+
/* These are the handlers used internally by upb_msgfactory_getmergehandlers().
|
6848
|
+
* They write scalar data to a known offset from the message pointer.
|
6849
|
+
*
|
6850
|
+
* These would be trivial for anyone to implement themselves, but it's better
|
6851
|
+
* to use these because some JITs will recognize and specialize these instead
|
6852
|
+
* of actually calling the function. */
|
6853
|
+
|
6854
|
+
/* Sets a handler for the given primitive field that will write the data at the
|
6855
|
+
* given offset. If hasbit > 0, also sets a hasbit at the given bit offset
|
6856
|
+
* (addressing each byte low to high). */
|
6857
|
+
bool upb_msg_setscalarhandler(upb_handlers *h,
|
6858
|
+
const upb_fielddef *f,
|
6859
|
+
size_t offset,
|
6860
|
+
int32_t hasbit);
|
6861
|
+
|
6862
|
+
/* If the given handler is a msghandlers_primitive field, returns true and sets
|
6863
|
+
* *type, *offset and *hasbit. Otherwise returns false. */
|
6864
|
+
bool upb_msg_getscalarhandlerdata(const upb_handlers *h,
|
6865
|
+
upb_selector_t s,
|
6866
|
+
upb_fieldtype_t *type,
|
6867
|
+
size_t *offset,
|
6868
|
+
int32_t *hasbit);
|
6869
|
+
|
6870
|
+
UPB_END_EXTERN_C
|
6587
6871
|
|
6588
|
-
#endif
|
6872
|
+
#endif /* UPB_MSG_H_ */
|
6589
6873
|
/*
|
6590
6874
|
** upb::descriptor::Reader (upb_descreader)
|
6591
6875
|
**
|
@@ -6853,111 +7137,111 @@ UPB_INLINE bool upbdefs_google_protobuf_FileOptions_OptimizeMode_is(const upb_en
|
|
6853
7137
|
|
6854
7138
|
|
6855
7139
|
/* Functions to get a fielddef from a msgdef reference. */
|
6856
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_end(const upb_msgdef *m) {
|
6857
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_start(const upb_msgdef *m) {
|
6858
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_end(const upb_msgdef *m) {
|
6859
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_start(const upb_msgdef *m) {
|
6860
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_type(const upb_msgdef *m) {
|
6861
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension(const upb_msgdef *m) {
|
6862
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension_range(const upb_msgdef *m) {
|
6863
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(const upb_msgdef *m) {
|
6864
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(const upb_msgdef *m) {
|
6865
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_type(const upb_msgdef *m) {
|
6866
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_decl(const upb_msgdef *m) {
|
6867
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options(const upb_msgdef *m) {
|
6868
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_name(const upb_msgdef *m) {
|
6869
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_range(const upb_msgdef *m) {
|
6870
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_name(const upb_msgdef *m) {
|
6871
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_options(const upb_msgdef *m) {
|
6872
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_value(const upb_msgdef *m) {
|
6873
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias(const upb_msgdef *m) {
|
6874
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated(const upb_msgdef *m) {
|
6875
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpreted_option(const upb_msgdef *m) {
|
6876
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_name(const upb_msgdef *m) {
|
6877
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_number(const upb_msgdef *m) {
|
6878
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_options(const upb_msgdef *m) {
|
6879
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprecated(const upb_msgdef *m) {
|
6880
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninterpreted_option(const upb_msgdef *m) {
|
6881
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_default_value(const upb_msgdef *m) {
|
6882
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_extendee(const upb_msgdef *m) {
|
6883
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_json_name(const upb_msgdef *m) {
|
6884
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_label(const upb_msgdef *m) {
|
6885
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_name(const upb_msgdef *m) {
|
6886
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_number(const upb_msgdef *m) {
|
6887
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_oneof_index(const upb_msgdef *m) {
|
6888
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_options(const upb_msgdef *m) {
|
6889
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type(const upb_msgdef *m) {
|
6890
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type_name(const upb_msgdef *m) {
|
6891
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(const upb_msgdef *m) {
|
6892
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated(const upb_msgdef *m) {
|
6893
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(const upb_msgdef *m) {
|
6894
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const upb_msgdef *m) {
|
6895
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(const upb_msgdef *m) {
|
6896
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpreted_option(const upb_msgdef *m) {
|
6897
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const upb_msgdef *m) {
|
6898
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dependency(const upb_msgdef *m) {
|
6899
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enum_type(const upb_msgdef *m) {
|
6900
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_extension(const upb_msgdef *m) {
|
6901
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_message_type(const upb_msgdef *m) {
|
6902
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_name(const upb_msgdef *m) {
|
6903
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_options(const upb_msgdef *m) {
|
6904
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_package(const upb_msgdef *m) {
|
6905
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_public_dependency(const upb_msgdef *m) {
|
6906
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_service(const upb_msgdef *m) {
|
6907
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_source_code_info(const upb_msgdef *m) {
|
6908
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syntax(const upb_msgdef *m) {
|
6909
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_weak_dependency(const upb_msgdef *m) {
|
6910
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file(const upb_msgdef *m) {
|
6911
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_arenas(const upb_msgdef *m) {
|
6912
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_services(const upb_msgdef *m) {
|
6913
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_namespace(const upb_msgdef *m) {
|
6914
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated(const upb_msgdef *m) {
|
6915
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package(const upb_msgdef *m) {
|
6916
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generate_equals_and_hash(const upb_msgdef *m) {
|
6917
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generic_services(const upb_msgdef *m) {
|
6918
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multiple_files(const upb_msgdef *m) {
|
6919
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_classname(const upb_msgdef *m) {
|
6920
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_package(const upb_msgdef *m) {
|
6921
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string_check_utf8(const upb_msgdef *m) {
|
6922
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_use_deprecated_package(const upb_msgdef *m) {
|
6923
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) {
|
6924
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) {
|
6925
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) {
|
6926
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) {
|
6927
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) {
|
6928
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entry(const upb_msgdef *m) {
|
6929
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_set_wire_format(const upb_msgdef *m) {
|
6930
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_standard_descriptor_accessor(const upb_msgdef *m) {
|
6931
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterpreted_option(const upb_msgdef *m) {
|
6932
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_client_streaming(const upb_msgdef *m) {
|
6933
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_input_type(const upb_msgdef *m) {
|
6934
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_name(const upb_msgdef *m) {
|
6935
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_options(const upb_msgdef *m) {
|
6936
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_output_type(const upb_msgdef *m) {
|
6937
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_server_streaming(const upb_msgdef *m) {
|
6938
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecated(const upb_msgdef *m) {
|
6939
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpreted_option(const upb_msgdef *m) {
|
6940
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_name(const upb_msgdef *m) {
|
6941
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_method(const upb_msgdef *m) {
|
6942
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_name(const upb_msgdef *m) {
|
6943
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_options(const upb_msgdef *m) {
|
6944
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecated(const upb_msgdef *m) {
|
6945
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterpreted_option(const upb_msgdef *m) {
|
6946
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_comments(const upb_msgdef *m) {
|
6947
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_detached_comments(const upb_msgdef *m) {
|
6948
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_path(const upb_msgdef *m) {
|
6949
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_span(const upb_msgdef *m) {
|
6950
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_trailing_comments(const upb_msgdef *m) {
|
6951
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location(const upb_msgdef *m) {
|
6952
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_is_extension(const upb_msgdef *m) {
|
6953
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_name_part(const upb_msgdef *m) {
|
6954
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_aggregate_value(const upb_msgdef *m) {
|
6955
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_double_value(const upb_msgdef *m) {
|
6956
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_identifier_value(const upb_msgdef *m) {
|
6957
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_name(const upb_msgdef *m) {
|
6958
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_negative_int_value(const upb_msgdef *m) {
|
6959
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_positive_int_value(const upb_msgdef *m) {
|
6960
|
-
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_string_value(const upb_msgdef *m) {
|
7140
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_end(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 2); }
|
7141
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_start(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 1); }
|
7142
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_end(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 2); }
|
7143
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_start(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 1); }
|
7144
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
|
7145
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
|
7146
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension_range(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
|
7147
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
|
7148
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
|
7149
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
|
7150
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_decl(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
|
7151
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
|
7152
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
|
7153
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_range(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
|
7154
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
|
7155
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
|
7156
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
|
7157
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 2); }
|
7158
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 3); }
|
7159
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 999); }
|
7160
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
|
7161
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_number(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
|
7162
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
|
7163
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 1); }
|
7164
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 999); }
|
7165
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_default_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
|
7166
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_extendee(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
|
7167
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_json_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
|
7168
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_label(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
|
7169
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
|
7170
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_number(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
|
7171
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_oneof_index(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
|
7172
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
|
7173
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
|
7174
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
|
7175
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 1); }
|
7176
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 3); }
|
7177
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 6); }
|
7178
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 5); }
|
7179
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 2); }
|
7180
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 999); }
|
7181
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 10); }
|
7182
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
|
7183
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enum_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
|
7184
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
|
7185
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_message_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
|
7186
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
|
7187
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
|
7188
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
|
7189
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_public_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
|
7190
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_service(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
|
7191
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_source_code_info(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
|
7192
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syntax(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 12); }
|
7193
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_weak_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 11); }
|
7194
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorSet_is(m)); return upb_msgdef_itof(m, 1); }
|
7195
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_arenas(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 31); }
|
7196
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 16); }
|
7197
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_namespace(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 37); }
|
7198
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 23); }
|
7199
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 11); }
|
7200
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generate_equals_and_hash(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 20); }
|
7201
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 17); }
|
7202
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multiple_files(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 10); }
|
7203
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_classname(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 8); }
|
7204
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 1); }
|
7205
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string_check_utf8(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 27); }
|
7206
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_use_deprecated_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 38); }
|
7207
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 36); }
|
7208
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); }
|
7209
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 18); }
|
7210
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 999); }
|
7211
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 3); }
|
7212
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entry(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 7); }
|
7213
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_set_wire_format(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 1); }
|
7214
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_standard_descriptor_accessor(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 2); }
|
7215
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 999); }
|
7216
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_client_streaming(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
|
7217
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_input_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
|
7218
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
|
7219
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
|
7220
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_output_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
|
7221
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_server_streaming(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
|
7222
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 33); }
|
7223
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 999); }
|
7224
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
|
7225
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_method(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
|
7226
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
|
7227
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
|
7228
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 33); }
|
7229
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 999); }
|
7230
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 3); }
|
7231
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_detached_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 6); }
|
7232
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_path(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 1); }
|
7233
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_span(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 2); }
|
7234
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_trailing_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 4); }
|
7235
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_is(m)); return upb_msgdef_itof(m, 1); }
|
7236
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_is_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 2); }
|
7237
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_name_part(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 1); }
|
7238
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_aggregate_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 8); }
|
7239
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_double_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 6); }
|
7240
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_identifier_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 3); }
|
7241
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 2); }
|
7242
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_negative_int_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 5); }
|
7243
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_positive_int_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 4); }
|
7244
|
+
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_string_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 7); }
|
6961
7245
|
|
6962
7246
|
UPB_END_EXTERN_C
|
6963
7247
|
|
@@ -6971,7 +7255,7 @@ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
6971
7255
|
public:
|
6972
7256
|
DescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
6973
7257
|
: reffed_ptr(m, ref_donor) {
|
6974
|
-
|
7258
|
+
UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m));
|
6975
7259
|
}
|
6976
7260
|
|
6977
7261
|
static DescriptorProto get() {
|
@@ -6983,7 +7267,7 @@ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
6983
7267
|
public:
|
6984
7268
|
ExtensionRange(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
6985
7269
|
: reffed_ptr(m, ref_donor) {
|
6986
|
-
|
7270
|
+
UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m));
|
6987
7271
|
}
|
6988
7272
|
|
6989
7273
|
static ExtensionRange get() {
|
@@ -6996,7 +7280,7 @@ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
6996
7280
|
public:
|
6997
7281
|
ReservedRange(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
6998
7282
|
: reffed_ptr(m, ref_donor) {
|
6999
|
-
|
7283
|
+
UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m));
|
7000
7284
|
}
|
7001
7285
|
|
7002
7286
|
static ReservedRange get() {
|
@@ -7010,7 +7294,7 @@ class EnumDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7010
7294
|
public:
|
7011
7295
|
EnumDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7012
7296
|
: reffed_ptr(m, ref_donor) {
|
7013
|
-
|
7297
|
+
UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m));
|
7014
7298
|
}
|
7015
7299
|
|
7016
7300
|
static EnumDescriptorProto get() {
|
@@ -7023,7 +7307,7 @@ class EnumOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7023
7307
|
public:
|
7024
7308
|
EnumOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7025
7309
|
: reffed_ptr(m, ref_donor) {
|
7026
|
-
|
7310
|
+
UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m));
|
7027
7311
|
}
|
7028
7312
|
|
7029
7313
|
static EnumOptions get() {
|
@@ -7036,7 +7320,7 @@ class EnumValueDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDe
|
|
7036
7320
|
public:
|
7037
7321
|
EnumValueDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7038
7322
|
: reffed_ptr(m, ref_donor) {
|
7039
|
-
|
7323
|
+
UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m));
|
7040
7324
|
}
|
7041
7325
|
|
7042
7326
|
static EnumValueDescriptorProto get() {
|
@@ -7049,7 +7333,7 @@ class EnumValueOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7049
7333
|
public:
|
7050
7334
|
EnumValueOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7051
7335
|
: reffed_ptr(m, ref_donor) {
|
7052
|
-
|
7336
|
+
UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m));
|
7053
7337
|
}
|
7054
7338
|
|
7055
7339
|
static EnumValueOptions get() {
|
@@ -7062,7 +7346,7 @@ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7062
7346
|
public:
|
7063
7347
|
FieldDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7064
7348
|
: reffed_ptr(m, ref_donor) {
|
7065
|
-
|
7349
|
+
UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m));
|
7066
7350
|
}
|
7067
7351
|
|
7068
7352
|
static FieldDescriptorProto get() {
|
@@ -7074,7 +7358,7 @@ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7074
7358
|
public:
|
7075
7359
|
Label(const ::upb::EnumDef* e, const void *ref_donor = NULL)
|
7076
7360
|
: reffed_ptr(e, ref_donor) {
|
7077
|
-
|
7361
|
+
UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_Label_is(e));
|
7078
7362
|
}
|
7079
7363
|
static Label get() {
|
7080
7364
|
const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Label_get(&e);
|
@@ -7086,7 +7370,7 @@ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7086
7370
|
public:
|
7087
7371
|
Type(const ::upb::EnumDef* e, const void *ref_donor = NULL)
|
7088
7372
|
: reffed_ptr(e, ref_donor) {
|
7089
|
-
|
7373
|
+
UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_Type_is(e));
|
7090
7374
|
}
|
7091
7375
|
static Type get() {
|
7092
7376
|
const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Type_get(&e);
|
@@ -7099,7 +7383,7 @@ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7099
7383
|
public:
|
7100
7384
|
FieldOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7101
7385
|
: reffed_ptr(m, ref_donor) {
|
7102
|
-
|
7386
|
+
UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m));
|
7103
7387
|
}
|
7104
7388
|
|
7105
7389
|
static FieldOptions get() {
|
@@ -7111,7 +7395,7 @@ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7111
7395
|
public:
|
7112
7396
|
CType(const ::upb::EnumDef* e, const void *ref_donor = NULL)
|
7113
7397
|
: reffed_ptr(e, ref_donor) {
|
7114
|
-
|
7398
|
+
UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_CType_is(e));
|
7115
7399
|
}
|
7116
7400
|
static CType get() {
|
7117
7401
|
const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_CType_get(&e);
|
@@ -7123,7 +7407,7 @@ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7123
7407
|
public:
|
7124
7408
|
JSType(const ::upb::EnumDef* e, const void *ref_donor = NULL)
|
7125
7409
|
: reffed_ptr(e, ref_donor) {
|
7126
|
-
|
7410
|
+
UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_JSType_is(e));
|
7127
7411
|
}
|
7128
7412
|
static JSType get() {
|
7129
7413
|
const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_JSType_get(&e);
|
@@ -7136,7 +7420,7 @@ class FileDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7136
7420
|
public:
|
7137
7421
|
FileDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7138
7422
|
: reffed_ptr(m, ref_donor) {
|
7139
|
-
|
7423
|
+
UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m));
|
7140
7424
|
}
|
7141
7425
|
|
7142
7426
|
static FileDescriptorProto get() {
|
@@ -7149,7 +7433,7 @@ class FileDescriptorSet : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7149
7433
|
public:
|
7150
7434
|
FileDescriptorSet(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7151
7435
|
: reffed_ptr(m, ref_donor) {
|
7152
|
-
|
7436
|
+
UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorSet_is(m));
|
7153
7437
|
}
|
7154
7438
|
|
7155
7439
|
static FileDescriptorSet get() {
|
@@ -7162,7 +7446,7 @@ class FileOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7162
7446
|
public:
|
7163
7447
|
FileOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7164
7448
|
: reffed_ptr(m, ref_donor) {
|
7165
|
-
|
7449
|
+
UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m));
|
7166
7450
|
}
|
7167
7451
|
|
7168
7452
|
static FileOptions get() {
|
@@ -7174,7 +7458,7 @@ class FileOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7174
7458
|
public:
|
7175
7459
|
OptimizeMode(const ::upb::EnumDef* e, const void *ref_donor = NULL)
|
7176
7460
|
: reffed_ptr(e, ref_donor) {
|
7177
|
-
|
7461
|
+
UPB_ASSERT(upbdefs_google_protobuf_FileOptions_OptimizeMode_is(e));
|
7178
7462
|
}
|
7179
7463
|
static OptimizeMode get() {
|
7180
7464
|
const ::upb::EnumDef* e = upbdefs_google_protobuf_FileOptions_OptimizeMode_get(&e);
|
@@ -7187,7 +7471,7 @@ class MessageOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7187
7471
|
public:
|
7188
7472
|
MessageOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7189
7473
|
: reffed_ptr(m, ref_donor) {
|
7190
|
-
|
7474
|
+
UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m));
|
7191
7475
|
}
|
7192
7476
|
|
7193
7477
|
static MessageOptions get() {
|
@@ -7200,7 +7484,7 @@ class MethodDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef>
|
|
7200
7484
|
public:
|
7201
7485
|
MethodDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7202
7486
|
: reffed_ptr(m, ref_donor) {
|
7203
|
-
|
7487
|
+
UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m));
|
7204
7488
|
}
|
7205
7489
|
|
7206
7490
|
static MethodDescriptorProto get() {
|
@@ -7213,7 +7497,7 @@ class MethodOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7213
7497
|
public:
|
7214
7498
|
MethodOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7215
7499
|
: reffed_ptr(m, ref_donor) {
|
7216
|
-
|
7500
|
+
UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m));
|
7217
7501
|
}
|
7218
7502
|
|
7219
7503
|
static MethodOptions get() {
|
@@ -7226,7 +7510,7 @@ class OneofDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7226
7510
|
public:
|
7227
7511
|
OneofDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7228
7512
|
: reffed_ptr(m, ref_donor) {
|
7229
|
-
|
7513
|
+
UPB_ASSERT(upbdefs_google_protobuf_OneofDescriptorProto_is(m));
|
7230
7514
|
}
|
7231
7515
|
|
7232
7516
|
static OneofDescriptorProto get() {
|
@@ -7239,7 +7523,7 @@ class ServiceDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef>
|
|
7239
7523
|
public:
|
7240
7524
|
ServiceDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7241
7525
|
: reffed_ptr(m, ref_donor) {
|
7242
|
-
|
7526
|
+
UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m));
|
7243
7527
|
}
|
7244
7528
|
|
7245
7529
|
static ServiceDescriptorProto get() {
|
@@ -7252,7 +7536,7 @@ class ServiceOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7252
7536
|
public:
|
7253
7537
|
ServiceOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7254
7538
|
: reffed_ptr(m, ref_donor) {
|
7255
|
-
|
7539
|
+
UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m));
|
7256
7540
|
}
|
7257
7541
|
|
7258
7542
|
static ServiceOptions get() {
|
@@ -7265,7 +7549,7 @@ class SourceCodeInfo : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7265
7549
|
public:
|
7266
7550
|
SourceCodeInfo(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7267
7551
|
: reffed_ptr(m, ref_donor) {
|
7268
|
-
|
7552
|
+
UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_is(m));
|
7269
7553
|
}
|
7270
7554
|
|
7271
7555
|
static SourceCodeInfo get() {
|
@@ -7277,7 +7561,7 @@ class SourceCodeInfo : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7277
7561
|
public:
|
7278
7562
|
Location(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7279
7563
|
: reffed_ptr(m, ref_donor) {
|
7280
|
-
|
7564
|
+
UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m));
|
7281
7565
|
}
|
7282
7566
|
|
7283
7567
|
static Location get() {
|
@@ -7291,7 +7575,7 @@ class UninterpretedOption : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7291
7575
|
public:
|
7292
7576
|
UninterpretedOption(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7293
7577
|
: reffed_ptr(m, ref_donor) {
|
7294
|
-
|
7578
|
+
UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m));
|
7295
7579
|
}
|
7296
7580
|
|
7297
7581
|
static UninterpretedOption get() {
|
@@ -7303,7 +7587,7 @@ class UninterpretedOption : public ::upb::reffed_ptr<const ::upb::MessageDef> {
|
|
7303
7587
|
public:
|
7304
7588
|
NamePart(const ::upb::MessageDef* m, const void *ref_donor = NULL)
|
7305
7589
|
: reffed_ptr(m, ref_donor) {
|
7306
|
-
|
7590
|
+
UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m));
|
7307
7591
|
}
|
7308
7592
|
|
7309
7593
|
static NamePart get() {
|
@@ -8112,9 +8396,9 @@ UPB_INLINE uint64_t upb_vencode32(uint32_t val) {
|
|
8112
8396
|
char buf[UPB_PB_VARINT_MAX_LEN];
|
8113
8397
|
size_t bytes = upb_vencode64(val, buf);
|
8114
8398
|
uint64_t ret = 0;
|
8115
|
-
|
8399
|
+
UPB_ASSERT(bytes <= 5);
|
8116
8400
|
memcpy(&ret, buf, bytes);
|
8117
|
-
|
8401
|
+
UPB_ASSERT(ret <= 0xffffffffffU);
|
8118
8402
|
return ret;
|
8119
8403
|
}
|
8120
8404
|
|