From 15e3f2b09f6bf2bbec4523c86d6b0c4a499db7c8 Mon Sep 17 00:00:00 2001 From: tiffany1618 Date: Thu, 19 Jan 2023 10:01:33 -0800 Subject: [PATCH 1/3] Fix bugs in C++ port writer --- .../codegen/CppWriter/PortCppWriter.scala | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/compiler/lib/src/main/scala/codegen/CppWriter/PortCppWriter.scala b/compiler/lib/src/main/scala/codegen/CppWriter/PortCppWriter.scala index dfa8b038f..6f038ff53 100644 --- a/compiler/lib/src/main/scala/codegen/CppWriter/PortCppWriter.scala +++ b/compiler/lib/src/main/scala/codegen/CppWriter/PortCppWriter.scala @@ -351,8 +351,8 @@ case class PortCppWriter ( |this->trace(); |#endif | - |FW_ASSERT(this->m_comp); - |FW_ASSERT(this->m_func); + |FW_ASSERT(this->m_comp != nullptr); + |FW_ASSERT(this->m_func != nullptr); |""" ) ++ paramList.flatMap((n, tn, _) => { @@ -422,8 +422,8 @@ case class PortCppWriter ( ), CppDoc.Type("void"), lines( - """|FW_ASSERT(callComp); - |FW_ASSERT(funcPtr); + """|FW_ASSERT(callComp != nullptr); + |FW_ASSERT(funcPtr != nullptr); | |this->m_comp = callComp; |this->m_func = funcPtr; @@ -443,8 +443,8 @@ case class PortCppWriter ( |this->trace(); |#endif | - |FW_ASSERT(this->m_comp); - |FW_ASSERT(this->m_func); + |FW_ASSERT(this->m_comp != nullptr); + |FW_ASSERT(this->m_func != nullptr); | |return this->m_func(this->m_comp, this->m_portNum${paramNames}); |""" @@ -501,20 +501,27 @@ case class PortCppWriter ( } private def getOutputPortFunctionMembers: List[CppDoc.Class.Member] = { - val paramNames = paramList.map(_._1).mkString(", ") + val invokeCall = s"this->m_port->invoke(${paramList.map(_._1).mkString(", ")});" val invokeBody = data.returnType match { case Some(_) => lines( - s"return this->m_port->invoke($paramNames);" - ) - case None => lines( - s"""|if (this->m_port) { - | this->m_port->invoke($paramNames); - |#if FW_PORT_SERIALIZATION - |} else if (this->m_serPort) { - | Fw::SerializeStatus _status; - | ${name}PortBuffer _buffer; + s"""| + |FW_ASSERT(this->m_port != nullptr); + |return $invokeCall |""" - ) ++ + ) + case None => List( + lines( + s"""| + |#if FW_PORT_SERIALIZATION + |FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr)); + | + |if (this->m_port != nullptr) { + | $invokeCall + |} else { + | Fw::SerializeStatus _status; + | ${name}PortBuffer _buffer; + |""" + ), paramList.flatMap((n, _, _) => { lines( s"""| @@ -522,17 +529,19 @@ case class PortCppWriter ( | FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast(_status)); |""" ) - }) ++ + }), lines( - """| - | _status = this->m_serPort->invokeSerial(_buffer); - | FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast(_status)); - |} - |#else - |} - |#endif - |""" + s"""| + | _status = this->m_serPort->invokeSerial(_buffer); + | FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast(_status)); + |} + |#else + |FW_ASSERT(this->m_port != nullptr); + |$invokeCall + |#endif + |""" ) + ).flatten } List( @@ -577,7 +586,7 @@ case class PortCppWriter ( ), CppDoc.Type("void"), lines( - """|FW_ASSERT(callPort); + """|FW_ASSERT(callPort != nullptr); | |this->m_port = callPort; |this->m_connObj = callPort; @@ -599,13 +608,6 @@ case class PortCppWriter ( s"""|#if FW_PORT_TRACING == 1 |this->trace(); |#endif - | - |#if FW_PORT_SERIALIZATION - |FW_ASSERT(this->m_port || this->m_serPort); - |#else - |FW_ASSERT(this->m_port); - |#endif - | |""" ) ++ invokeBody From 4b613dd4f86803296b93514577579b7d62b16329 Mon Sep 17 00:00:00 2001 From: tiffany1618 Date: Thu, 19 Jan 2023 10:01:46 -0800 Subject: [PATCH 2/3] Update unit tests for C++ port writer --- .../test/port/AbsTypePortAc.ref.cpp | 28 +++++++++---------- .../test/port/BuiltInTypePortAc.ref.cpp | 28 +++++++++---------- .../fpp-to-cpp/test/port/EmptyPortAc.ref.cpp | 28 +++++++++---------- .../test/port/FppTypePortAc.ref.cpp | 28 +++++++++---------- .../test/port/KwdNamePortAc.ref.cpp | 28 +++++++++---------- .../test/port/PrimitivePortAc.ref.cpp | 28 +++++++++---------- .../test/port/ReturnTypePortAc.ref.cpp | 16 ++++------- .../fpp-to-cpp/test/port/StringPortAc.ref.cpp | 28 +++++++++---------- 8 files changed, 97 insertions(+), 115 deletions(-) diff --git a/compiler/tools/fpp-to-cpp/test/port/AbsTypePortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/AbsTypePortAc.ref.cpp index 59e98e130..f94f237d7 100644 --- a/compiler/tools/fpp-to-cpp/test/port/AbsTypePortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/AbsTypePortAc.ref.cpp @@ -62,8 +62,8 @@ void InputAbsTypePort :: CompFuncPtr funcPtr ) { - FW_ASSERT(callComp); - FW_ASSERT(funcPtr); + FW_ASSERT(callComp != nullptr); + FW_ASSERT(funcPtr != nullptr); this->m_comp = callComp; this->m_func = funcPtr; @@ -80,8 +80,8 @@ void InputAbsTypePort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); return this->m_func(this->m_comp, this->m_portNum, t, tRef); } @@ -97,8 +97,8 @@ Fw::SerializeStatus InputAbsTypePort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); T t; _status = _buffer.deserialize(t); @@ -140,7 +140,7 @@ void OutputAbsTypePort :: void OutputAbsTypePort :: addCallPort(InputAbsTypePort* callPort) { - FW_ASSERT(callPort); + FW_ASSERT(callPort != nullptr); this->m_port = callPort; this->m_connObj = callPort; @@ -161,14 +161,11 @@ void OutputAbsTypePort :: #endif #if FW_PORT_SERIALIZATION - FW_ASSERT(this->m_port || this->m_serPort); -#else - FW_ASSERT(this->m_port); -#endif - if (this->m_port) { + FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr)); + + if (this->m_port != nullptr) { this->m_port->invoke(t, tRef); -#if FW_PORT_SERIALIZATION - } else if (this->m_serPort) { + } else { Fw::SerializeStatus _status; AbsTypePortBuffer _buffer; @@ -182,6 +179,7 @@ void OutputAbsTypePort :: FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast(_status)); } #else - } + FW_ASSERT(this->m_port != nullptr); + this->m_port->invoke(t, tRef); #endif } diff --git a/compiler/tools/fpp-to-cpp/test/port/BuiltInTypePortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/BuiltInTypePortAc.ref.cpp index 5286011ef..88c51ef34 100644 --- a/compiler/tools/fpp-to-cpp/test/port/BuiltInTypePortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/BuiltInTypePortAc.ref.cpp @@ -62,8 +62,8 @@ void InputBuiltInTypePort :: CompFuncPtr funcPtr ) { - FW_ASSERT(callComp); - FW_ASSERT(funcPtr); + FW_ASSERT(callComp != nullptr); + FW_ASSERT(funcPtr != nullptr); this->m_comp = callComp; this->m_func = funcPtr; @@ -80,8 +80,8 @@ void InputBuiltInTypePort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); return this->m_func(this->m_comp, this->m_portNum, t, tRef); } @@ -97,8 +97,8 @@ Fw::SerializeStatus InputBuiltInTypePort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); FwOpcodeType t; _status = _buffer.deserialize(t); @@ -140,7 +140,7 @@ void OutputBuiltInTypePort :: void OutputBuiltInTypePort :: addCallPort(InputBuiltInTypePort* callPort) { - FW_ASSERT(callPort); + FW_ASSERT(callPort != nullptr); this->m_port = callPort; this->m_connObj = callPort; @@ -161,14 +161,11 @@ void OutputBuiltInTypePort :: #endif #if FW_PORT_SERIALIZATION - FW_ASSERT(this->m_port || this->m_serPort); -#else - FW_ASSERT(this->m_port); -#endif - if (this->m_port) { + FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr)); + + if (this->m_port != nullptr) { this->m_port->invoke(t, tRef); -#if FW_PORT_SERIALIZATION - } else if (this->m_serPort) { + } else { Fw::SerializeStatus _status; BuiltInTypePortBuffer _buffer; @@ -182,6 +179,7 @@ void OutputBuiltInTypePort :: FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast(_status)); } #else - } + FW_ASSERT(this->m_port != nullptr); + this->m_port->invoke(t, tRef); #endif } diff --git a/compiler/tools/fpp-to-cpp/test/port/EmptyPortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/EmptyPortAc.ref.cpp index c3a127dab..edeabaac9 100644 --- a/compiler/tools/fpp-to-cpp/test/port/EmptyPortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/EmptyPortAc.ref.cpp @@ -58,8 +58,8 @@ void InputEmptyPort :: CompFuncPtr funcPtr ) { - FW_ASSERT(callComp); - FW_ASSERT(funcPtr); + FW_ASSERT(callComp != nullptr); + FW_ASSERT(funcPtr != nullptr); this->m_comp = callComp; this->m_func = funcPtr; @@ -73,8 +73,8 @@ void InputEmptyPort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); return this->m_func(this->m_comp, this->m_portNum); } @@ -90,8 +90,8 @@ Fw::SerializeStatus InputEmptyPort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); this->m_func(this->m_comp, this->m_portNum); @@ -121,7 +121,7 @@ void OutputEmptyPort :: void OutputEmptyPort :: addCallPort(InputEmptyPort* callPort) { - FW_ASSERT(callPort); + FW_ASSERT(callPort != nullptr); this->m_port = callPort; this->m_connObj = callPort; @@ -139,14 +139,11 @@ void OutputEmptyPort :: #endif #if FW_PORT_SERIALIZATION - FW_ASSERT(this->m_port || this->m_serPort); -#else - FW_ASSERT(this->m_port); -#endif - if (this->m_port) { + FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr)); + + if (this->m_port != nullptr) { this->m_port->invoke(); -#if FW_PORT_SERIALIZATION - } else if (this->m_serPort) { + } else { Fw::SerializeStatus _status; EmptyPortBuffer _buffer; @@ -154,6 +151,7 @@ void OutputEmptyPort :: FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast(_status)); } #else - } + FW_ASSERT(this->m_port != nullptr); + this->m_port->invoke(); #endif } diff --git a/compiler/tools/fpp-to-cpp/test/port/FppTypePortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/FppTypePortAc.ref.cpp index 5afd1db83..3dd8d0da8 100644 --- a/compiler/tools/fpp-to-cpp/test/port/FppTypePortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/FppTypePortAc.ref.cpp @@ -62,8 +62,8 @@ void InputFppTypePort :: CompFuncPtr funcPtr ) { - FW_ASSERT(callComp); - FW_ASSERT(funcPtr); + FW_ASSERT(callComp != nullptr); + FW_ASSERT(funcPtr != nullptr); this->m_comp = callComp; this->m_func = funcPtr; @@ -84,8 +84,8 @@ void InputFppTypePort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); return this->m_func(this->m_comp, this->m_portNum, e, eRef, a, aRef, s, sRef); } @@ -101,8 +101,8 @@ Fw::SerializeStatus InputFppTypePort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); E e; _status = _buffer.deserialize(e); @@ -168,7 +168,7 @@ void OutputFppTypePort :: void OutputFppTypePort :: addCallPort(InputFppTypePort* callPort) { - FW_ASSERT(callPort); + FW_ASSERT(callPort != nullptr); this->m_port = callPort; this->m_connObj = callPort; @@ -193,14 +193,11 @@ void OutputFppTypePort :: #endif #if FW_PORT_SERIALIZATION - FW_ASSERT(this->m_port || this->m_serPort); -#else - FW_ASSERT(this->m_port); -#endif - if (this->m_port) { + FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr)); + + if (this->m_port != nullptr) { this->m_port->invoke(e, eRef, a, aRef, s, sRef); -#if FW_PORT_SERIALIZATION - } else if (this->m_serPort) { + } else { Fw::SerializeStatus _status; FppTypePortBuffer _buffer; @@ -226,6 +223,7 @@ void OutputFppTypePort :: FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast(_status)); } #else - } + FW_ASSERT(this->m_port != nullptr); + this->m_port->invoke(e, eRef, a, aRef, s, sRef); #endif } diff --git a/compiler/tools/fpp-to-cpp/test/port/KwdNamePortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/KwdNamePortAc.ref.cpp index 4ddf8c146..a7b5c76b7 100644 --- a/compiler/tools/fpp-to-cpp/test/port/KwdNamePortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/KwdNamePortAc.ref.cpp @@ -62,8 +62,8 @@ void InputKwdNamePort :: CompFuncPtr funcPtr ) { - FW_ASSERT(callComp); - FW_ASSERT(funcPtr); + FW_ASSERT(callComp != nullptr); + FW_ASSERT(funcPtr != nullptr); this->m_comp = callComp; this->m_func = funcPtr; @@ -77,8 +77,8 @@ void InputKwdNamePort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); return this->m_func(this->m_comp, this->m_portNum, time); } @@ -94,8 +94,8 @@ Fw::SerializeStatus InputKwdNamePort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); U32 time; _status = _buffer.deserialize(time); @@ -131,7 +131,7 @@ void OutputKwdNamePort :: void OutputKwdNamePort :: addCallPort(InputKwdNamePort* callPort) { - FW_ASSERT(callPort); + FW_ASSERT(callPort != nullptr); this->m_port = callPort; this->m_connObj = callPort; @@ -149,14 +149,11 @@ void OutputKwdNamePort :: #endif #if FW_PORT_SERIALIZATION - FW_ASSERT(this->m_port || this->m_serPort); -#else - FW_ASSERT(this->m_port); -#endif - if (this->m_port) { + FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr)); + + if (this->m_port != nullptr) { this->m_port->invoke(time); -#if FW_PORT_SERIALIZATION - } else if (this->m_serPort) { + } else { Fw::SerializeStatus _status; KwdNamePortBuffer _buffer; @@ -167,6 +164,7 @@ void OutputKwdNamePort :: FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast(_status)); } #else - } + FW_ASSERT(this->m_port != nullptr); + this->m_port->invoke(time); #endif } diff --git a/compiler/tools/fpp-to-cpp/test/port/PrimitivePortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/PrimitivePortAc.ref.cpp index c6975f84a..a93865b5c 100644 --- a/compiler/tools/fpp-to-cpp/test/port/PrimitivePortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/PrimitivePortAc.ref.cpp @@ -62,8 +62,8 @@ void InputPrimitivePort :: CompFuncPtr funcPtr ) { - FW_ASSERT(callComp); - FW_ASSERT(funcPtr); + FW_ASSERT(callComp != nullptr); + FW_ASSERT(funcPtr != nullptr); this->m_comp = callComp; this->m_func = funcPtr; @@ -84,8 +84,8 @@ void InputPrimitivePort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); return this->m_func(this->m_comp, this->m_portNum, u32, u32Ref, f32, f32Ref, b, bRef); } @@ -101,8 +101,8 @@ Fw::SerializeStatus InputPrimitivePort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); U32 u32; _status = _buffer.deserialize(u32); @@ -168,7 +168,7 @@ void OutputPrimitivePort :: void OutputPrimitivePort :: addCallPort(InputPrimitivePort* callPort) { - FW_ASSERT(callPort); + FW_ASSERT(callPort != nullptr); this->m_port = callPort; this->m_connObj = callPort; @@ -193,14 +193,11 @@ void OutputPrimitivePort :: #endif #if FW_PORT_SERIALIZATION - FW_ASSERT(this->m_port || this->m_serPort); -#else - FW_ASSERT(this->m_port); -#endif - if (this->m_port) { + FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr)); + + if (this->m_port != nullptr) { this->m_port->invoke(u32, u32Ref, f32, f32Ref, b, bRef); -#if FW_PORT_SERIALIZATION - } else if (this->m_serPort) { + } else { Fw::SerializeStatus _status; PrimitivePortBuffer _buffer; @@ -226,6 +223,7 @@ void OutputPrimitivePort :: FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast(_status)); } #else - } + FW_ASSERT(this->m_port != nullptr); + this->m_port->invoke(u32, u32Ref, f32, f32Ref, b, bRef); #endif } diff --git a/compiler/tools/fpp-to-cpp/test/port/ReturnTypePortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/ReturnTypePortAc.ref.cpp index dd7c9ee94..93ee8d98f 100644 --- a/compiler/tools/fpp-to-cpp/test/port/ReturnTypePortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/ReturnTypePortAc.ref.cpp @@ -34,8 +34,8 @@ namespace M { CompFuncPtr funcPtr ) { - FW_ASSERT(callComp); - FW_ASSERT(funcPtr); + FW_ASSERT(callComp != nullptr); + FW_ASSERT(funcPtr != nullptr); this->m_comp = callComp; this->m_func = funcPtr; @@ -49,8 +49,8 @@ namespace M { this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); return this->m_func(this->m_comp, this->m_portNum, u); } @@ -90,7 +90,7 @@ namespace M { void OutputReturnTypePort :: addCallPort(InputReturnTypePort* callPort) { - FW_ASSERT(callPort); + FW_ASSERT(callPort != nullptr); this->m_port = callPort; this->m_connObj = callPort; @@ -107,11 +107,7 @@ namespace M { this->trace(); #endif -#if FW_PORT_SERIALIZATION - FW_ASSERT(this->m_port || this->m_serPort); -#else - FW_ASSERT(this->m_port); -#endif + FW_ASSERT(this->m_port != nullptr); return this->m_port->invoke(u); } diff --git a/compiler/tools/fpp-to-cpp/test/port/StringPortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/StringPortAc.ref.cpp index 9eb1e5db8..3db133e00 100644 --- a/compiler/tools/fpp-to-cpp/test/port/StringPortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/StringPortAc.ref.cpp @@ -224,8 +224,8 @@ void InputStringPort :: CompFuncPtr funcPtr ) { - FW_ASSERT(callComp); - FW_ASSERT(funcPtr); + FW_ASSERT(callComp != nullptr); + FW_ASSERT(funcPtr != nullptr); this->m_comp = callComp; this->m_func = funcPtr; @@ -244,8 +244,8 @@ void InputStringPort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); return this->m_func(this->m_comp, this->m_portNum, str80, str80Ref, str100, str100Ref); } @@ -261,8 +261,8 @@ Fw::SerializeStatus InputStringPort :: this->trace(); #endif - FW_ASSERT(this->m_comp); - FW_ASSERT(this->m_func); + FW_ASSERT(this->m_comp != nullptr); + FW_ASSERT(this->m_func != nullptr); StringPortStrings::StringSize80 str80; _status = _buffer.deserialize(str80); @@ -316,7 +316,7 @@ void OutputStringPort :: void OutputStringPort :: addCallPort(InputStringPort* callPort) { - FW_ASSERT(callPort); + FW_ASSERT(callPort != nullptr); this->m_port = callPort; this->m_connObj = callPort; @@ -339,14 +339,11 @@ void OutputStringPort :: #endif #if FW_PORT_SERIALIZATION - FW_ASSERT(this->m_port || this->m_serPort); -#else - FW_ASSERT(this->m_port); -#endif - if (this->m_port) { + FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr)); + + if (this->m_port != nullptr) { this->m_port->invoke(str80, str80Ref, str100, str100Ref); -#if FW_PORT_SERIALIZATION - } else if (this->m_serPort) { + } else { Fw::SerializeStatus _status; StringPortBuffer _buffer; @@ -366,6 +363,7 @@ void OutputStringPort :: FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast(_status)); } #else - } + FW_ASSERT(this->m_port != nullptr); + this->m_port->invoke(str80, str80Ref, str100, str100Ref); #endif } From 23a2288233166fdb46bca5314235471bbdcb5305 Mon Sep 17 00:00:00 2001 From: tiffany1618 Date: Mon, 23 Jan 2023 09:49:13 -0800 Subject: [PATCH 3/3] Move else statement to new line --- .../lib/src/main/scala/codegen/CppWriter/PortCppWriter.scala | 3 ++- compiler/tools/fpp-to-cpp/test/port/AbsTypePortAc.ref.cpp | 3 ++- compiler/tools/fpp-to-cpp/test/port/BuiltInTypePortAc.ref.cpp | 3 ++- compiler/tools/fpp-to-cpp/test/port/EmptyPortAc.ref.cpp | 3 ++- compiler/tools/fpp-to-cpp/test/port/FppTypePortAc.ref.cpp | 3 ++- compiler/tools/fpp-to-cpp/test/port/KwdNamePortAc.ref.cpp | 3 ++- compiler/tools/fpp-to-cpp/test/port/PrimitivePortAc.ref.cpp | 3 ++- compiler/tools/fpp-to-cpp/test/port/StringPortAc.ref.cpp | 3 ++- 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/compiler/lib/src/main/scala/codegen/CppWriter/PortCppWriter.scala b/compiler/lib/src/main/scala/codegen/CppWriter/PortCppWriter.scala index 6f038ff53..d152f2575 100644 --- a/compiler/lib/src/main/scala/codegen/CppWriter/PortCppWriter.scala +++ b/compiler/lib/src/main/scala/codegen/CppWriter/PortCppWriter.scala @@ -517,7 +517,8 @@ case class PortCppWriter ( | |if (this->m_port != nullptr) { | $invokeCall - |} else { + |} + |else { | Fw::SerializeStatus _status; | ${name}PortBuffer _buffer; |""" diff --git a/compiler/tools/fpp-to-cpp/test/port/AbsTypePortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/AbsTypePortAc.ref.cpp index f94f237d7..ff97e228c 100644 --- a/compiler/tools/fpp-to-cpp/test/port/AbsTypePortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/AbsTypePortAc.ref.cpp @@ -165,7 +165,8 @@ void OutputAbsTypePort :: if (this->m_port != nullptr) { this->m_port->invoke(t, tRef); - } else { + } + else { Fw::SerializeStatus _status; AbsTypePortBuffer _buffer; diff --git a/compiler/tools/fpp-to-cpp/test/port/BuiltInTypePortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/BuiltInTypePortAc.ref.cpp index 88c51ef34..515b3b9a2 100644 --- a/compiler/tools/fpp-to-cpp/test/port/BuiltInTypePortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/BuiltInTypePortAc.ref.cpp @@ -165,7 +165,8 @@ void OutputBuiltInTypePort :: if (this->m_port != nullptr) { this->m_port->invoke(t, tRef); - } else { + } + else { Fw::SerializeStatus _status; BuiltInTypePortBuffer _buffer; diff --git a/compiler/tools/fpp-to-cpp/test/port/EmptyPortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/EmptyPortAc.ref.cpp index edeabaac9..4e521f630 100644 --- a/compiler/tools/fpp-to-cpp/test/port/EmptyPortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/EmptyPortAc.ref.cpp @@ -143,7 +143,8 @@ void OutputEmptyPort :: if (this->m_port != nullptr) { this->m_port->invoke(); - } else { + } + else { Fw::SerializeStatus _status; EmptyPortBuffer _buffer; diff --git a/compiler/tools/fpp-to-cpp/test/port/FppTypePortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/FppTypePortAc.ref.cpp index 3dd8d0da8..402e34217 100644 --- a/compiler/tools/fpp-to-cpp/test/port/FppTypePortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/FppTypePortAc.ref.cpp @@ -197,7 +197,8 @@ void OutputFppTypePort :: if (this->m_port != nullptr) { this->m_port->invoke(e, eRef, a, aRef, s, sRef); - } else { + } + else { Fw::SerializeStatus _status; FppTypePortBuffer _buffer; diff --git a/compiler/tools/fpp-to-cpp/test/port/KwdNamePortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/KwdNamePortAc.ref.cpp index a7b5c76b7..20e867ae0 100644 --- a/compiler/tools/fpp-to-cpp/test/port/KwdNamePortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/KwdNamePortAc.ref.cpp @@ -153,7 +153,8 @@ void OutputKwdNamePort :: if (this->m_port != nullptr) { this->m_port->invoke(time); - } else { + } + else { Fw::SerializeStatus _status; KwdNamePortBuffer _buffer; diff --git a/compiler/tools/fpp-to-cpp/test/port/PrimitivePortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/PrimitivePortAc.ref.cpp index a93865b5c..03bf1b524 100644 --- a/compiler/tools/fpp-to-cpp/test/port/PrimitivePortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/PrimitivePortAc.ref.cpp @@ -197,7 +197,8 @@ void OutputPrimitivePort :: if (this->m_port != nullptr) { this->m_port->invoke(u32, u32Ref, f32, f32Ref, b, bRef); - } else { + } + else { Fw::SerializeStatus _status; PrimitivePortBuffer _buffer; diff --git a/compiler/tools/fpp-to-cpp/test/port/StringPortAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/port/StringPortAc.ref.cpp index 3db133e00..0dfad1965 100644 --- a/compiler/tools/fpp-to-cpp/test/port/StringPortAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/port/StringPortAc.ref.cpp @@ -343,7 +343,8 @@ void OutputStringPort :: if (this->m_port != nullptr) { this->m_port->invoke(str80, str80Ref, str100, str100Ref); - } else { + } + else { Fw::SerializeStatus _status; StringPortBuffer _buffer;