Skip to content

Commit

Permalink
Merge pull request #394 from fprime-community/issue-393-array-records
Browse files Browse the repository at this point in the history
Revise C++ code gen for array records
  • Loading branch information
bocchino authored Mar 5, 2024
2 parents f75c77e + a1011e1 commit 5a9d922
Show file tree
Hide file tree
Showing 15 changed files with 146 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ case class ComponentDataProducts (
|// Update the size of the buffer according to the data size
|const FwSizeType packetSize = container.getPacketSize();
|Fw::Buffer buffer = container.getBuffer();
|FW_ASSERT(packetSize <= buffer.getSize(), packetSize, buffer.getSize());
|buffer.setSize(packetSize);
|FW_ASSERT(packetSize <= buffer.getSize(), static_cast<FwAssertArgType>(packetSize),
| static_cast<FwAssertArgType>(buffer.getSize()));
|buffer.setSize(static_cast<U32>(packetSize));
|// Send the buffer
|this->$invokeProductSend(0, container.getId(), buffer);"""
)
Expand Down Expand Up @@ -424,8 +425,7 @@ case class ComponentDataProducts (
val serializeElts = (t match {
// Optimize the U8 case
case Type.U8 =>
"""| const bool omitSerializedLength = true;
| status = this->m_dataBuffer.serialize(array, size, omitSerializedLength);
"""| status = this->m_dataBuffer.serialize(array, size, Fw::Serialization::OMIT_LENGTH);
| FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);"""
case _ =>
"""| for (FwSizeType i = 0; i < size; i++) {
Expand All @@ -437,14 +437,14 @@ case class ComponentDataProducts (
s"""|FW_ASSERT(array != nullptr);
|const FwSizeType sizeDelta =
| sizeof(FwDpIdType) +
| sizeof(FwSizeType) +
| sizeof(FwSizeStoreType) +
| size * $eltSize;
|Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
|if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
| const FwDpIdType id = this->baseId + RecordId::$name;
| status = this->m_dataBuffer.serialize(id);
| FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
| status = this->m_dataBuffer.serialize(size);
| status = this->m_dataBuffer.serializeSize(size);
| FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
|$serializeElts
| this->m_dataSize += sizeDelta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ Fw::SerializeStatus ActiveAsyncProductsComponentBase::DpContainer ::
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * ActiveAsyncProducts_Data::SERIALIZED_SIZE;
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::DataArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
for (FwSizeType i = 0; i < size; i++) {
status = this->m_dataBuffer.serialize(array[i]);
Expand Down Expand Up @@ -153,14 +153,14 @@ Fw::SerializeStatus ActiveAsyncProductsComponentBase::DpContainer ::
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * sizeof(U32);
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::U32ArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
for (FwSizeType i = 0; i < size; i++) {
status = this->m_dataBuffer.serialize(array[i]);
Expand Down Expand Up @@ -204,17 +204,16 @@ Fw::SerializeStatus ActiveAsyncProductsComponentBase::DpContainer ::
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * sizeof(U8);
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::U8ArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
const bool omitSerializedLength = true;
status = this->m_dataBuffer.serialize(array, size, omitSerializedLength);
status = this->m_dataBuffer.serialize(array, size, Fw::Serialization::OMIT_LENGTH);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
this->m_dataSize += sizeDelta;
}
Expand Down Expand Up @@ -2811,8 +2810,9 @@ void ActiveAsyncProductsComponentBase ::
// Update the size of the buffer according to the data size
const FwSizeType packetSize = container.getPacketSize();
Fw::Buffer buffer = container.getBuffer();
FW_ASSERT(packetSize <= buffer.getSize(), packetSize, buffer.getSize());
buffer.setSize(packetSize);
FW_ASSERT(packetSize <= buffer.getSize(), static_cast<FwAssertArgType>(packetSize),
static_cast<FwAssertArgType>(buffer.getSize()));
buffer.setSize(static_cast<U32>(packetSize));
// Send the buffer
this->productSendOut_out(0, container.getId(), buffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ Fw::SerializeStatus ActiveGetProductsComponentBase::DpContainer ::
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * ActiveGetProducts_Data::SERIALIZED_SIZE;
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::DataArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
for (FwSizeType i = 0; i < size; i++) {
status = this->m_dataBuffer.serialize(array[i]);
Expand Down Expand Up @@ -151,14 +151,14 @@ Fw::SerializeStatus ActiveGetProductsComponentBase::DpContainer ::
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * sizeof(U32);
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::U32ArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
for (FwSizeType i = 0; i < size; i++) {
status = this->m_dataBuffer.serialize(array[i]);
Expand Down Expand Up @@ -202,17 +202,16 @@ Fw::SerializeStatus ActiveGetProductsComponentBase::DpContainer ::
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * sizeof(U8);
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::U8ArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
const bool omitSerializedLength = true;
status = this->m_dataBuffer.serialize(array, size, omitSerializedLength);
status = this->m_dataBuffer.serialize(array, size, Fw::Serialization::OMIT_LENGTH);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
this->m_dataSize += sizeDelta;
}
Expand Down Expand Up @@ -2660,8 +2659,9 @@ void ActiveGetProductsComponentBase ::
// Update the size of the buffer according to the data size
const FwSizeType packetSize = container.getPacketSize();
Fw::Buffer buffer = container.getBuffer();
FW_ASSERT(packetSize <= buffer.getSize(), packetSize, buffer.getSize());
buffer.setSize(packetSize);
FW_ASSERT(packetSize <= buffer.getSize(), static_cast<FwAssertArgType>(packetSize),
static_cast<FwAssertArgType>(buffer.getSize()));
buffer.setSize(static_cast<U32>(packetSize));
// Send the buffer
this->productSendOut_out(0, container.getId(), buffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ Fw::SerializeStatus ActiveGuardedProductsComponentBase::DpContainer ::
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * ActiveGuardedProducts_Data::SERIALIZED_SIZE;
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::DataArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
for (FwSizeType i = 0; i < size; i++) {
status = this->m_dataBuffer.serialize(array[i]);
Expand Down Expand Up @@ -151,14 +151,14 @@ Fw::SerializeStatus ActiveGuardedProductsComponentBase::DpContainer ::
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * sizeof(U32);
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::U32ArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
for (FwSizeType i = 0; i < size; i++) {
status = this->m_dataBuffer.serialize(array[i]);
Expand Down Expand Up @@ -202,17 +202,16 @@ Fw::SerializeStatus ActiveGuardedProductsComponentBase::DpContainer ::
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * sizeof(U8);
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::U8ArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
const bool omitSerializedLength = true;
status = this->m_dataBuffer.serialize(array, size, omitSerializedLength);
status = this->m_dataBuffer.serialize(array, size, Fw::Serialization::OMIT_LENGTH);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
this->m_dataSize += sizeDelta;
}
Expand Down Expand Up @@ -2767,8 +2766,9 @@ void ActiveGuardedProductsComponentBase ::
// Update the size of the buffer according to the data size
const FwSizeType packetSize = container.getPacketSize();
Fw::Buffer buffer = container.getBuffer();
FW_ASSERT(packetSize <= buffer.getSize(), packetSize, buffer.getSize());
buffer.setSize(packetSize);
FW_ASSERT(packetSize <= buffer.getSize(), static_cast<FwAssertArgType>(packetSize),
static_cast<FwAssertArgType>(buffer.getSize()));
buffer.setSize(static_cast<U32>(packetSize));
// Send the buffer
this->productSendOut_out(0, container.getId(), buffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ Fw::SerializeStatus ActiveSyncProductsComponentBase::DpContainer ::
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * ActiveSyncProducts_Data::SERIALIZED_SIZE;
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::DataArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
for (FwSizeType i = 0; i < size; i++) {
status = this->m_dataBuffer.serialize(array[i]);
Expand Down Expand Up @@ -151,14 +151,14 @@ Fw::SerializeStatus ActiveSyncProductsComponentBase::DpContainer ::
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * sizeof(U32);
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::U32ArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
for (FwSizeType i = 0; i < size; i++) {
status = this->m_dataBuffer.serialize(array[i]);
Expand Down Expand Up @@ -202,17 +202,16 @@ Fw::SerializeStatus ActiveSyncProductsComponentBase::DpContainer ::
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * sizeof(U8);
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::U8ArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
const bool omitSerializedLength = true;
status = this->m_dataBuffer.serialize(array, size, omitSerializedLength);
status = this->m_dataBuffer.serialize(array, size, Fw::Serialization::OMIT_LENGTH);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
this->m_dataSize += sizeDelta;
}
Expand Down Expand Up @@ -2761,8 +2760,9 @@ void ActiveSyncProductsComponentBase ::
// Update the size of the buffer according to the data size
const FwSizeType packetSize = container.getPacketSize();
Fw::Buffer buffer = container.getBuffer();
FW_ASSERT(packetSize <= buffer.getSize(), packetSize, buffer.getSize());
buffer.setSize(packetSize);
FW_ASSERT(packetSize <= buffer.getSize(), static_cast<FwAssertArgType>(packetSize),
static_cast<FwAssertArgType>(buffer.getSize()));
buffer.setSize(static_cast<U32>(packetSize));
// Send the buffer
this->productSendOut_out(0, container.getId(), buffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ namespace M {
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * M::ActiveTest_Data::SERIALIZED_SIZE;
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::DataArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
for (FwSizeType i = 0; i < size; i++) {
status = this->m_dataBuffer.serialize(array[i]);
Expand Down Expand Up @@ -189,14 +189,14 @@ namespace M {
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * sizeof(U32);
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::U32ArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
for (FwSizeType i = 0; i < size; i++) {
status = this->m_dataBuffer.serialize(array[i]);
Expand Down Expand Up @@ -240,17 +240,16 @@ namespace M {
FW_ASSERT(array != nullptr);
const FwSizeType sizeDelta =
sizeof(FwDpIdType) +
sizeof(FwSizeType) +
sizeof(FwSizeStoreType) +
size * sizeof(U8);
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
if (this->m_dataBuffer.getBuffLength() + sizeDelta <= this->m_dataBuffer.getBuffCapacity()) {
const FwDpIdType id = this->baseId + RecordId::U8ArrayRecord;
status = this->m_dataBuffer.serialize(id);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
status = this->m_dataBuffer.serialize(size);
status = this->m_dataBuffer.serializeSize(size);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
const bool omitSerializedLength = true;
status = this->m_dataBuffer.serialize(array, size, omitSerializedLength);
status = this->m_dataBuffer.serialize(array, size, Fw::Serialization::OMIT_LENGTH);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
this->m_dataSize += sizeDelta;
}
Expand Down Expand Up @@ -5608,8 +5607,9 @@ namespace M {
// Update the size of the buffer according to the data size
const FwSizeType packetSize = container.getPacketSize();
Fw::Buffer buffer = container.getBuffer();
FW_ASSERT(packetSize <= buffer.getSize(), packetSize, buffer.getSize());
buffer.setSize(packetSize);
FW_ASSERT(packetSize <= buffer.getSize(), static_cast<FwAssertArgType>(packetSize),
static_cast<FwAssertArgType>(buffer.getSize()));
buffer.setSize(static_cast<U32>(packetSize));
// Send the buffer
this->productSendOut_out(0, container.getId(), buffer);
}
Expand Down
Loading

0 comments on commit 5a9d922

Please sign in to comment.