Skip to content

Commit

Permalink
Merge pull request #366 from SMorettini/Add-index-size-in-asserting-a…
Browse files Browse the repository at this point in the history
…rray-index

Add index and size of array when asserting index is smaller than the SIZE
  • Loading branch information
bocchino authored Jan 9, 2024
2 parents 26e5ace + d384d04 commit 4554cdc
Show file tree
Hide file tree
Showing 26 changed files with 52 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ case class ArrayCppWriter (
),
CppDoc.Type("ElementType&", Some(s"$name::ElementType&")),
List(
line("FW_ASSERT(i < SIZE);"),
line("FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));"),
line("return this->elements[i];"),
),
),
Expand All @@ -281,7 +281,7 @@ case class ArrayCppWriter (
),
CppDoc.Type("const ElementType&", Some(s"const $name::ElementType&")),
List(
line("FW_ASSERT(i < SIZE);"),
line("FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));"),
line("return this->elements[i];"),
),
CppDoc.Function.NonSV,
Expand Down
4 changes: 2 additions & 2 deletions compiler/tools/fpp-to-cpp/test/array/AArrayAc.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ A ::
A::ElementType& A ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const A::ElementType& A ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/tools/fpp-to-cpp/test/array/AbsTypeArrayAc.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ AbsType ::
AbsType::ElementType& AbsType ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const AbsType::ElementType& AbsType ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ BuiltInType ::
BuiltInType::ElementType& BuiltInType ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const BuiltInType::ElementType& BuiltInType ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/tools/fpp-to-cpp/test/array/C_AArrayAc.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ C_A ::
C_A::ElementType& C_A ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const C_A::ElementType& C_A ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/tools/fpp-to-cpp/test/array/Enum1ArrayAc.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ Enum1 ::
Enum1::ElementType& Enum1 ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const Enum1::ElementType& Enum1 ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/tools/fpp-to-cpp/test/array/Enum2ArrayAc.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ Enum2 ::
Enum2::ElementType& Enum2 ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const Enum2::ElementType& Enum2 ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ HeaderPath ::
HeaderPath::ElementType& HeaderPath ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const HeaderPath::ElementType& HeaderPath ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ PrimitiveArray ::
PrimitiveArray::ElementType& PrimitiveArray ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const PrimitiveArray::ElementType& PrimitiveArray ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ namespace M {
PrimitiveBool::ElementType& PrimitiveBool ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const PrimitiveBool::ElementType& PrimitiveBool ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ namespace M {
PrimitiveF32e::ElementType& PrimitiveF32e ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const PrimitiveF32e::ElementType& PrimitiveF32e ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ namespace M {
PrimitiveF32f::ElementType& PrimitiveF32f ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const PrimitiveF32f::ElementType& PrimitiveF32f ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ namespace M {
PrimitiveF64::ElementType& PrimitiveF64 ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const PrimitiveF64::ElementType& PrimitiveF64 ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ namespace M {
PrimitiveI32::ElementType& PrimitiveI32 ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const PrimitiveI32::ElementType& PrimitiveI32 ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ namespace M {
PrimitiveI64::ElementType& PrimitiveI64 ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const PrimitiveI64::ElementType& PrimitiveI64 ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ namespace M {
PrimitiveU16::ElementType& PrimitiveU16 ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const PrimitiveU16::ElementType& PrimitiveU16 ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ namespace M {
PrimitiveU8::ElementType& PrimitiveU8 ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const PrimitiveU8::ElementType& PrimitiveU8 ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ SingleElement ::
SingleElement::ElementType& SingleElement ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const SingleElement::ElementType& SingleElement ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/tools/fpp-to-cpp/test/array/String1ArrayAc.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ String1 ::
String1::ElementType& String1 ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const String1::ElementType& String1 ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/tools/fpp-to-cpp/test/array/String2ArrayAc.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ String2 ::
String2::ElementType& String2 ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const String2::ElementType& String2 ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ StringArray ::
StringArray::ElementType& StringArray ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const StringArray::ElementType& StringArray ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/tools/fpp-to-cpp/test/array/Struct1ArrayAc.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ Struct1 ::
Struct1::ElementType& Struct1 ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const Struct1::ElementType& Struct1 ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/tools/fpp-to-cpp/test/array/Struct2ArrayAc.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ Struct2 ::
Struct2::ElementType& Struct2 ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

const Struct2::ElementType& Struct2 ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE);
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}

Expand Down
Loading

0 comments on commit 4554cdc

Please sign in to comment.