Skip to content

Commit

Permalink
More fixes to referencing a redefined external structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
billvaglienti committed Feb 26, 2023
1 parent 17a8c0f commit a32f13f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
49 changes: 45 additions & 4 deletions protocolfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2217,16 +2217,57 @@ void ProtocolField::getPrintIncludeDirectives(std::vector<std::string>& list) co
*/
std::string ProtocolField::getEncodeSignature(void) const
{
std::string signame = typeName;

// It is possible that this structure name is a redefined structure,
// in which case we have to lookup the base structure name.
if(inMemoryType.isStruct)
{
const ProtocolStructure* mystruct = parser->lookUpStructure(typeName);
if(mystruct != nullptr)
signame = mystruct->getStructName();
}

if(isNotEncoded() || isNotInMemory() || isConstant())
return "";
else if(is2dArray())
return ", const " + typeName + " " + name + "[" + array + "][" + array2d + "]";
return ", const " + signame + " " + name + "[" + array + "][" + array2d + "]";
else if(isArray())
return ", const " + typeName + " " + name + "[" + array + "]";
return ", const " + signame + " " + name + "[" + array + "]";
else if(!inMemoryType.isStruct)
return ", " + typeName + " " + name;
return ", " + signame + " " + name;
else
return ", const " + signame + "* " + name;
}


/*!
* Return the signature of this field in a decode function signature. The
* string will start with ", " assuming this field is not the first part of
* the function signature.
* \return the string that provides this fields decode function signature
*/
std::string ProtocolField::getDecodeSignature(void) const
{
std::string signame = typeName;

// It is possible that this structure name is a redefined structure,
// in which case we have to lookup the base structure name.
if(inMemoryType.isStruct)
{
const ProtocolStructure* mystruct = parser->lookUpStructure(typeName);
if(mystruct != nullptr)
signame = mystruct->getStructName();
}

if(isNotEncoded() || isNotInMemory())
return "";
else if(is2dArray())
return ", " + signame + " " + name + "[" + array + "][" + array2d + "]";
else if(isArray())
return ", " + signame + " " + name + "[" + array + "]";
else
return ", const " + typeName + "* " + name;
return ", " + signame + "* " + name;
}


Expand Down
3 changes: 3 additions & 0 deletions protocolfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ class ProtocolField : public Encodable
//! Return the signature of this field in an encode function signature
std::string getEncodeSignature(void) const override;

//! Return the signature of this field in an encode function signature
std::string getDecodeSignature(void) const override;

//! Get details needed to produce documentation for this encodable.
void getDocumentationDetails(std::vector<int>& outline, std::string& startByte, std::vector<std::string>& bytes, std::vector<std::string>& names, std::vector<std::string>& encodings, std::vector<std::string>& repeats, std::vector<std::string>& comments) const override;

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.b";
const std::string ProtocolParser::genVersion = "3.5.c";

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

0 comments on commit a32f13f

Please sign in to comment.