Skip to content

Commit 852525b

Browse files
committed
7.3.0
1 parent 80d9bcd commit 852525b

File tree

11 files changed

+102
-167
lines changed

11 files changed

+102
-167
lines changed

examples/arm-cm/dpp_efm32-slstk3401a/.dpp

Lines changed: 0 additions & 59 deletions
This file was deleted.

examples/posix-win32/reminder2/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
##############################################################################
22
# Product: Makefile for QP/C++ for Windows and POSIX *HOSTS*
3-
# Last updated for version 7.2.0
4-
# Last updated on 2022-11-13
3+
# Last updated for version 7.3.1
4+
# Last updated on 2023-09-25
55
#
66
# Q u a n t u m L e a P s
77
# ------------------------
@@ -83,7 +83,8 @@ LIBS :=
8383

8484
# defines...
8585
# QP_API_VERSION controls the QP API compatibility; 9999 means the latest API
86-
DEFINES := -DQP_API_VERSION=9999
86+
DEFINES := -DQP_API_VERSION=9999 \
87+
$(DEF)
8788

8889
ifeq (,$(CONF))
8990
CONF := dbg

examples/posix-win32/reminder2/bsp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void QF::onCleanup(void) {
5757
void QP::QF::onClockTick(void) {
5858
QTimeEvt::TICK_X(0U, &l_clock_tick); // perform the QF clock tick processing
5959
int key = QF::consoleGetKey();
60-
if (key != 0) { /* any key pressed? */
60+
if (key != 0U) { /* any key pressed? */
6161
BSP_onKeyboardInput((uint8_t)key);
6262
}
6363
}

examples/posix-win32/reminder2/reminder2.cpp

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,19 @@ enum ReminderSignals {
5151
class ReminderEvt : public QP::QEvt {
5252
public:
5353
std::uint32_t iter;
54+
55+
public:
56+
57+
#ifdef QEVT_DYN_CTOR
58+
explicit ReminderEvt(std::uint32_t i) noexcept
59+
: QEvt(QP::QEvt::DYNAMIC),
60+
iter(i)
61+
{}
62+
#endif // def QEVT_DYN_CTOR
5463
}; // class ReminderEvt
5564
//$enddecl${Events::ReminderEvt} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5665

57-
// Active object class -----------------------------------------------------..
66+
// Active object class -------------------------------------------------------
5867
//$declare${Components::Cruncher} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
5968

6069
//${Components::Cruncher} ....................................................
@@ -90,7 +99,7 @@ class Cruncher : public QP::QActive {
9099
//${Components::Cruncher::SM} ................................................
91100
Q_STATE_DEF(Cruncher, initial) {
92101
//${Components::Cruncher::SM::initial}
93-
(void)e; // unused parameter
102+
Q_UNUSED_PAR(e);
94103

95104
QS_FUN_DICTIONARY(&Cruncher::processing);
96105
QS_FUN_DICTIONARY(&Cruncher::final);
@@ -104,31 +113,41 @@ Q_STATE_DEF(Cruncher, processing) {
104113
switch (e->sig) {
105114
//${Components::Cruncher::SM::processing}
106115
case Q_ENTRY_SIG: {
116+
#ifdef QEVT_DYN_CTOR
117+
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG, 0U);
118+
#else
107119
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
108-
reminder->iter = 0;
120+
reminder->iter = 0U;
121+
#endif
122+
109123
POST(reminder, this);
110124
m_sum = 0.0;
111125
status_ = Q_RET_HANDLED;
112126
break;
113127
}
114128
//${Components::Cruncher::SM::processing::CRUNCH}
115129
case CRUNCH_SIG: {
116-
uint32_t i = Q_EVT_CAST(ReminderEvt)->iter;
117-
uint32_t n = i;
130+
std::uint32_t i = Q_EVT_CAST(ReminderEvt)->iter;
131+
std::uint32_t n = i;
118132
i += 100U;
119133
for (; n < i; ++n) {
120134
if ((n & 1) == 0) {
121-
m_sum += 1.0/(2*n + 1);
135+
m_sum += 1.0/(2U*n + 1U);
122136
}
123137
else {
124-
m_sum -= 1.0/(2*n + 1);
138+
m_sum -= 1.0/(2U*n + 1U);
125139
}
126140
}
127141
//${Components::Cruncher::SM::processing::CRUNCH::[i<0x07000000U]}
128142
if (i < 0x07000000U) {
143+
#ifdef QEVT_DYN_CTOR
144+
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG, i);
145+
#else
129146
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
130147
reminder->iter = i;
131-
POST(reminder, me);
148+
#endif
149+
150+
POST(reminder, this);
132151
status_ = Q_RET_HANDLED;
133152
}
134153
//${Components::Cruncher::SM::processing::CRUNCH::[else]}
@@ -189,7 +208,7 @@ int main(int argc, char *argv[]) {
189208
PRINTF_S("Reminder state pattern\nQP version: %s\n"
190209
"Press 'e' to echo the current value...\n"
191210
"Press ESC to quit...\n",
192-
QP::versionStr);
211+
QP_VERSION_STR);
193212

194213
BSP_init(argc, argv); // initialize the BSP
195214
QF::init(); // initialize the framework and the underlying RT kernel
@@ -210,14 +229,24 @@ int main(int argc, char *argv[]) {
210229
void BSP_onKeyboardInput(uint8_t key) {
211230
switch (key) {
212231
case 'e': {
213-
static QEvt const echoEvt(ECHO_SIG);
214-
l_cruncher.POST(&echoEvt, nullptr);
232+
// NOTE:
233+
// The following Q_NEW_X() allocation might potentially fail
234+
// but this is acceptable becasue the "ECHO" event is not
235+
// considered critical. This code illustrates the Q_NEW_X()
236+
// API and its use.
237+
#ifdef QEVT_DYN_CTOR
238+
QEvt const *echoEvt = Q_NEW_X(QEvt, 2U, ECHO_SIG, QEvt::DYNAMIC);
239+
#else
240+
QEvt const *echoEvt = Q_NEW_X(QEvt, 2U, ECHO_SIG);
241+
#endif
242+
if (echoEvt != nullptr) { // event allocated successfully?
243+
l_cruncher.POST(echoEvt, nullptr);
244+
}
215245
break;
216246
}
217247
case '\033': { // ESC pressed?
218248
// NOTE: this constant event is statically pre-allocated.
219249
// It can be posted/published as any other event.
220-
//
221250
static QEvt const terminateEvt(TERMINATE_SIG);
222251
l_cruncher.POST(&terminateEvt, nullptr);
223252
break;

examples/posix-win32/reminder2/reminder2.qm

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
<attribute name="iter" type="std::uint32_t" visibility="0x00" properties="0x00">
1212
<documentation>the next iteration to perform</documentation>
1313
</attribute>
14+
<!--${Events::ReminderEvt::ReminderEvt}-->
15+
<operation name="ReminderEvt?def QEVT_DYN_CTOR" type="explicit" visibility="0x00" properties="0x02">
16+
<specifiers>noexcept</specifiers>
17+
<!--${Events::ReminderEvt::ReminderEvt::i}-->
18+
<parameter name="i" type="std::uint32_t"/>
19+
<code> : QEvt(QP::QEvt::DYNAMIC),
20+
iter(i)</code>
21+
</operation>
1422
</class>
1523
</package>
1624
<!--${Components}-->
@@ -32,28 +40,33 @@
3240
<statechart properties="0x02">
3341
<!--${Components::Cruncher::SM::initial}-->
3442
<initial target="../1">
35-
<action>(void)e; // unused parameter</action>
43+
<action>Q_UNUSED_PAR(e);</action>
3644
<initial_glyph conn="2,2,5,1,44,6,-2">
3745
<action box="0,-2,6,2"/>
3846
</initial_glyph>
3947
</initial>
4048
<!--${Components::Cruncher::SM::processing}-->
4149
<state name="processing">
42-
<entry>ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
43-
reminder-&gt;iter = 0;
50+
<entry>#ifdef QEVT_DYN_CTOR
51+
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG, 0U);
52+
#else
53+
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
54+
reminder-&gt;iter = 0U;
55+
#endif
56+
4457
POST(reminder, this);
4558
m_sum = 0.0;</entry>
4659
<!--${Components::Cruncher::SM::processing::CRUNCH}-->
4760
<tran trig="CRUNCH">
48-
<action>uint32_t i = Q_EVT_CAST(ReminderEvt)-&gt;iter;
49-
uint32_t n = i;
61+
<action>std::uint32_t i = Q_EVT_CAST(ReminderEvt)-&gt;iter;
62+
std::uint32_t n = i;
5063
i += 100U;
5164
for (; n &lt; i; ++n) {
5265
if ((n &amp; 1) == 0) {
53-
m_sum += 1.0/(2*n + 1);
66+
m_sum += 1.0/(2U*n + 1U);
5467
}
5568
else {
56-
m_sum -= 1.0/(2*n + 1);
69+
m_sum -= 1.0/(2U*n + 1U);
5770
}
5871
}</action>
5972
<!--${Components::Cruncher::SM::processing::CRUNCH::[else]}-->
@@ -67,9 +80,14 @@ for (; n &lt; i; ++n) {
6780
<!--${Components::Cruncher::SM::processing::CRUNCH::[i<0x07000000U]}-->
6881
<choice>
6982
<guard>i &lt; 0x07000000U</guard>
70-
<action>ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
83+
<action>#ifdef QEVT_DYN_CTOR
84+
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG, i);
85+
#else
86+
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
7187
reminder-&gt;iter = i;
72-
POST(reminder, me);</action>
88+
#endif
89+
90+
POST(reminder, this);</action>
7391
<choice_glyph conn="24,18,4,-1,-4,14">
7492
<action box="0,-6,17,2"/>
7593
</choice_glyph>
@@ -130,7 +148,7 @@ enum ReminderSignals {
130148
//............................................................................
131149
$declare${Events::ReminderEvt}
132150

133-
// Active object class -----------------------------------------------------..
151+
// Active object class -------------------------------------------------------
134152
$declare${Components::Cruncher}
135153

136154
$define${Components::Cruncher}
@@ -147,7 +165,7 @@ int main(int argc, char *argv[]) {
147165
PRINTF_S(&quot;Reminder state pattern\nQP version: %s\n&quot;
148166
&quot;Press 'e' to echo the current value...\n&quot;
149167
&quot;Press ESC to quit...\n&quot;,
150-
QP::versionStr);
168+
QP_VERSION_STR);
151169

152170
BSP_init(argc, argv); // initialize the BSP
153171
QF::init(); // initialize the framework and the underlying RT kernel
@@ -168,14 +186,24 @@ int main(int argc, char *argv[]) {
168186
void BSP_onKeyboardInput(uint8_t key) {
169187
switch (key) {
170188
case 'e': {
171-
static QEvt const echoEvt(ECHO_SIG);
172-
l_cruncher.POST(&amp;echoEvt, nullptr);
189+
// NOTE:
190+
// The following Q_NEW_X() allocation might potentially fail
191+
// but this is acceptable becasue the &quot;ECHO&quot; event is not
192+
// considered critical. This code illustrates the Q_NEW_X()
193+
// API and its use.
194+
#ifdef QEVT_DYN_CTOR
195+
QEvt const *echoEvt = Q_NEW_X(QEvt, 2U, ECHO_SIG, QEvt::DYNAMIC);
196+
#else
197+
QEvt const *echoEvt = Q_NEW_X(QEvt, 2U, ECHO_SIG);
198+
#endif
199+
if (echoEvt != nullptr) { // event allocated successfully?
200+
l_cruncher.POST(echoEvt, nullptr);
201+
}
173202
break;
174203
}
175204
case '\033': { // ESC pressed?
176205
// NOTE: this constant event is statically pre-allocated.
177206
// It can be posted/published as any other event.
178-
//
179207
static QEvt const terminateEvt(TERMINATE_SIG);
180208
l_cruncher.POST(&amp;terminateEvt, nullptr);
181209
break;

examples/qutest/dpp/src/.dpp

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)