diff --git a/compiler/lib/src/main/scala/codegen/CppWriter/PortCppWriter.scala b/compiler/lib/src/main/scala/codegen/CppWriter/PortCppWriter.scala index dfa8b038f..d152f2575 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,28 @@ 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 +530,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 +587,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 +609,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 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..ff97e228c 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,12 @@ 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 +180,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..515b3b9a2 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,12 @@ 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 +180,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..4e521f630 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,12 @@ 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 +152,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..402e34217 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,12 @@ 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 +224,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..20e867ae0 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,12 @@ 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 +165,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..03bf1b524 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,12 @@ 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 +224,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..0dfad1965 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,12 @@ 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 +364,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 }