Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code gen for command overflow hooks #497

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ case class ComponentCommands (
priority,
MessageType.Command,
cmd.getName,
opcodeParam :: cmdSeqParam :: cmdParamMap(opcode)
opcodeParam :: cmdSeqParam :: Nil
)
)
)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ void ActiveOverflow ::
void ActiveOverflow ::
CMD_PARAMS_PRIORITY_HOOK_cmdOverflowHook(
FwOpcodeType opCode,
U32 cmdSeq,
U32 u32
U32 cmdSeq
)
{
// TODO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ void QueuedOverflow ::
void QueuedOverflow ::
CMD_PARAMS_PRIORITY_HOOK_cmdOverflowHook(
FwOpcodeType opCode,
U32 cmdSeq,
U32 u32
U32 cmdSeq
)
{
// TODO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

};
Expand Down
13 changes: 10 additions & 3 deletions docs/fpp-spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.20">
<title>The F Prime Prime (FPP) Language Specification, v2.1.0</title>
<title>The F Prime Prime (FPP) Language Specification, Unreleased, after v2.1.0</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<style>
/*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
Expand Down Expand Up @@ -436,7 +436,7 @@
</head>
<body class="article toc2 toc-left">
<div id="header">
<h1>The F Prime Prime (FPP) Language Specification, v2.1.0</h1>
<h1>The F Prime Prime (FPP) Language Specification, Unreleased, after v2.1.0</h1>
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
<ul class="sectlevel1">
Expand Down Expand Up @@ -1006,6 +1006,7 @@ <h3 id="Lexical-Elements_Reserved-Words">3.1. Reserved Words</h3>
guarded
health
high
hook
id
import
include
Expand Down Expand Up @@ -4595,6 +4596,9 @@ <h4 id="Specifiers_Port-Instance-Specifiers_Syntax">6.11.1. Syntax</h4>
<li>
<p><code>drop</code></p>
</li>
<li>
<p><code>hook</code></p>
</li>
</ol>
</div>
<div class="paragraph">
Expand Down Expand Up @@ -4747,6 +4751,9 @@ <h4 id="Specifiers_Port-Instance-Specifiers_Semantics">6.11.2. Semantics</h4>
<li>
<p><code>drop</code> means that the message is dropped.</p>
</li>
<li>
<p><code>hook</code> means that the message is passed to a user-supplied hook function.</p>
</li>
</ol>
</div>
<div class="paragraph">
Expand Down Expand Up @@ -8551,7 +8558,7 @@ <h3 id="Analysis-and-Translation_Translation-Tools">20.4. Translation Tools</h3>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2024-07-22 17:41:09 -0700
Last updated 2024-08-22 08:48:41 -0700
</div>
</div>
<script src="code-prettify/run_prettify.js"></script>
Expand Down
14 changes: 10 additions & 4 deletions docs/fpp-users-guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.20">
<title>The F Prime Prime (FPP) User&#8217;s Guide, v2.1.0</title>
<title>The F Prime Prime (FPP) User&#8217;s Guide, Unreleased, after v2.1.0</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<style>
/*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
Expand Down Expand Up @@ -436,7 +436,7 @@
</head>
<body class="article toc2 toc-left">
<div id="header">
<h1>The F Prime Prime (FPP) User&#8217;s Guide, v2.1.0</h1>
<h1>The F Prime Prime (FPP) User&#8217;s Guide, Unreleased, after v2.1.0</h1>
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
<ul class="sectlevel1">
Expand Down Expand Up @@ -3877,11 +3877,14 @@ <h4 id="Defining-Components_Port-Instances_Queue-Full-Behavior">9.2.5. Queue Ful
<li>
<p><code>drop</code>: Drop the incoming message and proceed.</p>
</li>
<li>
<p><code>hook</code>: Call a user function to respond to the queue overflow.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>To specify queue full behavior, you write one of the keywords <code>assert</code>,
<code>block</code>, or <code>drop</code> after the port type and after the priority
<code>block</code>, <code>drop</code>, or <code>hook</code> after the port type and after the priority
(if any).
As an example, here is the <code>ActiveF32Adder</code> updated with explicit
queue full behavior.</p>
Expand All @@ -3901,6 +3904,9 @@ <h4 id="Defining-Components_Port-Instances_Queue-Full-Behavior">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

Expand Down Expand Up @@ -12293,7 +12299,7 @@ <h4 id="Writing-C-Plus-Plus-Implementations_Implementing-Deployments_Public-Symb
</div>
<div id="footer">
<div id="footer-text">
Last updated 2024-07-22 17:45:06 -0700
Last updated 2024-08-22 08:49:17 -0700
</div>
</div>
<script src="code-prettify/run_prettify.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# The FPP version
# ----------------------------------------------------------------------

export VERSION="v2.1.0"
export VERSION="Unreleased, after v2.1.0"
Loading