mirror of
https://github.com/nasa/fpp.git
synced 2025-12-12 04:41:37 -06:00
Revise header files in generated C++
This commit is contained in:
parent
c88938b938
commit
cceec03f05
@ -8,11 +8,7 @@ import fpp.compiler.util._
|
||||
case class ArrayCppWriter (
|
||||
s: CppWriterState,
|
||||
aNode: Ast.Annotated[AstNode[Ast.DefArray]]
|
||||
) extends AstVisitor with CppWriterLineUtils {
|
||||
|
||||
type In = CppWriterState
|
||||
|
||||
type Out = List[Line]
|
||||
) extends CppWriterLineUtils {
|
||||
|
||||
private val node = aNode._2
|
||||
|
||||
@ -46,12 +42,10 @@ case class ArrayCppWriter (
|
||||
data.eltType
|
||||
)
|
||||
|
||||
override def default(s: CppWriterState): List[Line] = Nil
|
||||
|
||||
override def defArrayAnnotatedNode(
|
||||
private def writeIncludeDirectives(
|
||||
s: CppWriterState,
|
||||
aNode: Ast.Annotated[AstNode[Ast.DefArray]]
|
||||
): List[Line] = {
|
||||
): List[String] = {
|
||||
val Right(a) = UsedSymbols.defArrayAnnotatedNode(s.a, aNode)
|
||||
s.writeIncludeDirectives(a.usedSymbolSet)
|
||||
}
|
||||
@ -93,19 +87,14 @@ case class ArrayCppWriter (
|
||||
}
|
||||
|
||||
private def getHppIncludes: CppDoc.Member = {
|
||||
val strings = List(
|
||||
val standardHeaders = List(
|
||||
"Fw/Types/BasicTypes.hpp",
|
||||
"Fw/Types/Serializable.hpp",
|
||||
"Fw/Types/String.hpp"
|
||||
)
|
||||
CppWriter.linesMember(
|
||||
List(
|
||||
Line.blank ::
|
||||
strings.map(CppWriter.headerString).map(line),
|
||||
Line.blank ::
|
||||
defArrayAnnotatedNode(s, aNode),
|
||||
).flatten
|
||||
)
|
||||
).map(CppWriter.headerString)
|
||||
val symbolHeaders = writeIncludeDirectives(s, aNode)
|
||||
val headers = standardHeaders ++ symbolHeaders
|
||||
CppWriter.linesMember(addBlankPrefix(headers.sorted.map(line)))
|
||||
}
|
||||
|
||||
private def getCppIncludes: CppDoc.Member = {
|
||||
|
||||
@ -129,7 +129,7 @@ case class CppWriterState(
|
||||
}
|
||||
|
||||
/** Write include directives as lines */
|
||||
def writeIncludeDirectives(usedSymbols: Iterable[Symbol]): List[Line] = {
|
||||
def writeIncludeDirectives(usedSymbols: Iterable[Symbol]): List[String] = {
|
||||
def getHeaderStr(file: File.JavaPath) =
|
||||
CppWriter.headerString(s"${file.toString}.hpp")
|
||||
def getDirectiveforSymbol(sym: Symbol): Option[String] = sym match {
|
||||
@ -143,9 +143,6 @@ case class CppWriterState(
|
||||
case Symbol.Component(node) => Some(
|
||||
getHeaderStr(getRelativePath(ComputeCppFiles.FileNames.getComponent(getName(Symbol.Component(node)))))
|
||||
)
|
||||
case Symbol.Constant(_) => Some(
|
||||
getHeaderStr(getRelativePath(ComputeCppFiles.FileNames.getConstants))
|
||||
)
|
||||
case Symbol.Enum(node) => Some(
|
||||
getHeaderStr(getRelativePath(ComputeCppFiles.FileNames.getEnum(getName(Symbol.Enum(node)))))
|
||||
)
|
||||
@ -161,10 +158,7 @@ case class CppWriterState(
|
||||
case _ => None
|
||||
}
|
||||
|
||||
usedSymbols.map(getDirectiveforSymbol).filter(_.isDefined).map(_.get).toList match {
|
||||
case Nil => Nil
|
||||
case strings => strings.map(Line(_))
|
||||
}
|
||||
usedSymbols.map(getDirectiveforSymbol).filter(_.isDefined).map(_.get).toList
|
||||
}
|
||||
|
||||
/** Is this a built-in type? */
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "T.hpp"
|
||||
|
||||
//! An array of abstract type
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
|
||||
//! An array of a built-in type
|
||||
class BuiltInType :
|
||||
public Fw::Serializable
|
||||
|
||||
@ -7,12 +7,11 @@
|
||||
#ifndef Enum1ArrayAc_HPP
|
||||
#define Enum1ArrayAc_HPP
|
||||
|
||||
#include "E1EnumAc.hpp"
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "E1EnumAc.hpp"
|
||||
|
||||
//! Array with enum argument
|
||||
class Enum1 :
|
||||
public Fw::Serializable
|
||||
|
||||
@ -7,12 +7,11 @@
|
||||
#ifndef Enum2ArrayAc_HPP
|
||||
#define Enum2ArrayAc_HPP
|
||||
|
||||
#include "E2EnumAc.hpp"
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "E2EnumAc.hpp"
|
||||
|
||||
class Enum2 :
|
||||
public Fw::Serializable
|
||||
{
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "PrimitiveF64ArrayAc.hpp"
|
||||
|
||||
//! An array of arrays
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "FppConstantsAc.hpp"
|
||||
|
||||
namespace M {
|
||||
|
||||
class PrimitiveBool :
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "FppConstantsAc.hpp"
|
||||
|
||||
namespace M {
|
||||
|
||||
//! An array of F32 with default value and format string
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "FppConstantsAc.hpp"
|
||||
|
||||
namespace M {
|
||||
|
||||
//! An array of F32 with format string
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "FppConstantsAc.hpp"
|
||||
|
||||
namespace M {
|
||||
|
||||
//! An array of F64 with default value and format string
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "FppConstantsAc.hpp"
|
||||
|
||||
namespace M {
|
||||
|
||||
//! An array of I32 with format string
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "FppConstantsAc.hpp"
|
||||
|
||||
namespace M {
|
||||
|
||||
//! An array of I64 with format string
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "FppConstantsAc.hpp"
|
||||
|
||||
namespace M {
|
||||
|
||||
class PrimitiveU16 :
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "FppConstantsAc.hpp"
|
||||
|
||||
namespace M {
|
||||
|
||||
class PrimitiveU8 :
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
|
||||
//! An array of strings
|
||||
class String1 :
|
||||
public Fw::Serializable
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
|
||||
//! An array of strings with specified default value and format string
|
||||
class String2 :
|
||||
public Fw::Serializable
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "String2ArrayAc.hpp"
|
||||
|
||||
//! An array of arrays of strings
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "S1SerializableAc.hpp"
|
||||
|
||||
//! An array of structs
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "S2SerializableAc.hpp"
|
||||
|
||||
//! Array of structs with struct member
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
#include "Fw/Types/Serializable.hpp"
|
||||
#include "Fw/Types/String.hpp"
|
||||
|
||||
#include "S3SerializableAc.hpp"
|
||||
|
||||
//! An array of structs with array member
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user