summaryrefslogtreecommitdiffstats
path: root/pb.h
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@github.mail.kapsi.fi>2016-10-10 07:20:49 +0300
committerGitHub <noreply@github.com>2016-10-10 07:20:49 +0300
commit060e6a6cc21eaf555cba6d3ee2558527e6790a5f (patch)
tree36020dd4606d4c9eba3c88c8827c5ebf19641393 /pb.h
parent91bb64a47b36b112c9b22391ef76fab29cf2cffc (diff)
parentee44d0cee9fa87891fdc5371578f6ff3974a8d59 (diff)
Merge pull request #216 from berni155/proto3_singular_fields_support
Proto3 singular fields support
Diffstat (limited to 'pb.h')
-rw-r--r--pb.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/pb.h b/pb.h
index 4576f79a..0e1e92d5 100644
--- a/pb.h
+++ b/pb.h
@@ -413,6 +413,10 @@ struct pb_extension_s {
pb_delta(st, has_ ## m, m), \
pb_membersize(st, m), 0, ptr}
+#define PB_SINGULAR_STATIC(tag, st, m, fd, ltype, ptr) \
+ {tag, PB_ATYPE_STATIC | PB_HTYPE_OPTIONAL | ltype, \
+ fd, 0, pb_membersize(st, m), 0, ptr}
+
/* Repeated fields have a _count field and also the maximum number of entries. */
#define PB_REPEATED_STATIC(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_STATIC | PB_HTYPE_REPEATED | ltype, \
@@ -444,6 +448,11 @@ struct pb_extension_s {
{tag, PB_ATYPE_POINTER | PB_HTYPE_OPTIONAL | ltype, \
fd, 0, pb_membersize(st, m[0]), 0, ptr}
+/* Same as optional fields*/
+#define PB_SINGULAR_POINTER(tag, st, m, fd, ltype, ptr) \
+ {tag, PB_ATYPE_POINTER | PB_HTYPE_OPTIONAL | ltype, \
+ fd, 0, pb_membersize(st, m[0]), 0, ptr}
+
/* Repeated fields have a _count field and a pointer to array of pointers */
#define PB_REPEATED_POINTER(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_POINTER | PB_HTYPE_REPEATED | ltype, \
@@ -458,6 +467,10 @@ struct pb_extension_s {
#define PB_OPTIONAL_CALLBACK(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_CALLBACK | PB_HTYPE_OPTIONAL | ltype, \
fd, 0, pb_membersize(st, m), 0, ptr}
+
+#define PB_SINGULAR_CALLBACK(tag, st, m, fd, ltype, ptr) \
+ {tag, PB_ATYPE_CALLBACK | PB_HTYPE_OPTIONAL | ltype, \
+ fd, 0, pb_membersize(st, m), 0, ptr}
#define PB_REPEATED_CALLBACK(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_CALLBACK | PB_HTYPE_REPEATED | ltype, \