google-protobuf 3.17.0-x86-linux → 3.18.0.rc.1-x86-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

@@ -1,26 +1,53 @@
1
1
  /* Amalgamated source file */
2
- #include <stdint.h>/*
3
- * This is where we define macros used across upb.
4
- *
5
- * All of these macros are undef'd in port_undef.inc to avoid leaking them to
6
- * users.
7
- *
8
- * The correct usage is:
9
- *
10
- * #include "upb/foobar.h"
11
- * #include "upb/baz.h"
12
- *
13
- * // MUST be last included header.
14
- * #include "upb/port_def.inc"
15
- *
16
- * // Code for this file.
17
- * // <...>
18
- *
19
- * // Can be omitted for .c files, required for .h.
20
- * #include "upb/port_undef.inc"
21
- *
22
- * This file is private and must not be included by users!
23
- */
2
+ /*
3
+ * Copyright (c) 2009-2021, Google LLC
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are met:
8
+ * * Redistributions of source code must retain the above copyright
9
+ * notice, this list of conditions and the following disclaimer.
10
+ * * Redistributions in binary form must reproduce the above copyright
11
+ * notice, this list of conditions and the following disclaimer in the
12
+ * documentation and/or other materials provided with the distribution.
13
+ * * Neither the name of Google LLC nor the
14
+ * names of its contributors may be used to endorse or promote products
15
+ * derived from this software without specific prior written permission.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ * DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
21
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ */
28
+
29
+ /*
30
+ * This is where we define macros used across upb.
31
+ *
32
+ * All of these macros are undef'd in port_undef.inc to avoid leaking them to
33
+ * users.
34
+ *
35
+ * The correct usage is:
36
+ *
37
+ * #include "upb/foobar.h"
38
+ * #include "upb/baz.h"
39
+ *
40
+ * // MUST be last included header.
41
+ * #include "upb/port_def.inc"
42
+ *
43
+ * // Code for this file.
44
+ * // <...>
45
+ *
46
+ * // Can be omitted for .c files, required for .h.
47
+ * #include "upb/port_undef.inc"
48
+ *
49
+ * This file is private and must not be included by users!
50
+ */
24
51
 
25
52
  #if !((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
26
53
  (defined(__cplusplus) && __cplusplus >= 201103L) || \
@@ -136,9 +163,40 @@
136
163
  #define UPB_LONGJMP(buf, val) longjmp(buf, val)
137
164
  #endif
138
165
 
166
+ /* UPB_PTRADD(ptr, ofs): add pointer while avoiding "NULL + 0" UB */
167
+ #define UPB_PTRADD(ptr, ofs) ((ofs) ? (ptr) + (ofs) : (ptr))
168
+
139
169
  /* Configure whether fasttable is switched on or not. *************************/
140
170
 
141
- #if defined(__x86_64__) && defined(__GNUC__)
171
+ #ifdef __has_attribute
172
+ #define UPB_HAS_ATTRIBUTE(x) __has_attribute(x)
173
+ #else
174
+ #define UPB_HAS_ATTRIBUTE(x) 0
175
+ #endif
176
+
177
+ #if UPB_HAS_ATTRIBUTE(musttail)
178
+ #define UPB_MUSTTAIL __attribute__((musttail))
179
+ #else
180
+ #define UPB_MUSTTAIL
181
+ #endif
182
+
183
+ #undef UPB_HAS_ATTRIBUTE
184
+
185
+ /* This check is not fully robust: it does not require that we have "musttail"
186
+ * support available. We need tail calls to avoid consuming arbitrary amounts
187
+ * of stack space.
188
+ *
189
+ * GCC/Clang can mostly be trusted to generate tail calls as long as
190
+ * optimization is enabled, but, debug builds will not generate tail calls
191
+ * unless "musttail" is available.
192
+ *
193
+ * We should probably either:
194
+ * 1. require that the compiler supports musttail.
195
+ * 2. add some fallback code for when musttail isn't available (ie. return
196
+ * instead of tail calling). This is safe and portable, but this comes at
197
+ * a CPU cost.
198
+ */
199
+ #if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__)
142
200
  #define UPB_FASTTABLE_SUPPORTED 1
143
201
  #else
144
202
  #define UPB_FASTTABLE_SUPPORTED 0
@@ -149,7 +207,7 @@
149
207
  * for example for testing or benchmarking. */
150
208
  #if defined(UPB_ENABLE_FASTTABLE)
151
209
  #if !UPB_FASTTABLE_SUPPORTED
152
- #error fasttable is x86-64 + Clang/GCC only
210
+ #error fasttable is x86-64/ARM64 only and requires GCC or Clang.
153
211
  #endif
154
212
  #define UPB_FASTTABLE 1
155
213
  /* Define UPB_TRY_ENABLE_FASTTABLE to use fasttable if possible.
@@ -193,55 +251,36 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
193
251
  ((void)(addr), (void)(size))
194
252
  #define UPB_UNPOISON_MEMORY_REGION(addr, size) \
195
253
  ((void)(addr), (void)(size))
196
- #endif
254
+ #endif
255
+
256
+ /** upb/decode.h ************************************************************/
197
257
  /*
198
- ** upb_decode: parsing into a upb_msg using a upb_msglayout.
199
- */
258
+ * upb_decode: parsing into a upb_msg using a upb_msglayout.
259
+ */
200
260
 
201
261
  #ifndef UPB_DECODE_H_
202
262
  #define UPB_DECODE_H_
203
263
 
264
+
265
+ /** upb/msg.h ************************************************************/
204
266
  /*
205
- ** Our memory representation for parsing tables and messages themselves.
206
- ** Functions in this file are used by generated code and possibly reflection.
207
- **
208
- ** The definitions in this file are internal to upb.
209
- **/
267
+ * Public APIs for message operations that do not require descriptors.
268
+ * These functions can be used even in build that does not want to depend on
269
+ * reflection or descriptors.
270
+ *
271
+ * Descriptor-based reflection functionality lives in reflection.h.
272
+ */
210
273
 
211
274
  #ifndef UPB_MSG_H_
212
275
  #define UPB_MSG_H_
213
276
 
214
- #include <stdint.h>
215
- #include <stdlib.h>
216
- #include <string.h>
217
-
218
- /*
219
- ** upb_table
220
- **
221
- ** This header is INTERNAL-ONLY! Its interfaces are not public or stable!
222
- ** This file defines very fast int->upb_value (inttable) and string->upb_value
223
- ** (strtable) hash tables.
224
- **
225
- ** The table uses chained scatter with Brent's variation (inspired by the Lua
226
- ** implementation of hash tables). The hash function for strings is Austin
227
- ** Appleby's "MurmurHash."
228
- **
229
- ** The inttable uses uintptr_t as its key, which guarantees it can be used to
230
- ** store pointers or integers of at least 32 bits (upb isn't really useful on
231
- ** systems where sizeof(void*) < 4).
232
- **
233
- ** The table must be homogeneous (all values of the same type). In debug
234
- ** mode, we check this on insert and lookup.
235
- */
277
+ #include <stddef.h>
236
278
 
237
- #ifndef UPB_TABLE_H_
238
- #define UPB_TABLE_H_
239
279
 
240
- #include <stdint.h>
241
- #include <string.h>
280
+ /** upb/upb.h ************************************************************/
242
281
  /*
243
- ** This file contains shared definitions that are widely used across upb.
244
- */
282
+ * This file contains shared definitions that are widely used across upb.
283
+ */
245
284
 
246
285
  #ifndef UPB_H_
247
286
  #define UPB_H_
