aboutsummaryrefslogtreecommitdiffstats
path: root/pb_common.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-01-04 19:39:37 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-01-04 19:39:37 +0200
commit7713d43bc3d448358a04393c4e44dd12a768bdea (patch)
tree140573b1d78947739e5f46721d681a580a4d3030 /pb_common.c
parenta0f0440394ac3b38105dfad09366f95011c5d8d3 (diff)
Implement support for oneofs (C unions).
Basic test included, should probably add an oneof to the AllTypes test also. Update issue 131 Status: Started
Diffstat (limited to 'pb_common.c')
-rw-r--r--pb_common.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/pb_common.c b/pb_common.c
index a9cade63..98964850 100644
--- a/pb_common.c
+++ b/pb_common.c
@@ -54,6 +54,13 @@ bool pb_field_iter_next(pb_field_iter_t *iter)
* The data_size only applies to the dynamically allocated area. */
prev_size = sizeof(void*);
}
+ else if (PB_HTYPE(prev_field->type) == PB_HTYPE_ONEOF &&
+ PB_HTYPE(iter->pos->type) == PB_HTYPE_ONEOF)
+ {
+ /* Don't advance pointers inside unions */
+ prev_size = 0;
+ iter->pData = (char*)iter->pData - prev_field->data_offset;
+ }
if (PB_HTYPE(prev_field->type) == PB_HTYPE_REQUIRED)
{