mirror of
https://github.com/nasa/fpp.git
synced 2025-12-15 21:08:16 -06:00
Add initial unit tests for fpp-to-cpp arrays
This commit is contained in:
parent
a7b856a4be
commit
0dca790b97
203
compiler/tools/fpp-to-cpp/test/array/BuiltInTypeArrayAc.ref.cpp
Normal file
203
compiler/tools/fpp-to-cpp/test/array/BuiltInTypeArrayAc.ref.cpp
Normal file
@ -0,0 +1,203 @@
|
||||
// ======================================================================
|
||||
// \title BuiltInTypeArrayAc.cpp
|
||||
// \author Generated by fpp-to-cpp
|
||||
// \brief cpp file for BuiltInType array
|
||||
// ======================================================================
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#include "Fw/Types/Assert.hpp"
|
||||
#include "Fw/Types/StringUtils.hpp"
|
||||
|
||||
#include "BuiltInTypeArrayAc.hpp"
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
BuiltInType ::
|
||||
BuiltInType() :
|
||||
Serializable()
|
||||
{
|
||||
// Construct using element-wise constructor
|
||||
*this = BuiltInType(
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
BuiltInType ::
|
||||
BuiltInType(const ElementType (&a)[SIZE]) :
|
||||
Serializable()
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = a[index];
|
||||
}
|
||||
}
|
||||
|
||||
BuiltInType ::
|
||||
BuiltInType(const ElementType& e) :
|
||||
Serializable()
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = e;
|
||||
}
|
||||
}
|
||||
|
||||
BuiltInType ::
|
||||
BuiltInType(
|
||||
const ElementType (&e1),
|
||||
const ElementType (&e2),
|
||||
const ElementType (&e3)
|
||||
) :
|
||||
Serializable()
|
||||
{
|
||||
this->elements[0] = e1;
|
||||
this->elements[1] = e2;
|
||||
this->elements[2] = e3;
|
||||
}
|
||||
|
||||
BuiltInType ::
|
||||
BuiltInType(const BuiltInType& obj) :
|
||||
Serializable()
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = obj.elements[index];
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Operators
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
BuiltInType::ElementType& BuiltInType ::
|
||||
operator[](const U32 i)
|
||||
{
|
||||
FW_ASSERT(i < SIZE);
|
||||
return this->elements[i];
|
||||
}
|
||||
|
||||
const BuiltInType::ElementType& BuiltInType ::
|
||||
operator[](const U32 i) const
|
||||
{
|
||||
FW_ASSERT(i < SIZE);
|
||||
return this->elements[i];
|
||||
}
|
||||
|
||||
BuiltInType& BuiltInType ::
|
||||
operator=(const BuiltInType& obj)
|
||||
{
|
||||
if (this == &obj) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = obj.elements[index];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
BuiltInType& BuiltInType ::
|
||||
operator=(const ElementType (&a)[SIZE])
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = a[index];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
BuiltInType& BuiltInType ::
|
||||
operator=(const ElementType& e)
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = e;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool BuiltInType ::
|
||||
operator==(const BuiltInType& obj) const
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
if ((*this)[index] != obj[index]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuiltInType ::
|
||||
operator!=(const BuiltInType& obj) const
|
||||
{
|
||||
return !(*this == obj);
|
||||
}
|
||||
|
||||
#ifdef BUILD_UT
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const BuiltInType& obj) {
|
||||
Fw::String s;
|
||||
obj.toString(s);
|
||||
os << s;
|
||||
return os;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Fw::SerializeStatus BuiltInType ::
|
||||
serialize(Fw::SerializeBufferBase& buffer) const
|
||||
{
|
||||
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
status = buffer.serialize((*this)[index]);
|
||||
if (status != Fw::FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
Fw::SerializeStatus BuiltInType ::
|
||||
deserialize(Fw::SerializeBufferBase& buffer)
|
||||
{
|
||||
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
status = buffer.deserialize((*this)[index]);
|
||||
if (status != Fw::FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#if FW_ARRAY_TO_STRING || BUILD_UT
|
||||
|
||||
void BuiltInType ::
|
||||
toString(Fw::StringBase& sb) const
|
||||
{
|
||||
static const char *formatString = "[ "
|
||||
"%s "
|
||||
"%s "
|
||||
"%s ]";
|
||||
|
||||
// Declare strings to hold any serializable toString() arguments
|
||||
char outputString[FW_ARRAY_TO_STRING_BUFFER_SIZE];
|
||||
(void) snprintf(
|
||||
outputString,
|
||||
FW_ARRAY_TO_STRING_BUFFER_SIZE,
|
||||
formatString,
|
||||
this->elements[0],
|
||||
this->elements[1],
|
||||
this->elements[2]
|
||||
);
|
||||
|
||||
outputString[FW_ARRAY_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate
|
||||
sb = outputString;
|
||||
}
|
||||
|
||||
#endif
|
||||
160
compiler/tools/fpp-to-cpp/test/array/BuiltInTypeArrayAc.ref.hpp
Normal file
160
compiler/tools/fpp-to-cpp/test/array/BuiltInTypeArrayAc.ref.hpp
Normal file
@ -0,0 +1,160 @@
|
||||
// ======================================================================
|
||||
// \title BuiltInTypeArrayAc.hpp
|
||||
// \author Generated by fpp-to-cpp
|
||||
// \brief hpp file for BuiltInType array
|
||||
// ======================================================================
|
||||
|
||||
#ifndef BuiltInTypeArrayAc_HPP
|
||||
#define BuiltInTypeArrayAc_HPP
|
||||
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
|
||||
//! An array of a built-in type
|
||||
class BuiltInType :
|
||||
public Fw::Serializable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Types
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! The element type
|
||||
typedef FwOpcodeType ElementType;
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constants
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
enum {
|
||||
//! The size of the array
|
||||
SIZE = 3,
|
||||
//! The size of the serial representation
|
||||
SERIALIZED_SIZE = SIZE * sizeof(ElementType),
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Constructor (default value)
|
||||
BuiltInType();
|
||||
|
||||
//! Constructor (user-provided value)
|
||||
BuiltInType(
|
||||
const ElementType (&a)[SIZE] //!< The array
|
||||
);
|
||||
|
||||
//! Constructor (single element)
|
||||
BuiltInType(
|
||||
const ElementType& e //!< The element
|
||||
);
|
||||
|
||||
//! Constructor (multiple elements)
|
||||
BuiltInType(
|
||||
const ElementType (&e1), //!< Element 1
|
||||
const ElementType (&e2), //!< Element 2
|
||||
const ElementType (&e3) //!< Element 3
|
||||
);
|
||||
|
||||
//! Copy Constructor
|
||||
BuiltInType(
|
||||
const BuiltInType& obj //!< The source object
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Operators
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Subscript operator
|
||||
ElementType& operator[](
|
||||
const U32 i //!< The subscript index
|
||||
);
|
||||
|
||||
//! Const subscript operator
|
||||
const ElementType& operator[](
|
||||
const U32 i //!< The subscript index
|
||||
) const;
|
||||
|
||||
//! Copy assignment operator (object)
|
||||
BuiltInType& operator=(
|
||||
const BuiltInType& obj //!< The source object
|
||||
);
|
||||
|
||||
//! Copy assignment operator (raw array)
|
||||
BuiltInType& operator=(
|
||||
const ElementType (&a)[SIZE] //!< The source array
|
||||
);
|
||||
|
||||
//! Copy assignment operator (single element)
|
||||
BuiltInType& operator=(
|
||||
const ElementType& e //!< The element
|
||||
);
|
||||
|
||||
//! Equality operator
|
||||
bool operator==(
|
||||
const BuiltInType& obj //!< The other object
|
||||
) const;
|
||||
|
||||
//! Inequality operator
|
||||
bool operator!=(
|
||||
const BuiltInType& obj //!< The other object
|
||||
) const;
|
||||
|
||||
#ifdef BUILD_UT
|
||||
|
||||
//! Ostream operator
|
||||
friend std::ostream& operator<<(
|
||||
std::ostream& os, //!< The ostream
|
||||
const BuiltInType& obj //!< The object
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Serialization
|
||||
Fw::SerializeStatus serialize(
|
||||
Fw::SerializeBufferBase& buffer //!< The serial buffer
|
||||
) const;
|
||||
|
||||
//! Deserialization
|
||||
Fw::SerializeStatus deserialize(
|
||||
Fw::SerializeBufferBase& buffer //!< The serial buffer
|
||||
);
|
||||
|
||||
#if FW_ARRAY_TO_STRING || BUILD_UT
|
||||
|
||||
//! Convert array to string
|
||||
void toString(
|
||||
Fw::StringBase& sb //!< The StringBase object to hold the result
|
||||
) const;
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member variables
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! The array elements
|
||||
ElementType elements[SIZE];
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
143
compiler/tools/fpp-to-cpp/test/array/E1EnumAcE2Enum.ref.cpp
Normal file
143
compiler/tools/fpp-to-cpp/test/array/E1EnumAcE2Enum.ref.cpp
Normal file
@ -0,0 +1,143 @@
|
||||
// ======================================================================
|
||||
// \title E1EnumAc.cpp
|
||||
// \author Generated by fpp-to-cpp
|
||||
// \brief cpp file for E1 enum
|
||||
// ======================================================================
|
||||
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
||||
#include "Fw/Types/Assert.hpp"
|
||||
#include "E1EnumAc.hpp"
|
||||
|
||||
namespace M {
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
E1 ::
|
||||
E1()
|
||||
{
|
||||
this->e = X;
|
||||
}
|
||||
|
||||
E1 ::
|
||||
E1(const T e)
|
||||
{
|
||||
this->e = e;
|
||||
}
|
||||
|
||||
E1 ::
|
||||
E1(const E1& obj)
|
||||
{
|
||||
this->e = obj.e;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Operators
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
E1& E1 ::
|
||||
operator=(const E1& obj)
|
||||
{
|
||||
this->e = obj.e;
|
||||
return *this;
|
||||
}
|
||||
|
||||
E1& E1 ::
|
||||
operator=(T e)
|
||||
{
|
||||
this->e = e;
|
||||
return *this;
|
||||
}
|
||||
|
||||
E1 ::
|
||||
operator t() const
|
||||
{
|
||||
return this->e;
|
||||
}
|
||||
|
||||
bool E1 ::
|
||||
operator==(const E1& obj) const
|
||||
{
|
||||
return this->e == obj.e;
|
||||
}
|
||||
|
||||
bool E1 ::
|
||||
operator!=(const E1& obj) const
|
||||
{
|
||||
return !(*this == obj);
|
||||
}
|
||||
|
||||
#ifdef BUILD_UT
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const E1& obj) {
|
||||
Fw::String s;
|
||||
obj.toString(s);
|
||||
os << s;
|
||||
return os;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool E1 ::
|
||||
isValid() const
|
||||
{
|
||||
return ((e >= X) && (e <= Y))
|
||||
|| ((e >= Z) && (e <= Z));
|
||||
}
|
||||
|
||||
Fw::SerializeStatus E1 ::
|
||||
serialize(Fw::SerializeBufferBase& buffer) const
|
||||
{
|
||||
const Fw::SerializeStatus status = buffer.serialize(
|
||||
static_cast<SerialType>(this->e)
|
||||
);
|
||||
return status;
|
||||
}
|
||||
|
||||
Fw::SerializeStatus E1 ::
|
||||
deserialize(Fw::SerializeBufferBase& buffer)
|
||||
{
|
||||
SerialType es;
|
||||
Fw::SerializeStatus status = buffer.deserialize(es);
|
||||
if (status == Fw::FW_SERIALIZE_OK) {
|
||||
this->e = static_cast<T>(es);
|
||||
if (!this->isValid()) {
|
||||
status = Fw::FW_DESERIALIZE_FORMAT_ERROR;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#if FW_SERIALIZABLE_TO_STRING || BUILD_UT
|
||||
|
||||
void E1 ::
|
||||
toString(Fw::StringBase& sb) const
|
||||
{
|
||||
Fw::String s;
|
||||
switch (e) {
|
||||
case X:
|
||||
s = "X";
|
||||
break;
|
||||
case Y:
|
||||
s = "Y";
|
||||
break;
|
||||
case Z:
|
||||
s = "Z";
|
||||
break;
|
||||
default:
|
||||
s = "[invalid]";
|
||||
break;
|
||||
}
|
||||
sb.format("%s (%d)", s.toChar(), e);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
152
compiler/tools/fpp-to-cpp/test/array/E1EnumAcE2Enum.ref.hpp
Normal file
152
compiler/tools/fpp-to-cpp/test/array/E1EnumAcE2Enum.ref.hpp
Normal file
@ -0,0 +1,152 @@
|
||||
// ======================================================================
|
||||
// \title E1EnumAc.hpp
|
||||
// \author Generated by fpp-to-cpp
|
||||
// \brief hpp file for E1 enum
|
||||
// ======================================================================
|
||||
|
||||
#ifndef M_E1EnumAc_HPP
|
||||
#define M_E1EnumAc_HPP
|
||||
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
namespace M {
|
||||
|
||||
class E1 :
|
||||
public Fw::Serializable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Types
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! The serial representation type
|
||||
typedef I32 SerialType;
|
||||
|
||||
//! The raw enum type
|
||||
typedef enum {
|
||||
//! Example comment
|
||||
X = 1,
|
||||
Y = 2,
|
||||
Z = 9,
|
||||
} T;
|
||||
|
||||
//! For backwards compatibility
|
||||
typedef T t;
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constants
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
enum {
|
||||
//! The size of the serial representation
|
||||
SERIALIZED_SIZE = sizeof(SerialType),
|
||||
//! The number of enumerated constants
|
||||
NUM_CONSTANTS = 3,
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Constructor (default value of X)
|
||||
E1();
|
||||
|
||||
//! Constructor (user-provided value)
|
||||
E1(
|
||||
const T e //!< The raw enum value
|
||||
);
|
||||
|
||||
//! Copy constructor
|
||||
E1(
|
||||
const E1& obj //!< The source object
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Operators
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Copy assignment operator (object)
|
||||
E1& operator=(
|
||||
const E1& obj //!< The source object
|
||||
);
|
||||
|
||||
//! Copy assignment operator (raw enum)
|
||||
E1& operator=(
|
||||
T e //!< The enum value
|
||||
);
|
||||
|
||||
//! Conversion operator
|
||||
operator t() const;
|
||||
|
||||
//! Equality operator
|
||||
bool operator==(
|
||||
const E1& obj //!< The other object
|
||||
) const;
|
||||
|
||||
//! Inequality operator
|
||||
bool operator!=(
|
||||
const E1& obj //!< The other object
|
||||
) const;
|
||||
|
||||
#ifdef BUILD_UT
|
||||
|
||||
//! Ostream operator
|
||||
friend std::ostream& operator<<(
|
||||
std::ostream& os, //!< The ostream
|
||||
const E1& obj //!< The object
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Check raw enum value for validity
|
||||
bool isValid() const;
|
||||
|
||||
//! Serialize raw enum value to SerialType
|
||||
Fw::SerializeStatus serialize(
|
||||
Fw::SerializeBufferBase& buffer //!< The serial buffer
|
||||
) const;
|
||||
|
||||
//! Deserialize raw enum value from SerialType
|
||||
Fw::SerializeStatus deserialize(
|
||||
Fw::SerializeBufferBase& buffer //!< The serial buffer
|
||||
);
|
||||
|
||||
#if FW_SERIALIZABLE_TO_STRING || BUILD_UT
|
||||
|
||||
//! Convert enum to string
|
||||
void toString(
|
||||
Fw::StringBase& sb //!< The StringBase object to hold the result
|
||||
) const;
|
||||
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member variables
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! The raw enum value
|
||||
T e;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,207 @@
|
||||
// ======================================================================
|
||||
// \title Primitive1ArrayAc.cpp
|
||||
// \author Generated by fpp-to-cpp
|
||||
// \brief cpp file for Primitive1 array
|
||||
// ======================================================================
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#include "Fw/Types/Assert.hpp"
|
||||
#include "Fw/Types/StringUtils.hpp"
|
||||
|
||||
#include "Primitive1ArrayAc.hpp"
|
||||
|
||||
namespace M {
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Primitive1 ::
|
||||
Primitive1() :
|
||||
Serializable()
|
||||
{
|
||||
// Construct using element-wise constructor
|
||||
*this = Primitive1(
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
Primitive1 ::
|
||||
Primitive1(const ElementType (&a)[SIZE]) :
|
||||
Serializable()
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = a[index];
|
||||
}
|
||||
}
|
||||
|
||||
Primitive1 ::
|
||||
Primitive1(const ElementType& e) :
|
||||
Serializable()
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = e;
|
||||
}
|
||||
}
|
||||
|
||||
Primitive1 ::
|
||||
Primitive1(
|
||||
const ElementType (&e1),
|
||||
const ElementType (&e2),
|
||||
const ElementType (&e3)
|
||||
) :
|
||||
Serializable()
|
||||
{
|
||||
this->elements[0] = e1;
|
||||
this->elements[1] = e2;
|
||||
this->elements[2] = e3;
|
||||
}
|
||||
|
||||
Primitive1 ::
|
||||
Primitive1(const Primitive1& obj) :
|
||||
Serializable()
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = obj.elements[index];
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Operators
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Primitive1::ElementType& Primitive1 ::
|
||||
operator[](const U32 i)
|
||||
{
|
||||
FW_ASSERT(i < SIZE);
|
||||
return this->elements[i];
|
||||
}
|
||||
|
||||
const Primitive1::ElementType& Primitive1 ::
|
||||
operator[](const U32 i) const
|
||||
{
|
||||
FW_ASSERT(i < SIZE);
|
||||
return this->elements[i];
|
||||
}
|
||||
|
||||
Primitive1& Primitive1 ::
|
||||
operator=(const Primitive1& obj)
|
||||
{
|
||||
if (this == &obj) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = obj.elements[index];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Primitive1& Primitive1 ::
|
||||
operator=(const ElementType (&a)[SIZE])
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = a[index];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Primitive1& Primitive1 ::
|
||||
operator=(const ElementType& e)
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = e;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Primitive1 ::
|
||||
operator==(const Primitive1& obj) const
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
if ((*this)[index] != obj[index]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Primitive1 ::
|
||||
operator!=(const Primitive1& obj) const
|
||||
{
|
||||
return !(*this == obj);
|
||||
}
|
||||
|
||||
#ifdef BUILD_UT
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Primitive1& obj) {
|
||||
Fw::String s;
|
||||
obj.toString(s);
|
||||
os << s;
|
||||
return os;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Fw::SerializeStatus Primitive1 ::
|
||||
serialize(Fw::SerializeBufferBase& buffer) const
|
||||
{
|
||||
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
status = buffer.serialize((*this)[index]);
|
||||
if (status != Fw::FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
Fw::SerializeStatus Primitive1 ::
|
||||
deserialize(Fw::SerializeBufferBase& buffer)
|
||||
{
|
||||
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
status = buffer.deserialize((*this)[index]);
|
||||
if (status != Fw::FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#if FW_ARRAY_TO_STRING || BUILD_UT
|
||||
|
||||
void Primitive1 ::
|
||||
toString(Fw::StringBase& sb) const
|
||||
{
|
||||
static const char *formatString = "[ "
|
||||
"%u "
|
||||
"%u "
|
||||
"%u ]";
|
||||
|
||||
// Declare strings to hold any serializable toString() arguments
|
||||
char outputString[FW_ARRAY_TO_STRING_BUFFER_SIZE];
|
||||
(void) snprintf(
|
||||
outputString,
|
||||
FW_ARRAY_TO_STRING_BUFFER_SIZE,
|
||||
formatString,
|
||||
this->elements[0],
|
||||
this->elements[1],
|
||||
this->elements[2]
|
||||
);
|
||||
|
||||
outputString[FW_ARRAY_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate
|
||||
sb = outputString;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -0,0 +1,164 @@
|
||||
// ======================================================================
|
||||
// \title Primitive1ArrayAc.hpp
|
||||
// \author Generated by fpp-to-cpp
|
||||
// \brief hpp file for Primitive1 array
|
||||
// ======================================================================
|
||||
|
||||
#ifndef M_Primitive1ArrayAc_HPP
|
||||
#define M_Primitive1ArrayAc_HPP
|
||||
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
|
||||
namespace M {
|
||||
|
||||
//! An array of primitives
|
||||
class Primitive1 :
|
||||
public Fw::Serializable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Types
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! The element type
|
||||
typedef U32 ElementType;
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constants
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
enum {
|
||||
//! The size of the array
|
||||
SIZE = 3,
|
||||
//! The size of the serial representation
|
||||
SERIALIZED_SIZE = SIZE * sizeof(ElementType),
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Constructor (default value)
|
||||
Primitive1();
|
||||
|
||||
//! Constructor (user-provided value)
|
||||
Primitive1(
|
||||
const ElementType (&a)[SIZE] //!< The array
|
||||
);
|
||||
|
||||
//! Constructor (single element)
|
||||
Primitive1(
|
||||
const ElementType& e //!< The element
|
||||
);
|
||||
|
||||
//! Constructor (multiple elements)
|
||||
Primitive1(
|
||||
const ElementType (&e1), //!< Element 1
|
||||
const ElementType (&e2), //!< Element 2
|
||||
const ElementType (&e3) //!< Element 3
|
||||
);
|
||||
|
||||
//! Copy Constructor
|
||||
Primitive1(
|
||||
const Primitive1& obj //!< The source object
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Operators
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Subscript operator
|
||||
ElementType& operator[](
|
||||
const U32 i //!< The subscript index
|
||||
);
|
||||
|
||||
//! Const subscript operator
|
||||
const ElementType& operator[](
|
||||
const U32 i //!< The subscript index
|
||||
) const;
|
||||
|
||||
//! Copy assignment operator (object)
|
||||
Primitive1& operator=(
|
||||
const Primitive1& obj //!< The source object
|
||||
);
|
||||
|
||||
//! Copy assignment operator (raw array)
|
||||
Primitive1& operator=(
|
||||
const ElementType (&a)[SIZE] //!< The source array
|
||||
);
|
||||
|
||||
//! Copy assignment operator (single element)
|
||||
Primitive1& operator=(
|
||||
const ElementType& e //!< The element
|
||||
);
|
||||
|
||||
//! Equality operator
|
||||
bool operator==(
|
||||
const Primitive1& obj //!< The other object
|
||||
) const;
|
||||
|
||||
//! Inequality operator
|
||||
bool operator!=(
|
||||
const Primitive1& obj //!< The other object
|
||||
) const;
|
||||
|
||||
#ifdef BUILD_UT
|
||||
|
||||
//! Ostream operator
|
||||
friend std::ostream& operator<<(
|
||||
std::ostream& os, //!< The ostream
|
||||
const Primitive1& obj //!< The object
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Serialization
|
||||
Fw::SerializeStatus serialize(
|
||||
Fw::SerializeBufferBase& buffer //!< The serial buffer
|
||||
) const;
|
||||
|
||||
//! Deserialization
|
||||
Fw::SerializeStatus deserialize(
|
||||
Fw::SerializeBufferBase& buffer //!< The serial buffer
|
||||
);
|
||||
|
||||
#if FW_ARRAY_TO_STRING || BUILD_UT
|
||||
|
||||
//! Convert array to string
|
||||
void toString(
|
||||
Fw::StringBase& sb //!< The StringBase object to hold the result
|
||||
) const;
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member variables
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! The array elements
|
||||
ElementType elements[SIZE];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,282 @@
|
||||
// ======================================================================
|
||||
// \title String1ArrayAc.cpp
|
||||
// \author Generated by fpp-to-cpp
|
||||
// \brief cpp file for String1 array
|
||||
// ======================================================================
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#include "Fw/Types/Assert.hpp"
|
||||
#include "Fw/Types/StringUtils.hpp"
|
||||
|
||||
#include "String1ArrayAc.hpp"
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// StringSize80 class
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
String1::StringSize80 ::
|
||||
StringSize80() :
|
||||
StringBase()
|
||||
{
|
||||
this->m_buf[0] = 0;
|
||||
}
|
||||
|
||||
String1::StringSize80 ::
|
||||
StringSize80(const char* src) :
|
||||
StringBase()
|
||||
{
|
||||
Fw::StringUtils::string_copy(this->m_buf, src, sizeof(this->m_buf));
|
||||
}
|
||||
|
||||
String1::StringSize80 ::
|
||||
StringSize80(const Fw::StringBase& src) :
|
||||
StringBase()
|
||||
{
|
||||
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
|
||||
}
|
||||
|
||||
String1::StringSize80 ::
|
||||
StringSize80(const StringSize80& src) :
|
||||
StringBase()
|
||||
{
|
||||
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
|
||||
}
|
||||
|
||||
String1::StringSize80 ::
|
||||
~StringSize80()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
StringSize80& StringSize80 ::
|
||||
operator=(const StringSize80& other)
|
||||
{
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf));
|
||||
return *this;
|
||||
}
|
||||
|
||||
StringSize80& StringSize80 ::
|
||||
operator=(const Fw::StringBase& other)
|
||||
{
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf));
|
||||
return *this;
|
||||
}
|
||||
|
||||
StringSize80& StringSize80 ::
|
||||
operator=(const char* other)
|
||||
{
|
||||
Fw::StringUtils::string_copy(this->m_buf, other, sizeof(this->m_buf));
|
||||
return *this;
|
||||
}
|
||||
|
||||
const char* StringSize80 ::
|
||||
toChar() const
|
||||
{
|
||||
return this->m_buf;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE StringSize80 ::
|
||||
getCapacity() const
|
||||
{
|
||||
return sizeof(this->m_buf);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
String1 ::
|
||||
String1() :
|
||||
Serializable()
|
||||
{
|
||||
// Construct using element-wise constructor
|
||||
*this = String1(
|
||||
"",
|
||||
"",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
String1 ::
|
||||
String1(const ElementType (&a)[SIZE]) :
|
||||
Serializable()
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = a[index];
|
||||
}
|
||||
}
|
||||
|
||||
String1 ::
|
||||
String1(const ElementType& e) :
|
||||
Serializable()
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = e;
|
||||
}
|
||||
}
|
||||
|
||||
String1 ::
|
||||
String1(
|
||||
const ElementType (&e1),
|
||||
const ElementType (&e2),
|
||||
const ElementType (&e3)
|
||||
) :
|
||||
Serializable()
|
||||
{
|
||||
this->elements[0] = e1;
|
||||
this->elements[1] = e2;
|
||||
this->elements[2] = e3;
|
||||
}
|
||||
|
||||
String1 ::
|
||||
String1(const String1& obj) :
|
||||
Serializable()
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = obj.elements[index];
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Operators
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
String1::ElementType& String1 ::
|
||||
operator[](const U32 i)
|
||||
{
|
||||
FW_ASSERT(i < SIZE);
|
||||
return this->elements[i];
|
||||
}
|
||||
|
||||
const String1::ElementType& String1 ::
|
||||
operator[](const U32 i) const
|
||||
{
|
||||
FW_ASSERT(i < SIZE);
|
||||
return this->elements[i];
|
||||
}
|
||||
|
||||
String1& String1 ::
|
||||
operator=(const String1& obj)
|
||||
{
|
||||
if (this == &obj) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = obj.elements[index];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
String1& String1 ::
|
||||
operator=(const ElementType (&a)[SIZE])
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = a[index];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
String1& String1 ::
|
||||
operator=(const ElementType& e)
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
this->elements[index] = e;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool String1 ::
|
||||
operator==(const String1& obj) const
|
||||
{
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
if ((*this)[index] != obj[index]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool String1 ::
|
||||
operator!=(const String1& obj) const
|
||||
{
|
||||
return !(*this == obj);
|
||||
}
|
||||
|
||||
#ifdef BUILD_UT
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const String1& obj) {
|
||||
Fw::String s;
|
||||
obj.toString(s);
|
||||
os << s;
|
||||
return os;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Fw::SerializeStatus String1 ::
|
||||
serialize(Fw::SerializeBufferBase& buffer) const
|
||||
{
|
||||
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
status = buffer.serialize((*this)[index]);
|
||||
if (status != Fw::FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
Fw::SerializeStatus String1 ::
|
||||
deserialize(Fw::SerializeBufferBase& buffer)
|
||||
{
|
||||
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
|
||||
for (U32 index = 0; index < SIZE; index++) {
|
||||
status = buffer.deserialize((*this)[index]);
|
||||
if (status != Fw::FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#if FW_ARRAY_TO_STRING || BUILD_UT
|
||||
|
||||
void String1 ::
|
||||
toString(Fw::StringBase& sb) const
|
||||
{
|
||||
static const char *formatString = "[ "
|
||||
"%s "
|
||||
"%s "
|
||||
"%s ]";
|
||||
|
||||
// Declare strings to hold any serializable toString() arguments
|
||||
char outputString[FW_ARRAY_TO_STRING_BUFFER_SIZE];
|
||||
(void) snprintf(
|
||||
outputString,
|
||||
FW_ARRAY_TO_STRING_BUFFER_SIZE,
|
||||
formatString,
|
||||
this->elements[0],
|
||||
this->elements[1],
|
||||
this->elements[2]
|
||||
);
|
||||
|
||||
outputString[FW_ARRAY_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate
|
||||
sb = outputString;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,211 @@
|
||||
// ======================================================================
|
||||
// \title String1ArrayAc.hpp
|
||||
// \author Generated by fpp-to-cpp
|
||||
// \brief hpp file for String1 array
|
||||
// ======================================================================
|
||||
|
||||
#ifndef String1ArrayAc_HPP
|
||||
#define String1ArrayAc_HPP
|
||||
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
|
||||
//! An array of strings
|
||||
class String1 :
|
||||
public Fw::Serializable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// StringSize80 class
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
class StringSize80 :
|
||||
public Fw::StringBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
enum {
|
||||
SERIALIZED_SIZE = 80 + sizeof(FwBuffSizeType); //!< Size of buffer + storage of two size words
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
StringSize80();
|
||||
|
||||
//! Char array constructor
|
||||
StringSize80(const char* src);
|
||||
|
||||
//! String base constructor
|
||||
StringSize80(const Fw::StringBase& src);
|
||||
|
||||
//! Copy constructor
|
||||
StringSize80(const StringSize80& src);
|
||||
|
||||
//! Destructor
|
||||
~StringSize80();
|
||||
|
||||
//! Copy assignment operator
|
||||
StringSize80& operator=(const StringSize80& other);
|
||||
|
||||
//! String base assignment operator
|
||||
StringSize80& operator=(const Fw::StringBase& other);
|
||||
|
||||
//! char* assignment operator
|
||||
StringSize80& operator=(const char* other);
|
||||
|
||||
//! Retrieves char buffer of string
|
||||
const char* toChar() const;
|
||||
|
||||
NATIVE_UINT_TYPE getCapacity() const;
|
||||
|
||||
private:
|
||||
|
||||
char m_buf[80]; //!< Buffer for string storage
|
||||
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Types
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! The element type
|
||||
typedef StringSize80 ElementType;
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constants
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
enum {
|
||||
//! The size of the array
|
||||
SIZE = 3,
|
||||
//! The size of the serial representation
|
||||
SERIALIZED_SIZE = SIZE * StringSize80::SERIALIZED_SIZE,
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Constructor (default value)
|
||||
String1();
|
||||
|
||||
//! Constructor (user-provided value)
|
||||
String1(
|
||||
const ElementType (&a)[SIZE] //!< The array
|
||||
);
|
||||
|
||||
//! Constructor (single element)
|
||||
String1(
|
||||
const ElementType& e //!< The element
|
||||
);
|
||||
|
||||
//! Constructor (multiple elements)
|
||||
String1(
|
||||
const ElementType (&e1), //!< Element 1
|
||||
const ElementType (&e2), //!< Element 2
|
||||
const ElementType (&e3) //!< Element 3
|
||||
);
|
||||
|
||||
//! Copy Constructor
|
||||
String1(
|
||||
const String1& obj //!< The source object
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Operators
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Subscript operator
|
||||
ElementType& operator[](
|
||||
const U32 i //!< The subscript index
|
||||
);
|
||||
|
||||
//! Const subscript operator
|
||||
const ElementType& operator[](
|
||||
const U32 i //!< The subscript index
|
||||
) const;
|
||||
|
||||
//! Copy assignment operator (object)
|
||||
String1& operator=(
|
||||
const String1& obj //!< The source object
|
||||
);
|
||||
|
||||
//! Copy assignment operator (raw array)
|
||||
String1& operator=(
|
||||
const ElementType (&a)[SIZE] //!< The source array
|
||||
);
|
||||
|
||||
//! Copy assignment operator (single element)
|
||||
String1& operator=(
|
||||
const ElementType& e //!< The element
|
||||
);
|
||||
|
||||
//! Equality operator
|
||||
bool operator==(
|
||||
const String1& obj //!< The other object
|
||||
) const;
|
||||
|
||||
//! Inequality operator
|
||||
bool operator!=(
|
||||
const String1& obj //!< The other object
|
||||
) const;
|
||||
|
||||
#ifdef BUILD_UT
|
||||
|
||||
//! Ostream operator
|
||||
friend std::ostream& operator<<(
|
||||
std::ostream& os, //!< The ostream
|
||||
const String1& obj //!< The object
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! Serialization
|
||||
Fw::SerializeStatus serialize(
|
||||
Fw::SerializeBufferBase& buffer //!< The serial buffer
|
||||
) const;
|
||||
|
||||
//! Deserialization
|
||||
Fw::SerializeStatus deserialize(
|
||||
Fw::SerializeBufferBase& buffer //!< The serial buffer
|
||||
);
|
||||
|
||||
#if FW_ARRAY_TO_STRING || BUILD_UT
|
||||
|
||||
//! Convert array to string
|
||||
void toString(
|
||||
Fw::StringBase& sb //!< The StringBase object to hold the result
|
||||
) const;
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member variables
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//! The array elements
|
||||
ElementType elements[SIZE];
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
9
compiler/tools/fpp-to-cpp/test/array/T.cpp
Normal file
9
compiler/tools/fpp-to-cpp/test/array/T.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "T.hpp"
|
||||
|
||||
bool T::operator==(const T& obj) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool T::operator!=(const T& obj) const {
|
||||
return false;
|
||||
}
|
||||
9
compiler/tools/fpp-to-cpp/test/array/T.hpp
Normal file
9
compiler/tools/fpp-to-cpp/test/array/T.hpp
Normal file
@ -0,0 +1,9 @@
|
||||
class T {
|
||||
public:
|
||||
enum {
|
||||
SERIALIZED_SIZE = 1
|
||||
};
|
||||
|
||||
bool operator==(const T& obj) const;
|
||||
bool operator!=(const T& obj) const;
|
||||
};
|
||||
4
compiler/tools/fpp-to-cpp/test/array/abs_type.fpp
Normal file
4
compiler/tools/fpp-to-cpp/test/array/abs_type.fpp
Normal file
@ -0,0 +1,4 @@
|
||||
type T
|
||||
|
||||
@ An array of abstract type
|
||||
array AbsType = [3] T
|
||||
4
compiler/tools/fpp-to-cpp/test/array/builtin_type.fpp
Normal file
4
compiler/tools/fpp-to-cpp/test/array/builtin_type.fpp
Normal file
@ -0,0 +1,4 @@
|
||||
type FwOpcodeType
|
||||
|
||||
@ An array of a built-in type
|
||||
array BuiltInType = [3] FwOpcodeType
|
||||
17
compiler/tools/fpp-to-cpp/test/array/check-cpp
Executable file
17
compiler/tools/fpp-to-cpp/test/array/check-cpp
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Compile ref C++ files, to check them for validity
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
fprime_gcc=../../../../scripts/fprime-gcc
|
||||
|
||||
for file in `find . -name '*Ac.ref.cpp'`
|
||||
do
|
||||
echo "compiling $file"
|
||||
base=`echo $file | sed 's;\.cpp;;'`
|
||||
dest_base=`echo $base | sed 's;\(.*Ac\).*;\1;'`
|
||||
cp $base.hpp $dest_base.hpp
|
||||
cp $base.cpp $dest_base.cpp
|
||||
$fprime_gcc -I../../.. -c $dest_base.cpp
|
||||
done
|
||||
10
compiler/tools/fpp-to-cpp/test/array/clean
Executable file
10
compiler/tools/fpp-to-cpp/test/array/clean
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
. ../../../../scripts/utils.sh
|
||||
|
||||
clean
|
||||
rm -f default-tests.sh default-update-ref.sh
|
||||
for file in `find . -name '*out.*' -or -name '*.names.txt' -or -name '*o' -or -name '*Ac.cpp' -or -name '*Ac.hpp'`
|
||||
do
|
||||
rm $file
|
||||
done
|
||||
18
compiler/tools/fpp-to-cpp/test/array/enum.fpp
Normal file
18
compiler/tools/fpp-to-cpp/test/array/enum.fpp
Normal file
@ -0,0 +1,18 @@
|
||||
module M {
|
||||
enum E1 {
|
||||
X = 1 @< Example comment
|
||||
Y = 2
|
||||
Z = 9
|
||||
}
|
||||
}
|
||||
|
||||
@ An enum with specified default value
|
||||
enum E2 {
|
||||
A = 10
|
||||
B = 20
|
||||
C = 30
|
||||
D = 40
|
||||
} default C
|
||||
|
||||
array Enum1 = [2] M.E1 default [ M.E1.X, M.E1.Y ] @< Array with enum argument
|
||||
array Enum2 = [5] E2
|
||||
0
compiler/tools/fpp-to-cpp/test/array/enum.ref.txt
Normal file
0
compiler/tools/fpp-to-cpp/test/array/enum.ref.txt
Normal file
10
compiler/tools/fpp-to-cpp/test/array/primitive.fpp
Normal file
10
compiler/tools/fpp-to-cpp/test/array/primitive.fpp
Normal file
@ -0,0 +1,10 @@
|
||||
module M {
|
||||
@ An array of primitives
|
||||
array Primitive1 = [3] U32
|
||||
|
||||
@ An array of primitives with specified default value and format string
|
||||
array Primitive2 = [5] F32 default 1 format "{.03f}"
|
||||
}
|
||||
|
||||
@ An array of arrays
|
||||
array PrimitiveArray = [5] M.Primitive2
|
||||
5
compiler/tools/fpp-to-cpp/test/array/run
Executable file
5
compiler/tools/fpp-to-cpp/test/array/run
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
export COMPILER_ROOT=../../../..
|
||||
|
||||
sh ../scripts/run.sh
|
||||
29
compiler/tools/fpp-to-cpp/test/array/run.sh
Normal file
29
compiler/tools/fpp-to-cpp/test/array/run.sh
Normal file
@ -0,0 +1,29 @@
|
||||
primitive()
|
||||
{
|
||||
run_test "-p $PWD" primitive && \
|
||||
diff_cpp Primitive1Array Primitive2Array PrimitiveArrayArray
|
||||
}
|
||||
|
||||
string()
|
||||
{
|
||||
run_test "-p $PWD" string && \
|
||||
diff_cpp String1Array String2Array StringArrayArray
|
||||
}
|
||||
|
||||
enum()
|
||||
{
|
||||
run_test "-p $PWD" enum && \
|
||||
diff_cpp E1Enum E2Enum Enum1Array Enum2Array
|
||||
}
|
||||
|
||||
builtin_type()
|
||||
{
|
||||
run_test "-p $PWD" builtin_type && \
|
||||
diff_cpp BuiltInTypeArray
|
||||
}
|
||||
|
||||
abs_type()
|
||||
{
|
||||
run_test "-p $PWD" abs_type && \
|
||||
diff_cpp AbsTypeArray
|
||||
}
|
||||
11
compiler/tools/fpp-to-cpp/test/array/string.fpp
Normal file
11
compiler/tools/fpp-to-cpp/test/array/string.fpp
Normal file
@ -0,0 +1,11 @@
|
||||
@ An array of strings
|
||||
array String1 = [3] string
|
||||
|
||||
@ An array of strings with specified default value and format string
|
||||
array String2 = [2] string default ["\"\\", """
|
||||
abc
|
||||
def
|
||||
"""] format "a {} b"
|
||||
|
||||
@ An array of arrays of strings
|
||||
array StringArray = [5] String2
|
||||
0
compiler/tools/fpp-to-cpp/test/array/string.ref.txt
Normal file
0
compiler/tools/fpp-to-cpp/test/array/string.ref.txt
Normal file
6
compiler/tools/fpp-to-cpp/test/array/tests.sh
Normal file
6
compiler/tools/fpp-to-cpp/test/array/tests.sh
Normal file
@ -0,0 +1,6 @@
|
||||
tests="
|
||||
primitive
|
||||
string
|
||||
enum
|
||||
builtin_type
|
||||
"
|
||||
5
compiler/tools/fpp-to-cpp/test/array/update-ref
Executable file
5
compiler/tools/fpp-to-cpp/test/array/update-ref
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
export COMPILER_ROOT=../../../..
|
||||
|
||||
sh ../scripts/update-ref.sh
|
||||
29
compiler/tools/fpp-to-cpp/test/array/update-ref.sh
Normal file
29
compiler/tools/fpp-to-cpp/test/array/update-ref.sh
Normal file
@ -0,0 +1,29 @@
|
||||
primitive()
|
||||
{
|
||||
update "-p $PWD" primitive
|
||||
move_cpp Primitive1Array Primitive2Array PrimitiveArrayArray
|
||||
}
|
||||
|
||||
string()
|
||||
{
|
||||
update "-p $PWD" string
|
||||
move_cpp String1Array String2Array StringArrayArray
|
||||
}
|
||||
|
||||
enum()
|
||||
{
|
||||
update "-p $PWD" enum
|
||||
move_cpp E1Enum E2Enum Enum1Array Enum2Array
|
||||
}
|
||||
|
||||
builtin_type()
|
||||
{
|
||||
update "-p $PWD" builtin_type
|
||||
move_cpp BuiltInTypeArray
|
||||
}
|
||||
|
||||
abs_type()
|
||||
{
|
||||
update "-p $PWD" abs_type
|
||||
move_cpp AbsTypeArray
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user