1111 <attribute name =" iter" type =" uint32_t" visibility =" 0x00" properties =" 0x00" >
1212 <documentation >// the next iteration to perform</documentation >
1313 </attribute >
14+ <!-- ${Events::ReminderEvt::ctor}-->
15+ <operation name =" ctor?def QEVT_DYN_CTOR" type =" ReminderEvt *" visibility =" 0x00" properties =" 0x02" >
16+ <!-- ${Events::ReminderEvt::ctor::iter}-->
17+ <parameter name =" iter" type =" uint32_t" />
18+ <code >if (me != (ReminderEvt *)0) {
19+ // don't call QEvt_ctor() because the initialization of all
20+ // QEvt attributes is already done in QF_QF_newX_()
21+ me-> iter = iter;
22+ }
23+ return me;</code >
24+ </operation >
1425 </class >
1526 </package >
1627 <!-- ${Components}-->
3849 </initial >
3950 <!-- ${Components::Cruncher::SM::processing}-->
4051 <state name =" processing" >
41- <entry >ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
52+ <entry >#ifdef QEVT_DYN_CTOR
53+ ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG, 0U);
54+ #else
55+ ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
4256reminder-> iter = 0U;
57+ #endif
58+
4359QACTIVE_POST(& me-> super, & reminder-> super, me);
4460me-> sum = 0.0;</entry >
4561 <!-- ${Components::Cruncher::SM::processing::CRUNCH}-->
@@ -66,8 +82,13 @@ for (; n < i; ++n) {
6682 <!-- ${Components::Cruncher::SM::processing::CRUNCH::[i<0x07000000U]}-->
6783 <choice >
6884 <guard >i < 0x07000000U</guard >
69- <action >ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
85+ <action >#ifdef QEVT_DYN_CTOR
86+ ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG, i);
87+ #else
88+ ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
7089reminder-> iter = i;
90+ #endif
91+
7192QACTIVE_POST(& me-> super, & reminder-> super, me);</action >
7293 <choice_glyph conn =" 24,18,4,-1,-4,14" >
7394 <action box =" 0,-6,17,2" />
@@ -169,8 +190,19 @@ int main(int argc, char *argv[]) {
169190void BSP_onKeyboardInput(uint8_t key) {
170191 switch (key) {
171192 case 'e': { // echo the progress so far
172- static QEvt const echoEvt = QEVT_INITIALIZER(ECHO_SIG);
173- QACTIVE_POST((QActive *)& l_cruncher, & echoEvt, (void *)0);
193+ // NOTE:
194+ // The following Q_NEW_X() allocation might potentially fail
195+ // but this is acceptable becasue the " ECHO" event is not
196+ // considered critical. This code illustrates the Q_NEW_X()
197+ // API and its use.
198+ #ifdef QEVT_DYN_CTOR
199+ QEvt const *echoEvt = Q_NEW_X(QEvt, 2U, ECHO_SIG, QEVT_DYNAMIC);
200+ #else
201+ QEvt const *echoEvt = Q_NEW_X(QEvt, 2U, ECHO_SIG);
202+ #endif
203+ if (echoEvt != (QEvt *)0) { // event allocated successfully?
204+ QACTIVE_POST((QActive *)& l_cruncher, echoEvt, (void *)0);
205+ }
174206 break;
175207 }
176208 case '\033': { // ESC pressed?
0 commit comments