mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-28 14:48:18 +08:00
Issue 20: Update for UnknownField API change (by dcreager).
See: http://code.google.com/p/protobuf-c/issues/detail?id=20 git-svn-id: https://protobuf-c.googlecode.com/svn/trunk@188 00440858-1255-0410-a3e6-75ea37f81c3a
This commit is contained in:
parent
38d89f78ba
commit
03e11c4fa6
@ -757,18 +757,32 @@ static void dump_test_unknown_fields (void)
|
|||||||
EmptyMess mess;
|
EmptyMess mess;
|
||||||
const google::protobuf::Message::Reflection *reflection = mess.GetReflection();
|
const google::protobuf::Message::Reflection *reflection = mess.GetReflection();
|
||||||
google::protobuf::UnknownFieldSet *fs = reflection->MutableUnknownFields(&mess);
|
google::protobuf::UnknownFieldSet *fs = reflection->MutableUnknownFields(&mess);
|
||||||
|
|
||||||
|
#if PROTOC_VERSION >= 2001000
|
||||||
|
fs->AddVarint(5454, 255);
|
||||||
|
fs->AddFixed32(5555, 260);
|
||||||
|
#else
|
||||||
google::protobuf::UnknownField *f;
|
google::protobuf::UnknownField *f;
|
||||||
f = fs->AddField(5454);
|
f = fs->AddField(5454);
|
||||||
f->add_varint(255);
|
f->add_varint(255);
|
||||||
f = fs->AddField(5555);
|
f = fs->AddField(5555);
|
||||||
f->add_fixed32(260);
|
f->add_fixed32(260);
|
||||||
|
#endif
|
||||||
|
|
||||||
dump_message_bytes (&mess, "test_unknown_fields_0");
|
dump_message_bytes (&mess, "test_unknown_fields_0");
|
||||||
|
|
||||||
fs->Clear();
|
fs->Clear();
|
||||||
|
|
||||||
|
#if PROTOC_VERSION >= 2001000
|
||||||
|
fs->AddLengthDelimited(6666, "xxxxxxxx");
|
||||||
|
fs->AddFixed64(7777, 0x10101);
|
||||||
|
#else
|
||||||
f = fs->AddField(6666);
|
f = fs->AddField(6666);
|
||||||
f->add_length_delimited("xxxxxxxx");
|
f->add_length_delimited("xxxxxxxx");
|
||||||
f = fs->AddField(7777);
|
f = fs->AddField(7777);
|
||||||
f->add_fixed64(0x10101);
|
f->add_fixed64(0x10101);
|
||||||
|
#endif
|
||||||
|
|
||||||
dump_message_bytes (&mess, "test_unknown_fields_1");
|
dump_message_bytes (&mess, "test_unknown_fields_1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user