According to google protobuf documentation:
https://developers.google.com/protocol-buffers/docs/encoding#optional
"... For embedded message fields, the parser merges multiple instances of the
same field, as if with the Message::MergeFrom method – that is, all singular
scalar fields in the latter instance replace those in the former, singular
embedded messages are merged, and repeated fields are concatenated ..."
But protobuf-c replaces submessage field with last value.
What steps will reproduce the problem?
1. Source
test.proto:
----------
message MergeTest {
message SubMessage {
optional uint32 f1 = 1;
optional uint32 f2 = 2;
}
optional SubMessage submsg = 5;
}
----------
test.c:
----------
#include <stdio.h>
#include <stdlib.h>
#include "test.pb-c.h"
uint8_t MERGE_TEST[11] = { 0x2a,0x4,0x8,0xa,0x10,0x2a,0x2a,0x3,0x8,0x89,0x6 };
/*
MergeTest(submsg=SubMessage(f1=10, f2=42)) +
MergeTest(submsg=SubMessage(f1=777))
*/
int main() {
MergeTest* m = merge_test__unpack(NULL, sizeof(MERGE_TEST), MERGE_TEST);
printf("m->submsg->f1: %d\nm->submsg->f2: %d\n", m->submsg->f1, m->submsg->f2);
}
----------
2. Compile and execute
What is the expected output? What do you see instead?
----------
m->submsg->f1: 777
m->submsg->f2: 0
----------
instead of f1=777,f2=42
What version of the product are you using? On what operating system?
protobuf-c 0.15
Please provide any additional information below.
Original issue reported on code.google.com by r.lomono...@gmail.com on 16 Nov 2012 at 6:28
Original issue reported on code.google.com by
r.lomono...@gmail.com
on 16 Nov 2012 at 6:28