google-protobuf 3.4.1.1-x86-linux → 3.5.0-x86-linux

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

@@ -1,70 +1,5 @@
1
1
  // Amalgamated source file
2
2
  /*
3
- ** Defs are upb's internal representation of the constructs that can appear
4
- ** in a .proto file:
5
- **
6
- ** - upb::MessageDef (upb_msgdef): describes a "message" construct.
7
- ** - upb::FieldDef (upb_fielddef): describes a message field.
8
- ** - upb::FileDef (upb_filedef): describes a .proto file and its defs.
9
- ** - upb::EnumDef (upb_enumdef): describes an enum.
10
- ** - upb::OneofDef (upb_oneofdef): describes a oneof.
11
- ** - upb::Def (upb_def): base class of all the others.
12
- **
13
- ** TODO: definitions of services.
14
- **
15
- ** Like upb_refcounted objects, defs are mutable only until frozen, and are
16
- ** only thread-safe once frozen.
17
- **
18
- ** This is a mixed C/C++ interface that offers a full API to both languages.
19
- ** See the top-level README for more information.
20
- */
21
-
22
- #ifndef UPB_DEF_H_
23
- #define UPB_DEF_H_
24
-
25
- /*
26
- ** upb::RefCounted (upb_refcounted)
27
- **
28
- ** A refcounting scheme that supports circular refs. It accomplishes this by
29
- ** partitioning the set of objects into groups such that no cycle spans groups;
30
- ** we can then reference-count the group as a whole and ignore refs within the
31
- ** group. When objects are mutable, these groups are computed very
32
- ** conservatively; we group any objects that have ever had a link between them.
33
- ** When objects are frozen, we compute strongly-connected components which
34
- ** allows us to be precise and only group objects that are actually cyclic.
35
- **
36
- ** This is a mixed C/C++ interface that offers a full API to both languages.
37
- ** See the top-level README for more information.
38
- */
39
-
40
- #ifndef UPB_REFCOUNTED_H_
41
- #define UPB_REFCOUNTED_H_
42
-
43
- /*
44
- ** upb_table
45
- **
46
- ** This header is INTERNAL-ONLY! Its interfaces are not public or stable!
47
- ** This file defines very fast int->upb_value (inttable) and string->upb_value
48
- ** (strtable) hash tables.
49
- **
50
- ** The table uses chained scatter with Brent's variation (inspired by the Lua
51
- ** implementation of hash tables). The hash function for strings is Austin
52
- ** Appleby's "MurmurHash."
53
- **
54
- ** The inttable uses uintptr_t as its key, which guarantees it can be used to
55
- ** store pointers or integers of at least 32 bits (upb isn't really useful on
56
- ** systems where sizeof(void*) < 4).
57
- **
58
- ** The table must be homogenous (all values of the same type). In debug
59
- ** mode, we check this on insert and lookup.
60
- */
61
-
62
- #ifndef UPB_TABLE_H_
63
- #define UPB_TABLE_H_
64
-
65
- #include <stdint.h>
66
- #include <string.h>
67
- /*
68
3
  ** This file contains shared definitions that are widely used across upb.
69
4
  **
70
5
  ** This is a mixed C/C++ interface that offers a full API to both languages.
@@ -100,6 +35,9 @@ template <int N> class InlinedEnvironment;
100
35
  #define UPB_INLINE static
101
36
  #endif
102
37
 
38
+ /* Hints to the compiler about likely/unlikely branches. */
39
+ #define UPB_LIKELY(x) __builtin_expect((x),1)
40
+
103
41
  /* Define UPB_BIG_ENDIAN manually if you're on big endian and your compiler
104
42
  * doesn't provide these preprocessor symbols. */
105
43
  #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
