Skip to content

Commit

Permalink
Final (I hope) fix for external structure redefine
Browse files Browse the repository at this point in the history
  • Loading branch information
billvaglienti committed Feb 27, 2023
1 parent a32f13f commit a30fc3d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
40 changes: 36 additions & 4 deletions protocolfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2943,7 +2943,15 @@ std::string ProtocolField::getTextPrintString(void) const
if(inMemoryType.isStruct)
{
if(support.language == ProtocolSupport::c_language)
output += spacing + "_pg_report += textPrint" + typeName + "(_pg_prename + \":" + name + "\"";
{
// In case of a structure redefines
std::string signame = typeName;
const ProtocolStructure* mystruct = parser->lookUpStructure(typeName);
if(mystruct != nullptr)
signame = mystruct->getStructName();

output += spacing + "_pg_report += textPrint" + signame + "(_pg_prename + \":" + name + "\"";
}
else
output += spacing + "_pg_report += " + getEncodeFieldAccess(true) + ".textPrint(_pg_prename + \":" + name + "\"";

Expand Down Expand Up @@ -3027,7 +3035,15 @@ std::string ProtocolField::getTextReadString(void) const
if(inMemoryType.isStruct)
{
if(support.language == ProtocolSupport::c_language)
output += spacing + "_pg_fieldcount += textRead" + typeName + "(_pg_prename + \":" + name + "\"";
{
// In case of a structure redefines
std::string signame = typeName;
const ProtocolStructure* mystruct = parser->lookUpStructure(typeName);
if(mystruct != nullptr)
signame = mystruct->getStructName();

output += spacing + "_pg_fieldcount += textRead" + signame + "(_pg_prename + \":" + name + "\"";
}
else
output += spacing + "_pg_fieldcount += " + getDecodeFieldAccess(true) + ".textRead(_pg_prename + \":" + name + "\"";

Expand Down Expand Up @@ -3141,7 +3157,15 @@ std::string ProtocolField::getMapEncodeString(void) const
if(inMemoryType.isStruct)
{
if(support.language == ProtocolSupport::c_language)
output += spacing + "mapEncode" + typeName + "(_pg_prename + \":" + name + "\"";
{
// In case of a structure redefines
std::string signame = typeName;
const ProtocolStructure* mystruct = parser->lookUpStructure(typeName);
if(mystruct != nullptr)
signame = mystruct->getStructName();

output += spacing + "mapEncode" + signame + "(_pg_prename + \":" + name + "\"";
}
else
output += spacing + getEncodeFieldAccess(true) + ".mapEncode(_pg_prename + \":" + name + "\"";

Expand Down Expand Up @@ -3240,7 +3264,15 @@ std::string ProtocolField::getMapDecodeString(void) const
if(inMemoryType.isStruct)
{
if(support.language == ProtocolSupport::c_language)
output += spacing + "mapDecode" + typeName + "(_pg_prename + \":" + name + "\"";
{
// In case of a structure redefines
std::string signame = typeName;
const ProtocolStructure* mystruct = parser->lookUpStructure(typeName);
if(mystruct != nullptr)
signame = mystruct->getStructName();

output += spacing + "mapDecode" + signame + "(_pg_prename + \":" + name + "\"";
}
else
output += spacing + getDecodeFieldAccess(true) + ".mapDecode(_pg_prename + \":" + name + "\"";

Expand Down
2 changes: 1 addition & 1 deletion protocolparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <fstream>

// The version of the protocol generator is set here
const std::string ProtocolParser::genVersion = "3.5.c";
const std::string ProtocolParser::genVersion = "3.5.d";

/*!
* \brief ProtocolParser::ProtocolParser
Expand Down

0 comments on commit a30fc3d

Please sign in to comment.