From 4e3644393c29f43180dae8bbe38bf9c7dbd7b666 Mon Sep 17 00:00:00 2001 From: Rob Bocchino Date: Wed, 21 Aug 2024 18:07:56 -0700 Subject: [PATCH 1/4] Revise command hooks (#496) --- .../ComponentCommands.scala | 4 +-- .../ComponentCppWriterUtils.scala | 28 +++++-------------- .../base/ActiveOverflowComponentAc.ref.cpp | 6 ++-- .../base/ActiveOverflowComponentAc.ref.hpp | 3 +- .../base/QueuedOverflowComponentAc.ref.cpp | 6 ++-- .../base/QueuedOverflowComponentAc.ref.hpp | 3 +- 6 files changed, 15 insertions(+), 35 deletions(-) diff --git a/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentCommands.scala b/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentCommands.scala index 33e4d3294..cc3373909 100644 --- a/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentCommands.scala +++ b/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentCommands.scala @@ -192,7 +192,7 @@ case class ComponentCommands ( priority, MessageType.Command, cmd.getName, - opcodeParam :: cmdSeqParam :: cmdParamMap(opcode) + opcodeParam :: cmdSeqParam :: Nil ) ) ) @@ -339,7 +339,7 @@ case class ComponentCommands ( functionClassMember( Some(s"Overflow hook for command ${cmd.getName}"), inputOverflowHookName(cmd.getName, MessageType.Command), - opcodeParam :: cmdSeqParam :: cmdParamMap(opcode), + opcodeParam :: cmdSeqParam :: Nil, CppDoc.Type("void"), Nil, CppDoc.Function.PureVirtual diff --git a/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentCppWriterUtils.scala b/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentCppWriterUtils.scala index b1cdb9ad0..996c84bd4 100644 --- a/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentCppWriterUtils.scala +++ b/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentCppWriterUtils.scala @@ -631,27 +631,13 @@ abstract class ComponentCppWriterUtils( |} |""" ) - case Ast.QueueFull.Hook => { - messageType match { - case MessageType.Command => - lines( - s"""|if (qStatus == Os::Queue::QUEUE_FULL) { - | // TODO: Deserialize command arguments and call the hook - | // this->${inputOverflowHookName(name, messageType)}(${arguments.map(_.name).mkString(", ")}); - | return; - |} - |""" - ) - case _ => - lines( - s"""|if (qStatus == Os::Queue::QUEUE_FULL) { - | this->${inputOverflowHookName(name, messageType)}(${arguments.map(_.name).mkString(", ")}); - | return; - |} - |""" - ) - } - } + case Ast.QueueFull.Hook => lines( + s"""|if (qStatus == Os::Queue::QUEUE_FULL) { + | this->${inputOverflowHookName(name, messageType)}(${arguments.map(_.name).mkString(", ")}); + | return; + |} + |""" + ) case _ => Nil } , diff --git a/compiler/tools/fpp-to-cpp/test/component/base/ActiveOverflowComponentAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/component/base/ActiveOverflowComponentAc.ref.cpp index d2ef0d914..1edf44a71 100644 --- a/compiler/tools/fpp-to-cpp/test/component/base/ActiveOverflowComponentAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/component/base/ActiveOverflowComponentAc.ref.cpp @@ -1819,8 +1819,7 @@ void ActiveOverflowComponentBase :: Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block); if (qStatus == Os::Queue::QUEUE_FULL) { - // TODO: Deserialize command arguments and call the hook - // this->CMD_HOOK_cmdOverflowHook(opCode, cmdSeq); + this->CMD_HOOK_cmdOverflowHook(opCode, cmdSeq); return; } @@ -1884,8 +1883,7 @@ void ActiveOverflowComponentBase :: Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 30, _block); if (qStatus == Os::Queue::QUEUE_FULL) { - // TODO: Deserialize command arguments and call the hook - // this->CMD_PARAMS_PRIORITY_HOOK_cmdOverflowHook(opCode, cmdSeq, u32); + this->CMD_PARAMS_PRIORITY_HOOK_cmdOverflowHook(opCode, cmdSeq); return; } diff --git a/compiler/tools/fpp-to-cpp/test/component/base/ActiveOverflowComponentAc.ref.hpp b/compiler/tools/fpp-to-cpp/test/component/base/ActiveOverflowComponentAc.ref.hpp index 6dc14d28a..60a502b8c 100644 --- a/compiler/tools/fpp-to-cpp/test/component/base/ActiveOverflowComponentAc.ref.hpp +++ b/compiler/tools/fpp-to-cpp/test/component/base/ActiveOverflowComponentAc.ref.hpp @@ -912,8 +912,7 @@ class ActiveOverflowComponentBase : //! Overflow hook for command CMD_PARAMS_PRIORITY_HOOK virtual void CMD_PARAMS_PRIORITY_HOOK_cmdOverflowHook( FwOpcodeType opCode, //!< The opcode - U32 cmdSeq, //!< The command sequence number - U32 u32 + U32 cmdSeq //!< The command sequence number ) = 0; PROTECTED: diff --git a/compiler/tools/fpp-to-cpp/test/component/base/QueuedOverflowComponentAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/component/base/QueuedOverflowComponentAc.ref.cpp index 345dadd80..5ab6e47d9 100644 --- a/compiler/tools/fpp-to-cpp/test/component/base/QueuedOverflowComponentAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/component/base/QueuedOverflowComponentAc.ref.cpp @@ -1819,8 +1819,7 @@ void QueuedOverflowComponentBase :: Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block); if (qStatus == Os::Queue::QUEUE_FULL) { - // TODO: Deserialize command arguments and call the hook - // this->CMD_HOOK_cmdOverflowHook(opCode, cmdSeq); + this->CMD_HOOK_cmdOverflowHook(opCode, cmdSeq); return; } @@ -1884,8 +1883,7 @@ void QueuedOverflowComponentBase :: Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 30, _block); if (qStatus == Os::Queue::QUEUE_FULL) { - // TODO: Deserialize command arguments and call the hook - // this->CMD_PARAMS_PRIORITY_HOOK_cmdOverflowHook(opCode, cmdSeq, u32); + this->CMD_PARAMS_PRIORITY_HOOK_cmdOverflowHook(opCode, cmdSeq); return; } diff --git a/compiler/tools/fpp-to-cpp/test/component/base/QueuedOverflowComponentAc.ref.hpp b/compiler/tools/fpp-to-cpp/test/component/base/QueuedOverflowComponentAc.ref.hpp index 1e54a2604..59e01933b 100644 --- a/compiler/tools/fpp-to-cpp/test/component/base/QueuedOverflowComponentAc.ref.hpp +++ b/compiler/tools/fpp-to-cpp/test/component/base/QueuedOverflowComponentAc.ref.hpp @@ -912,8 +912,7 @@ class QueuedOverflowComponentBase : //! Overflow hook for command CMD_PARAMS_PRIORITY_HOOK virtual void CMD_PARAMS_PRIORITY_HOOK_cmdOverflowHook( FwOpcodeType opCode, //!< The opcode - U32 cmdSeq, //!< The command sequence number - U32 u32 + U32 cmdSeq //!< The command sequence number ) = 0; PROTECTED: From 2e08ac1c774a90c01ffb7c828f9773e092228966 Mon Sep 17 00:00:00 2001 From: Rob Bocchino Date: Thu, 22 Aug 2024 08:28:21 -0700 Subject: [PATCH 2/4] Revise code gen for component implementations Revise command hooks --- .../CppWriter/ComponentCppWriter/ComponentImplWriter.scala | 2 +- .../test/component/impl/ActiveOverflow.template.ref.cpp | 3 +-- .../test/component/impl/ActiveOverflow.template.ref.hpp | 3 +-- .../test/component/impl/QueuedOverflow.template.ref.cpp | 3 +-- .../test/component/impl/QueuedOverflow.template.ref.hpp | 3 +-- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentImplWriter.scala b/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentImplWriter.scala index c8125c006..0a8218d03 100644 --- a/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentImplWriter.scala +++ b/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentImplWriter.scala @@ -209,7 +209,7 @@ private def getOverflowHooks: List[CppDoc.Class.Member] = { functionClassMember( Some(s"Overflow hook implementation for ${cmd.getName}"), inputOverflowHookName(cmd.getName, MessageType.Command), - opcodeParam :: cmdSeqParam :: cmdParamMap(opcode), + opcodeParam :: cmdSeqParam :: Nil, CppDoc.Type("void"), lines("// TODO"), CppDoc.Function.Override diff --git a/compiler/tools/fpp-to-cpp/test/component/impl/ActiveOverflow.template.ref.cpp b/compiler/tools/fpp-to-cpp/test/component/impl/ActiveOverflow.template.ref.cpp index 944af7728..2994bcebe 100644 --- a/compiler/tools/fpp-to-cpp/test/component/impl/ActiveOverflow.template.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/component/impl/ActiveOverflow.template.ref.cpp @@ -201,8 +201,7 @@ void ActiveOverflow :: void ActiveOverflow :: CMD_PARAMS_PRIORITY_HOOK_cmdOverflowHook( FwOpcodeType opCode, - U32 cmdSeq, - U32 u32 + U32 cmdSeq ) { // TODO diff --git a/compiler/tools/fpp-to-cpp/test/component/impl/ActiveOverflow.template.ref.hpp b/compiler/tools/fpp-to-cpp/test/component/impl/ActiveOverflow.template.ref.hpp index 0f503417b..afbfa08ca 100644 --- a/compiler/tools/fpp-to-cpp/test/component/impl/ActiveOverflow.template.ref.hpp +++ b/compiler/tools/fpp-to-cpp/test/component/impl/ActiveOverflow.template.ref.hpp @@ -193,8 +193,7 @@ class ActiveOverflow : //! Overflow hook implementation for CMD_PARAMS_PRIORITY_HOOK void CMD_PARAMS_PRIORITY_HOOK_cmdOverflowHook( FwOpcodeType opCode, //!< The opcode - U32 cmdSeq, //!< The command sequence number - U32 u32 + U32 cmdSeq //!< The command sequence number ) override; }; diff --git a/compiler/tools/fpp-to-cpp/test/component/impl/QueuedOverflow.template.ref.cpp b/compiler/tools/fpp-to-cpp/test/component/impl/QueuedOverflow.template.ref.cpp index 9fc11c94d..5dcb7a358 100644 --- a/compiler/tools/fpp-to-cpp/test/component/impl/QueuedOverflow.template.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/component/impl/QueuedOverflow.template.ref.cpp @@ -201,8 +201,7 @@ void QueuedOverflow :: void QueuedOverflow :: CMD_PARAMS_PRIORITY_HOOK_cmdOverflowHook( FwOpcodeType opCode, - U32 cmdSeq, - U32 u32 + U32 cmdSeq ) { // TODO diff --git a/compiler/tools/fpp-to-cpp/test/component/impl/QueuedOverflow.template.ref.hpp b/compiler/tools/fpp-to-cpp/test/component/impl/QueuedOverflow.template.ref.hpp index 898595922..2bf11b03b 100644 --- a/compiler/tools/fpp-to-cpp/test/component/impl/QueuedOverflow.template.ref.hpp +++ b/compiler/tools/fpp-to-cpp/test/component/impl/QueuedOverflow.template.ref.hpp @@ -193,8 +193,7 @@ class QueuedOverflow : //! Overflow hook implementation for CMD_PARAMS_PRIORITY_HOOK void CMD_PARAMS_PRIORITY_HOOK_cmdOverflowHook( FwOpcodeType opCode, //!< The opcode - U32 cmdSeq, //!< The command sequence number - U32 u32 + U32 cmdSeq //!< The command sequence number ) override; }; From 11aa3aa7039dcb3b6a726e16812a19971d6cc3de Mon Sep 17 00:00:00 2001 From: Rob Bocchino Date: Thu, 22 Aug 2024 08:29:43 -0700 Subject: [PATCH 3/4] Regenerate docs --- docs/fpp-spec.html | 9 ++++++++- docs/fpp-users-guide.html | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/fpp-spec.html b/docs/fpp-spec.html index 06d2d3c6f..9fcbe49b4 100644 --- a/docs/fpp-spec.html +++ b/docs/fpp-spec.html @@ -1006,6 +1006,7 @@

3.1. Reserved Words

guarded health high +hook id import include @@ -4595,6 +4596,9 @@

6.11.1. Syntax

  • drop

  • +
  • +

    hook

    +
  • @@ -4747,6 +4751,9 @@

    6.11.2. Semantics

  • drop means that the message is dropped.

  • +
  • +

    hook means that the message is passed to a user-supplied hook function.

    +
  • @@ -8551,7 +8558,7 @@

    20.4. Translation Tools

    diff --git a/docs/fpp-users-guide.html b/docs/fpp-users-guide.html index e986fa16e..e90d86e2b 100644 --- a/docs/fpp-users-guide.html +++ b/docs/fpp-users-guide.html @@ -3877,11 +3877,14 @@

    9.2.5. Queue Ful
  • drop: Drop the incoming message and proceed.

  • +
  • +

    hook: Call a user function to respond to the queue overflow.

    +
  • To specify queue full behavior, you write one of the keywords assert, -block, or drop after the port type and after the priority +block, drop, or hook after the port type and after the priority (if any). As an example, here is the ActiveF32Adder updated with explicit queue full behavior.

    @@ -3901,6 +3904,9 @@

    9.2.5. Queue Ful @ Input 2: Drop on queue full async input port f32ValueIn2: F32Value drop + @ Input 3: Call hook function on queue full + async input port f32ValueIn3: F32Value hook + @ Output output port f32ValueOut: F32Value @@ -12293,7 +12299,7 @@

    From 921be69cbf79f66106c4e55a8152f38282fa18dc Mon Sep 17 00:00:00 2001 From: Rob Bocchino Date: Thu, 22 Aug 2024 08:49:54 -0700 Subject: [PATCH 4/4] Update version stamp --- docs/fpp-spec.html | 6 +++--- docs/fpp-users-guide.html | 6 +++--- version.sh | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/fpp-spec.html b/docs/fpp-spec.html index 9fcbe49b4..bc3e318e9 100644 --- a/docs/fpp-spec.html +++ b/docs/fpp-spec.html @@ -5,7 +5,7 @@ -The F Prime Prime (FPP) Language Specification, v2.1.0 +The F Prime Prime (FPP) Language Specification, Unreleased, after v2.1.0