@@ -399,7 +438,7 @@ typedef struct {
399
438
  upb_arena *upb_arena_init(void *mem, size_t n, upb_alloc *alloc);
400
439
  void upb_arena_free(upb_arena *a);
401
440
  bool upb_arena_addcleanup(upb_arena *a, void *ud, upb_cleanup_func *func);
402
- void upb_arena_fuse(upb_arena *a, upb_arena *b);
441
+ bool upb_arena_fuse(upb_arena *a, upb_arena *b);
403
442
  void *_upb_arena_slowmalloc(upb_arena *a, size_t size);
404
443
 
405
444
  UPB_INLINE upb_alloc *upb_arena_alloc(upb_arena *a) { return (upb_alloc*)a; }
@@ -578,55 +617,177 @@ UPB_INLINE int _upb_lg2ceilsize(int x) {
578
617
 
579
618
  #endif /* UPB_H_ */
580
619
 
620
+ #ifdef __cplusplus
621
+ extern "C" {
622
+ #endif
623
+
624
+ typedef void upb_msg;
625
+
626
+ /* For users these are opaque. They can be obtained from upb_msgdef_layout()
627
+ * but users cannot access any of the members. */
628
+ struct upb_msglayout;
629
+ typedef struct upb_msglayout upb_msglayout;
630
+
631
+ /* Adds unknown data (serialized protobuf data) to the given message. The data
632
+ * is copied into the message instance. */
633
+ void upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
634
+ upb_arena *arena);
635
+
636
+ /* Returns a reference to the message's unknown data. */
637
+ const char *upb_msg_getunknown(const upb_msg *msg, size_t *len);
638
+
639
+ /** upb_extreg *******************************************************************/
640
+
641
+ /* Extension registry: a dynamic data structure that stores a map of:
642
+ * (upb_msglayout, number) -> extension info
643
+ *
644
+ * upb_decode() uses upb_extreg to look up extensions while parsing binary
645
+ * format.
646
+ *
647
+ * upb_extreg is part of the mini-table (msglayout) family of objects. Like all
648
+ * mini-table objects, it is suitable for reflection-less builds that do not
649
+ * want to expose names into the binary.
650
+ *
651
+ * Unlike most mini-table types, upb_extreg requires dynamic memory allocation
652
+ * and dynamic initialization:
653
+ * * If reflection is being used, then upb_symtab will construct an appropriate
654
+ * upb_extreg automatically.
655
+ * * For a mini-table only build, the user must manually construct the
656
+ * upb_extreg and populate it with all of the extensions the user cares about.
657
+ * * A third alternative is to manually unpack relevant extensions after the
658
+ * main parse is complete, similar to how Any works. This is perhaps the
659
+ * nicest solution from the perspective of reducing dependencies, avoiding
660
+ * dynamic memory allocation, and avoiding the need to parse uninteresting
661
+ * extensions. The downsides are:
662
+ * (1) parse errors are not caught during the main parse
663
+ * (2) the CPU hit of parsing comes during access, which could cause an
664
+ * undesirable stutter in application performance.
665
+ *
666
+ * Users cannot directly get or put into this map. Users can only add the
667
+ * extensions from a generated module and pass the extension registry to the
668
+ * binary decoder.
669
+ *
670
+ * A upb_symtab provides a upb_extreg, so any users who use reflection do not
671
+ * need to populate a upb_extreg directly.
672
+ */
673
+
674
+ struct upb_extreg;
675
+ typedef struct upb_extreg upb_extreg;
676
+
677
+ /* Creates a upb_extreg in the given arena. The arena must outlive any use of
678
+ * the extreg. */
679
+ upb_extreg *upb_extreg_new(upb_arena *arena);
680
+
681
+ #ifdef __cplusplus
682
+ } /* extern "C" */
683
+ #endif
684
+
685
+ #endif /* UPB_MSG_INT_H_ */
686
+
687
+ /* Must be last. */
581
688
 
582
689
  #ifdef __cplusplus
583
690
  extern "C" {
584
691
  #endif
585
692
 
693
+ enum {
694
+ /* If set, strings will alias the input buffer instead of copying into the
695
+ * arena. */
696
+ UPB_DECODE_ALIAS = 1,
697
+ };
586
698
 
587
- /* upb_value ******************************************************************/
699
+ #define UPB_DECODE_MAXDEPTH(depth) ((depth) << 16)
588
700
 
589
- /* A tagged union (stored untagged inside the table) so that we can check that
590
- * clients calling table accessors are correctly typed without having to have
591
- * an explosion of accessors. */
592
- typedef enum {
593
- UPB_CTYPE_INT32 = 1,
594
- UPB_CTYPE_INT64 = 2,
595
- UPB_CTYPE_UINT32 = 3,
596
- UPB_CTYPE_UINT64 = 4,
597
- UPB_CTYPE_BOOL = 5,
598
- UPB_CTYPE_CSTR = 6,
599
- UPB_CTYPE_PTR = 7,
600
- UPB_CTYPE_CONSTPTR = 8,
601
- UPB_CTYPE_FPTR = 9,
602
- UPB_CTYPE_FLOAT = 10,
603
- UPB_CTYPE_DOUBLE = 11
604
- } upb_ctype_t;
701
+ bool _upb_decode(const char *buf, size_t size, upb_msg *msg,
702
+ const upb_msglayout *l, const upb_extreg *extreg, int options,
703
+ upb_arena *arena);
704
+
705
+ UPB_INLINE
706
+ bool upb_decode(const char *buf, size_t size, upb_msg *msg,
707
+ const upb_msglayout *l, upb_arena *arena) {
708
+ return _upb_decode(buf, size, msg, l, NULL, 0, arena);
709
+ }
710
+
711
+ #ifdef __cplusplus
712
+ } /* extern "C" */
713
+ #endif
714
+
715
+
716
+ #endif /* UPB_DECODE_H_ */
717
+
718
+ /** upb/decode_internal.h ************************************************************/
719
+ /*
720
+ * Internal implementation details of the decoder that are shared between
721
+ * decode.c and decode_fast.c.
722
+ */
723
+
724
+ #ifndef UPB_DECODE_INT_H_
725
+ #define UPB_DECODE_INT_H_
726
+
727
+ #include <setjmp.h>
728
+
729
+
730
+ /** upb/msg_internal.h ************************************************************//*
731
+ ** Our memory representation for parsing tables and messages themselves.
732
+ ** Functions in this file are used by generated code and possibly reflection.
733
+ **
734
+ ** The definitions in this file are internal to upb.
735
+ **/
736
+
737
+ #ifndef UPB_MSG_INT_H_
738
+ #define UPB_MSG_INT_H_
739
+
740
+ #include <stdint.h>
741
+ #include <stdlib.h>
742
+ #include <string.h>
743
+
744
+
745
+ /** upb/table_internal.h ************************************************************/
746
+ /*
747
+ * upb_table
748
+ *
749
+ * This header is INTERNAL-ONLY! Its interfaces are not public or stable!
750
+ * This file defines very fast int->upb_value (inttable) and string->upb_value
751
+ * (strtable) hash tables.
752
+ *
753
+ * The table uses chained scatter with Brent's variation (inspired by the Lua
754
+ * implementation of hash tables). The hash function for strings is Austin
755
+ * Appleby's "MurmurHash."
756
+ *
757
+ * The inttable uses uintptr_t as its key, which guarantees it can be used to
758
+ * store pointers or integers of at least 32 bits (upb isn't really useful on
759
+ * systems where sizeof(void*) < 4).
760
+ *
761
+ * The table must be homogeneous (all values of the same type). In debug
762
+ * mode, we check this on insert and lookup.
763
+ */
764
+
765
+ #ifndef UPB_TABLE_H_
766
+ #define UPB_TABLE_H_
767
+
768
+ #include <stdint.h>
769
+ #include <string.h>
770
+
771
+
772
+ #ifdef __cplusplus
773
+ extern "C" {
774
+ #endif
775
+
776
+
777
+ /* upb_value ******************************************************************/
605
778
 
606
779
  typedef struct {
607
780
  uint64_t val;
608
781
  } upb_value;
609
782
 
610
- /* Like strdup(), which isn't always available since it's not ANSI C. */
611
- char *upb_strdup(const char *s, upb_alloc *a);
612
783
  /* Variant that works with a length-delimited rather than NULL-delimited string,
613
784
  * as supported by strtable. */
614
- char *upb_strdup2(const char *s, size_t len, upb_alloc *a);
615
-
616
- UPB_INLINE char *upb_gstrdup(const char *s) {
617
- return upb_strdup(s, &upb_alloc_global);
618
- }
785
+ char *upb_strdup2(const char *s, size_t len, upb_arena *a);
619
786
 
620
787
  UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val) {
621
788
  v->val = val;
622
789
  }
623
790
 
624
- UPB_INLINE upb_value _upb_value_val(uint64_t val) {
625
- upb_value ret;
626
- _upb_value_setval(&ret, val);
627
- return ret;
628
- }
629
-
630
791
  /* For each value ctype, define the following set of functions:
631
792
  *
632
793
  * // Get/set an int32 from a upb_value.
@@ -718,6 +879,10 @@ typedef struct upb_tabval {
718
879
 
719
880
  /* upb_table ******************************************************************/
720
881
 
882
+ uint64_t Wyhash(const void *data, size_t len, uint64_t seed,
883
+ const uint64_t salt[]);
884
+ extern const uint64_t kWyhashSalt[5];
885
+
721
886
  typedef struct _upb_tabent {
722
887
  upb_tabkey key;
723
888
  upb_tabval val;
@@ -734,14 +899,7 @@ typedef struct {
734
899
  uint32_t mask; /* Mask to turn hash value -> bucket. */
735
900
  uint32_t max_count; /* Max count before we hit our load limit. */
736
901
  uint8_t size_lg2; /* Size of the hashtable part is 2^size_lg2 entries. */
737
-
738
- /* Hash table entries.
739
- * Making this const isn't entirely accurate; what we really want is for it to
740
- * have the same const-ness as the table it's inside. But there's no way to
741
- * declare that in C. So we have to make it const so that we can statically
742
- * initialize const hash tables. Then we cast away const when we have to.
743
- */
744
- const upb_tabent *entries;
902
+ upb_tabent *entries;
745
903
  } upb_table;
746
904
 
747
905
  typedef struct {
@@ -755,8 +913,6 @@ typedef struct {
755
913
  size_t array_count; /* Array part number of elements. */
756
914
  } upb_inttable;
757
915
 
758
- #define UPB_ARRAY_EMPTYENT -1
759
-
760
916
  UPB_INLINE size_t upb_table_size(const upb_table *t) {
761
917
  if (t->size_lg2 == 0)
762
918
  return 0;
@@ -769,48 +925,10 @@ UPB_INLINE bool upb_tabent_isempty(const upb_tabent *e) {
769
925
  return e->key == 0;
770
926
  }
771
927
 
772
- /* Used by some of the unit tests for generic hashing functionality. */
773
- uint32_t upb_murmur_hash2(const void * key, size_t len, uint32_t seed);
774
-
775
- UPB_INLINE uintptr_t upb_intkey(uintptr_t key) {
776
- return key;
777
- }
778
-
779
- UPB_INLINE uint32_t upb_inthash(uintptr_t key) {
780
- return (uint32_t)key;
781
- }
782
-
783
- static const upb_tabent *upb_getentry(const upb_table *t, uint32_t hash) {
784
- return t->entries + (hash & t->mask);
785
- }
786
-
787
- UPB_INLINE bool upb_arrhas(upb_tabval key) {
788
- return key.val != (uint64_t)-1;
789
- }
790
-
791
928
  /* Initialize and uninitialize a table, respectively. If memory allocation
792
929
  * failed, false is returned that the table is uninitialized. */
793
- bool upb_inttable_init2(upb_inttable *table, upb_ctype_t ctype, upb_alloc *a);
794
- bool upb_strtable_init2(upb_strtable *table, upb_ctype_t ctype,
795
- size_t expected_size, upb_alloc *a);
796
- void upb_inttable_uninit2(upb_inttable *table, upb_alloc *a);
797
- void upb_strtable_uninit2(upb_strtable *table, upb_alloc *a);
798
-
799
- UPB_INLINE bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype) {
800
- return upb_inttable_init2(table, ctype, &upb_alloc_global);
801
- }
802
-
803
- UPB_INLINE bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype) {
804
- return upb_strtable_init2(table, ctype, 4, &upb_alloc_global);
805
- }
806
-
807
- UPB_INLINE void upb_inttable_uninit(upb_inttable *table) {
808
- upb_inttable_uninit2(table, &upb_alloc_global);
809
- }
810
-
811
- UPB_INLINE void upb_strtable_uninit(upb_strtable *table) {
812
- upb_strtable_uninit2(table, &upb_alloc_global);
813
- }
930
+ bool upb_inttable_init(upb_inttable *table, upb_arena *a);
931
+ bool upb_strtable_init(upb_strtable *table, size_t expected_size, upb_arena *a);
814
932
 
815
933
  /* Returns the number of values in the table. */
816
934
  size_t upb_inttable_count(const upb_inttable *t);
@@ -818,12 +936,6 @@ UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) {
818
936
  return t->t.count;
819
937
  }
820
938
 
821
- void upb_inttable_packedsize(const upb_inttable *t, size_t *size);
822
- void upb_strtable_packedsize(const upb_strtable *t, size_t *size);
823
- upb_inttable *upb_inttable_pack(const upb_inttable *t, void *p, size_t *ofs,
824
- size_t size);
825
- upb_strtable *upb_strtable_pack(const upb_strtable *t, void *p, size_t *ofs,
826
- size_t size);
827
939
  void upb_strtable_clear(upb_strtable *t);
828
940
 
829
941
  /* Inserts the given key into the hashtable with the given value. The key must
@@ -833,26 +945,10 @@ void upb_strtable_clear(upb_strtable *t);
833
945
  *
834
946
  * If a table resize was required but memory allocation failed, false is
835
947
  * returned and the table is unchanged. */
836
- bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val,
837
- upb_alloc *a);
838
- bool upb_strtable_insert3(upb_strtable *t, const char *key, size_t len,
839
- upb_value val, upb_alloc *a);
840
-
841
- UPB_INLINE bool upb_inttable_insert(upb_inttable *t, uintptr_t key,
842
- upb_value val) {
843
- return upb_inttable_insert2(t, key, val, &upb_alloc_global);
844
- }
845
-
846
- UPB_INLINE bool upb_strtable_insert2(upb_strtable *t, const char *key,
847
- size_t len, upb_value val) {
848
- return upb_strtable_insert3(t, key, len, val, &upb_alloc_global);
849
- }
850
-
851
- /* For NULL-terminated strings. */
852
- UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key,
853
- upb_value val) {
854
- return upb_strtable_insert2(t, key, strlen(key), val);
855
- }
948
+ bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val,
949
+ upb_arena *a);
950
+ bool upb_strtable_insert(upb_strtable *t, const char *key, size_t len,
951
+ upb_value val, upb_arena *a);
856
952
 
857
953
  /* Looks up key in this table, returning "true" if the key was found.
858
954
  * If v is non-NULL, copies the value for this key into *v. */
@@ -869,74 +965,21 @@ UPB_INLINE bool upb_strtable_lookup(const upb_strtable *t, const char *key,
869
965
  /* Removes an item from the table. Returns true if the remove was successful,
870
966
  * and stores the removed item in *val if non-NULL. */
871
967
  bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val);
