Skip to content

Commit

Permalink
Merge pull request #385 from thomas-bc/fw-objec-name
Browse files Browse the repository at this point in the history
Add support for Fw::ObjectName
  • Loading branch information
bocchino authored Feb 26, 2024
2 parents d9fa43a + b76f713 commit f75c77e
Show file tree
Hide file tree
Showing 68 changed files with 5,724 additions and 17,044 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -967,21 +967,13 @@ object ComponentCppWriter extends CppWriterUtils {
},
Line.blank :: lines(
s"""|#if FW_OBJECT_NAMES == 1
|// The port name consists of this->m_objName and some extra info.
|// We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
|// However, the compiler may assume that this->m_objName fills
|// the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
|// avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
|// bytes to cover the extra info.
|char portName[2*FW_OBJ_NAME_MAX_SIZE];
|(void) snprintf(
| portName,
| sizeof(portName),
|Fw::ObjectName portName;
|portName.format(
| "%s_${printName(port)}[%" PRI_PlatformIntType "]",
| this->m_objName,
| this->m_objName.toChar(),
| port
|);
|this->${variableName(port)}[port].setObjName(portName);
|this->${variableName(port)}[port].setObjName(portName.toChar());
|#endif
|"""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ case class ComponentEvents (
| FW_LOG_TEXT_BUFFER_SIZE,
| _formatString,
|#if FW_OBJECT_NAMES == 1
| this->m_objName,
| this->m_objName.toChar(),
|#endif
|"""
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,13 @@ void ActiveAsyncProductPortsOnlyComponentBase ::
this->m_productRecvIn_InputPort[port].setPortNum(port);

#if FW_OBJECT_NAMES == 1
// The port name consists of this->m_objName and some extra info.
// We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
// However, the compiler may assume that this->m_objName fills
// the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
// avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
// bytes to cover the extra info.
char portName[2*FW_OBJ_NAME_MAX_SIZE];
(void) snprintf(
portName,
sizeof(portName),
Fw::ObjectName portName;
portName.format(
"%s_productRecvIn_InputPort[%" PRI_PlatformIntType "]",
this->m_objName,
this->m_objName.toChar(),
port
);
this->m_productRecvIn_InputPort[port].setObjName(portName);
this->m_productRecvIn_InputPort[port].setObjName(portName.toChar());
#endif
}

Expand All @@ -113,21 +105,13 @@ void ActiveAsyncProductPortsOnlyComponentBase ::
this->m_productRequestOut_OutputPort[port].init();

#if FW_OBJECT_NAMES == 1
// The port name consists of this->m_objName and some extra info.
// We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
// However, the compiler may assume that this->m_objName fills
// the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
// avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
// bytes to cover the extra info.
char portName[2*FW_OBJ_NAME_MAX_SIZE];
(void) snprintf(
portName,
sizeof(portName),
Fw::ObjectName portName;
portName.format(
"%s_productRequestOut_OutputPort[%" PRI_PlatformIntType "]",
this->m_objName,
this->m_objName.toChar(),
port
);
this->m_productRequestOut_OutputPort[port].setObjName(portName);
this->m_productRequestOut_OutputPort[port].setObjName(portName.toChar());
#endif
}

Expand All @@ -140,21 +124,13 @@ void ActiveAsyncProductPortsOnlyComponentBase ::
this->m_productSendOut_OutputPort[port].init();

#if FW_OBJECT_NAMES == 1
// The port name consists of this->m_objName and some extra info.
// We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
// However, the compiler may assume that this->m_objName fills
// the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
// avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
// bytes to cover the extra info.
char portName[2*FW_OBJ_NAME_MAX_SIZE];
(void) snprintf(
portName,
sizeof(portName),
Fw::ObjectName portName;
portName.format(
"%s_productSendOut_OutputPort[%" PRI_PlatformIntType "]",
this->m_objName,
this->m_objName.toChar(),
port
);
this->m_productSendOut_OutputPort[port].setObjName(portName);
this->m_productSendOut_OutputPort[port].setObjName(portName.toChar());
#endif
}

Expand Down
Loading

0 comments on commit f75c77e

Please sign in to comment.