Revert the change to wire_format.h.
It seems too much code relies on the broken behaviour. See issue #493. Instead, we reimplement MakeTag just for C#, temporarily.
This commit is contained in:
parent
bfee2dfe13
commit
322ec53161
@ -57,7 +57,7 @@ void FieldGeneratorBase::SetCommonFieldVariables(
|
||||
// repeated fields varies by wire format. The wire format is encoded in the bottom 3 bits, which
|
||||
// never effects the tag size.
|
||||
int tag_size = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type());
|
||||
uint tag = internal::WireFormat::MakeTag(descriptor_);
|
||||
uint tag = FixedMakeTag(descriptor_);
|
||||
uint8 tag_array[5];
|
||||
io::CodedOutputStream::WriteTagToArray(tag, tag_array);
|
||||
string tag_bytes = SimpleItoa(tag_array[0]);
|
||||
|
@ -338,6 +338,17 @@ std::string FileDescriptorToBase64(const FileDescriptor* descriptor) {
|
||||
return StringToBase64(fdp_bytes);
|
||||
}
|
||||
|
||||
// TODO(jonskeet): Remove this when internal::WireFormat::MakeTag works
|
||||
// properly...
|
||||
// Workaround for issue #493
|
||||
uint FixedMakeTag(const FieldDescriptor* field) {
|
||||
internal::WireFormatLite::WireType field_type = field->is_packed()
|
||||
? internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED
|
||||
: internal::WireFormat::WireTypeForFieldType(field->type());
|
||||
|
||||
return internal::WireFormatLite::MakeTag(field->number(), field_type);
|
||||
}
|
||||
|
||||
FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor,
|
||||
int fieldOrdinal) {
|
||||
switch (descriptor->type()) {
|
||||
|
@ -97,6 +97,8 @@ std::string StringToBase64(const std::string& input);
|
||||
|
||||
std::string FileDescriptorToBase64(const FileDescriptor* descriptor);
|
||||
|
||||
uint FixedMakeTag(const FieldDescriptor* descriptor);
|
||||
|
||||
FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal);
|
||||
|
||||
bool HasRequiredFields(const Descriptor* descriptor);
|
||||
|
@ -194,8 +194,7 @@ void MessageGenerator::Generate(io::Printer* printer) {
|
||||
"slash", field_names().size() > 0 ? "\"" : "");
|
||||
std::vector<std::string> tags;
|
||||
for (int i = 0; i < field_names().size(); i++) {
|
||||
uint32 tag = internal::WireFormat::MakeTag(
|
||||
descriptor_->FindFieldByName(field_names()[i]));
|
||||
uint32 tag = FixedMakeTag(descriptor_->FindFieldByName(field_names()[i]));
|
||||
tags.push_back(SimpleItoa(tag));
|
||||
}
|
||||
printer->Print(
|
||||
|
@ -290,7 +290,7 @@ class LIBPROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper {
|
||||
|
||||
inline WireFormatLite::WireType WireFormat::WireTypeForField(
|
||||
const FieldDescriptor* field) {
|
||||
if (field->is_packed()) {
|
||||
if (field->options().packed()) {
|
||||
return WireFormatLite::WIRETYPE_LENGTH_DELIMITED;
|
||||
} else {
|
||||
return WireTypeForFieldType(field->type());
|
||||
|
Loading…
Reference in New Issue
Block a user