872
- bool upb_strtable_remove3(upb_strtable *t, const char *key, size_t len,
873
- upb_value *val, upb_alloc *alloc);
874
-
875
- UPB_INLINE bool upb_strtable_remove2(upb_strtable *t, const char *key,
876
- size_t len, upb_value *val) {
877
- return upb_strtable_remove3(t, key, len, val, &upb_alloc_global);
878
- }
879
-
880
- /* For NULL-terminated strings. */
881
- UPB_INLINE bool upb_strtable_remove(upb_strtable *t, const char *key,
882
- upb_value *v) {
883
- return upb_strtable_remove2(t, key, strlen(key), v);
884
- }
968
+ bool upb_strtable_remove(upb_strtable *t, const char *key, size_t len,
969
+ upb_value *val);
885
970
 
886
971
  /* Updates an existing entry in an inttable. If the entry does not exist,
887
972
  * returns false and does nothing. Unlike insert/remove, this does not
888
973
  * invalidate iterators. */
889
974
  bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val);
890
975
 
891
- /* Convenience routines for inttables with pointer keys. */
892
- bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val,
893
- upb_alloc *a);
894
- bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val);
895
- bool upb_inttable_lookupptr(
896
- const upb_inttable *t, const void *key, upb_value *val);
897
-
898
- UPB_INLINE bool upb_inttable_insertptr(upb_inttable *t, const void *key,
899
- upb_value val) {
900
- return upb_inttable_insertptr2(t, key, val, &upb_alloc_global);
901
- }
902
-
903
976
  /* Optimizes the table for the current set of entries, for both memory use and
904
977
  * lookup time. Client should call this after all entries have been inserted;
905
978
  * inserting more entries is legal, but will likely require a table resize. */
906
- void upb_inttable_compact2(upb_inttable *t, upb_alloc *a);
907
-
908
- UPB_INLINE void upb_inttable_compact(upb_inttable *t) {
909
- upb_inttable_compact2(t, &upb_alloc_global);
910
- }
911
-
912
- /* A special-case inlinable version of the lookup routine for 32-bit
913
- * integers. */
914
- UPB_INLINE bool upb_inttable_lookup32(const upb_inttable *t, uint32_t key,
915
- upb_value *v) {
916
- *v = upb_value_int32(0); /* Silence compiler warnings. */
917
- if (key < t->array_size) {
918
- upb_tabval arrval = t->array[key];
919
- if (upb_arrhas(arrval)) {
920
- _upb_value_setval(v, arrval.val);
921
- return true;
922
- } else {
923
- return false;
924
- }
925
- } else {
926
- const upb_tabent *e;
927
- if (t->t.entries == NULL) return false;
928
- for (e = upb_getentry(&t->t, upb_inthash(key)); true; e = e->next) {
929
- if ((uint32_t)e->key == key) {
930
- _upb_value_setval(v, e->val.val);
931
- return true;
932
- }
933
- if (e->next == NULL) return false;
934
- }
935
- }
936
- }
979
+ void upb_inttable_compact(upb_inttable *t, upb_arena *a);
937
980
 
938
981
  /* Exposed for testing only. */
939
- bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_alloc *a);
982
+ bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_arena *a);
940
983
 
941
984
  /* Iterators ******************************************************************/
942
985
 
@@ -1032,10 +1075,6 @@ bool upb_inttable_iter_isequal(const upb_inttable_iter *i1,
1032
1075
  extern "C" {
1033
1076
  #endif
1034
1077
 
1035
- #define PTR_AT(msg, ofs, type) (type*)((const char*)msg + ofs)
1036
-
1037
- typedef void upb_msg;
1038
-
1039
1078
  /** upb_msglayout *************************************************************/
1040
1079
 
1041
1080
  /* upb_msglayout represents the memory layout of a given upb_msgdef. The
@@ -1055,9 +1094,34 @@ typedef struct {
1055
1094
  int16_t presence; /* If >0, hasbit_index. If <0, ~oneof_index. */
1056
1095
  uint16_t submsg_index; /* undefined if descriptortype != MESSAGE or GROUP. */
1057
1096
  uint8_t descriptortype;
1058
- uint8_t label; /* google.protobuf.Label or _UPB_LABEL_* above. */
1097
+ int8_t mode; /* upb_fieldmode, with flags from upb_labelflags */
1059
1098
  } upb_msglayout_field;
1060
1099
 
1100
+ typedef enum {
1101
+ _UPB_MODE_MAP = 0,
1102
+ _UPB_MODE_ARRAY = 1,
1103
+ _UPB_MODE_SCALAR = 2,
1104
+ } upb_fieldmode;
1105
+
1106
+ /* Extra flags on the mode field. */
1107
+ enum upb_labelflags {
1108
+ _UPB_MODE_IS_PACKED = 4,
1109
+ };
1110
+
1111
+ UPB_INLINE upb_fieldmode _upb_getmode(const upb_msglayout_field *field) {
1112
+ return (upb_fieldmode)(field->mode & 3);
1113
+ }
1114
+
1115
+ UPB_INLINE bool _upb_repeated_or_map(const upb_msglayout_field *field) {
1116
+ /* This works because upb_fieldmode has no value 3. */
1117
+ return !(field->mode & _UPB_MODE_SCALAR);
1118
+ }
1119
+
1120
+ UPB_INLINE bool _upb_issubmsg(const upb_msglayout_field *field) {
1121
+ return field->descriptortype == UPB_DTYPE_MESSAGE ||
1122
+ field->descriptortype == UPB_DTYPE_GROUP;
1123
+ }
1124
+
1061
1125
  struct upb_decstate;
1062
1126
  struct upb_msglayout;
1063
1127
 
@@ -1070,7 +1134,7 @@ typedef struct {
1070
1134
  _upb_field_parser *field_parser;
1071
1135
  } _upb_fasttable_entry;
1072
1136
 
1073
- typedef struct upb_msglayout {
1137
+ struct upb_msglayout {
1074
1138
  const struct upb_msglayout *const* submsgs;
1075
1139
  const upb_msglayout_field *fields;
1076
1140
  /* Must be aligned to sizeof(void*). Doesn't include internal members like
@@ -1078,27 +1142,65 @@ typedef struct upb_msglayout {
1078
1142
  uint16_t size;
1079
1143
  uint16_t field_count;
1080
1144
  bool extendable;
1145
+ uint8_t dense_below;
1081
1146
  uint8_t table_mask;
1082
1147
  /* To constant-initialize the tables of variable length, we need a flexible
1083
1148
  * array member, and we need to compile in C99 mode. */
1084
1149
  _upb_fasttable_entry fasttable[];
1085
- } upb_msglayout;
1150
+ };
1151
+
1152
+ typedef struct {
1153
+ upb_msglayout_field field;
1154
+ const upb_msglayout *extendee;
1155
+ const upb_msglayout *submsg; /* NULL for non-submessage fields. */
1156
+ } upb_msglayout_ext;
1157
+
1158
+ /** upb_extreg ****************************************************************/
1159
+
1160
+ /* Adds the given extension info for message type |l| and field number |num|
1161
+ * into the registry. Returns false if this message type and field number were
1162
+ * already in the map, or if memory allocation fails. */
1163
+ bool _upb_extreg_add(upb_extreg *r, const upb_msglayout_ext *e, size_t count);
1164
+
1165
+ /* Looks up the extension (if any) defined for message type |l| and field
1166
+ * number |num|. If an extension was found, copies the field info into |*ext|
1167
+ * and returns true. Otherwise returns false. */
1168
+ const upb_msglayout_field *_upb_extreg_get(const upb_extreg *r,
1169
+ const upb_msglayout *l,
1170
+ uint32_t num);
1086
1171
 
1087
1172
  /** upb_msg *******************************************************************/
1088
1173
 
1089
- /* Internal members of a upb_msg. We can change this without breaking binary
1090
- * compatibility. We put these before the user's data. The user's upb_msg*
1091
- * points after the upb_msg_internal. */
1174
+ /* Internal members of a upb_msg that track unknown fields and/or extensions.
1175
+ * We can change this without breaking binary compatibility. We put these
1176
+ * before the user's data. The user's upb_msg* points after the
1177
+ * upb_msg_internal. */
1092
1178
 
1093
1179
  typedef struct {
1094
- uint32_t len;
1180
+ /* Total size of this structure, including the data that follows.
1181
+ * Must be aligned to 8, which is alignof(upb_msg_ext) */
1095
1182
  uint32_t size;
1096
- /* Data follows. */
1097
- } upb_msg_unknowndata;
1098
1183
 
1099
- /* Used when a message is not extendable. */
1184
+ /* Offsets relative to the beginning of this structure.
1185
+ *
1186
+ * Unknown data grows forward from the beginning to unknown_end.
1187
+ * Extension data grows backward from size to ext_begin.
1188
+ * When the two meet, we're out of data and have to realloc.
1189
+ *
1190
+ * If we imagine that the final member of this struct is:
1191
+ * char data[size - overhead]; // overhead = sizeof(upb_msg_internaldata)
1192
+ *
1193
+ * Then we have:
1194
+ * unknown data: data[0 .. (unknown_end - overhead)]
1195
+ * extensions data: data[(ext_begin - overhead) .. (size - overhead)] */
1196
+ uint32_t unknown_end;
1197
+ uint32_t ext_begin;
1198
+ /* Data follows, as if there were an array:
1199
+ * char data[size - sizeof(upb_msg_internaldata)]; */
1200
+ } upb_msg_internaldata;
1201
+
1100
1202
  typedef struct {
1101
- upb_msg_unknowndata *unknown;
1203
+ upb_msg_internaldata *internal;
1102
1204
  } upb_msg_internal;
1103
1205
 
1104
1206
  /* Maps upb_fieldtype_t -> memory size. */
@@ -1137,21 +1239,47 @@ void _upb_msg_discardunknown_shallow(upb_msg *msg);
1137
1239
  bool _upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
1138
1240
  upb_arena *arena);
1139
1241
 
1140
- /* Returns a reference to the message's unknown data. */
1141
- const char *upb_msg_getunknown(const upb_msg *msg, size_t *len);
1242
+ /** upb_msg_ext ***************************************************************/
1243
+
1244
+ /* The internal representation of an extension is self-describing: it contains
1245
+ * enough information that we can serialize it to binary format without needing
1246
+ * to look it up in a registry. */
1247
+ typedef struct {
1248
+ const upb_msglayout_ext *ext;
1249
+ union {
1250
+ upb_strview str;
1251
+ void *ptr;
1252
+ double dbl;
1253
+ char scalar_data[8];
1254
+ } data;
1255
+ } upb_msg_ext;
1256
+
1257
+ /* Adds the given extension data to the given message. The returned extension will
1258
+ * have its "ext" member initialized according to |ext|. */
1259
+ upb_msg_ext *_upb_msg_getorcreateext(upb_msg *msg, const upb_msglayout_ext *ext,
1260
+ upb_arena *arena);
1261
+
1262
+ /* Returns an array of extensions for this message. Note: the array is
1263
+ * ordered in reverse relative to the order of creation. */
1264
+ const upb_msg_ext *_upb_msg_getexts(const upb_msg *msg, size_t *count);
1265
+
1266
+ /* Returns an extension for the given field number, or NULL if no extension
1267
+ * exists for this field number. */
1268
+ const upb_msg_ext *_upb_msg_getext(const upb_msg *msg,
1269
+ const upb_msglayout_ext *ext);
1142
1270
 
1143
1271
  /** Hasbit access *************************************************************/
1144
1272
 
1145
1273
  UPB_INLINE bool _upb_hasbit(const upb_msg *msg, size_t idx) {
1146
- return (*PTR_AT(msg, idx / 8, const char) & (1 << (idx % 8))) != 0;
1274
+ return (*UPB_PTR_AT(msg, idx / 8, const char) & (1 << (idx % 8))) != 0;
1147
1275
  }
1148
1276
 
