Implement support for oneofs (C unions).

Basic test included, should probably add an oneof to the AllTypes test also.

Update issue 131
Status: Started
This commit is contained in:
Petteri Aimonen
2015-01-04 19:39:37 +02:00
parent a0f0440394
commit 7713d43bc3
9 changed files with 415 additions and 73 deletions

View File

@@ -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)
{