Bugfix: Variable fields related code is now generated correctly when saving a stream as a python script

Fixes #158
This commit is contained in:
Srivats P 2015-10-02 13:49:54 +05:30
parent dbf91934a8
commit 7f224f61cd

View File

@ -80,9 +80,8 @@ bool PythonFileFormat::saveStreams(const OstProto::StreamConfigList streams,
refl->ListFields(protocol, &fields);
for (uint k = 0; k < fields.size(); k++) {
// skip protocol_id field
if (fields.at(k)->number() ==
OstProto::Protocol::kProtocolIdFieldNumber)
// skip non extension fields
if (!fields.at(k)->is_extension())
continue;
if (fields.at(k)->file()->name() !=
@ -199,7 +198,8 @@ bool PythonFileFormat::saveStreams(const OstProto::StreamConfigList streams,
OstProto::Protocol::kProtocolIdFieldNumber)
continue;
QString pfx(" p.Extensions[X]");
pfx.replace("X", fields.at(k)->name().c_str());
pfx.replace(fields.at(k)->is_extension()? "X": "Extensions[X]",
fields.at(k)->name().c_str());
writeFieldAssignment(out, pfx, protocol,
refl, fields.at(k));
}