From 828539fe0b3fae292167cdeab224e7da0a900708 Mon Sep 17 00:00:00 2001
From: jawest
Date: Wed, 28 Jan 2026 12:16:51 -0800
Subject: [PATCH 1/4] Get default string size from analysis, remove default
string size arg from fpp-to-dict and fpp-to-cpp, regenerate tests
---
.../scala/analysis/Semantics/ImpliedUse.scala | 3 +-
.../codegen/CppWriter/CppWriterState.scala | 11 +-
.../codegen/CppWriter/CppWriterUtils.scala | 4 +-
.../DictionaryJsonEncoder.scala | 3 +-
.../DictionaryJsonEncoderState.scala | 17 +--
.../struct/StringArraySerializableAc.ref.hpp | 4 +-
.../test/struct/StringSerializableAc.ref.hpp | 4 +-
.../tools/fpp-to-cpp/test/struct/string.fpp | 2 +
.../top/BasicDpTopologyDictionary.ref.json | 28 ++++-
.../test/top/BasicTopologyDictionary.ref.json | 32 +++++-
.../DictionaryDefsTopologyDictionary.ref.json | 100 +++++++++++-------
.../top/FirstTopTopologyDictionary.ref.json | 26 ++++-
...alifiedCompInstTopologyDictionary.ref.json | 26 ++++-
.../top/SecondTopTopologyDictionary.ref.json | 26 ++++-
...alifiedCompInstTopologyDictionary.ref.json | 26 ++++-
...missingFwFixedLengthStringSizeConstant.fpp | 29 +++++
...ingFwFixedLengthStringSizeConstant.ref.txt | 7 ++
.../test/top/missingFwOpcodeType.fpp | 1 +
.../test/top/missingFwOpcodeType.ref.txt | 2 +-
.../test/top/missingUserDataSizeConstant.fpp | 1 +
.../top/missingUserDataSizeConstant.ref.txt | 2 +-
compiler/tools/fpp-to-dict/test/top/tests.sh | 1 +
.../tools/fpp/src/main/scala/fpp-to-cpp.scala | 7 --
.../fpp/src/main/scala/fpp-to-dict.scala | 8 +-
24 files changed, 283 insertions(+), 87 deletions(-)
create mode 100644 compiler/tools/fpp-to-dict/test/top/missingFwFixedLengthStringSizeConstant.fpp
create mode 100644 compiler/tools/fpp-to-dict/test/top/missingFwFixedLengthStringSizeConstant.ref.txt
diff --git a/compiler/lib/src/main/scala/analysis/Semantics/ImpliedUse.scala b/compiler/lib/src/main/scala/analysis/Semantics/ImpliedUse.scala
index ea505fde1..9dc672fba 100644
--- a/compiler/lib/src/main/scala/analysis/Semantics/ImpliedUse.scala
+++ b/compiler/lib/src/main/scala/analysis/Semantics/ImpliedUse.scala
@@ -77,7 +77,8 @@ object ImpliedUse {
* Each name is a list of identifiers */
def getTopologyConstants(a: Analysis) =
if (a.dictionaryGeneration) then List(
- List("Fw", "DpCfg", "CONTAINER_USER_DATA_SIZE")
+ List("Fw", "DpCfg", "CONTAINER_USER_DATA_SIZE"),
+ List("FW_FIXED_LENGTH_STRING_SIZE")
)
else Nil
diff --git a/compiler/lib/src/main/scala/codegen/CppWriter/CppWriterState.scala b/compiler/lib/src/main/scala/codegen/CppWriter/CppWriterState.scala
index 4d4ebcedf..39232dcb3 100644
--- a/compiler/lib/src/main/scala/codegen/CppWriter/CppWriterState.scala
+++ b/compiler/lib/src/main/scala/codegen/CppWriter/CppWriterState.scala
@@ -14,8 +14,6 @@ case class CppWriterState(
guardPrefix: Option[String] = None,
/** The list of include path prefixes */
pathPrefixes: List[String] = Nil,
- /** The default string size */
- defaultStringSize: Int = CppWriterState.defaultDefaultStringSize,
/** The name of the tool using the CppWriter */
toolName: Option[String] = None,
/** The map from strings to locations */
@@ -216,6 +214,15 @@ case class CppWriterState(
case _ => false
}
+ def getFwDefaultStringSize: BigInt = {
+ a.frameworkDefinitions.constants.fwFixedLengthStringSize match {
+ case Some(s: Symbol.Constant) => a.valueMap(s.getNodeId) match {
+ case Value.Integer(value) => value
+ case _ => throw InternalError("expected integer value")
+ }
+ case None => CppWriterState.defaultDefaultStringSize
+ }
+ }
}
object CppWriterState {
diff --git a/compiler/lib/src/main/scala/codegen/CppWriter/CppWriterUtils.scala b/compiler/lib/src/main/scala/codegen/CppWriter/CppWriterUtils.scala
index 58fd75f20..20cbfdebe 100644
--- a/compiler/lib/src/main/scala/codegen/CppWriter/CppWriterUtils.scala
+++ b/compiler/lib/src/main/scala/codegen/CppWriter/CppWriterUtils.scala
@@ -294,12 +294,12 @@ trait CppWriterUtils extends LineUtils {
val _ @ Value.Integer(value) = s.a.valueMap(node.id).convertToType(Type.Integer).get
value
}
- ).getOrElse(BigInt(s.defaultStringSize))
+ ).getOrElse(s.getFwDefaultStringSize)
/** Write the size of a string type */
def writeStringSize(s: CppWriterState, t: Type.String): String =
t.size.map(node => ValueCppWriter.write(s, s.a.valueMap(node.id))).
- getOrElse(s.defaultStringSize.toString)
+ getOrElse(s.getFwDefaultStringSize.toString)
/** Write a C++ expression for static serialized size */
def writeStaticSerializedSizeExpr(s: CppWriterState, t: Type, typeName: String): String =
diff --git a/compiler/lib/src/main/scala/codegen/DictionaryJsonWriter/DictionaryJsonEncoder.scala b/compiler/lib/src/main/scala/codegen/DictionaryJsonWriter/DictionaryJsonEncoder.scala
index 8870332e8..9b91c2aa7 100644
--- a/compiler/lib/src/main/scala/codegen/DictionaryJsonWriter/DictionaryJsonEncoder.scala
+++ b/compiler/lib/src/main/scala/codegen/DictionaryJsonWriter/DictionaryJsonEncoder.scala
@@ -132,9 +132,10 @@ case class DictionaryJsonEncoder(
"name" -> "string".asJson,
"kind" -> "string".asJson
)
+ val fwDefaultStringSize = dictionaryState.getFwDefaultStringSize
size match {
case Some(s) => Json.obj("size" -> valueAsJson(dictionaryState.a.valueMap(s.id))).deepMerge(jsonObj)
- case None => Json.obj("size" -> dictionaryState.defaultStringSize.asJson).deepMerge(jsonObj)
+ case None => Json.obj("size" -> fwDefaultStringSize.asJson).deepMerge(jsonObj)
}
}
case Type.Array(node, _, _, _) => {
diff --git a/compiler/lib/src/main/scala/codegen/DictionaryJsonWriter/DictionaryJsonEncoderState.scala b/compiler/lib/src/main/scala/codegen/DictionaryJsonWriter/DictionaryJsonEncoderState.scala
index 125a95ff1..2d5a44908 100644
--- a/compiler/lib/src/main/scala/codegen/DictionaryJsonWriter/DictionaryJsonEncoderState.scala
+++ b/compiler/lib/src/main/scala/codegen/DictionaryJsonWriter/DictionaryJsonEncoderState.scala
@@ -10,8 +10,6 @@ case class DictionaryJsonEncoderState(
a: Analysis,
/** The output directory */
dir: String = ".",
- /** The default string size */
- defaultStringSize: Int = DictionaryJsonEncoderState.defaultDefaultStringSize,
/** The default bool size */
boolSize: Int = DictionaryJsonEncoderState.boolSize,
/** The Dictionary metadata */
@@ -29,17 +27,24 @@ case class DictionaryJsonEncoderState(
}
}
+ def getFwDefaultStringSize: BigInt = {
+ a.frameworkDefinitions.constants.fwFixedLengthStringSize match {
+ case Some(s: Symbol.Constant) => a.valueMap(s.getNodeId) match {
+ case Value.Integer(value) => value
+ case _ => throw InternalError("expected integer value")
+ }
+ case None => throw InternalError("FW_FIXED_LENGTH_STRING_SIZE constant not defined")
+ }
+ }
+
}
case object DictionaryJsonEncoderState {
- /** The default string size */
- val defaultDefaultStringSize = 80
-
/** The default bool size */
val boolSize = 8
/** Gets the generated JSON file name for a topology definition */
def getTopologyFileName(baseName: String): String = s"${baseName}TopologyDictionary.json"
-}
\ No newline at end of file
+}
diff --git a/compiler/tools/fpp-to-cpp/test/struct/StringArraySerializableAc.ref.hpp b/compiler/tools/fpp-to-cpp/test/struct/StringArraySerializableAc.ref.hpp
index 2e20b37c9..e5fc47180 100644
--- a/compiler/tools/fpp-to-cpp/test/struct/StringArraySerializableAc.ref.hpp
+++ b/compiler/tools/fpp-to-cpp/test/struct/StringArraySerializableAc.ref.hpp
@@ -34,7 +34,7 @@ class StringArray :
enum {
//! The size of the serial representation
SERIALIZED_SIZE =
- Fw::StringBase::STATIC_SERIALIZED_SIZE(80) +
+ Fw::StringBase::STATIC_SERIALIZED_SIZE(60) +
Fw::StringBase::STATIC_SERIALIZED_SIZE(40) * 16
};
@@ -175,7 +175,7 @@ class StringArray :
// Member variables
// ----------------------------------------------------------------------
- char m___fprime_ac_s1_buffer[Fw::StringBase::BUFFER_SIZE(80)];
+ char m___fprime_ac_s1_buffer[Fw::StringBase::BUFFER_SIZE(60)];
Fw::ExternalString m_s1;
char m___fprime_ac_s2_buffer[16][Fw::StringBase::BUFFER_SIZE(40)];
Fw::ExternalString m_s2[16];
diff --git a/compiler/tools/fpp-to-cpp/test/struct/StringSerializableAc.ref.hpp b/compiler/tools/fpp-to-cpp/test/struct/StringSerializableAc.ref.hpp
index 775bc8f3b..5c449f4a9 100644
--- a/compiler/tools/fpp-to-cpp/test/struct/StringSerializableAc.ref.hpp
+++ b/compiler/tools/fpp-to-cpp/test/struct/StringSerializableAc.ref.hpp
@@ -25,7 +25,7 @@ class String :
enum {
//! The size of the serial representation
SERIALIZED_SIZE =
- Fw::StringBase::STATIC_SERIALIZED_SIZE(80) +
+ Fw::StringBase::STATIC_SERIALIZED_SIZE(60) +
Fw::StringBase::STATIC_SERIALIZED_SIZE(40)
};
@@ -160,7 +160,7 @@ class String :
// Member variables
// ----------------------------------------------------------------------
- char m___fprime_ac_s1_buffer[Fw::StringBase::BUFFER_SIZE(80)];
+ char m___fprime_ac_s1_buffer[Fw::StringBase::BUFFER_SIZE(60)];
Fw::ExternalString m_s1;
char m___fprime_ac_s2_buffer[Fw::StringBase::BUFFER_SIZE(40)];
Fw::ExternalString m_s2;
diff --git a/compiler/tools/fpp-to-cpp/test/struct/string.fpp b/compiler/tools/fpp-to-cpp/test/struct/string.fpp
index ffeb297d5..30901faa4 100644
--- a/compiler/tools/fpp-to-cpp/test/struct/string.fpp
+++ b/compiler/tools/fpp-to-cpp/test/struct/string.fpp
@@ -1,3 +1,5 @@
+constant FW_FIXED_LENGTH_STRING_SIZE = 60
+
struct String {
s1: string
s2: string size 40
diff --git a/compiler/tools/fpp-to-dict/test/top/BasicDpTopologyDictionary.ref.json b/compiler/tools/fpp-to-dict/test/top/BasicDpTopologyDictionary.ref.json
index ecaee69e3..0db4571bd 100644
--- a/compiler/tools/fpp-to-dict/test/top/BasicDpTopologyDictionary.ref.json
+++ b/compiler/tools/fpp-to-dict/test/top/BasicDpTopologyDictionary.ref.json
@@ -313,6 +313,29 @@
}
],
"constants" : [
+ {
+ "kind" : "constant",
+ "qualifiedName" : "FW_FIXED_LENGTH_STRING_SIZE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 256
+ },
+ {
+ "kind" : "constant",
+ "qualifiedName" : "Fw.DpCfg.CONTAINER_USER_DATA_SIZE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 32,
+ "annotation" : "The container user data size"
+ },
{
"kind" : "constant",
"qualifiedName" : "FW_SERIALIZE_TRUE_VALUE",
@@ -337,15 +360,14 @@
},
{
"kind" : "constant",
- "qualifiedName" : "Fw.DpCfg.CONTAINER_USER_DATA_SIZE",
+ "qualifiedName" : "STRING_SIZE",
"type" : {
"name" : "U64",
"kind" : "integer",
"size" : 64,
"signed" : false
},
- "value" : 32,
- "annotation" : "The container user data size"
+ "value" : 256
}
],
"commands" : [
diff --git a/compiler/tools/fpp-to-dict/test/top/BasicTopologyDictionary.ref.json b/compiler/tools/fpp-to-dict/test/top/BasicTopologyDictionary.ref.json
index 3fdcfcdd9..8ba9dd19a 100644
--- a/compiler/tools/fpp-to-dict/test/top/BasicTopologyDictionary.ref.json
+++ b/compiler/tools/fpp-to-dict/test/top/BasicTopologyDictionary.ref.json
@@ -249,14 +249,26 @@
"constants" : [
{
"kind" : "constant",
- "qualifiedName" : "FW_SERIALIZE_FALSE_VALUE",
+ "qualifiedName" : "FW_FIXED_LENGTH_STRING_SIZE",
"type" : {
"name" : "U64",
"kind" : "integer",
"size" : 64,
"signed" : false
},
- "value" : 0
+ "value" : 256
+ },
+ {
+ "kind" : "constant",
+ "qualifiedName" : "Fw.DpCfg.CONTAINER_USER_DATA_SIZE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 32,
+ "annotation" : "The container user data size"
},
{
"kind" : "constant",
@@ -271,15 +283,25 @@
},
{
"kind" : "constant",
- "qualifiedName" : "Fw.DpCfg.CONTAINER_USER_DATA_SIZE",
+ "qualifiedName" : "FW_SERIALIZE_FALSE_VALUE",
"type" : {
"name" : "U64",
"kind" : "integer",
"size" : 64,
"signed" : false
},
- "value" : 32,
- "annotation" : "The container user data size"
+ "value" : 0
+ },
+ {
+ "kind" : "constant",
+ "qualifiedName" : "STRING_SIZE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 256
}
],
"commands" : [
diff --git a/compiler/tools/fpp-to-dict/test/top/DictionaryDefsTopologyDictionary.ref.json b/compiler/tools/fpp-to-dict/test/top/DictionaryDefsTopologyDictionary.ref.json
index 82d2d9c49..1d1613fb2 100644
--- a/compiler/tools/fpp-to-dict/test/top/DictionaryDefsTopologyDictionary.ref.json
+++ b/compiler/tools/fpp-to-dict/test/top/DictionaryDefsTopologyDictionary.ref.json
@@ -86,45 +86,6 @@
"signed" : false
}
},
- {
- "kind" : "struct",
- "qualifiedName" : "S",
- "members" : {
- "X" : {
- "type" : {
- "name" : "string",
- "kind" : "string",
- "size" : 80
- },
- "index" : 0
- },
- "Y" : {
- "type" : {
- "name" : "A2",
- "kind" : "qualifiedIdentifier"
- },
- "index" : 1
- },
- "Z" : {
- "type" : {
- "name" : "S2",
- "kind" : "qualifiedIdentifier"
- },
- "index" : 2
- }
- },
- "default" : {
- "X" : "",
- "Y" : [
- 0,
- 0,
- 0
- ],
- "Z" : {
- "X" : 0
- }
- }
- },
{
"kind" : "alias",
"qualifiedName" : "FwEventIdType",
@@ -345,6 +306,45 @@
"signed" : false
}
},
+ {
+ "kind" : "struct",
+ "qualifiedName" : "S",
+ "members" : {
+ "X" : {
+ "type" : {
+ "name" : "string",
+ "kind" : "string",
+ "size" : 256
+ },
+ "index" : 0
+ },
+ "Y" : {
+ "type" : {
+ "name" : "A2",
+ "kind" : "qualifiedIdentifier"
+ },
+ "index" : 1
+ },
+ "Z" : {
+ "type" : {
+ "name" : "S2",
+ "kind" : "qualifiedIdentifier"
+ },
+ "index" : 2
+ }
+ },
+ "default" : {
+ "X" : "",
+ "Y" : [
+ 0,
+ 0,
+ 0
+ ],
+ "Z" : {
+ "X" : 0
+ }
+ }
+ },
{
"kind" : "alias",
"qualifiedName" : "FwSizeType",
@@ -408,6 +408,17 @@
}
],
"constants" : [
+ {
+ "kind" : "constant",
+ "qualifiedName" : "FW_FIXED_LENGTH_STRING_SIZE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 256
+ },
{
"kind" : "constant",
"qualifiedName" : "Fw.DpCfg.CONTAINER_USER_DATA_SIZE",
@@ -431,6 +442,17 @@
},
"value" : 255
},
+ {
+ "kind" : "constant",
+ "qualifiedName" : "STRING_SIZE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 256
+ },
{
"kind" : "constant",
"qualifiedName" : "P.C",
diff --git a/compiler/tools/fpp-to-dict/test/top/FirstTopTopologyDictionary.ref.json b/compiler/tools/fpp-to-dict/test/top/FirstTopTopologyDictionary.ref.json
index 7af198df9..c7bd3d684 100644
--- a/compiler/tools/fpp-to-dict/test/top/FirstTopTopologyDictionary.ref.json
+++ b/compiler/tools/fpp-to-dict/test/top/FirstTopTopologyDictionary.ref.json
@@ -111,7 +111,7 @@
"elementType" : {
"name" : "string",
"kind" : "string",
- "size" : 80
+ "size" : 256
},
"default" : [
"A",
@@ -594,6 +594,17 @@
}
],
"constants" : [
+ {
+ "kind" : "constant",
+ "qualifiedName" : "FW_FIXED_LENGTH_STRING_SIZE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 256
+ },
{
"kind" : "constant",
"qualifiedName" : "Fw.DpCfg.CONTAINER_USER_DATA_SIZE",
@@ -627,6 +638,17 @@
"signed" : false
},
"value" : 0
+ },
+ {
+ "kind" : "constant",
+ "qualifiedName" : "STRING_SIZE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 256
}
],
"commands" : [
@@ -851,7 +873,7 @@
"type" : {
"name" : "string",
"kind" : "string",
- "size" : 80
+ "size" : 256
},
"ref" : false
},
diff --git a/compiler/tools/fpp-to-dict/test/top/QualifiedCompInstTopologyDictionary.ref.json b/compiler/tools/fpp-to-dict/test/top/QualifiedCompInstTopologyDictionary.ref.json
index 0447cd19e..07a3dbc48 100644
--- a/compiler/tools/fpp-to-dict/test/top/QualifiedCompInstTopologyDictionary.ref.json
+++ b/compiler/tools/fpp-to-dict/test/top/QualifiedCompInstTopologyDictionary.ref.json
@@ -274,6 +274,17 @@
}
],
"constants" : [
+ {
+ "kind" : "constant",
+ "qualifiedName" : "FW_FIXED_LENGTH_STRING_SIZE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 256
+ },
{
"kind" : "constant",
"qualifiedName" : "Fw.DpCfg.CONTAINER_USER_DATA_SIZE",
@@ -286,6 +297,17 @@
"value" : 32,
"annotation" : "The container user data size"
},
+ {
+ "kind" : "constant",
+ "qualifiedName" : "FW_SERIALIZE_TRUE_VALUE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 255
+ },
{
"kind" : "constant",
"qualifiedName" : "FW_SERIALIZE_FALSE_VALUE",
@@ -299,14 +321,14 @@
},
{
"kind" : "constant",
- "qualifiedName" : "FW_SERIALIZE_TRUE_VALUE",
+ "qualifiedName" : "STRING_SIZE",
"type" : {
"name" : "U64",
"kind" : "integer",
"size" : 64,
"signed" : false
},
- "value" : 255
+ "value" : 256
}
],
"commands" : [
diff --git a/compiler/tools/fpp-to-dict/test/top/SecondTopTopologyDictionary.ref.json b/compiler/tools/fpp-to-dict/test/top/SecondTopTopologyDictionary.ref.json
index c4c44f708..53e26b244 100644
--- a/compiler/tools/fpp-to-dict/test/top/SecondTopTopologyDictionary.ref.json
+++ b/compiler/tools/fpp-to-dict/test/top/SecondTopTopologyDictionary.ref.json
@@ -111,7 +111,7 @@
"elementType" : {
"name" : "string",
"kind" : "string",
- "size" : 80
+ "size" : 256
},
"default" : [
"A",
@@ -594,6 +594,17 @@
}
],
"constants" : [
+ {
+ "kind" : "constant",
+ "qualifiedName" : "FW_FIXED_LENGTH_STRING_SIZE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 256
+ },
{
"kind" : "constant",
"qualifiedName" : "Fw.DpCfg.CONTAINER_USER_DATA_SIZE",
@@ -627,6 +638,17 @@
"signed" : false
},
"value" : 0
+ },
+ {
+ "kind" : "constant",
+ "qualifiedName" : "STRING_SIZE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 256
}
],
"commands" : [
@@ -851,7 +873,7 @@
"type" : {
"name" : "string",
"kind" : "string",
- "size" : 80
+ "size" : 256
},
"ref" : false
},
diff --git a/compiler/tools/fpp-to-dict/test/top/UnqualifiedCompInstTopologyDictionary.ref.json b/compiler/tools/fpp-to-dict/test/top/UnqualifiedCompInstTopologyDictionary.ref.json
index e67108777..e1bc186f0 100644
--- a/compiler/tools/fpp-to-dict/test/top/UnqualifiedCompInstTopologyDictionary.ref.json
+++ b/compiler/tools/fpp-to-dict/test/top/UnqualifiedCompInstTopologyDictionary.ref.json
@@ -274,6 +274,17 @@
}
],
"constants" : [
+ {
+ "kind" : "constant",
+ "qualifiedName" : "FW_FIXED_LENGTH_STRING_SIZE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 256
+ },
{
"kind" : "constant",
"qualifiedName" : "Fw.DpCfg.CONTAINER_USER_DATA_SIZE",
@@ -286,6 +297,17 @@
"value" : 32,
"annotation" : "The container user data size"
},
+ {
+ "kind" : "constant",
+ "qualifiedName" : "FW_SERIALIZE_TRUE_VALUE",
+ "type" : {
+ "name" : "U64",
+ "kind" : "integer",
+ "size" : 64,
+ "signed" : false
+ },
+ "value" : 255
+ },
{
"kind" : "constant",
"qualifiedName" : "FW_SERIALIZE_FALSE_VALUE",
@@ -299,14 +321,14 @@
},
{
"kind" : "constant",
- "qualifiedName" : "FW_SERIALIZE_TRUE_VALUE",
+ "qualifiedName" : "STRING_SIZE",
"type" : {
"name" : "U64",
"kind" : "integer",
"size" : 64,
"signed" : false
},
- "value" : 255
+ "value" : 256
}
],
"commands" : [
diff --git a/compiler/tools/fpp-to-dict/test/top/missingFwFixedLengthStringSizeConstant.fpp b/compiler/tools/fpp-to-dict/test/top/missingFwFixedLengthStringSizeConstant.fpp
new file mode 100644
index 000000000..8b286586a
--- /dev/null
+++ b/compiler/tools/fpp-to-dict/test/top/missingFwFixedLengthStringSizeConstant.fpp
@@ -0,0 +1,29 @@
+type FwChanIdType = U32
+type FwDpIdType = U32
+type FwDpPriorityType = U32
+type FwEventIdType = U32
+type FwOpcodeType = U32
+type FwPacketDescriptorType = U32
+type FwTlmPacketizeIdType = U16
+type FwSizeType = U32
+type FwSizeStoreType = U16
+type FwTimeBaseStoreType = U16
+type FwTimeContextStoreType = U8
+
+module Fw {
+ enum DpState {
+ UNTRANSMITTED
+ }
+
+ module DpCfg {
+ enum ProcType {
+ UNTRANSMITTED
+ }
+
+ constant CONTAINER_USER_DATA_SIZE = 1
+ }
+}
+
+topology T {
+
+}
diff --git a/compiler/tools/fpp-to-dict/test/top/missingFwFixedLengthStringSizeConstant.ref.txt b/compiler/tools/fpp-to-dict/test/top/missingFwFixedLengthStringSizeConstant.ref.txt
new file mode 100644
index 000000000..92fc56867
--- /dev/null
+++ b/compiler/tools/fpp-to-dict/test/top/missingFwFixedLengthStringSizeConstant.ref.txt
@@ -0,0 +1,7 @@
+fpp-to-dict
+[ local path prefix ]/tools/fpp-to-dict/test/top/missingFwFixedLengthStringSizeConstant.fpp:27.1
+topology T {
+^
+error: symbol FW_FIXED_LENGTH_STRING_SIZE is not defined
+note: looking for a constant here
+note: when constructing a dictionary, the constant FW_FIXED_LENGTH_STRING_SIZE must be defined
diff --git a/compiler/tools/fpp-to-dict/test/top/missingFwOpcodeType.fpp b/compiler/tools/fpp-to-dict/test/top/missingFwOpcodeType.fpp
index c8763ee74..05a999b28 100644
--- a/compiler/tools/fpp-to-dict/test/top/missingFwOpcodeType.fpp
+++ b/compiler/tools/fpp-to-dict/test/top/missingFwOpcodeType.fpp
@@ -8,6 +8,7 @@ type FwSizeType = U32
type FwSizeStoreType = U16
type FwTimeBaseStoreType = U16
type FwTimeContextStoreType = U8
+constant FW_FIXED_LENGTH_STRING_SIZE = 256
module Fw {
enum DpState {
diff --git a/compiler/tools/fpp-to-dict/test/top/missingFwOpcodeType.ref.txt b/compiler/tools/fpp-to-dict/test/top/missingFwOpcodeType.ref.txt
index d55ad9957..0fa836cd5 100644
--- a/compiler/tools/fpp-to-dict/test/top/missingFwOpcodeType.ref.txt
+++ b/compiler/tools/fpp-to-dict/test/top/missingFwOpcodeType.ref.txt
@@ -1,5 +1,5 @@
fpp-to-dict
-[ local path prefix ]/tools/fpp-to-dict/test/top/missingFwOpcodeType.fpp:26.1
+[ local path prefix ]/tools/fpp-to-dict/test/top/missingFwOpcodeType.fpp:27.1
topology T {
^
error: symbol FwOpcodeType is not defined
diff --git a/compiler/tools/fpp-to-dict/test/top/missingUserDataSizeConstant.fpp b/compiler/tools/fpp-to-dict/test/top/missingUserDataSizeConstant.fpp
index 58ce4e0a2..2e2b9284f 100644
--- a/compiler/tools/fpp-to-dict/test/top/missingUserDataSizeConstant.fpp
+++ b/compiler/tools/fpp-to-dict/test/top/missingUserDataSizeConstant.fpp
@@ -9,6 +9,7 @@ type FwSizeType = U32
type FwSizeStoreType = U16
type FwTimeBaseStoreType = U16
type FwTimeContextStoreType = U8
+constant FW_FIXED_LENGTH_STRING_SIZE = 256
module Fw {
enum DpState {
diff --git a/compiler/tools/fpp-to-dict/test/top/missingUserDataSizeConstant.ref.txt b/compiler/tools/fpp-to-dict/test/top/missingUserDataSizeConstant.ref.txt
index 42e97a1eb..e02e7ddbd 100644
--- a/compiler/tools/fpp-to-dict/test/top/missingUserDataSizeConstant.ref.txt
+++ b/compiler/tools/fpp-to-dict/test/top/missingUserDataSizeConstant.ref.txt
@@ -1,5 +1,5 @@
fpp-to-dict
-[ local path prefix ]/tools/fpp-to-dict/test/top/missingUserDataSizeConstant.fpp:25.1
+[ local path prefix ]/tools/fpp-to-dict/test/top/missingUserDataSizeConstant.fpp:26.1
topology T {
^
error: symbol CONTAINER_USER_DATA_SIZE is not defined
diff --git a/compiler/tools/fpp-to-dict/test/top/tests.sh b/compiler/tools/fpp-to-dict/test/top/tests.sh
index ad520ef6b..d9baae306 100644
--- a/compiler/tools/fpp-to-dict/test/top/tests.sh
+++ b/compiler/tools/fpp-to-dict/test/top/tests.sh
@@ -4,6 +4,7 @@ basic
dataProducts
duplicate
missingFwOpcodeType
+missingFwFixedLengthStringSizeConstant
missingUserDataSizeConstant
invalidUserDataSizeConstant
unqualifiedComponentInstances
diff --git a/compiler/tools/fpp/src/main/scala/fpp-to-cpp.scala b/compiler/tools/fpp/src/main/scala/fpp-to-cpp.scala
index 5af74fd38..49ac4bb67 100644
--- a/compiler/tools/fpp/src/main/scala/fpp-to-cpp.scala
+++ b/compiler/tools/fpp/src/main/scala/fpp-to-cpp.scala
@@ -18,7 +18,6 @@ object FPPToCpp {
guardPrefix: Option[String] = None,
names: Option[String] = None,
pathPrefixes: List[String] = Nil,
- defaultStringSize: Int = CppWriterState.defaultDefaultStringSize,
template: Boolean = false,
unitTest: Boolean = false,
)
@@ -97,7 +96,6 @@ object FPPToCpp {
dir,
options.guardPrefix,
options.pathPrefixes,
- options.defaultStringSize,
Some(name)
)
mode match {
@@ -157,11 +155,6 @@ object FPPToCpp {
.valueName(",...")
.action((p, c) => c.copy(pathPrefixes = p.toList))
.text("prefixes to delete from generated file paths"),
- opt[Int]('s', "size")
- .valueName("")
- .validate(s => if (s > 0) success else failure("size must be greater than zero"))
- .action((s, c) => c.copy(defaultStringSize = s))
- .text("default string size"),
opt[Unit]('t', "template")
.action((_, c) => c.copy(template = true))
.text("emit template code"),
diff --git a/compiler/tools/fpp/src/main/scala/fpp-to-dict.scala b/compiler/tools/fpp/src/main/scala/fpp-to-dict.scala
index 088581369..8ff5fda58 100644
--- a/compiler/tools/fpp/src/main/scala/fpp-to-dict.scala
+++ b/compiler/tools/fpp/src/main/scala/fpp-to-dict.scala
@@ -14,7 +14,6 @@ object FPPToDict {
files: List[File] = Nil,
imports: List[File] = Nil,
dir: Option[String] = None,
- defaultStringSize: Int = DictionaryJsonEncoderState.defaultDefaultStringSize,
frameworkVersion: String = "",
projectVersion: String = "",
libraryVersions: List[String] = Nil,
@@ -50,7 +49,7 @@ object FPPToDict {
case None => "."
}
ComputeDictionaryFiles.visitList(
- DictionaryJsonEncoderState(a=a, dir=dir, defaultStringSize=options.defaultStringSize, metadata=metadata),
+ DictionaryJsonEncoderState(a=a, dir=dir, metadata=metadata),
tulFiles,
ComputeDictionaryFiles.transUnit
)
@@ -85,11 +84,6 @@ object FPPToDict {
.valueName("")
.action((d, c) => c.copy(dir = Some(d)))
.text("output directory"),
- opt[Int]('s', "size")
- .valueName("")
- .validate(s => if (s > 0) success else failure("size must be greater than zero"))
- .action((s, c) => c.copy(defaultStringSize = s))
- .text("default string size"),
opt[String]('f', "frameworkVersion")
.valueName("")
.action((f, c) => c.copy(frameworkVersion = f))
From 1548baff634b66e419d0bf14c4a399ffd5ecbfbd Mon Sep 17 00:00:00 2001
From: jawest
Date: Wed, 28 Jan 2026 12:41:23 -0800
Subject: [PATCH 2/4] Update user guide
---
docs/fpp-spec.html | 2 +-
docs/fpp-users-guide.html | 55 +++++--------------
docs/index.html | 2 +-
.../Analyzing-and-Translating-Models.adoc | 42 +++++---------
4 files changed, 31 insertions(+), 70 deletions(-)
diff --git a/docs/fpp-spec.html b/docs/fpp-spec.html
index 2bc7ed7e8..445cd54aa 100644
--- a/docs/fpp-spec.html
+++ b/docs/fpp-spec.html
@@ -12152,7 +12152,7 @@
diff --git a/docs/fpp-users-guide.html b/docs/fpp-users-guide.html
index fc5f9c61b..643471bcd 100644
--- a/docs/fpp-users-guide.html
+++ b/docs/fpp-users-guide.html
@@ -14299,23 +14299,16 @@
-
+
FPP allows string types with no specified size.
When generating code we need to provide a default size
to use when FPP doesn’t specify the size.
-If you don’t specify the -s option, then the tool uses
-an automatic default of 80.
-
-
-
+If the FW_FIXED_LENGTH_STRING_SIZE
+framework constant
+is not defined in the model, then the tool uses an
+automatic default of 80.
@@ -14830,34 +14823,16 @@
16.5. G
F Prime configuration:
-When you run fpp-to-dict on an FPP model, the model must define the following
-types:
-
-
-
--
-
FwChanIdType
-
--
-
FwEventIdType
-
--
-
FwOpcodeType
-
--
-
FwPacketDescriptorType
-
--
-
FwTlmPacketizeIdType
-
-
+When you run
fpp-to-dict on an FPP model, the model must define the
+framework definitions specified in the
+
F Prime
+dictionary specification.
-
These types are required by the F Prime GDS, so they are included in the
-dictionary.
-Each of these types must be an alias of an integer type.
-Typically you specify these types as part of F Prime configuration,
-in the file config/FpConfig.fpp.
+
These types and constants are required by the F Prime GDS, so they are
+included in the dictionary.
+Typically you specify these types and constants as part of F Prime configuration,
+in the file default/config/FpConfig.fpp or default/config/FpConstants.fpp.
See the
F
Prime documentation for details.
@@ -14869,7 +14844,7 @@
16.5. G
diff --git a/docs/index.html b/docs/index.html
index 41ba698fb..d66d1ca04 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -464,7 +464,7 @@ F Prime Prime (FPP)