Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nanopb/nanopb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/pb.h
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-07-22 19:59:15 +0400
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-07-22 19:59:15 +0400
commit1f13e8cd2c5bb091677f35e53ae5757774e7d1ba (patch)
tree99bfe3fcafe147f514f00128615a0a7b850d53ea /pb.h
parent64947cb382271e2ab17dbf40ab634846d7d30ad9 (diff)
Fix bugs in extension support when multiple extension fields are present.
Diffstat (limited to 'pb.h')
-rw-r--r--pb.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/pb.h b/pb.h
index da38d7b..bb0a584 100644
--- a/pb.h
+++ b/pb.h
@@ -364,6 +364,17 @@ struct _pb_extension_t {
{tag, PB_ATYPE_CALLBACK | PB_HTYPE_REPEATED | ltype, \
pb_delta_end(st, m, pm), 0, pb_membersize(st, m), 0, ptr}
+/* Optional extensions don't have the has_ field, as that would be redundant. */
+#define PB_OPTEXT_STATIC(tag, st, m, pm, ltype, ptr) \
+ {tag, PB_ATYPE_STATIC | PB_HTYPE_OPTIONAL | ltype, \
+ 0, \
+ 0, \
+ pb_membersize(st, m), 0, ptr}
+
+#define PB_OPTEXT_CALLBACK(tag, st, m, pm, ltype, ptr) \
+ {tag, PB_ATYPE_CALLBACK | PB_HTYPE_OPTIONAL | ltype, \
+ 0, 0, pb_membersize(st, m), 0, ptr}
+
/* The mapping from protobuf types to LTYPEs is done using these macros. */
#define PB_LTYPE_MAP_BOOL PB_LTYPE_VARINT
#define PB_LTYPE_MAP_BYTES PB_LTYPE_BYTES