nasa / fpp

F Prime Prime: A modeling language for F Prime
https://fprime.jpl.nasa.gov
Apache License 2.0
49 stars 31 forks source link

Fix generation of struct containing only arrays #253

Closed SMorettini closed 1 year ago

SMorettini commented 1 year ago

Problem

The generation of the equal operator of .cpp for the following fpp

struct Modules4 {
  arr1: [3] M.Modules2
  arr2: [6] M.Modules2
}

is

bool Modules4 ::
  operator==(const Modules4& obj) const
{
  // Compare non-array members
  if (!(

  )) {
    return false;
  }

  // Compare array members
...

The first if is empty and doesn't compile.

Solution

I change the fpp-to-cpp to generate correct code also if there are no non-array members.

Note: it's my first time working with Scala, let me know if I should make the change using a different approach

SMorettini commented 1 year ago

I apply the formatting changes suggested