1149
1277
  UPB_INLINE void _upb_sethas(const upb_msg *msg, size_t idx) {
1150
- (*PTR_AT(msg, idx / 8, char)) |= (char)(1 << (idx % 8));
1278
+ (*UPB_PTR_AT(msg, idx / 8, char)) |= (char)(1 << (idx % 8));
1151
1279
  }
1152
1280
 
1153
1281
  UPB_INLINE void _upb_clearhas(const upb_msg *msg, size_t idx) {
1154
- (*PTR_AT(msg, idx / 8, char)) &= (char)(~(1 << (idx % 8)));
1282
+ (*UPB_PTR_AT(msg, idx / 8, char)) &= (char)(~(1 << (idx % 8)));
1155
1283
  }
1156
1284
 
1157
1285
  UPB_INLINE size_t _upb_msg_hasidx(const upb_msglayout_field *f) {
@@ -1177,11 +1305,11 @@ UPB_INLINE void _upb_clearhas_field(const upb_msg *msg,
1177
1305
  /** Oneof case access *********************************************************/
1178
1306
 
1179
1307
  UPB_INLINE uint32_t *_upb_oneofcase(upb_msg *msg, size_t case_ofs) {
1180
- return PTR_AT(msg, case_ofs, uint32_t);
1308
+ return UPB_PTR_AT(msg, case_ofs, uint32_t);
1181
1309
  }
1182
1310
 
1183
1311
  UPB_INLINE uint32_t _upb_getoneofcase(const void *msg, size_t case_ofs) {
1184
- return *PTR_AT(msg, case_ofs, uint32_t);
1312
+ return *UPB_PTR_AT(msg, case_ofs, uint32_t);
1185
1313
  }
1186
1314
 
1187
1315
  UPB_INLINE size_t _upb_oneofcase_ofs(const upb_msglayout_field *f) {
@@ -1200,15 +1328,7 @@ UPB_INLINE uint32_t _upb_getoneofcase_field(const upb_msg *msg,
1200
1328
  }
1201
1329
 
1202
1330
  UPB_INLINE bool _upb_has_submsg_nohasbit(const upb_msg *msg, size_t ofs) {
1203
- return *PTR_AT(msg, ofs, const upb_msg*) != NULL;
1204
- }
1205
-
1206
- UPB_INLINE bool _upb_isrepeated(const upb_msglayout_field *field) {
1207
- return (field->label & 3) == UPB_LABEL_REPEATED;
1208
- }
1209
-
1210
- UPB_INLINE bool _upb_repeated_or_map(const upb_msglayout_field *field) {
1211
- return field->label >= UPB_LABEL_REPEATED;
1331
+ return *UPB_PTR_AT(msg, ofs, const upb_msg*) != NULL;
1212
1332
  }
1213
1333
 
1214
1334
  /** upb_array *****************************************************************/
@@ -1277,7 +1397,7 @@ UPB_INLINE bool _upb_array_resize(upb_array *arr, size_t size,
1277
1397
 
1278
1398
  UPB_INLINE const void *_upb_array_accessor(const void *msg, size_t ofs,
1279
1399
  size_t *size) {
1280
- const upb_array *arr = *PTR_AT(msg, ofs, const upb_array*);
1400
+ const upb_array *arr = *UPB_PTR_AT(msg, ofs, const upb_array*);
1281
1401
  if (arr) {
1282
1402
  if (size) *size = arr->len;
1283
1403
  return _upb_array_constptr(arr);
@@ -1289,7 +1409,7 @@ UPB_INLINE const void *_upb_array_accessor(const void *msg, size_t ofs,
1289
1409
 
1290
1410
  UPB_INLINE void *_upb_array_mutable_accessor(void *msg, size_t ofs,
1291
1411
  size_t *size) {
1292
- upb_array *arr = *PTR_AT(msg, ofs, upb_array*);
1412
+ upb_array *arr = *UPB_PTR_AT(msg, ofs, upb_array*);
1293
1413
  if (arr) {
1294
1414
  if (size) *size = arr->len;
1295
1415
  return _upb_array_ptr(arr);
@@ -1302,7 +1422,7 @@ UPB_INLINE void *_upb_array_mutable_accessor(void *msg, size_t ofs,
1302
1422
  UPB_INLINE void *_upb_array_resize_accessor2(void *msg, size_t ofs, size_t size,
1303
1423
  int elem_size_lg2,
1304
1424
  upb_arena *arena) {
1305
- upb_array **arr_ptr = PTR_AT(msg, ofs, upb_array *);
1425
+ upb_array **arr_ptr = UPB_PTR_AT(msg, ofs, upb_array *);
1306
1426
  upb_array *arr = *arr_ptr;
1307
1427
  if (!arr || arr->size < size) {
1308
1428
  return _upb_array_resize_fallback(arr_ptr, size, elem_size_lg2, arena);
@@ -1315,7 +1435,7 @@ UPB_INLINE bool _upb_array_append_accessor2(void *msg, size_t ofs,
1315
1435
  int elem_size_lg2,
1316
1436
  const void *value,
1317
1437
  upb_arena *arena) {
1318
- upb_array **arr_ptr = PTR_AT(msg, ofs, upb_array *);
1438
+ upb_array **arr_ptr = UPB_PTR_AT(msg, ofs, upb_array *);
1319
1439
  size_t elem_size = 1 << elem_size_lg2;
1320
1440
  upb_array *arr = *arr_ptr;
1321
1441
  void *ptr;
@@ -1323,7 +1443,7 @@ UPB_INLINE bool _upb_array_append_accessor2(void *msg, size_t ofs,
1323
1443
  return _upb_array_append_fallback(arr_ptr, value, elem_size_lg2, arena);
1324
1444
  }
1325
1445
  ptr = _upb_array_ptr(arr);
1326
- memcpy(PTR_AT(ptr, arr->len * elem_size, char), value, elem_size);
1446
+ memcpy(UPB_PTR_AT(ptr, arr->len * elem_size, char), value, elem_size);
1327
1447
  arr->len++;
1328
1448
  return true;
1329
1449
  }
@@ -1470,20 +1590,19 @@ UPB_INLINE void* _upb_map_next(const upb_map *map, size_t *iter) {
1470
1590
  }
1471
1591
 
1472
1592
  UPB_INLINE bool _upb_map_set(upb_map *map, const void *key, size_t key_size,
1473
- void *val, size_t val_size, upb_arena *arena) {
1593
+ void *val, size_t val_size, upb_arena *a) {
1474
1594
  upb_strview strkey = _upb_map_tokey(key, key_size);
1475
1595
  upb_value tabval = {0};
1476
- if (!_upb_map_tovalue(val, val_size, &tabval, arena)) return false;
1477
- upb_alloc *a = upb_arena_alloc(arena);
1596
+ if (!_upb_map_tovalue(val, val_size, &tabval, a)) return false;
1478
1597
 
1479
1598
  /* TODO(haberman): add overwrite operation to minimize number of lookups. */
1480
- upb_strtable_remove3(&map->table, strkey.data, strkey.size, NULL, a);
1481
- return upb_strtable_insert3(&map->table, strkey.data, strkey.size, tabval, a);
1599
+ upb_strtable_remove(&map->table, strkey.data, strkey.size, NULL);
1600
+ return upb_strtable_insert(&map->table, strkey.data, strkey.size, tabval, a);
1482
1601
  }
1483
1602
 
1484
1603
  UPB_INLINE bool _upb_map_delete(upb_map *map, const void *key, size_t key_size) {
1485
1604
  upb_strview k = _upb_map_tokey(key, key_size);
1486
- return upb_strtable_remove3(&map->table, k.data, k.size, NULL, NULL);
1605
+ return upb_strtable_remove(&map->table, k.data, k.size, NULL);
1487
1606
  }
1488
1607
 
1489
1608
  UPB_INLINE void _upb_map_clear(upb_map *map) {
@@ -1515,7 +1634,7 @@ UPB_INLINE void *_upb_msg_map_next(const upb_msg *msg, size_t ofs,
1515
1634
  UPB_INLINE bool _upb_msg_map_set(upb_msg *msg, size_t ofs, const void *key,
1516
1635
  size_t key_size, void *val, size_t val_size,
1517
1636
  upb_arena *arena) {
1518
- upb_map **map = PTR_AT(msg, ofs, upb_map *);
1637
+ upb_map **map = UPB_PTR_AT(msg, ofs, upb_map *);
1519
1638
  if (!*map) {
1520
1639
  *map = _upb_map_new(arena, key_size, val_size);
1521
1640
  }
@@ -1548,8 +1667,7 @@ UPB_INLINE void _upb_msg_map_key(const void* msg, void* key, size_t size) {
1548
1667
 
1549
1668
  UPB_INLINE void _upb_msg_map_value(const void* msg, void* val, size_t size) {
1550
1669
  const upb_tabent *ent = (const upb_tabent*)msg;
1551
- upb_value v;
1552
- _upb_value_setval(&v, ent->val.val);
1670
+ upb_value v = {ent->val.val};
1553
1671
  _upb_map_fromvalue(v, val, size);
1554
1672
  }
1555
1673
 
@@ -1612,55 +1730,14 @@ UPB_INLINE bool _upb_sortedmap_next(_upb_mapsorter *s, const upb_map *map,
1612
1730
  return true;
1613
1731
  }
1614
1732
 
1615
- #undef PTR_AT
1616
-
1617
- #ifdef __cplusplus
1618
- } /* extern "C" */
1619
- #endif
1620
-
1621
-
1622
- #endif /* UPB_MSG_H_ */
1623
-
1624
- /* Must be last. */
1625
-
1626
- #ifdef __cplusplus
1627
- extern "C" {
1628
- #endif
1629
-
1630
- enum {
1631
- /* If set, strings will alias the input buffer instead of copying into the
1632
- * arena. */
1633
- UPB_DECODE_ALIAS = 1,
1634
- };
1635
-
1636
- #define UPB_DECODE_MAXDEPTH(depth) ((depth) << 16)
1637
-
1638
- bool _upb_decode(const char *buf, size_t size, upb_msg *msg,
1639
- const upb_msglayout *l, upb_arena *arena, int options);
1640
-
1641
- UPB_INLINE
1642
- bool upb_decode(const char *buf, size_t size, upb_msg *msg,
1643
- const upb_msglayout *l, upb_arena *arena) {
1644
- return _upb_decode(buf, size, msg, l, arena, 0);
1645
- }
1646
-
1647
1733
  #ifdef __cplusplus
1648
1734
  } /* extern "C" */
1649
1735
  #endif
1650
1736
 
1651
1737
 
1652
- #endif /* UPB_DECODE_H_ */
1653
- /*
1654
- ** Internal implementation details of the decoder that are shared between
1655
- ** decode.c and decode_fast.c.
1656
- */
1657
-
1658
- #ifndef UPB_DECODE_INT_H_
1659
- #define UPB_DECODE_INT_H_
1660
-
1661
- #include <setjmp.h>
1662
-
1738
+ #endif /* UPB_MSG_INT_H_ */
1663
1739
 
1740
+ /** upb/upb_internal.h ************************************************************/
1664
1741
  #ifndef UPB_INT_H_
1665
1742
  #define UPB_INT_H_
1666
1743
 
@@ -1670,7 +1747,10 @@ typedef struct mem_block mem_block;
1670
1747
 
1671
1748
  struct upb_arena {
1672
1749
  _upb_arena_head head;
1673
- uint32_t *cleanups;
1750
+ /* Stores cleanup metadata for this arena.
1751
+ * - a pointer to the current cleanup counter.
1752
+ * - a boolean indicating if there is an unowned initial block. */
1753
+ uintptr_t cleanup_metadata;
1674
1754
 
1675
1755
  /* Allocator to allocate arena blocks. We are responsible for freeing these
1676
1756
  * when we are destroyed. */
@@ -1792,10 +1872,11 @@ bool decode_isdone(upb_decstate *d, const char **ptr) {
1792
1872
  }
1793
1873
  }
1794
1874
 
1875
+ #if UPB_FASTTABLE
1795
1876
  UPB_INLINE
1796
1877
  const char *fastdecode_tagdispatch(upb_decstate *d, const char *ptr,
1797
1878
  upb_msg *msg, intptr_t table,
1798
- uint64_t hasbits, uint32_t tag) {
1879
+ uint64_t hasbits, uint64_t tag) {
1799
1880
  const upb_msglayout *table_p = decode_totablep(table);
1800
1881
  uint8_t mask = table;
1801
1882
  uint64_t data;
@@ -1803,8 +1884,10 @@ const char *fastdecode_tagdispatch(upb_decstate *d, const char *ptr,
1803
1884
  UPB_ASSUME((idx & 7) == 0);
1804
1885
  idx >>= 3;
1805
1886
  data = table_p->fasttable[idx].field_data ^ tag;
1806
- return table_p->fasttable[idx].field_parser(d, ptr, msg, table, hasbits, data);
1887
+ UPB_MUSTTAIL return table_p->fasttable[idx].field_parser(d, ptr, msg, table,
1888
+ hasbits, data);
1807
1889
  }
1890
+ #endif
1808
1891
 
1809
1892
  UPB_INLINE uint32_t fastdecode_loadtag(const char* ptr) {
1810
1893
  uint16_t tag;
@@ -1837,9 +1920,11 @@ UPB_INLINE void decode_poplimit(upb_decstate *d, const char *ptr,
1837
1920
 
1838
1921
 
1839
1922
  #endif /* UPB_DECODE_INT_H_ */
1923
+
1924
+ /** upb/encode.h ************************************************************/
1840
1925
  /*
1841
- ** upb_encode: parsing into a upb_msg using a upb_msglayout.
1842
- */
1926
+ * upb_encode: parsing into a upb_msg using a upb_msglayout.
1927
+ */
1843
1928
 
1844
1929
  #ifndef UPB_ENCODE_H_
1845
1930
  #define UPB_ENCODE_H_
@@ -1880,6 +1965,8 @@ UPB_INLINE char *upb_encode(const void *msg, const upb_msglayout *l,
1880
1965
  #endif
1881
1966
 
1882
1967
  #endif /* UPB_ENCODE_H_ */
1968
+
1969
+ /** upb/decode_fast.h ************************************************************/
1883
1970
  // These are the specialized field parser functions for the fast parser.
1884
1971
  // Generated tables will refer to these by name.
1885
1972
  //
@@ -2005,7 +2092,8 @@ TAGBYTES(r)
2005
2092
  #undef UPB_PARSE_PARAMS
2006
2093
 
2007
2094
  #endif /* UPB_DECODE_FAST_H_ */
2008
- /* This file was generated by upbc (the upb compiler) from the input
2095
+
2096
+ /** google/protobuf/descriptor.upb.h ************************************************************//* This file was generated by upbc (the upb compiler) from the input
2009
2097
  * file:
2010
2098
  *
2011
2099
  * google/protobuf/descriptor.proto
@@ -2164,13 +2252,19 @@ UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_
2164
2252
  UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_parse(const char *buf, size_t size,
2165
2253
  upb_arena *arena) {
2166
2254
  google_protobuf_FileDescriptorSet *ret = google_protobuf_FileDescriptorSet_new(arena);
2167
- return (ret && upb_decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, arena)) ? ret : NULL;
2255
+ if (!ret) return NULL;
2256
+ if (!upb_decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, arena)) return NULL;
2257
+ return ret;
2168
2258
  }
2169
2259
  UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_parse_ex(const char *buf, size_t size,
2170
- upb_arena *arena, int options) {
2260
+ const upb_extreg *extreg, int options,
2261
+ upb_arena *arena) {
2171
2262
  google_protobuf_FileDescriptorSet *ret = google_protobuf_FileDescriptorSet_new(arena);
2172
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, arena, options))
2173
- ? ret : NULL;
2263
+ if (!ret) return NULL;
2264
+ if (!_upb_decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, extreg, options, arena)) {
2265
+ return NULL;
2266
+ }
2267
+ return ret;
2174
2268
  }
2175
2269
  UPB_INLINE char *google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet *msg, upb_arena *arena, size_t *len) {
2176
2270
  return upb_encode(msg, &google_protobuf_FileDescriptorSet_msginit, arena, len);
@@ -2201,13 +2295,19 @@ UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorPr
2201
2295
  UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_parse(const char *buf, size_t size,
2202
2296
  upb_arena *arena) {
2203
2297
  google_protobuf_FileDescriptorProto *ret = google_protobuf_FileDescriptorProto_new(arena);
2204
- return (ret && upb_decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, arena)) ? ret : NULL;
2298
+ if (!ret) return NULL;
2299
+ if (!upb_decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, arena)) return NULL;
2300
+ return ret;
2205
2301
  }
2206
2302
  UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_parse_ex(const char *buf, size_t size,
2207
- upb_arena *arena, int options) {
2303
+ const upb_extreg *extreg, int options,
2304
+ upb_arena *arena) {
2208
2305
  google_protobuf_FileDescriptorProto *ret = google_protobuf_FileDescriptorProto_new(arena);
2209
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, arena, options))
2210
- ? ret : NULL;
2306
+ if (!ret) return NULL;
2307
+ if (!_upb_decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, extreg, options, arena)) {
2308
+ return NULL;
2309
+ }
2310
+ return ret;
2211
2311
  }
2212
2312
  UPB_INLINE char *google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto *msg, upb_arena *arena, size_t *len) {
2213
2313
  return upb_encode(msg, &google_protobuf_FileDescriptorProto_msginit, arena, len);
@@ -2364,13 +2464,19 @@ UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_new(
2364
2464
  UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_parse(const char *buf, size_t size,
2365
2465
  upb_arena *arena) {
2366
2466
  google_protobuf_DescriptorProto *ret = google_protobuf_DescriptorProto_new(arena);
2367
- return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, arena)) ? ret : NULL;
2467
+ if (!ret) return NULL;
2468
+ if (!upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, arena)) return NULL;
2469
+ return ret;
2368
2470
  }
2369
2471
  UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_parse_ex(const char *buf, size_t size,
2370
- upb_arena *arena, int options) {
2472
+ const upb_extreg *extreg, int options,
2473
+ upb_arena *arena) {
2371
2474
  google_protobuf_DescriptorProto *ret = google_protobuf_DescriptorProto_new(arena);
2372
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, arena, options))
2373
- ? ret : NULL;
2475
+ if (!ret) return NULL;
2476
+ if (!_upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, extreg, options, arena)) {
2477
+ return NULL;
2478
+ }
2479
+ return ret;
2374
2480
  }
2375
2481
  UPB_INLINE char *google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto *msg, upb_arena *arena, size_t *len) {
2376
2482
  return upb_encode(msg, &google_protobuf_DescriptorProto_msginit, arena, len);
@@ -2523,13 +2629,19 @@ UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_Descr
2523
2629
  UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_parse(const char *buf, size_t size,
2524
2630
  upb_arena *arena) {
2525
2631
  google_protobuf_DescriptorProto_ExtensionRange *ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena);
2526
- return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena)) ? ret : NULL;
2632
+ if (!ret) return NULL;
2633
+ if (!upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena)) return NULL;
2634
+ return ret;
2527
2635
  }
2528
2636
  UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_parse_ex(const char *buf, size_t size,
2529
- upb_arena *arena, int options) {
2637
+ const upb_extreg *extreg, int options,
2638
+ upb_arena *arena) {
2530
2639
  google_protobuf_DescriptorProto_ExtensionRange *ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena);
2531
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena, options))
2532
- ? ret : NULL;
2640
+ if (!ret) return NULL;
2641
+ if (!_upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, extreg, options, arena)) {
2642
+ return NULL;
2643
+ }
2644
+ return ret;
2533
2645
  }
2534
2646
  UPB_INLINE char *google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange *msg, upb_arena *arena, size_t *len) {
2535
2647
  return upb_encode(msg, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena, len);
@@ -2572,13 +2684,19 @@ UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_Descri
2572
2684
  UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_parse(const char *buf, size_t size,
2573
2685
  upb_arena *arena) {
2574
2686
  google_protobuf_DescriptorProto_ReservedRange *ret = google_protobuf_DescriptorProto_ReservedRange_new(arena);
2575
- return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena)) ? ret : NULL;
2687
+ if (!ret) return NULL;
2688
+ if (!upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena)) return NULL;
2689
+ return ret;
2576
2690
  }
2577
2691
  UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_parse_ex(const char *buf, size_t size,
2578
- upb_arena *arena, int options) {
2692
+ const upb_extreg *extreg, int options,
2693
+ upb_arena *arena) {
2579
2694
  google_protobuf_DescriptorProto_ReservedRange *ret = google_protobuf_DescriptorProto_ReservedRange_new(arena);
2580
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena, options))
2581
- ? ret : NULL;
2695
+ if (!ret) return NULL;
2696
+ if (!_upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, extreg, options, arena)) {
2697
+ return NULL;
2698
+ }
2699
+ return ret;
2582
2700
  }
2583
2701
  UPB_INLINE char *google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange *msg, upb_arena *arena, size_t *len) {
2584
2702
  return upb_encode(msg, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena, len);
@@ -2606,13 +2724,19 @@ UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRange
2606
2724
  UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_parse(const char *buf, size_t size,
2607
2725
  upb_arena *arena) {
2608
2726
  google_protobuf_ExtensionRangeOptions *ret = google_protobuf_ExtensionRangeOptions_new(arena);
2609
- return (ret && upb_decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, arena)) ? ret : NULL;
2727
+ if (!ret) return NULL;
2728
+ if (!upb_decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, arena)) return NULL;
2729
+ return ret;
2610
2730
  }
2611
2731
  UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_parse_ex(const char *buf, size_t size,
2612
- upb_arena *arena, int options) {
2732
+ const upb_extreg *extreg, int options,
2733
+ upb_arena *arena) {
2613
2734
  google_protobuf_ExtensionRangeOptions *ret = google_protobuf_ExtensionRangeOptions_new(arena);
2614
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, arena, options))
2615
- ? ret : NULL;
2735
+ if (!ret) return NULL;
2736
+ if (!_upb_decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, extreg, options, arena)) {
2737
+ return NULL;
2738
+ }
2739
+ return ret;
2616
2740
  }
2617
2741
  UPB_INLINE char *google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions *msg, upb_arena *arena, size_t *len) {
2618
2742
  return upb_encode(msg, &google_protobuf_ExtensionRangeOptions_msginit, arena, len);
@@ -2643,13 +2767,19 @@ UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptor
2643
2767
  UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_parse(const char *buf, size_t size,
2644
2768
  upb_arena *arena) {
2645
2769
  google_protobuf_FieldDescriptorProto *ret = google_protobuf_FieldDescriptorProto_new(arena);
2646
- return (ret && upb_decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, arena)) ? ret : NULL;
2770
+ if (!ret) return NULL;
2771
+ if (!upb_decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, arena)) return NULL;
2772
+ return ret;
2647
2773
  }
2648
2774
  UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_parse_ex(const char *buf, size_t size,
2649
- upb_arena *arena, int options) {
2775
+ const upb_extreg *extreg, int options,
2776
+ upb_arena *arena) {
2650
2777
  google_protobuf_FieldDescriptorProto *ret = google_protobuf_FieldDescriptorProto_new(arena);
2651
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, arena, options))
2652
- ? ret : NULL;
2778
+ if (!ret) return NULL;
2779
+ if (!_upb_decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, extreg, options, arena)) {
2780
+ return NULL;
2781
+ }
2782
+ return ret;
2653
2783
  }
2654
2784
  UPB_INLINE char *google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto *msg, upb_arena *arena, size_t *len) {
2655
2785
  return upb_encode(msg, &google_protobuf_FieldDescriptorProto_msginit, arena, len);
@@ -2740,13 +2870,19 @@ UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptor
2740
2870
  UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_parse(const char *buf, size_t size,
2741
2871
  upb_arena *arena) {
2742
2872
  google_protobuf_OneofDescriptorProto *ret = google_protobuf_OneofDescriptorProto_new(arena);
2743
- return (ret && upb_decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, arena)) ? ret : NULL;
2873
+ if (!ret) return NULL;
2874
+ if (!upb_decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, arena)) return NULL;
2875
+ return ret;
2744
2876
  }
2745
2877
  UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_parse_ex(const char *buf, size_t size,
2746
- upb_arena *arena, int options) {
2878
+ const upb_extreg *extreg, int options,
2879
+ upb_arena *arena) {
2747
2880
  google_protobuf_OneofDescriptorProto *ret = google_protobuf_OneofDescriptorProto_new(arena);
2748
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, arena, options))
2749
- ? ret : NULL;
2881
+ if (!ret) return NULL;
2882
+ if (!_upb_decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, extreg, options, arena)) {
2883
+ return NULL;
2884
+ }
2885
+ return ret;
2750
2886
  }
2751
2887
  UPB_INLINE char *google_protobuf_OneofDescriptorProto_serialize(const google_protobuf_OneofDescriptorProto *msg, upb_arena *arena, size_t *len) {
2752
2888
  return upb_encode(msg, &google_protobuf_OneofDescriptorProto_msginit, arena, len);
@@ -2783,13 +2919,19 @@ UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorPr
2783
2919
  UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_parse(const char *buf, size_t size,
2784
2920
  upb_arena *arena) {
2785
2921
  google_protobuf_EnumDescriptorProto *ret = google_protobuf_EnumDescriptorProto_new(arena);
2786
- return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, arena)) ? ret : NULL;
2922
+ if (!ret) return NULL;
2923
+ if (!upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, arena)) return NULL;
2924
+ return ret;
2787
2925
  }
2788
2926
  UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_parse_ex(const char *buf, size_t size,
2789
- upb_arena *arena, int options) {
2927
+ const upb_extreg *extreg, int options,
2928
+ upb_arena *arena) {
2790
2929
  google_protobuf_EnumDescriptorProto *ret = google_protobuf_EnumDescriptorProto_new(arena);
2791
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, arena, options))
2792
- ? ret : NULL;
2930
+ if (!ret) return NULL;
2931
+ if (!_upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, extreg, options, arena)) {
2932
+ return NULL;
2933
+ }
2934
+ return ret;
2793
2935
  }
2794
2936
  UPB_INLINE char *google_protobuf_EnumDescriptorProto_serialize(const google_protobuf_EnumDescriptorProto *msg, upb_arena *arena, size_t *len) {
2795
2937
  return upb_encode(msg, &google_protobuf_EnumDescriptorProto_msginit, arena, len);
@@ -2867,13 +3009,19 @@ UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobu
2867
3009
  UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_parse(const char *buf, size_t size,
2868
3010
  upb_arena *arena) {
2869
3011
  google_protobuf_EnumDescriptorProto_EnumReservedRange *ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena);
2870
- return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena)) ? ret : NULL;
3012
+ if (!ret) return NULL;
3013
+ if (!upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena)) return NULL;
3014
+ return ret;
2871
3015
  }
2872
3016
  UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_parse_ex(const char *buf, size_t size,
2873
- upb_arena *arena, int options) {
3017
+ const upb_extreg *extreg, int options,
3018
+ upb_arena *arena) {
2874
3019
  google_protobuf_EnumDescriptorProto_EnumReservedRange *ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena);
2875
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena, options))
2876
- ? ret : NULL;
3020
+ if (!ret) return NULL;
3021
+ if (!_upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, extreg, options, arena)) {
3022
+ return NULL;
3023
+ }
3024
+ return ret;
2877
3025
  }
2878
3026
  UPB_INLINE char *google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, upb_arena *arena, size_t *len) {
2879
3027
  return upb_encode(msg, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena, len);
@@ -2901,13 +3049,19 @@ UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDe
2901
3049
  UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_parse(const char *buf, size_t size,
2902
3050
  upb_arena *arena) {
2903
3051
  google_protobuf_EnumValueDescriptorProto *ret = google_protobuf_EnumValueDescriptorProto_new(arena);
2904
- return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, arena)) ? ret : NULL;
3052
+ if (!ret) return NULL;
3053
+ if (!upb_decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, arena)) return NULL;
3054
+ return ret;
2905
3055
  }
2906
3056
  UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_parse_ex(const char *buf, size_t size,
2907
- upb_arena *arena, int options) {
3057
+ const upb_extreg *extreg, int options,
3058
+ upb_arena *arena) {
2908
3059
  google_protobuf_EnumValueDescriptorProto *ret = google_protobuf_EnumValueDescriptorProto_new(arena);
2909
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, arena, options))
2910
- ? ret : NULL;
3060
+ if (!ret) return NULL;
3061
+ if (!_upb_decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, extreg, options, arena)) {
3062
+ return NULL;
3063
+ }
3064
+ return ret;
2911
3065
  }
2912
3066
  UPB_INLINE char *google_protobuf_EnumValueDescriptorProto_serialize(const google_protobuf_EnumValueDescriptorProto *msg, upb_arena *arena, size_t *len) {
2913
3067
  return upb_encode(msg, &google_protobuf_EnumValueDescriptorProto_msginit, arena, len);
@@ -2950,13 +3104,19 @@ UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescri
2950
3104
  UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_parse(const char *buf, size_t size,
2951
3105
  upb_arena *arena) {
2952
3106
  google_protobuf_ServiceDescriptorProto *ret = google_protobuf_ServiceDescriptorProto_new(arena);
2953
- return (ret && upb_decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, arena)) ? ret : NULL;
3107
+ if (!ret) return NULL;
3108
+ if (!upb_decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, arena)) return NULL;
3109
+ return ret;
2954
3110
  }
2955
3111
  UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_parse_ex(const char *buf, size_t size,
2956
- upb_arena *arena, int options) {
3112
+ const upb_extreg *extreg, int options,
3113
+ upb_arena *arena) {
2957
3114
  google_protobuf_ServiceDescriptorProto *ret = google_protobuf_ServiceDescriptorProto_new(arena);
2958
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, arena, options))
2959
- ? ret : NULL;
3115
+ if (!ret) return NULL;
3116
+ if (!_upb_decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, extreg, options, arena)) {
3117
+ return NULL;
3118
+ }
3119
+ return ret;
2960
3120
  }
2961
3121
  UPB_INLINE char *google_protobuf_ServiceDescriptorProto_serialize(const google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena, size_t *len) {
2962
3122
  return upb_encode(msg, &google_protobuf_ServiceDescriptorProto_msginit, arena, len);
@@ -3008,13 +3168,19 @@ UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescript
3008
3168
  UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_parse(const char *buf, size_t size,
3009
3169
  upb_arena *arena) {
3010
3170
  google_protobuf_MethodDescriptorProto *ret = google_protobuf_MethodDescriptorProto_new(arena);
3011
- return (ret && upb_decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, arena)) ? ret : NULL;
3171
+ if (!ret) return NULL;
3172
+ if (!upb_decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, arena)) return NULL;
3173
+ return ret;
3012
3174
  }
3013
3175
  UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_parse_ex(const char *buf, size_t size,
3014
- upb_arena *arena, int options) {
3176
+ const upb_extreg *extreg, int options,
3177
+ upb_arena *arena) {
3015
3178
  google_protobuf_MethodDescriptorProto *ret = google_protobuf_MethodDescriptorProto_new(arena);
3016
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, arena, options))
3017
- ? ret : NULL;
3179
+ if (!ret) return NULL;
3180
+ if (!_upb_decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, extreg, options, arena)) {
3181
+ return NULL;
3182
+ }
3183
+ return ret;
3018
3184
  }
3019
3185
  UPB_INLINE char *google_protobuf_MethodDescriptorProto_serialize(const google_protobuf_MethodDescriptorProto *msg, upb_arena *arena, size_t *len) {
3020
3186
  return upb_encode(msg, &google_protobuf_MethodDescriptorProto_msginit, arena, len);
@@ -3075,13 +3241,19 @@ UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_new(upb_aren
3075
3241
  UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_parse(const char *buf, size_t size,
3076
3242
  upb_arena *arena) {
3077
3243
  google_protobuf_FileOptions *ret = google_protobuf_FileOptions_new(arena);
3078
- return (ret && upb_decode(buf, size, ret, &google_protobuf_FileOptions_msginit, arena)) ? ret : NULL;
3244
+ if (!ret) return NULL;
3245
+ if (!upb_decode(buf, size, ret, &google_protobuf_FileOptions_msginit, arena)) return NULL;
3246
+ return ret;
3079
3247
  }
3080
3248
  UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_parse_ex(const char *buf, size_t size,
3081
- upb_arena *arena, int options) {
3249
+ const upb_extreg *extreg, int options,
3250
+ upb_arena *arena) {
3082
3251
  google_protobuf_FileOptions *ret = google_protobuf_FileOptions_new(arena);
3083
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_FileOptions_msginit, arena, options))
3084
- ? ret : NULL;
3252
+ if (!ret) return NULL;
3253
+ if (!_upb_decode(buf, size, ret, &google_protobuf_FileOptions_msginit, extreg, options, arena)) {
3254
+ return NULL;
3255
+ }
3256
+ return ret;
3085
3257
  }
3086
3258
  UPB_INLINE char *google_protobuf_FileOptions_serialize(const google_protobuf_FileOptions *msg, upb_arena *arena, size_t *len) {
3087
3259
  return upb_encode(msg, &google_protobuf_FileOptions_msginit, arena, len);
@@ -3232,13 +3404,19 @@ UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_new(up
3232
3404
  UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_parse(const char *buf, size_t size,
3233
3405
  upb_arena *arena) {
3234
3406
  google_protobuf_MessageOptions *ret = google_protobuf_MessageOptions_new(arena);
3235
- return (ret && upb_decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, arena)) ? ret : NULL;
3407
+ if (!ret) return NULL;
3408
+ if (!upb_decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, arena)) return NULL;
3409
+ return ret;
3236
3410
  }
3237
3411
  UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_parse_ex(const char *buf, size_t size,
3238
- upb_arena *arena, int options) {
3412
+ const upb_extreg *extreg, int options,
3413
+ upb_arena *arena) {
3239
3414
  google_protobuf_MessageOptions *ret = google_protobuf_MessageOptions_new(arena);
3240
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, arena, options))
3241
- ? ret : NULL;
3415
+ if (!ret) return NULL;
3416
+ if (!_upb_decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, extreg, options, arena)) {
3417
+ return NULL;
3418
+ }
3419
+ return ret;
3242
3420
  }
3243
3421
  UPB_INLINE char *google_protobuf_MessageOptions_serialize(const google_protobuf_MessageOptions *msg, upb_arena *arena, size_t *len) {
3244
3422
  return upb_encode(msg, &google_protobuf_MessageOptions_msginit, arena, len);
@@ -3293,13 +3471,19 @@ UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_new(upb_ar
3293
3471
  UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_parse(const char *buf, size_t size,
3294
3472
  upb_arena *arena) {
3295
3473
  google_protobuf_FieldOptions *ret = google_protobuf_FieldOptions_new(arena);
3296
- return (ret && upb_decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, arena)) ? ret : NULL;
3474
+ if (!ret) return NULL;
3475
+ if (!upb_decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, arena)) return NULL;
3476
+ return ret;
3297
3477
  }
3298
3478
  UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_parse_ex(const char *buf, size_t size,
3299
- upb_arena *arena, int options) {
3479
+ const upb_extreg *extreg, int options,
3480
+ upb_arena *arena) {
3300
3481
  google_protobuf_FieldOptions *ret = google_protobuf_FieldOptions_new(arena);
3301
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, arena, options))
3302
- ? ret : NULL;
3482
+ if (!ret) return NULL;
3483
+ if (!_upb_decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, extreg, options, arena)) {
3484
+ return NULL;
3485
+ }
3486
+ return ret;
3303
3487
  }
3304
3488
  UPB_INLINE char *google_protobuf_FieldOptions_serialize(const google_protobuf_FieldOptions *msg, upb_arena *arena, size_t *len) {
3305
3489
  return upb_encode(msg, &google_protobuf_FieldOptions_msginit, arena, len);
@@ -3366,13 +3550,19 @@ UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_new(upb_ar
3366
3550
  UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_parse(const char *buf, size_t size,
3367
3551
  upb_arena *arena) {
3368
3552
  google_protobuf_OneofOptions *ret = google_protobuf_OneofOptions_new(arena);
3369
- return (ret && upb_decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, arena)) ? ret : NULL;
3553
+ if (!ret) return NULL;
3554
+ if (!upb_decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, arena)) return NULL;
3555
+ return ret;
3370
3556
  }
3371
3557
  UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_parse_ex(const char *buf, size_t size,
3372
- upb_arena *arena, int options) {
3558
+ const upb_extreg *extreg, int options,
3559
+ upb_arena *arena) {
3373
3560
  google_protobuf_OneofOptions *ret = google_protobuf_OneofOptions_new(arena);
3374
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, arena, options))
3375
- ? ret : NULL;
3561
+ if (!ret) return NULL;
3562
+ if (!_upb_decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, extreg, options, arena)) {
3563
+ return NULL;
3564
+ }
3565
+ return ret;
3376
3566
  }
3377
3567
  UPB_INLINE char *google_protobuf_OneofOptions_serialize(const google_protobuf_OneofOptions *msg, upb_arena *arena, size_t *len) {
3378
3568
  return upb_encode(msg, &google_protobuf_OneofOptions_msginit, arena, len);
@@ -3403,13 +3593,19 @@ UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_new(upb_aren
3403
3593
  UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_parse(const char *buf, size_t size,
3404
3594
  upb_arena *arena) {
3405
3595
  google_protobuf_EnumOptions *ret = google_protobuf_EnumOptions_new(arena);
3406
- return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, arena)) ? ret : NULL;
3596
+ if (!ret) return NULL;
3597
+ if (!upb_decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, arena)) return NULL;
3598
+ return ret;
3407
3599
  }
3408
3600
  UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_parse_ex(const char *buf, size_t size,
3409
- upb_arena *arena, int options) {
3601
+ const upb_extreg *extreg, int options,
3602
+ upb_arena *arena) {
3410
3603
  google_protobuf_EnumOptions *ret = google_protobuf_EnumOptions_new(arena);
3411
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, arena, options))
3412
- ? ret : NULL;
3604
+ if (!ret) return NULL;
3605
+ if (!_upb_decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, extreg, options, arena)) {
3606
+ return NULL;
3607
+ }
3608
+ return ret;
3413
3609
  }
3414
3610
  UPB_INLINE char *google_protobuf_EnumOptions_serialize(const google_protobuf_EnumOptions *msg, upb_arena *arena, size_t *len) {
3415
3611
  return upb_encode(msg, &google_protobuf_EnumOptions_msginit, arena, len);
@@ -3452,13 +3648,19 @@ UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_ne
3452
3648
  UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_parse(const char *buf, size_t size,
3453
3649
  upb_arena *arena) {
3454
3650
  google_protobuf_EnumValueOptions *ret = google_protobuf_EnumValueOptions_new(arena);
3455
- return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, arena)) ? ret : NULL;
3651
+ if (!ret) return NULL;
3652
+ if (!upb_decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, arena)) return NULL;
3653
+ return ret;
3456
3654
  }
3457
3655
  UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_parse_ex(const char *buf, size_t size,
3458
- upb_arena *arena, int options) {
3656
+ const upb_extreg *extreg, int options,
3657
+ upb_arena *arena) {
3459
3658
  google_protobuf_EnumValueOptions *ret = google_protobuf_EnumValueOptions_new(arena);
3460
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, arena, options))
3461
- ? ret : NULL;
3659
+ if (!ret) return NULL;
3660
+ if (!_upb_decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, extreg, options, arena)) {
3661
+ return NULL;
3662
+ }
3663
+ return ret;
3462
3664
  }
3463
3665
  UPB_INLINE char *google_protobuf_EnumValueOptions_serialize(const google_protobuf_EnumValueOptions *msg, upb_arena *arena, size_t *len) {
3464
3666
  return upb_encode(msg, &google_protobuf_EnumValueOptions_msginit, arena, len);
@@ -3495,13 +3697,19 @@ UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_new(up
3495
3697
  UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_parse(const char *buf, size_t size,
3496
3698
  upb_arena *arena) {
3497
3699
  google_protobuf_ServiceOptions *ret = google_protobuf_ServiceOptions_new(arena);
3498
- return (ret && upb_decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, arena)) ? ret : NULL;
3700
+ if (!ret) return NULL;
3701
+ if (!upb_decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, arena)) return NULL;
3702
+ return ret;
3499
3703
  }
3500
3704
  UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_parse_ex(const char *buf, size_t size,
3501
- upb_arena *arena, int options) {
3705
+ const upb_extreg *extreg, int options,
3706
+ upb_arena *arena) {
3502
3707
  google_protobuf_ServiceOptions *ret = google_protobuf_ServiceOptions_new(arena);
3503
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, arena, options))
3504
- ? ret : NULL;
3708
+ if (!ret) return NULL;
3709
+ if (!_upb_decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, extreg, options, arena)) {
3710
+ return NULL;
3711
+ }
3712
+ return ret;
3505
3713
  }
3506
3714
  UPB_INLINE char *google_protobuf_ServiceOptions_serialize(const google_protobuf_ServiceOptions *msg, upb_arena *arena, size_t *len) {
3507
3715
  return upb_encode(msg, &google_protobuf_ServiceOptions_msginit, arena, len);
@@ -3538,13 +3746,19 @@ UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_new(upb_
3538
3746
  UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_parse(const char *buf, size_t size,
3539
3747
  upb_arena *arena) {
3540
3748
  google_protobuf_MethodOptions *ret = google_protobuf_MethodOptions_new(arena);
3541
- return (ret && upb_decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, arena)) ? ret : NULL;
3749
+ if (!ret) return NULL;
3750
+ if (!upb_decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, arena)) return NULL;
3751
+ return ret;
3542
3752
  }
3543
3753
  UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_parse_ex(const char *buf, size_t size,
3544
- upb_arena *arena, int options) {
3754
+ const upb_extreg *extreg, int options,
3755
+ upb_arena *arena) {
3545
3756
  google_protobuf_MethodOptions *ret = google_protobuf_MethodOptions_new(arena);
3546
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, arena, options))
3547
- ? ret : NULL;
3757
+ if (!ret) return NULL;
3758
+ if (!_upb_decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, extreg, options, arena)) {
3759
+ return NULL;
3760
+ }
3761
+ return ret;
3548
3762
  }
3549
3763
  UPB_INLINE char *google_protobuf_MethodOptions_serialize(const google_protobuf_MethodOptions *msg, upb_arena *arena, size_t *len) {
3550
3764
  return upb_encode(msg, &google_protobuf_MethodOptions_msginit, arena, len);
@@ -3587,13 +3801,19 @@ UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOpt
3587
3801
  UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_parse(const char *buf, size_t size,
3588
3802
  upb_arena *arena) {
3589
3803
  google_protobuf_UninterpretedOption *ret = google_protobuf_UninterpretedOption_new(arena);
3590
- return (ret && upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, arena)) ? ret : NULL;
3804
+ if (!ret) return NULL;
3805
+ if (!upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, arena)) return NULL;
3806
+ return ret;
3591
3807
  }
3592
3808
  UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_parse_ex(const char *buf, size_t size,
3593
- upb_arena *arena, int options) {
3809
+ const upb_extreg *extreg, int options,
3810
+ upb_arena *arena) {
3594
3811
  google_protobuf_UninterpretedOption *ret = google_protobuf_UninterpretedOption_new(arena);
3595
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, arena, options))
3596
- ? ret : NULL;
3812
+ if (!ret) return NULL;
3813
+ if (!_upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, extreg, options, arena)) {
3814
+ return NULL;
3815
+ }
3816
+ return ret;
3597
3817
  }
3598
3818
  UPB_INLINE char *google_protobuf_UninterpretedOption_serialize(const google_protobuf_UninterpretedOption *msg, upb_arena *arena, size_t *len) {
3599
3819
  return upb_encode(msg, &google_protobuf_UninterpretedOption_msginit, arena, len);
@@ -3660,13 +3880,19 @@ UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_Uninter
3660
3880
  UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_parse(const char *buf, size_t size,
3661
3881
  upb_arena *arena) {
3662
3882
  google_protobuf_UninterpretedOption_NamePart *ret = google_protobuf_UninterpretedOption_NamePart_new(arena);
3663
- return (ret && upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, arena)) ? ret : NULL;
3883
+ if (!ret) return NULL;
3884
+ if (!upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, arena)) return NULL;
3885
+ return ret;
3664
3886
  }
3665
3887
  UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_parse_ex(const char *buf, size_t size,
3666
- upb_arena *arena, int options) {
3888
+ const upb_extreg *extreg, int options,
3889
+ upb_arena *arena) {
3667
3890
  google_protobuf_UninterpretedOption_NamePart *ret = google_protobuf_UninterpretedOption_NamePart_new(arena);
3668
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, arena, options))
3669
- ? ret : NULL;
3891
+ if (!ret) return NULL;
3892
+ if (!_upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, extreg, options, arena)) {
3893
+ return NULL;
3894
+ }
3895
+ return ret;
3670
3896
  }
3671
3897
  UPB_INLINE char *google_protobuf_UninterpretedOption_NamePart_serialize(const google_protobuf_UninterpretedOption_NamePart *msg, upb_arena *arena, size_t *len) {
3672
3898
  return upb_encode(msg, &google_protobuf_UninterpretedOption_NamePart_msginit, arena, len);
@@ -3694,13 +3920,19 @@ UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_new(up
3694
3920
  UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_parse(const char *buf, size_t size,
3695
3921
  upb_arena *arena) {
3696
3922
  google_protobuf_SourceCodeInfo *ret = google_protobuf_SourceCodeInfo_new(arena);
3697
- return (ret && upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, arena)) ? ret : NULL;
3923
+ if (!ret) return NULL;
3924
+ if (!upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, arena)) return NULL;
3925
+ return ret;
3698
3926
  }
3699
3927
  UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_parse_ex(const char *buf, size_t size,
3700
- upb_arena *arena, int options) {
3928
+ const upb_extreg *extreg, int options,
3929
+ upb_arena *arena) {
3701
3930
  google_protobuf_SourceCodeInfo *ret = google_protobuf_SourceCodeInfo_new(arena);
3702
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, arena, options))
3703
- ? ret : NULL;
3931
+ if (!ret) return NULL;
3932
+ if (!_upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, extreg, options, arena)) {
3933
+ return NULL;
3934
+ }
3935
+ return ret;
3704
3936
  }
3705
3937
  UPB_INLINE char *google_protobuf_SourceCodeInfo_serialize(const google_protobuf_SourceCodeInfo *msg, upb_arena *arena, size_t *len) {
3706
3938
  return upb_encode(msg, &google_protobuf_SourceCodeInfo_msginit, arena, len);
@@ -3731,13 +3963,19 @@ UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeIn
3731
3963
  UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_parse(const char *buf, size_t size,
3732
3964
  upb_arena *arena) {
3733
3965
  google_protobuf_SourceCodeInfo_Location *ret = google_protobuf_SourceCodeInfo_Location_new(arena);
3734
- return (ret && upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, arena)) ? ret : NULL;
3966
+ if (!ret) return NULL;
3967
+ if (!upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, arena)) return NULL;
3968
+ return ret;
3735
3969
  }
3736
3970
  UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_parse_ex(const char *buf, size_t size,
3737
- upb_arena *arena, int options) {
3971
+ const upb_extreg *extreg, int options,
3972
+ upb_arena *arena) {
3738
3973
  google_protobuf_SourceCodeInfo_Location *ret = google_protobuf_SourceCodeInfo_Location_new(arena);
3739
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, arena, options))
3740
- ? ret : NULL;
3974
+ if (!ret) return NULL;
3975
+ if (!_upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, extreg, options, arena)) {
3976
+ return NULL;
3977
+ }
3978
+ return ret;
3741
3979
  }
3742
3980
  UPB_INLINE char *google_protobuf_SourceCodeInfo_Location_serialize(const google_protobuf_SourceCodeInfo_Location *msg, upb_arena *arena, size_t *len) {
3743
3981
  return upb_encode(msg, &google_protobuf_SourceCodeInfo_Location_msginit, arena, len);
@@ -3798,13 +4036,19 @@ UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_
3798
4036
  UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_parse(const char *buf, size_t size,
3799
4037
  upb_arena *arena) {
3800
4038
  google_protobuf_GeneratedCodeInfo *ret = google_protobuf_GeneratedCodeInfo_new(arena);
3801
- return (ret && upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, arena)) ? ret : NULL;
4039
+ if (!ret) return NULL;
4040
+ if (!upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, arena)) return NULL;
4041
+ return ret;
3802
4042
  }
3803
4043
  UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_parse_ex(const char *buf, size_t size,
3804
- upb_arena *arena, int options) {
4044
+ const upb_extreg *extreg, int options,
4045
+ upb_arena *arena) {
3805
4046
  google_protobuf_GeneratedCodeInfo *ret = google_protobuf_GeneratedCodeInfo_new(arena);
3806
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, arena, options))
3807
- ? ret : NULL;
4047
+ if (!ret) return NULL;
4048
+ if (!_upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, extreg, options, arena)) {
4049
+ return NULL;
4050
+ }
4051
+ return ret;
3808
4052
  }
3809
4053
  UPB_INLINE char *google_protobuf_GeneratedCodeInfo_serialize(const google_protobuf_GeneratedCodeInfo *msg, upb_arena *arena, size_t *len) {
3810
4054
  return upb_encode(msg, &google_protobuf_GeneratedCodeInfo_msginit, arena, len);
@@ -3835,13 +4079,19 @@ UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_Generat
3835
4079
  UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_parse(const char *buf, size_t size,
3836
4080
  upb_arena *arena) {
3837
4081
  google_protobuf_GeneratedCodeInfo_Annotation *ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena);
3838
- return (ret && upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena)) ? ret : NULL;
4082
+ if (!ret) return NULL;
4083
+ if (!upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena)) return NULL;
4084
+ return ret;
3839
4085
  }
3840
4086
  UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_parse_ex(const char *buf, size_t size,
3841
- upb_arena *arena, int options) {
4087
+ const upb_extreg *extreg, int options,
4088
+ upb_arena *arena) {
3842
4089
  google_protobuf_GeneratedCodeInfo_Annotation *ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena);
3843
- return (ret && _upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena, options))
3844
- ? ret : NULL;
4090
+ if (!ret) return NULL;
4091
+ if (!_upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, extreg, options, arena)) {
4092
+ return NULL;
4093
+ }
4094
+ return ret;
3845
4095
  }
3846
4096
  UPB_INLINE char *google_protobuf_GeneratedCodeInfo_Annotation_serialize(const google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_arena *arena, size_t *len) {
3847
4097
  return upb_encode(msg, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena, len);
@@ -3884,18 +4134,20 @@ UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_end(google_prot
3884
4134
 
3885
4135
 
3886
4136
  #endif /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ */
4137
+
4138
+ /** upb/def.h ************************************************************/
3887
4139
  /*
3888
- ** Defs are upb's internal representation of the constructs that can appear
3889
- ** in a .proto file:
3890
- **
3891
- ** - upb_msgdef: describes a "message" construct.
3892
- ** - upb_fielddef: describes a message field.
3893
- ** - upb_filedef: describes a .proto file and its defs.
3894
- ** - upb_enumdef: describes an enum.
3895
- ** - upb_oneofdef: describes a oneof.
3896
- **
3897
- ** TODO: definitions of services.
3898
- */
4140
+ * Defs are upb's internal representation of the constructs that can appear
4141
+ * in a .proto file:
4142
+ *
4143
+ * - upb_msgdef: describes a "message" construct.
4144
+ * - upb_fielddef: describes a message field.
4145
+ * - upb_filedef: describes a .proto file and its defs.
4146
+ * - upb_enumdef: describes an enum.
4147
+ * - upb_oneofdef: describes a oneof.
4148
+ *
4149
+ * TODO: definitions of services.
4150
+ */
3899
4151
 
3900
4152
  #ifndef UPB_DEF_H_
3901
4153
  #define UPB_DEF_H_
@@ -3991,9 +4243,6 @@ const upb_msgdef *upb_fielddef_msgsubdef(const upb_fielddef *f);
3991
4243
  const upb_enumdef *upb_fielddef_enumsubdef(const upb_fielddef *f);
3992
4244
  const upb_msglayout_field *upb_fielddef_layout(const upb_fielddef *f);
3993
4245
 
3994
- /* Internal only. */
3995
- uint32_t upb_fielddef_selectorbase(const upb_fielddef *f);
3996
-
3997
4246
  /* upb_oneofdef ***************************************************************/
3998
4247
 
3999
4248
  typedef upb_inttable_iter upb_oneof_iter;
@@ -4078,10 +4327,6 @@ UPB_INLINE const upb_fielddef *upb_msgdef_ntofz(const upb_msgdef *m,
4078
4327
  return upb_msgdef_ntof(m, name, strlen(name));
4079
4328
  }
4080
4329
 
4081
- /* Internal-only. */
4082
- size_t upb_msgdef_selectorcount(const upb_msgdef *m);
4083
- uint32_t upb_msgdef_submsgfieldcount(const upb_msgdef *m);
4084
-
4085
4330
  /* Lookup of either field or oneof by name. Returns whether either was found.
4086
4331
  * If the return is true, then the found def will be set, and the non-found
4087
4332
  * one set to NULL. */
@@ -4197,6 +4442,7 @@ bool _upb_symtab_loaddefinit(upb_symtab *s, const upb_def_init *init);
4197
4442
 
4198
4443
  #endif /* UPB_DEF_H_ */
4199
4444
 
4445
+ /** upb/reflection.h ************************************************************/
4200
4446
  #ifndef UPB_REFLECTION_H_
4201
4447
  #define UPB_REFLECTION_H_
4202
4448
 
@@ -4278,17 +4524,9 @@ bool upb_msg_next(const upb_msg *msg, const upb_msgdef *m,
4278
4524
  const upb_symtab *ext_pool, const upb_fielddef **f,
4279
4525
  upb_msgval *val, size_t *iter);
4280
4526
 
4281
- /* Adds unknown data (serialized protobuf data) to the given message. The data
4282
- * is copied into the message instance. */
4283
- void upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
4284
- upb_arena *arena);
4285
-
4286
4527
  /* Clears all unknown field data from this message and all submessages. */
4287
4528
  bool upb_msg_discardunknown(upb_msg *msg, const upb_msgdef *m, int maxdepth);
4288
4529
 
4289
- /* Returns a reference to the message's unknown data. */
4290
- const char *upb_msg_getunknown(const upb_msg *msg, size_t *len);
4291
-
4292
4530
  /** upb_array *****************************************************************/
4293
4531
 
4294
4532
  /* Creates a new array on the given arena that holds elements of this type. */
@@ -4370,6 +4608,7 @@ void upb_mapiter_setvalue(upb_map *map, size_t iter, upb_msgval value);
4370
4608
 
4371
4609
  #endif /* UPB_REFLECTION_H_ */
4372
4610
 
4611
+ /** upb/json_decode.h ************************************************************/
4373
4612
  #ifndef UPB_JSONDECODE_H_
4374
4613
  #define UPB_JSONDECODE_H_
4375
4614
 
@@ -4392,6 +4631,7 @@ bool upb_json_decode(const char *buf, size_t size, upb_msg *msg,
4392
4631
 
4393
4632
  #endif /* UPB_JSONDECODE_H_ */
4394
4633
 
4634
+ /** upb/json_encode.h ************************************************************/
4395
4635
  #ifndef UPB_JSONENCODE_H_
4396
4636
  #define UPB_JSONENCODE_H_
4397
4637
 
@@ -4426,27 +4666,39 @@ size_t upb_json_encode(const upb_msg *msg, const upb_msgdef *m,
4426
4666
  #endif
4427
4667
 
4428
4668
  #endif /* UPB_JSONENCODE_H_ */
4669
+
4670
+ /** upb/port_undef.inc ************************************************************/
4429
4671
  /* See port_def.inc. This should #undef all macros #defined there. */
4430
4672
 
4431
- #undef UPB_MAPTYPE_STRING
4432
4673
  #undef UPB_SIZE
4433
4674
  #undef UPB_PTR_AT
4434
4675
  #undef UPB_READ_ONEOF
4435
4676
  #undef UPB_WRITE_ONEOF
4677
+ #undef UPB_MAPTYPE_STRING
4436
4678
  #undef UPB_INLINE
4437
4679
  #undef UPB_ALIGN_UP
4438
4680
  #undef UPB_ALIGN_DOWN
4439
4681
  #undef UPB_ALIGN_MALLOC
4440
4682
  #undef UPB_ALIGN_OF
4683
+ #undef UPB_LIKELY
4684
+ #undef UPB_UNLIKELY
4441
4685
  #undef UPB_FORCEINLINE
4442
4686
  #undef UPB_NOINLINE
4443
4687
  #undef UPB_NORETURN
4688
+ #undef UPB_PRINTF
4444
4689
  #undef UPB_MAX
4445
4690
  #undef UPB_MIN
4446
4691
  #undef UPB_UNUSED
4447
4692
  #undef UPB_ASSUME
4448
4693
  #undef UPB_ASSERT
4449
4694
  #undef UPB_UNREACHABLE
4695
+ #undef UPB_SETJMP
4696
+ #undef UPB_LONGJMP
4697
+ #undef UPB_PTRADD
4698
+ #undef UPB_MUSTTAIL
4699
+ #undef UPB_FASTTABLE_SUPPORTED
4700
+ #undef UPB_FASTTABLE
4701
+ #undef UPB_FASTTABLE_INIT
4450
4702
  #undef UPB_POISON_MEMORY_REGION
4451
4703
  #undef UPB_UNPOISON_MEMORY_REGION
4452
4704
  #undef UPB_ASAN