@@ -361,6 +299,16 @@ class PointerBase2 : public PointerBase<T, Base> {
361
299
 
362
300
  #endif
363
301
 
302
+ /* A list of types as they are encoded on-the-wire. */
303
+ typedef enum {
304
+ UPB_WIRE_TYPE_VARINT = 0,
305
+ UPB_WIRE_TYPE_64BIT = 1,
306
+ UPB_WIRE_TYPE_DELIMITED = 2,
307
+ UPB_WIRE_TYPE_START_GROUP = 3,
308
+ UPB_WIRE_TYPE_END_GROUP = 4,
309
+ UPB_WIRE_TYPE_32BIT = 5
310
+ } upb_wiretype_t;
311
+
364
312
 
365
313
  /* upb::ErrorSpace ************************************************************/
366
314
 
@@ -689,7 +637,7 @@ void upb_env_uninit(upb_env *e);
689
637
 
690
638
  void upb_env_initonly(upb_env *e);
691
639
 
692
- upb_arena *upb_env_arena(upb_env *e);
640
+ UPB_INLINE upb_arena *upb_env_arena(upb_env *e) { return (upb_arena*)e; }
693
641
  bool upb_env_ok(const upb_env *e);
694
642
  void upb_env_seterrorfunc(upb_env *e, upb_error_func *func, void *ud);
695
643
 
@@ -789,6 +737,106 @@ template <int N> class upb::InlinedEnvironment : public upb::Environment {
789
737
 
790
738
 
791
739
  #endif /* UPB_H_ */
740
+ /*
741
+ ** upb_decode: parsing into a upb_msg using a upb_msglayout.
742
+ */
743
+
744
+ #ifndef UPB_DECODE_H_
745
+ #define UPB_DECODE_H_
746
+
747
+ /*
748
+ ** upb::Message is a representation for protobuf messages.
749
+ **
750
+ ** However it differs from other common representations like
751
+ ** google::protobuf::Message in one key way: it does not prescribe any
752
+ ** ownership between messages and submessages, and it relies on the
753
+ ** client to delete each message/submessage/array/map at the appropriate
754
+ ** time.
755
+ **
756
+ ** A client can access a upb::Message without knowing anything about
757
+ ** ownership semantics, but to create or mutate a message a user needs
758
+ ** to implement the memory management themselves.
759
+ **
760
+ ** Currently all messages, arrays, and maps store a upb_alloc* internally.
761
+ ** Mutating operations use this when they require dynamically-allocated
762
+ ** memory. We could potentially eliminate this size overhead later by
763
+ ** letting the user flip a bit on the factory that prevents this from
764
+ ** being stored. The user would then need to use separate functions where
765
+ ** the upb_alloc* is passed explicitly. However for handlers to populate
766
+ ** such structures, they would need a place to store this upb_alloc* during
767
+ ** parsing; upb_handlers don't currently have a good way to accommodate this.
768
+ **
769
+ ** TODO: UTF-8 checking?
770
+ **/
771
+
772
+ #ifndef UPB_MSG_H_
773
+ #define UPB_MSG_H_
774
+
775
+ /*
776
+ ** Defs are upb's internal representation of the constructs that can appear
777
+ ** in a .proto file:
778
+ **
779
+ ** - upb::MessageDef (upb_msgdef): describes a "message" construct.
780
+ ** - upb::FieldDef (upb_fielddef): describes a message field.
781
+ ** - upb::FileDef (upb_filedef): describes a .proto file and its defs.
782
+ ** - upb::EnumDef (upb_enumdef): describes an enum.
783
+ ** - upb::OneofDef (upb_oneofdef): describes a oneof.
784
+ ** - upb::Def (upb_def): base class of all the others.
785
+ **
786
+ ** TODO: definitions of services.
787
+ **
788
+ ** Like upb_refcounted objects, defs are mutable only until frozen, and are
789
+ ** only thread-safe once frozen.
790
+ **
791
+ ** This is a mixed C/C++ interface that offers a full API to both languages.
792
+ ** See the top-level README for more information.
793
+ */
794
+
795
+ #ifndef UPB_DEF_H_
796
+ #define UPB_DEF_H_
797
+
798
+ /*
799
+ ** upb::RefCounted (upb_refcounted)
800
+ **
801
+ ** A refcounting scheme that supports circular refs. It accomplishes this by
802
+ ** partitioning the set of objects into groups such that no cycle spans groups;
803
+ ** we can then reference-count the group as a whole and ignore refs within the
804
+ ** group. When objects are mutable, these groups are computed very
805
+ ** conservatively; we group any objects that have ever had a link between them.
806
+ ** When objects are frozen, we compute strongly-connected components which
807
+ ** allows us to be precise and only group objects that are actually cyclic.
808
+ **
809
+ ** This is a mixed C/C++ interface that offers a full API to both languages.
810
+ ** See the top-level README for more information.
811
+ */
812
+
813
+ #ifndef UPB_REFCOUNTED_H_
814
+ #define UPB_REFCOUNTED_H_
815
+
816
+ /*
817
+ ** upb_table
818
+ **
819
+ ** This header is INTERNAL-ONLY! Its interfaces are not public or stable!
820
+ ** This file defines very fast int->upb_value (inttable) and string->upb_value
821
+ ** (strtable) hash tables.
822
+ **
823
+ ** The table uses chained scatter with Brent's variation (inspired by the Lua
824
+ ** implementation of hash tables). The hash function for strings is Austin
825
+ ** Appleby's "MurmurHash."
826
+ **
827
+ ** The inttable uses uintptr_t as its key, which guarantees it can be used to
828
+ ** store pointers or integers of at least 32 bits (upb isn't really useful on
829
+ ** systems where sizeof(void*) < 4).
830
+ **
831
+ ** The table must be homogenous (all values of the same type). In debug
832
+ ** mode, we check this on insert and lookup.
833
+ */
834
+
835
+ #ifndef UPB_TABLE_H_
836
+ #define UPB_TABLE_H_
837
+
838
+ #include <stdint.h>
839
+ #include <string.h>
792
840
 
793
841
  #ifdef __cplusplus
794
842
  extern "C" {
@@ -3851,265 +3899,75 @@ inline bool FileDef::AddDependency(const FileDef* file) {
3851
3899
 
3852
3900
  #endif /* UPB_DEF_H_ */
3853
3901
  /*
3854
- ** This file contains definitions of structs that should be considered private
3855
- ** and NOT stable across versions of upb.
3902
+ ** upb::Handlers (upb_handlers)
3856
3903
  **
3857
- ** The only reason they are declared here and not in .c files is to allow upb
3858
- ** and the application (if desired) to embed statically-initialized instances
3859
- ** of structures like defs.
3904
+ ** A upb_handlers is like a virtual table for a upb_msgdef. Each field of the
3905
+ ** message can have associated functions that will be called when we are
3906
+ ** parsing or visiting a stream of data. This is similar to how handlers work
3907
+ ** in SAX (the Simple API for XML).
3860
3908
  **
3861
- ** If you include this file, all guarantees of ABI compatibility go out the
3862
- ** window! Any code that includes this file needs to recompile against the
3863
- ** exact same version of upb that they are linking against.
3909
+ ** The handlers have no idea where the data is coming from, so a single set of
3910
+ ** handlers could be used with two completely different data sources (for
3911
+ ** example, a parser and a visitor over in-memory objects). This decoupling is
3912
+ ** the most important feature of upb, because it allows parsers and serializers
3913
+ ** to be highly reusable.
3864
3914
  **
3865
- ** You also need to recompile if you change the value of the UPB_DEBUG_REFS
3866
- ** flag.
3915
+ ** This is a mixed C/C++ interface that offers a full API to both languages.
3916
+ ** See the top-level README for more information.
3867
3917
  */
3868
3918
 
3919
+ #ifndef UPB_HANDLERS_H
3920
+ #define UPB_HANDLERS_H
3869
3921
 
3870
- #ifndef UPB_STATICINIT_H_
3871
- #define UPB_STATICINIT_H_
3872
3922
 
3873
3923
  #ifdef __cplusplus
3874
- /* Because of how we do our typedefs, this header can't be included from C++. */
3875
- #error This file cannot be included from C++
3924
+ namespace upb {
3925
+ class BufferHandle;
3926
+ class BytesHandler;
3927
+ class HandlerAttributes;
3928
+ class Handlers;
3929
+ template <class T> class Handler;
3930
+ template <class T> struct CanonicalType;
3931
+ } /* namespace upb */
3876
3932
  #endif
3877
3933
 
3878
- /* upb_refcounted *************************************************************/
3879
-
3934
+ UPB_DECLARE_TYPE(upb::BufferHandle, upb_bufhandle)
3935
+ UPB_DECLARE_TYPE(upb::BytesHandler, upb_byteshandler)
3936
+ UPB_DECLARE_TYPE(upb::HandlerAttributes, upb_handlerattr)
3937
+ UPB_DECLARE_DERIVED_TYPE(upb::Handlers, upb::RefCounted,
3938
+ upb_handlers, upb_refcounted)
3880
3939
 
3881
- /* upb_def ********************************************************************/
3940
+ /* The maximum depth that the handler graph can have. This is a resource limit
3941
+ * for the C stack since we sometimes need to recursively traverse the graph.
3942
+ * Cycles are ok; the traversal will stop when it detects a cycle, but we must
3943
+ * hit the cycle before the maximum depth is reached.
3944
+ *
3945
+ * If having a single static limit is too inflexible, we can add another variant
3946
+ * of Handlers::Freeze that allows specifying this as a parameter. */
3947
+ #define UPB_MAX_HANDLER_DEPTH 64
3882
3948
 
3883
- struct upb_def {
3884
- upb_refcounted base;
3949
+ /* All the different types of handlers that can be registered.
3950
+ * Only needed for the advanced functions in upb::Handlers. */
3951
+ typedef enum {
3952
+ UPB_HANDLER_INT32,
3953
+ UPB_HANDLER_INT64,
3954
+ UPB_HANDLER_UINT32,
3955
+ UPB_HANDLER_UINT64,
3956
+ UPB_HANDLER_FLOAT,
3957
+ UPB_HANDLER_DOUBLE,
3958
+ UPB_HANDLER_BOOL,
3959
+ UPB_HANDLER_STARTSTR,
3960
+ UPB_HANDLER_STRING,
3961
+ UPB_HANDLER_ENDSTR,
3962
+ UPB_HANDLER_STARTSUBMSG,
3963
+ UPB_HANDLER_ENDSUBMSG,
3964
+ UPB_HANDLER_STARTSEQ,
3965
+ UPB_HANDLER_ENDSEQ
3966
+ } upb_handlertype_t;
3885
3967
 
3886
- const char *fullname;
3887
- const upb_filedef* file;
3888
- char type; /* A upb_deftype_t (char to save space) */
3968
+ #define UPB_HANDLER_MAX (UPB_HANDLER_ENDSEQ+1)
3889
3969
 
3890
- /* Used as a flag during the def's mutable stage. Must be false unless
3891
- * it is currently being used by a function on the stack. This allows
3892
- * us to easily determine which defs were passed into the function's
3893
- * current invocation. */
3894
- bool came_from_user;
3895
- };
3896
-
3897
- #define UPB_DEF_INIT(name, type, vtbl, refs, ref2s) \
3898
- { UPB_REFCOUNT_INIT(vtbl, refs, ref2s), name, NULL, type, false }
3899
-
3900
-
3901
- /* upb_fielddef ***************************************************************/
3902
-
3903
- struct upb_fielddef {
3904
- upb_def base;
3905
-
3906
- union {
3907
- int64_t sint;
3908
- uint64_t uint;
3909
- double dbl;
3910
- float flt;
3911
- void *bytes;
3912
- } defaultval;
3913
- union {
3914
- const upb_msgdef *def; /* If !msg_is_symbolic. */
3915
- char *name; /* If msg_is_symbolic. */
3916
- } msg;
3917
- union {
3918
- const upb_def *def; /* If !subdef_is_symbolic. */
3919
- char *name; /* If subdef_is_symbolic. */
3920
- } sub; /* The msgdef or enumdef for this field, if upb_hassubdef(f). */
3921
- bool subdef_is_symbolic;
3922
- bool msg_is_symbolic;
3923
- const upb_oneofdef *oneof;
3924
- bool default_is_string;
3925
- bool type_is_set_; /* False until type is explicitly set. */
3926
- bool is_extension_;
3927
- bool lazy_;
3928
- bool packed_;
3929
- upb_intfmt_t intfmt;
3930
- bool tagdelim;
3931
- upb_fieldtype_t type_;
3932
- upb_label_t label_;
3933
- uint32_t number_;
3934
- uint32_t selector_base; /* Used to index into a upb::Handlers table. */
3935
- uint32_t index_;
3936
- };
3937
-
3938
- extern const struct upb_refcounted_vtbl upb_fielddef_vtbl;
3939
-
3940
- #define UPB_FIELDDEF_INIT(label, type, intfmt, tagdelim, is_extension, lazy, \
3941
- packed, name, num, msgdef, subdef, selector_base, \
3942
- index, defaultval, refs, ref2s) \
3943
- { \
3944
- UPB_DEF_INIT(name, UPB_DEF_FIELD, &upb_fielddef_vtbl, refs, ref2s), \
3945
- defaultval, {msgdef}, {subdef}, NULL, false, false, \
3946
- type == UPB_TYPE_STRING || type == UPB_TYPE_BYTES, true, is_extension, \
3947
- lazy, packed, intfmt, tagdelim, type, label, num, selector_base, index \
3948
- }
3949
-
3950
-
3951
- /* upb_msgdef *****************************************************************/
3952
-
3953
- struct upb_msgdef {
3954
- upb_def base;
3955
-
3956
- size_t selector_count;
3957
- uint32_t submsg_field_count;
3958
-
3959
- /* Tables for looking up fields by number and name. */
3960
- upb_inttable itof; /* int to field */
3961
- upb_strtable ntof; /* name to field/oneof */
3962
-
3963
- /* Is this a map-entry message? */
3964
- bool map_entry;
3965
-
3966
- /* Whether this message has proto2 or proto3 semantics. */
3967
- upb_syntax_t syntax;
3968
-
3969
- /* TODO(haberman): proper extension ranges (there can be multiple). */
3970
- };
3971
-
3972
- extern const struct upb_refcounted_vtbl upb_msgdef_vtbl;
3973
-
3974
- /* TODO: also support static initialization of the oneofs table. This will be
3975
- * needed if we compile in descriptors that contain oneofs. */
3976
- #define UPB_MSGDEF_INIT(name, selector_count, submsg_field_count, itof, ntof, \
3977
- map_entry, syntax, refs, ref2s) \
3978
- { \
3979
- UPB_DEF_INIT(name, UPB_DEF_MSG, &upb_fielddef_vtbl, refs, ref2s), \
3980
- selector_count, submsg_field_count, itof, ntof, map_entry, syntax \
3981
- }
3982
-
3983
-
3984
- /* upb_enumdef ****************************************************************/
3985
-
3986
- struct upb_enumdef {
3987
- upb_def base;
3988
-
3989
- upb_strtable ntoi;
3990
- upb_inttable iton;
3991
- int32_t defaultval;
3992
- };
3993
-
3994
- extern const struct upb_refcounted_vtbl upb_enumdef_vtbl;
3995
-
3996
- #define UPB_ENUMDEF_INIT(name, ntoi, iton, defaultval, refs, ref2s) \
3997
- { UPB_DEF_INIT(name, UPB_DEF_ENUM, &upb_enumdef_vtbl, refs, ref2s), ntoi, \
3998
- iton, defaultval }
3999
-
4000
-
4001
- /* upb_oneofdef ***************************************************************/
4002
-
4003
- struct upb_oneofdef {
4004
- upb_refcounted base;
4005
-
4006
- uint32_t index; /* Index within oneofs. */
4007
- const char *name;
4008
- upb_strtable ntof;
4009
- upb_inttable itof;
4010
- const upb_msgdef *parent;
4011
- };
4012
-
4013
- extern const struct upb_refcounted_vtbl upb_oneofdef_vtbl;
4014
-
4015
- #define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \
4016
- { UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), 0, name, ntof, itof }
4017
-
4018
-
4019
- /* upb_symtab *****************************************************************/
4020
-
4021
- struct upb_symtab {
4022
- upb_refcounted base;
4023
-
4024
- upb_strtable symtab;
4025
- };
4026
-
4027
- struct upb_filedef {
4028
- upb_refcounted base;
4029
-
4030
- const char *name;
4031
- const char *package;
4032
- const char *phpprefix;
4033
- const char *phpnamespace;
4034
- upb_syntax_t syntax;
4035
-
4036
- upb_inttable defs;
4037
- upb_inttable deps;
4038
- };
4039
-
4040
- extern const struct upb_refcounted_vtbl upb_filedef_vtbl;
4041
-
4042
- #endif /* UPB_STATICINIT_H_ */
4043
- /*
4044
- ** upb::Handlers (upb_handlers)
4045
- **
4046
- ** A upb_handlers is like a virtual table for a upb_msgdef. Each field of the
4047
- ** message can have associated functions that will be called when we are
4048
- ** parsing or visiting a stream of data. This is similar to how handlers work
4049
- ** in SAX (the Simple API for XML).
4050
- **
4051
- ** The handlers have no idea where the data is coming from, so a single set of
4052
- ** handlers could be used with two completely different data sources (for
4053
- ** example, a parser and a visitor over in-memory objects). This decoupling is
4054
- ** the most important feature of upb, because it allows parsers and serializers
4055
- ** to be highly reusable.
4056
- **
4057
- ** This is a mixed C/C++ interface that offers a full API to both languages.
4058
- ** See the top-level README for more information.
4059
- */
4060
-
4061
- #ifndef UPB_HANDLERS_H
4062
- #define UPB_HANDLERS_H
4063
-
4064
-
4065
- #ifdef __cplusplus
4066
- namespace upb {
4067
- class BufferHandle;
4068
- class BytesHandler;
4069
- class HandlerAttributes;
4070
- class Handlers;
4071
- template <class T> class Handler;
4072
- template <class T> struct CanonicalType;
4073
- } /* namespace upb */
4074
- #endif
4075
-
4076
- UPB_DECLARE_TYPE(upb::BufferHandle, upb_bufhandle)
4077
- UPB_DECLARE_TYPE(upb::BytesHandler, upb_byteshandler)
4078
- UPB_DECLARE_TYPE(upb::HandlerAttributes, upb_handlerattr)
4079
- UPB_DECLARE_DERIVED_TYPE(upb::Handlers, upb::RefCounted,
4080
- upb_handlers, upb_refcounted)
4081
-
4082
- /* The maximum depth that the handler graph can have. This is a resource limit
4083
- * for the C stack since we sometimes need to recursively traverse the graph.
4084
- * Cycles are ok; the traversal will stop when it detects a cycle, but we must
4085
- * hit the cycle before the maximum depth is reached.
4086
- *
4087
- * If having a single static limit is too inflexible, we can add another variant
4088
- * of Handlers::Freeze that allows specifying this as a parameter. */
4089
- #define UPB_MAX_HANDLER_DEPTH 64
4090
-
4091
- /* All the different types of handlers that can be registered.
4092
- * Only needed for the advanced functions in upb::Handlers. */
4093
- typedef enum {
4094
- UPB_HANDLER_INT32,
4095
- UPB_HANDLER_INT64,
4096
- UPB_HANDLER_UINT32,
4097
- UPB_HANDLER_UINT64,
4098
- UPB_HANDLER_FLOAT,
4099
- UPB_HANDLER_DOUBLE,
4100
- UPB_HANDLER_BOOL,
4101
- UPB_HANDLER_STARTSTR,
4102
- UPB_HANDLER_STRING,
4103
- UPB_HANDLER_ENDSTR,
4104
- UPB_HANDLER_STARTSUBMSG,
4105
- UPB_HANDLER_ENDSUBMSG,
4106
- UPB_HANDLER_STARTSEQ,
4107
- UPB_HANDLER_ENDSEQ
4108
- } upb_handlertype_t;
4109
-
4110
- #define UPB_HANDLER_MAX (UPB_HANDLER_ENDSEQ+1)
4111
-
4112
- #define UPB_BREAK NULL
3970
+ #define UPB_BREAK NULL
4113
3971
 
4114
3972
  /* A convenient definition for when no closure is needed. */
4115
3973
  extern char _upb_noclosure;
@@ -4144,7 +4002,8 @@ UPB_END_EXTERN_C
4144
4002
  /* Static selectors for upb::Handlers. */
4145
4003
  #define UPB_STARTMSG_SELECTOR 0
4146
4004
  #define UPB_ENDMSG_SELECTOR 1
4147
- #define UPB_STATIC_SELECTOR_COUNT 2
4005
+ #define UPB_UNKNOWN_SELECTOR 2
4006
+ #define UPB_STATIC_SELECTOR_COUNT 3
4148
4007
 
4149
4008
  /* Static selectors for upb::BytesHandler. */
4150
4009
  #define UPB_STARTSTR_SELECTOR 0
@@ -4673,6 +4532,8 @@ UPB_BEGIN_EXTERN_C
4673
4532
  /* Native C API. */
4674
4533
 
4675
4534
  /* Handler function typedefs. */
4535
+ typedef bool upb_unknown_handlerfunc(void *c, const void *hd, const char *buf,
4536
+ size_t n);
4676
4537
  typedef bool upb_startmsg_handlerfunc(void *c, const void*);
4677
4538
  typedef bool upb_endmsg_handlerfunc(void *c, const void *, upb_status *status);
4678
4539
  typedef void* upb_startfield_handlerfunc(void *c, const void *hd);
@@ -4726,6 +4587,8 @@ const upb_status *upb_handlers_status(upb_handlers *h);
4726
4587
  void upb_handlers_clearerr(upb_handlers *h);
4727
4588
  const upb_msgdef *upb_handlers_msgdef(const upb_handlers *h);
4728
4589
  bool upb_handlers_addcleanup(upb_handlers *h, void *p, upb_handlerfree *hfree);
4590
+ bool upb_handlers_setunknown(upb_handlers *h, upb_unknown_handlerfunc *func,
4591
+ upb_handlerattr *attr);
4729
4592
 
4730
4593
  bool upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handlerfunc *func,
4731
4594
  upb_handlerattr *attr);
