aboutsummaryrefslogtreecommitdiffstats
path: root/pb.h
diff options
context:
space:
mode:
authorBenjamin Kamath <ben.kamath@synapse.com>2015-11-04 16:42:25 -0800
committerBenjamin Kamath <ben.kamath@synapse.com>2015-11-10 22:35:46 -0800
commit9a8cc59703b227ff418cc55b4dc24f63eda64b62 (patch)
tree46fc92a7ef1021610386802a2616d05caad84e91 /pb.h
parent6c136580a091a30e94aaebd66dd978117d999ad0 (diff)
Add option to allow for anonymous unions
Diffstat (limited to 'pb.h')
-rw-r--r--pb.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/pb.h b/pb.h
index 98613a0..0286b85 100644
--- a/pb.h
+++ b/pb.h
@@ -518,10 +518,25 @@ struct pb_extension_s {
pb_membersize(st, u.m[0]), 0, ptr}
#define PB_ONEOF_FIELD(union_name, tag, type, rules, allocation, placement, message, field, prevfield, ptr) \
- PB_ ## rules ## _ ## allocation(union_name, tag, message, field, \
+ PB_ ## ONEOF_ ## allocation(union_name, tag, message, field, \
PB_DATAOFFSET_ ## placement(message, union_name.field, prevfield), \
PB_LTYPE_MAP_ ## type, ptr)
+#define PB_ANONYMOUS_ONEOF_STATIC(u, tag, st, m, fd, ltype, ptr) \
+ {tag, PB_ATYPE_STATIC | PB_HTYPE_ONEOF | ltype, \
+ fd, pb_delta(st, which_ ## u, m), \
+ pb_membersize(st, m), 0, ptr}
+
+#define PB_ANONYMOUS_ONEOF_POINTER(u, tag, st, m, fd, ltype, ptr) \
+ {tag, PB_ATYPE_POINTER | PB_HTYPE_ONEOF | ltype, \
+ fd, pb_delta(st, which_ ## u, m), \
+ pb_membersize(st, m[0]), 0, ptr}
+
+#define PB_ANONYMOUS_ONEOF_FIELD(union_name, tag, type, rules, allocation, placement, message, field, prevfield, ptr) \
+ PB_ ## ANONYMOUS_ONEOF_ ## allocation(union_name, tag, message, field, \
+ PB_DATAOFFSET_ ## placement(message, field, prevfield), \
+ PB_LTYPE_MAP_ ## type, ptr)
+
/* These macros are used for giving out error messages.
* They are mostly a debugging aid; the main error information
* is the true/false return value from functions.