@@ -6295,6 +6158,18 @@ UPB_INLINE size_t upb_sink_putstring(upb_sink *s, upb_selector_t sel,
6295
6158
  return handler(s->closure, hd, buf, n, handle);
6296
6159
  }
6297
6160
 
6161
+ UPB_INLINE bool upb_sink_putunknown(upb_sink *s, const char *buf, size_t n) {
6162
+ typedef upb_unknown_handlerfunc func;
6163
+ func *handler;
6164
+ const void *hd;
6165
+ if (!s->handlers) return true;
6166
+ handler = (func *)upb_handlers_gethandler(s->handlers, UPB_UNKNOWN_SELECTOR);
6167
+
6168
+ if (!handler) return n;
6169
+ hd = upb_handlers_gethandlerdata(s->handlers, UPB_UNKNOWN_SELECTOR);
6170
+ return handler(s->closure, hd, buf, n);
6171
+ }
6172
+
6298
6173
  UPB_INLINE bool upb_sink_startmsg(upb_sink *s) {
6299
6174
  typedef upb_startmsg_handlerfunc func;
6300
6175
  func *startmsg;
@@ -6499,34 +6374,6 @@ inline bool BufferSource::PutBuffer(const char *buf, size_t len,
6499
6374
  #endif
6500
6375
 
6501
6376
  #endif
6502
- /*
6503
- ** upb::Message is a representation for protobuf messages.
6504
- **
6505
- ** However it differs from other common representations like
6506
- ** google::protobuf::Message in one key way: it does not prescribe any
6507
- ** ownership between messages and submessages, and it relies on the
6508
- ** client to delete each message/submessage/array/map at the appropriate
6509
- ** time.
6510
- **
6511
- ** A client can access a upb::Message without knowing anything about
6512
- ** ownership semantics, but to create or mutate a message a user needs
6513
- ** to implement the memory management themselves.
6514
- **
6515
- ** Currently all messages, arrays, and maps store a upb_alloc* internally.
6516
- ** Mutating operations use this when they require dynamically-allocated
6517
- ** memory. We could potentially eliminate this size overhead later by
6518
- ** letting the user flip a bit on the factory that prevents this from
6519
- ** being stored. The user would then need to use separate functions where
6520
- ** the upb_alloc* is passed explicitly. However for handlers to populate
6521
- ** such structures, they would need a place to store this upb_alloc* during
6522
- ** parsing; upb_handlers don't currently have a good way to accommodate this.
6523
- **
6524
- ** TODO: UTF-8 checking?
6525
- **/
6526
-
6527
- #ifndef UPB_MSG_H_
6528
- #define UPB_MSG_H_
6529
-
6530
6377
 
6531
6378
  #ifdef __cplusplus
6532
6379
 
@@ -6563,21 +6410,6 @@ typedef void upb_msg;
6563
6410
  * instances of this from a upb_msgfactory, and the factory always owns the
6564
6411
  * msglayout. */
6565
6412
 
6566
- /* Gets the factory for this layout */
6567
- upb_msgfactory *upb_msglayout_factory(const upb_msglayout *l);
6568
-
6569
- /* Get the msglayout for a submessage. This requires that this field is a
6570
- * submessage, ie. upb_fielddef_issubmsg(upb_msglayout_msgdef(l)) == true.
6571
- *
6572
- * Since map entry messages don't have layouts, if upb_fielddef_ismap(f) == true
6573
- * then this function will return the layout for the map's value. It requires
6574
- * that the value type of the map field is a submessage. */
6575
- const upb_msglayout *upb_msglayout_sublayout(const upb_msglayout *l,
6576
- const upb_fielddef *f);
6577
-
6578
- /* Returns the msgdef for this msglayout. */
6579
- const upb_msgdef *upb_msglayout_msgdef(const upb_msglayout *l);
6580
-
6581
6413
 
6582
6414
  /** upb_visitor ***************************************************************/
6583
6415
 
@@ -6623,6 +6455,23 @@ const upb_visitorplan *upb_msgfactory_getvisitorplan(upb_msgfactory *f,
6623
6455
  const upb_handlers *h);
6624
6456
 
6625
6457
 
6458
+ /** upb_stringview ************************************************************/
6459
+
6460
+ typedef struct {
6461
+ const char *data;
6462
+ size_t size;
6463
+ } upb_stringview;
6464
+
6465
+ UPB_INLINE upb_stringview upb_stringview_make(const char *data, size_t size) {
6466
+ upb_stringview ret;
6467
+ ret.data = data;
6468
+ ret.size = size;
6469
+ return ret;
6470
+ }
6471
+
6472
+ #define UPB_STRINGVIEW_INIT(ptr, len) {ptr, len}
6473
+
6474
+
6626
6475
  /** upb_msgval ****************************************************************/
6627
6476
 
6628
6477
  /* A union representing all possible protobuf values. Used for generic get/set
@@ -6640,10 +6489,7 @@ typedef union {
6640
6489
  const upb_msg* msg;
6641
6490
  const upb_array* arr;
6642
6491
  const void* ptr;
6643
- struct {
6644
- const char *ptr;
6645
- size_t len;
6646
- } str;
6492
+ upb_stringview str;
6647
6493
  } upb_msgval;
6648
6494
 
6649
6495
  #define ACCESSORS(name, membername, ctype) \
@@ -6670,22 +6516,12 @@ ACCESSORS(map, map, const upb_map*)
6670
6516
  ACCESSORS(msg, msg, const upb_msg*)
6671
6517
  ACCESSORS(ptr, ptr, const void*)
6672
6518
  ACCESSORS(arr, arr, const upb_array*)
6519
+ ACCESSORS(str, str, upb_stringview)
6673
6520
 
6674
6521
  #undef ACCESSORS
6675
6522
 
6676
- UPB_INLINE upb_msgval upb_msgval_str(const char *ptr, size_t len) {
6677
- upb_msgval ret;
6678
- ret.str.ptr = ptr;
6679
- ret.str.len = len;
6680
- return ret;
6681
- }
6682
-
6683
- UPB_INLINE const char* upb_msgval_getstr(upb_msgval val) {
6684
- return val.str.ptr;
6685
- }
6686
-
6687
- UPB_INLINE size_t upb_msgval_getstrlen(upb_msgval val) {
6688
- return val.str.len;
6523
+ UPB_INLINE upb_msgval upb_msgval_makestr(const char *data, size_t size) {
6524
+ return upb_msgval_str(upb_stringview_make(data, size));
6689
6525
  }
6690
6526
 
6691
6527
 
@@ -6710,19 +6546,29 @@ size_t upb_msg_sizeof(const upb_msglayout *l);
6710
6546
  * upb_msg_uninit() must be called to release internally-allocated memory
6711
6547
  * unless the allocator is an arena that does not require freeing.
6712
6548
  *
6549
+ * Please note that upb_msg_init() may return a value that is different than
6550
+ * |msg|, so you must assign the return value and not cast your memory block
6551
+ * to upb_msg* directly!
6552
+ *
6713
6553
  * Please note that upb_msg_uninit() does *not* free any submessages, maps,
6714
6554
  * or arrays referred to by this message's fields. You must free them manually
6715
- * yourself. */
6716
- void upb_msg_init(upb_msg *msg, const upb_msglayout *l, upb_alloc *a);
6717
- void upb_msg_uninit(upb_msg *msg, const upb_msglayout *l);
6555
+ * yourself.
6556
+ *
6557
+ * upb_msg_uninit returns the original memory block, which may be useful if
6558
+ * you dynamically allocated it (though upb_msg_new() would normally be more
6559
+ * appropriate in this case). */
6560
+ upb_msg *upb_msg_init(void *msg, const upb_msglayout *l, upb_alloc *a);
6561
+ void *upb_msg_uninit(upb_msg *msg, const upb_msglayout *l);
6718
6562
 
6719
6563
  /* Like upb_msg_init() / upb_msg_uninit(), except the message's memory is
6720
6564
  * allocated / freed from the given upb_alloc. */
6721
6565
  upb_msg *upb_msg_new(const upb_msglayout *l, upb_alloc *a);
6722
6566
  void upb_msg_free(upb_msg *msg, const upb_msglayout *l);
6723
6567
 
6724
- /* Returns the upb_alloc for the given message. */
6725
- upb_alloc *upb_msg_alloc(const upb_msg *msg, const upb_msglayout *l);
6568
+ /* Returns the upb_alloc for the given message.
6569
+ * TODO(haberman): get rid of this? Not sure we want to be storing this
6570
+ * for every message. */
6571
+ upb_alloc *upb_msg_alloc(const upb_msg *msg);
6726
6572
 
6727
6573
  /* Packs the tree of messages rooted at "msg" into a single hunk of memory,
6728
6574
  * allocated from the given allocator. */
@@ -6742,25 +6588,14 @@ void *upb_msg_pack(const upb_msg *msg, const upb_msglayout *l,
6742
6588
  * arenas).
6743
6589
  */
6744
6590
  upb_msgval upb_msg_get(const upb_msg *msg,
6745
- const upb_fielddef *f,
6591
+ int field_index,
6746
6592
  const upb_msglayout *l);
6747
6593
 
6748
6594
  /* May only be called for fields where upb_fielddef_haspresence(f) == true. */
6749
6595
  bool upb_msg_has(const upb_msg *msg,
6750
- const upb_fielddef *f,
6596
+ int field_index,
6751
6597
  const upb_msglayout *l);
6752
6598
 
6753
- /* Returns NULL if no field in the oneof is set. */
6754
- const upb_fielddef *upb_msg_getoneofcase(const upb_msg *msg,
6755
- const upb_oneofdef *o,
6756
- const upb_msglayout *l);
6757
-
6758
- /* Returns true if any field in the oneof is set. */
6759
- bool upb_msg_hasoneof(const upb_msg *msg,
6760
- const upb_oneofdef *o,
6761
- const upb_msglayout *l);
6762
-
6763
-
6764
6599
  /* Mutable message API. May only be called by the owner of the message who
6765
6600
  * knows its ownership scheme and how to keep it consistent. */
6766
6601
 
@@ -6768,8 +6603,8 @@ bool upb_msg_hasoneof(const upb_msg *msg,
6768
6603
  * management: if you overwrite a pointer to a msg/array/map/string without
6769
6604
  * cleaning it up (or using an arena) it will leak.
6770
6605
  */
6771
- bool upb_msg_set(upb_msg *msg,
6772
- const upb_fielddef *f,
6606
+ void upb_msg_set(upb_msg *msg,
6607
+ int field_index,
6773
6608
  upb_msgval val,
6774
6609
  const upb_msglayout *l);
6775
6610
 
@@ -6780,12 +6615,7 @@ bool upb_msg_set(upb_msg *msg,
6780
6615
  * arrays/maps/strings/msgs that this field may have pointed to.
6781
6616
  */
6782
6617
  bool upb_msg_clearfield(upb_msg *msg,
6783
- const upb_fielddef *f,
6784
- const upb_msglayout *l);
6785
-
6786
- /* Clears all fields in the oneof such that none of them are set. */
6787
- bool upb_msg_clearoneof(upb_msg *msg,
6788
- const upb_oneofdef *o,
6618
+ int field_index,
6789
6619
  const upb_msglayout *l);
6790
6620
 
6791
6621
  /* TODO(haberman): copyfrom()/mergefrom()? */
@@ -6898,9 +6728,288 @@ bool upb_msg_getscalarhandlerdata(const upb_handlers *h,
6898
6728
  size_t *offset,
6899
6729
  int32_t *hasbit);
6900
6730
 
6731
+
6732
+ /** Interfaces for generated code *********************************************/
6733
+
6734
+ #define UPB_NOT_IN_ONEOF UINT16_MAX
6735
+ #define UPB_NO_HASBIT UINT16_MAX
6736
+ #define UPB_NO_SUBMSG UINT16_MAX
6737
+
6738
+ typedef struct {
6739
+ uint32_t number;
6740
+ uint32_t offset; /* If in a oneof, offset of default in default_msg below. */
6741
+ uint16_t hasbit; /* UPB_NO_HASBIT if no hasbit. */
6742
+ uint16_t oneof_index; /* UPB_NOT_IN_ONEOF if not in a oneof. */
6743
+ uint16_t submsg_index; /* UPB_NO_SUBMSG if no submsg. */
6744
+ uint8_t type;
6745
+ uint8_t label;
6746
+ } upb_msglayout_fieldinit_v1;
6747
+
6748
+ typedef struct {
6749
+ uint32_t data_offset;
6750
+ uint32_t case_offset;
6751
+ } upb_msglayout_oneofinit_v1;
6752
+
6753
+ typedef struct upb_msglayout_msginit_v1 {
6754
+ const struct upb_msglayout_msginit_v1 *const* submsgs;
6755
+ const upb_msglayout_fieldinit_v1 *fields;
6756
+ const upb_msglayout_oneofinit_v1 *oneofs;
6757
+ void *default_msg;
6758
+ /* Must be aligned to sizeof(void*). Doesn't include internal members like
6759
+ * unknown fields, extension dict, pointer to msglayout, etc. */
6760
+ uint32_t size;
6761
+ uint16_t field_count;
6762
+ uint16_t oneof_count;
6763
+ bool extendable;
6764
+ bool is_proto2;
6765
+ } upb_msglayout_msginit_v1;
6766
+
6767
+ #define UPB_ALIGN_UP_TO(val, align) ((val + (align - 1)) & -align)
6768
+ #define UPB_ALIGNED_SIZEOF(type) UPB_ALIGN_UP_TO(sizeof(type), sizeof(void*))
6769
+
6770
+ /* Initialize/uninitialize a msglayout from a msginit. If upb uses v1
6771
+ * internally, this will not allocate any memory. Should only be used by
6772
+ * generated code. */
6773
+ upb_msglayout *upb_msglayout_frominit_v1(
6774
+ const upb_msglayout_msginit_v1 *init, upb_alloc *a);
6775
+ void upb_msglayout_uninit_v1(upb_msglayout *layout, upb_alloc *a);
6776
+
6901
6777
  UPB_END_EXTERN_C
6902
6778
 
6903
6779
  #endif /* UPB_MSG_H_ */
6780
+
6781
+ UPB_BEGIN_EXTERN_C
6782
+
6783
+ bool upb_decode(upb_stringview buf, void *msg,
6784
+ const upb_msglayout_msginit_v1 *l, upb_env *env);
6785
+
6786
+ UPB_END_EXTERN_C
6787
+
6788
+ #endif /* UPB_DECODE_H_ */
6789
+ /*
6790
+ ** structs.int.h: structures definitions that are internal to upb.
6791
+ */
6792
+
6793
+ #ifndef UPB_STRUCTS_H_
6794
+ #define UPB_STRUCTS_H_
6795
+
6796
+ struct upb_array {
6797
+ upb_fieldtype_t type;
6798
+ uint8_t element_size;
6799
+ void *data; /* Each element is element_size. */
6800
+ size_t len; /* Measured in elements. */
6801
+ size_t size; /* Measured in elements. */
6802
+ upb_alloc *alloc;
6803
+ };
6804
+
6805
+ #endif /* UPB_STRUCTS_H_ */
6806
+
6807
+ /*
6808
+ ** This file contains definitions of structs that should be considered private
6809
+ ** and NOT stable across versions of upb.
6810
+ **
6811
+ ** The only reason they are declared here and not in .c files is to allow upb
6812
+ ** and the application (if desired) to embed statically-initialized instances
6813
+ ** of structures like defs.
6814
+ **
6815
+ ** If you include this file, all guarantees of ABI compatibility go out the
6816
+ ** window! Any code that includes this file needs to recompile against the
6817
+ ** exact same version of upb that they are linking against.
6818
+ **
6819
+ ** You also need to recompile if you change the value of the UPB_DEBUG_REFS
6820
+ ** flag.
6821
+ */
6822
+
6823
+
6824
+ #ifndef UPB_STATICINIT_H_
6825
+ #define UPB_STATICINIT_H_
6826
+
6827
+ #ifdef __cplusplus
6828
+ /* Because of how we do our typedefs, this header can't be included from C++. */
6829
+ #error This file cannot be included from C++
6830
+ #endif
6831
+
6832
+ /* upb_refcounted *************************************************************/
6833
+
6834
+
6835
+ /* upb_def ********************************************************************/
6836
+
6837
+ struct upb_def {
6838
+ upb_refcounted base;
6839
+
6840
+ const char *fullname;
6841
+ const upb_filedef* file;
6842
+ char type; /* A upb_deftype_t (char to save space) */
6843
+
6844
+ /* Used as a flag during the def's mutable stage. Must be false unless
6845
+ * it is currently being used by a function on the stack. This allows
6846
+ * us to easily determine which defs were passed into the function's
6847
+ * current invocation. */
6848
+ bool came_from_user;
6849
+ };
6850
+
6851
+ #define UPB_DEF_INIT(name, type, vtbl, refs, ref2s) \
6852
+ { UPB_REFCOUNT_INIT(vtbl, refs, ref2s), name, NULL, type, false }
6853
+
6854
+
6855
+ /* upb_fielddef ***************************************************************/
6856
+
6857
+ struct upb_fielddef {
6858
+ upb_def base;
6859
+
6860
+ union {
6861
+ int64_t sint;
6862
+ uint64_t uint;
6863
+ double dbl;
6864
+ float flt;
6865
+ void *bytes;
6866
+ } defaultval;
6867
+ union {
6868
+ const upb_msgdef *def; /* If !msg_is_symbolic. */
6869
+ char *name; /* If msg_is_symbolic. */
6870
+ } msg;
6871
+ union {
6872
+ const upb_def *def; /* If !subdef_is_symbolic. */
6873
+ char *name; /* If subdef_is_symbolic. */
6874
+ } sub; /* The msgdef or enumdef for this field, if upb_hassubdef(f). */
6875
+ bool subdef_is_symbolic;
6876
+ bool msg_is_symbolic;
6877
+ const upb_oneofdef *oneof;
6878
+ bool default_is_string;
6879
+ bool type_is_set_; /* False until type is explicitly set. */
6880
+ bool is_extension_;
6881
+ bool lazy_;
6882
+ bool packed_;
6883
+ upb_intfmt_t intfmt;
6884
+ bool tagdelim;
6885
+ upb_fieldtype_t type_;
6886
+ upb_label_t label_;
6887
+ uint32_t number_;
6888
+ uint32_t selector_base; /* Used to index into a upb::Handlers table. */
6889
+ uint32_t index_;
6890
+ };
6891
+
6892
+ extern const struct upb_refcounted_vtbl upb_fielddef_vtbl;
6893
+
6894
+ #define UPB_FIELDDEF_INIT(label, type, intfmt, tagdelim, is_extension, lazy, \
6895
+ packed, name, num, msgdef, subdef, selector_base, \
6896
+ index, defaultval, refs, ref2s) \
6897
+ { \
6898
+ UPB_DEF_INIT(name, UPB_DEF_FIELD, &upb_fielddef_vtbl, refs, ref2s), \
6899
+ defaultval, {msgdef}, {subdef}, NULL, false, false, \
6900
+ type == UPB_TYPE_STRING || type == UPB_TYPE_BYTES, true, is_extension, \
6901
+ lazy, packed, intfmt, tagdelim, type, label, num, selector_base, index \
6902
+ }
6903
+
6904
+
6905
+ /* upb_msgdef *****************************************************************/
6906
+
6907
+ struct upb_msgdef {
6908
+ upb_def base;
6909
+
6910
+ size_t selector_count;
6911
+ uint32_t submsg_field_count;
6912
+
6913
+ /* Tables for looking up fields by number and name. */
6914
+ upb_inttable itof; /* int to field */
6915
+ upb_strtable ntof; /* name to field/oneof */
6916
+
6917
+ /* Is this a map-entry message? */
6918
+ bool map_entry;
6919
+
6920
+ /* Whether this message has proto2 or proto3 semantics. */
6921
+ upb_syntax_t syntax;
6922
+
6923
+ /* TODO(haberman): proper extension ranges (there can be multiple). */
6924
+ };
6925
+
6926
+ extern const struct upb_refcounted_vtbl upb_msgdef_vtbl;
6927
+
6928
+ /* TODO: also support static initialization of the oneofs table. This will be
6929
+ * needed if we compile in descriptors that contain oneofs. */
6930
+ #define UPB_MSGDEF_INIT(name, selector_count, submsg_field_count, itof, ntof, \
6931
+ map_entry, syntax, refs, ref2s) \
6932
+ { \
6933
+ UPB_DEF_INIT(name, UPB_DEF_MSG, &upb_fielddef_vtbl, refs, ref2s), \
6934
+ selector_count, submsg_field_count, itof, ntof, map_entry, syntax \
6935
+ }
6936
+
6937
+
6938
+ /* upb_enumdef ****************************************************************/
6939
+
6940
+ struct upb_enumdef {
6941
+ upb_def base;
6942
+
6943
+ upb_strtable ntoi;
6944
+ upb_inttable iton;
6945
+ int32_t defaultval;
6946
+ };
6947
+
6948
+ extern const struct upb_refcounted_vtbl upb_enumdef_vtbl;
6949
+
6950
+ #define UPB_ENUMDEF_INIT(name, ntoi, iton, defaultval, refs, ref2s) \
6951
+ { UPB_DEF_INIT(name, UPB_DEF_ENUM, &upb_enumdef_vtbl, refs, ref2s), ntoi, \
6952
+ iton, defaultval }
6953
+
6954
+
6955
+ /* upb_oneofdef ***************************************************************/
6956
+
6957
+ struct upb_oneofdef {
6958
+ upb_refcounted base;
6959
+
6960
+ uint32_t index; /* Index within oneofs. */
6961
+ const char *name;
6962
+ upb_strtable ntof;
6963
+ upb_inttable itof;
6964
+ const upb_msgdef *parent;
6965
+ };
6966
+
6967
+ extern const struct upb_refcounted_vtbl upb_oneofdef_vtbl;
6968
+
6969
+ #define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \
6970
+ { UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), 0, name, ntof, itof }
6971
+
6972
+
6973
+ /* upb_symtab *****************************************************************/
6974
+
6975
+ struct upb_symtab {
6976
+ upb_refcounted base;
6977
+
6978
+ upb_strtable symtab;
6979
+ };
6980
+
6981
+ struct upb_filedef {
6982
+ upb_refcounted base;
6983
+
6984
+ const char *name;
6985
+ const char *package;
6986
+ const char *phpprefix;
6987
+ const char *phpnamespace;
6988
+ upb_syntax_t syntax;
6989
+
6990
+ upb_inttable defs;
6991
+ upb_inttable deps;
6992
+ };
6993
+
6994
+ extern const struct upb_refcounted_vtbl upb_filedef_vtbl;
6995
+
6996
+ #endif /* UPB_STATICINIT_H_ */
6997
+ /*
6998
+ ** upb_encode: parsing into a upb_msg using a upb_msglayout.
6999
+ */
7000
+
7001
+ #ifndef UPB_ENCODE_H_
7002
+ #define UPB_ENCODE_H_
7003
+
7004
+
7005
+ UPB_BEGIN_EXTERN_C
7006
+
7007
+ char *upb_encode(const void *msg, const upb_msglayout_msginit_v1 *l,
7008
+ upb_env *env, size_t *size);
7009
+
7010
+ UPB_END_EXTERN_C
7011
+
7012
+ #endif /* UPB_ENCODE_H_ */
6904
7013
  /*
6905
7014
  ** upb::descriptor::Reader (upb_descreader)
6906
7015
  **
@@ -8290,21 +8399,9 @@ UPB_INLINE void upb_pbdecoder_unpackdispatch(uint64_t dispatch, uint64_t *ofs,
8290
8399
  extern "C" {
8291
8400
  #endif
8292
8401
 
8293
- /* A list of types as they are encoded on-the-wire. */
8294
- typedef enum {
8295
- UPB_WIRE_TYPE_VARINT = 0,
8296
- UPB_WIRE_TYPE_64BIT = 1,
8297
- UPB_WIRE_TYPE_DELIMITED = 2,
8298
- UPB_WIRE_TYPE_START_GROUP = 3,
8299
- UPB_WIRE_TYPE_END_GROUP = 4,
8300
- UPB_WIRE_TYPE_32BIT = 5
8301
- } upb_wiretype_t;
8302
-
8303
8402
  #define UPB_MAX_WIRE_TYPE 5
8304
8403
 
8305
- /* The maximum number of bytes that it takes to encode a 64-bit varint.
8306
- * Note that with a better encoding this could be 9 (TODO: write up a
8307
- * wiki document about this). */
8404
+ /* The maximum number of bytes that it takes to encode a 64-bit varint. */
8308
8405
  #define UPB_PB_VARINT_MAX_LEN 10
8309
8406
 
8310
8407
  /* Array of the "native" (ie. non-packed-repeated) wire type for the given a