From 628fb1b8686c2f408a6c0381383f9f650085ebcb Mon Sep 17 00:00:00 2001 From: anyssen Date: Wed, 23 Dec 2015 10:45:47 +0100 Subject: [PATCH] #266: Add support for optional generation of tracing callbacks. - Add Tracing generator feature with parameters to trigger generation of state-enter and state-exit callbacks. - Enhanced C code generator to generate callbacks to required header and respective calls based on corresponding trace steps. - Ensure that ADD_TRACES option is enabled for C code generator in case Tracing feature is enabled. Ensured its disabled for all other generators by default. Had to change contract of GenericDomainInjectorProvider to accept an overriding module, and replaced child injector usage in code generators with an overriding module instead. --- .../cyclebased/IStatemachine.class | Bin 0 -> 227 bytes .../trafficlight/cyclebased/ITimer.class | Bin 0 -> 328 bytes .../cyclebased/ITimerCallback.class | Bin 0 -> 187 bytes ...RuntimeService$StatemachineTimerTask.class | Bin 0 -> 2814 bytes .../cyclebased/RuntimeService.class | Bin 0 -> 3211 bytes .../TimerService$TimeEventTask.class | Bin 0 -> 1336 bytes .../cyclebased/TimerService.class | Bin 0 -> 2200 bytes ...ghtWaitingStatemachine$SCIPedestrian.class | Bin 0 -> 509 bytes ...tWaitingStatemachine$SCITrafficLight.class | Bin 0 -> 511 bytes ...LightWaitingStatemachine$SCInterface.class | Bin 0 -> 438 bytes .../ITrafficLightWaitingStatemachine.class | Bin 0 -> 1260 bytes ...aitingStatemachine$SCIPedestrianImpl.class | Bin 0 -> 2334 bytes ...tingStatemachine$SCITrafficLightImpl.class | Bin 0 -> 2345 bytes ...tWaitingStatemachine$SCInterfaceImpl.class | Bin 0 -> 2001 bytes ...rafficLightWaitingStatemachine$State.class | Bin 0 -> 2551 bytes .../TrafficLightWaitingStatemachine.class | Bin 0 -> 17705 bytes .../yakindu/sct/ui/examples/Activator.class | Bin 0 -> 796 bytes .../help/05_reference/reference.textile | 18 +++++ .../GenericDomainInjectorProvider.java | 13 +++- .../modules/GenericSequencerModule.java | 4 +- .../extension/IDomainInjectorProvider.java | 11 ++- .../META-INF/MANIFEST.MF | 3 +- .../library/FeatureTypeLibrary.xmi | 13 ++++ .../sct/generator/c/CCodeGenerator.java | 47 +++++++++--- .../{CSCTGenerator.xtend => CGenerator.xtend} | 21 ++---- .../yakindu/sct/generator/c/FlowCode.xtend | 22 ++++++ .../sct/generator/c/GenmodelEntries.xtend | 33 ++++++-- ...machine.xtend => StatemachineHeader.xtend} | 8 +- ...xtend => StatemachineRequiredHeader.xtend} | 24 +++++- ...achineC.xtend => StatemachineSource.xtend} | 8 +- .../CDefaultFeatureValueProvider.java | 60 ++++++++------- .../c/features/CFeatureConstants.java | 31 -------- .../c/features/ICFeatureConstants.java | 45 +++++++++++ .../META-INF/MANIFEST.MF | 3 +- .../impl/AbstractSExecModelGenerator.java | 71 ++++++++++-------- .../impl/AbstractSGraphModelGenerator.java | 15 ++-- .../core/impl/GenericJavaBasedGenerator.java | 6 +- .../sct/generator/cpp/CppCodeGenerator.java | 4 +- .../generator/cpp/StatemachineHeader.xtend | 9 +-- .../CPPDefaultFeatureValueProvider.java | 16 ++-- .../sct/generator/java/JavaCodeGenerator.java | 4 +- .../META-INF/MANIFEST.MF | 12 +-- .../transformation/SequenceBuilder.xtend | 5 +- 43 files changed, 328 insertions(+), 178 deletions(-) create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/IStatemachine.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/ITimer.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/ITimerCallback.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/RuntimeService$StatemachineTimerTask.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/RuntimeService.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/TimerService$TimeEventTask.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/TimerService.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine$SCIPedestrian.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine$SCITrafficLight.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine$SCInterface.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/TrafficLightWaitingStatemachine$SCIPedestrianImpl.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/TrafficLightWaitingStatemachine$SCITrafficLightImpl.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/TrafficLightWaitingStatemachine$SCInterfaceImpl.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/TrafficLightWaitingStatemachine$State.class create mode 100644 examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/TrafficLightWaitingStatemachine.class create mode 100644 examples/org.yakindu.sct.ui.examples/bin/org/yakindu/sct/ui/examples/Activator.class rename plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/{CSCTGenerator.xtend => CGenerator.xtend} (71%) rename plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/{Statemachine.xtend => StatemachineHeader.xtend} (96%) rename plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/{StatemachineRequired.xtend => StatemachineRequiredHeader.xtend} (84%) rename plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/{StatemachineC.xtend => StatemachineSource.xtend} (97%) delete mode 100644 plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/features/CFeatureConstants.java create mode 100644 plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/features/ICFeatureConstants.java diff --git a/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/IStatemachine.class b/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/IStatemachine.class new file mode 100644 index 0000000000000000000000000000000000000000..3140396b18aef4cc333701c107fb2f4f32fe6394 GIT binary patch literal 227 zcmY+8Jr2S!3`W0{Ld(y9I0YVq!pIcT=|n+JMp&!POWz0Ea>(QWq9K`;+zT z&-e8Pu)-ukB(T2PQa!J|_~W$--&jFY9j7EAdFkHALRqK)@Qx%Pp0ekicn9ZuXgwc?OVDyrm>chu|jBk dsyca4g+M4~9|46dvWyDySP#{V5NbI`{RI@JWBC98 literal 0 HcmV?d00001 diff --git a/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/ITimerCallback.class b/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/ITimerCallback.class new file mode 100644 index 0000000000000000000000000000000000000000..6a5a92ab5e0afbca522dbd8aca960e6ac42f8be2 GIT binary patch literal 187 zcmY+8I}Uu_@;%r8~fNOjUi5mx`A?ckUY2qSk7Am<%p KGBgA(JxqW0Au|gA literal 0 HcmV?d00001 diff --git a/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/RuntimeService$StatemachineTimerTask.class b/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/RuntimeService$StatemachineTimerTask.class new file mode 100644 index 0000000000000000000000000000000000000000..9b50a8a09a8ec79bdb0e4c03845e036456f76aea GIT binary patch literal 2814 zcmbtW=~CNP7(Le}78oT^wzPx>NC~ygq9&wU*aD=qB!&>PHKd!6FCc8oj3m?KRniCO zpU!kT6JTg(I{n>8=|hyBD;qCq+QDHM>u$Q|JNJC&e&Wx+fBhZ67&00{0&979$9QgL zY$shXJj*xaGc&iJm7d|d=JvL2W$m3^->{xrS-E9;GHs*^j&JAWigXWbOAf5~rZ01* zwQDP0;yM) zCz5q@UZ`d{KE(hH*}Rnz7^}jz@{Uz-UFrCSTJ(&RWZyL%KPAodhHLvW$$4&Ww7q4s zKrsZwra;8swY`B41ZL`IR;wnlBNMh``%?n7z}>oqE2Ajgx|(qdV;XJ?T&W6(7t73iwr zyil4SZ^p;?RKq7!xq@)Es^c!yrEugk-p7tJgskc87>~C0q~(umn4}&TyLru+z_gBg z%6yGfeNI&sMQm2b9PSHfyQa4kaG*Cgm3;F$K3A_t3QjgiiC$el1n$*ui`rr!aGAxy z$}F1uCBwCt>2!6y5SV*|t5_RF9i|6MIv!z})$RMUVj?hoCU#IL&v~l`D%B{8l=9e$ zz<4FEb;Brst?5|D2JZvUFVGn)I=|Wj>J%x=t1BbvlQvi8@&~e7D~0owj;|F?q_`|_ zXY@ za2)B*WlhhMtWu3Fk;YL7jr_6V z27T6BptV(f066A{U!9L{zQxf~?hdiNnHV}mTjCfUiQjPb$uZtJL^r!V>|Q@aZz6n% z{$B#P_xNmMK;Q;L44?yp=tYb@Fp%K$CjSQ63cQc5QlOvNDx$NAm*_o0>sKn8zI9VMfWp;B%BE z!~g&Q literal 0 HcmV?d00001 diff --git a/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/RuntimeService.class b/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/Runtime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GKO~}oQcv`;0-OoobQGvXL0tVj47JR@9 z{X^`=M>v3w(T`7X5}zsbtx7)wMf3v-v*7+6R8)qmQb|=1fANT5j#g05aY@!oX9++_ zO9A|V(?v{Ipb9GC2KiiMf|e+UWrd_k>Akavq%%YkD!HBBt^4tQWfku~(EBZVzfJEy z{#Wm_#hSMXRWSB;nS@(t4RYZGuOKDMm=jR#K=y#3Rs$vd%&h!EQ@^4KzhNhSM;rc7 d7=m8V9x@Qd-9}#?O+;8d1-@k`O7lOD$iL#f5t0A^ literal 0 HcmV?d00001 diff --git a/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/TimerService$TimeEventTask.class b/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/TimerService$TimeEventTask.class new file mode 100644 index 0000000000000000000000000000000000000000..a441179cd00f6120b842a02d18d1fcd64879cbee GIT binary patch literal 1336 zcmbtTO>fgc5PfT>ahtdyO`7moC=g2GlsZt5K>YwzK#EA=(5eRxNE>IHI(3|2I}yEb z;!pI(56A_np@IW~D?bV`>qI5(E$YR)vorJF%$xC_zdwEgSjK$~3d8G`S2qv%zU|gJ zrf&tN_{f`WNBCyo@!eh9a_stEU|I*3BdXjNHFMi;3U5nzUE2~lX}s(TH`wO>zJ>@x zy1~2L>;$$mh?EY7NsBv9m0NUuUKyLR9CB_9AyybPAvw!07+9Gh8tmDAuEg+keCW|` z2spZGyLPb7@Hu}@tnt&&bXhL!Fhn+5H8BN-3p%C{i$TSVjyO^bYQC@|J+nF{5S6#A z4h@qOTd`g7rqiqnZ<|*g!H}x7XaGChv!y+Jj7ZrSHpj1YRJ7A8KoY86$BknSH#A(Q zk(_hbI_7bcAs)y@b9kFJkW|Ts;zY%V4tJ=9OuiCsox|O_`L@~+Rxbv#SFvZb6eqXI0+YzDpTy29IVxbF*J zgUPTqcI%_CRDv{5elF613Z_3-g(3$|H^^}V$)sG3&_hB&r?_dd-cwwJ&RL__N5VKp z(pc;xZOrwN`AY8!F48v@#ylW|WhC$rX*|LudY=!uW^ox;$Rd=GQweX9RV9|Ils({D zB{W99gmFX+N637~H3k1!V&n%NQ(aF&bXg-s57C*N#t`WfMatMx@i*8Z7K*>X2AJt@ z$Q>d*c*sbSFPMn*)Sgj1My^LWYS>YhDg{FHE#{!)Oo`t;G0rp8(CFD^cW`i;! WQ1XoYMY=0k#63D=3Gg2k_;UmkPegGyZ6U;zVDvz9RB(D&%XeCi63-m0<$f* zncJ6JmeXkGJk!sqJ-NMOD=+7}a%00XZL7KI=gfW6R(0vAMy_gYE4QNDUCUHD!UCf& zMxY(>xc;4IW=%GKo%JAIf6i}900d{%kBit3k(NqRq1V&EzhUeeS3I@ zwhUFQrX&5fs|0>Lu{={gHLHHP*Z5;$S2;d2$QLMDWX5tVzaS7wXKDiB`BpG(+C z@&A~FC{p;C@A?ygpWcIHe|qz0*O;lDLmF8f8G(^rPC1F0UNf$Dr1e%-B(&|*HnuZ_lsEn&D~&s3K&JlQSQ7gJx@{F80Ia2YYVYvHsfG;?52psupfbxhU6)AR^qApRUmZ?ZraEnAR zivq=>NL>~@xxZ{6|IeM~; zUkRF}7npia$`S5sC`@X<;5si%9$`_#-$)&xw8|ct%=#a*_enD#q~~3Dk(f zDsJLCBC;Mx$#$Y0ODP;nDRiZb)0yWaDg>q-fq0Ess#bPUm-Bskv-r^tliFKCy>yNQ f7a{3t>!i}`OXX-cvPPWPHEYBRfs0av`8~8ZYz{7R literal 0 HcmV?d00001 diff --git a/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine$SCIPedestrian.class b/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine$SCIPedestrian.class new file mode 100644 index 0000000000000000000000000000000000000000..d09b437307af49edf87400518e5b8118abbdb0b1 GIT binary patch literal 509 zcmchUO-{ow6okj6ByDK1}`{5B~T?K5J4by=Q^*ci|az{0KFOu4#1%hFKHHZ z#g2{N%y?{BpTE98J^@_dBt}cXuZmo*)st~qDZLJo-qrHil9!=SvzgJ>!tF>f44-5;~)k{SR2 literal 0 HcmV?d00001 diff --git a/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine$SCITrafficLight.class b/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine$SCITrafficLight.class new file mode 100644 index 0000000000000000000000000000000000000000..10b7097ca2ba45ebb08cead8dc961799186b36c8 GIT binary patch literal 511 zcmcgp%TB{E5FD41G@(!)zW`Eu!3RE}5~xxoB!WQn<~rNd#Z6G`Q2J{e_y9f%v1!Ah zh%*=O%@aK{p&EpWV0uS#0Q^S9FlX)h3DvZIk^lez literal 0 HcmV?d00001 diff --git a/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine$SCInterface.class b/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine$SCInterface.class new file mode 100644 index 0000000000000000000000000000000000000000..b988cfca9c797e6f1befbd06b7e0bba53e3b6747 GIT binary patch literal 438 zcmcgpOHRWu6dVUgXefvkCjbdHc)<}WAw@z8A_&&6&U5PGy3}@nUX29@;7|ys-N1?+ zoA;g3Xx{t$dj9}$g`)zQz-s9`xuz%M+Fk|~CBM<)*>aH4lh#IA)6Jq(Yh`&#f!km6 zS2EGKPFD9@@XY{z+zy*akr$+9#_?%0sa#~QNpXQ)f#W&7khGMz^>ofE3Y>T{fp59x z5WOLH$E!Y-0z2my4+7<8UAtQA)HKW9E50_C1(b;QVbax_BU~aGUYNM6B&p3=o|cgh*1Cl literal 0 HcmV?d00001 diff --git a/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine.class b/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine.class new file mode 100644 index 0000000000000000000000000000000000000000..b3c8a8836d093f697be49167e3ca93a9f88a3590 GIT binary patch literal 1260 zcmchXO-}+b5Qg7^Qu#*w#;YcJaSt9%^gv=lLZS&Io=X{^P!`=SB7e<;KfoVl9M}*( z;z2HZ**EP@JI}r|JKsN_UjS}#E|CzRQPB0KYGC~K*bBAu=tB)(Erp&7RHtLKHQk=` z^i*4FsgT-h`x9lH@w;BF83os8!7tHf!zo8YrF+IFi5-DbU%e~ODvp0@^+`L4l)%H* z0JWwWQczXawv--7>2*s!JOM@?7QRTH=^}j16S<2Nfu8G@Qhlz*}rEi;4EP z85m-Z@4R<}Zv-CS+_X){u5AT|xoQRse!xie~%f?Pscx$}s2!>pxZgOXxQ(H-HZKh5|8P0*t;Vpb8S-d)aBKB!!yOQEypz9 z<-|?Pi-H1A(D?JGTupKC6>socp~GS zMAnGNo4*msf|^@sRd<4_mZXj-#i>I~wtYn#OU=(_FooL@j2wv0jx;e3!`MyCop?;7 pcuhyxEFP3q!p1!BgbKd9uIPZS`{{92N8lL5lVmNKO4daY|u$+3! z@J!zjr~K%nEj+__`To9T+E(MhH_S8B7B%jP`j!0?ZuyqeFm^(0Rbt!JXLTN(zSsYqi; z!wn2maw-xqSfz5lZXMNxyTfa?U?^3aCbxIFYe_rW%*b>xeCmtxr0$XlYzY6YEGQ}8 zlQG@bkVBq6c+rPUWlzSGJ?3_cA}J8zeNcCaeyE`!(FH<>y9{|kypjze0kaxZ3CI&5 z*kt(Cr&3*CTIY9F3SE~yag##lrYStHyu$FgKcOeqI;i5MmesbbH3oIN*>X+s(vq!O z?sDsvP16;pIT5h@RZ}ZUc#KSI3;p;R!>%C(gTs&M?&BTh3@KQ?b+Z z%OZo6ygl^Kk&^c!SgHMiVo^>CvIpo3bp@dZ$yz5XMXRbWoTI2;p!7B1+@_~O7+@G9 z^wffP6?br#EQV3si%u|TmAI__4P#&EC51M5G)B(;C68kwB5y?Q6@Ba+V{O-JAZnZf zng~u932Y@gK}vf-K}pAxi9)72g-j<3nNAim)hT3-gjBi+DJKe<=@hbH>gs){SI&ApZkMX|bC z4wZ;}?ujy?o5(QaH~AiS15V~^^-bX^69&WXQ23PpgAl{ij%bKjMUsba#cqeL3~YlT z+YZ-!pTSTq85dU={K`<+4IuZFJU)}5R4*9h;%Ho!Y7Cjxc0-JVDr3V!&O#am8#bmH z(u-PQvO=|d-Px{-Xr0#s!BD8QJs#9JrH76^Q>kWA5EJ}V9wnPt6880>NwifA?9aV%mJB?d8+fgQ9?sB;n< z&cuC&#!ws&2%APS;a6`~tWZ(Y^kwNx>1L;0pVHk8-IBt0Q1MSsg# zI>4lJh^en#n~QWBqyuc=5}kJUZea$ONn*Hy=>&q-Gn~u;W>2lHF75~7@-cy6oFH5~ z8)2>=K@fs}Cc=#qgy-Z-bI3Vq;-HTN%mgI^kOZ?yDcDLt<$7fDI=q`l;Vcl8);FA` zL)wLr97rLZyn!kG2Vb7#^rpau-$@^my0-Eo_E#Myg R3nXW;2*=QSYY7if_yg3UEy4f* literal 0 HcmV?d00001 diff --git a/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/TrafficLightWaitingStatemachine$State.class b/examples/org.yakindu.sct.examples.trafficlight/bin/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/TrafficLightWaitingStatemachine$State.class new file mode 100644 index 0000000000000000000000000000000000000000..5fe3ee1ef304b382cf86c5a03e4aae16920abafc GIT binary patch literal 2551 zcmchYZC4vr5Xb+wfjn`6Emf34Td}b~`j8?Ptwah%irDaA7pSo+F3AlnZZ^2twDQK| zN7C(!_S7TC*M2CE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rJb6}5|2?45}l43lv*1$f9?S6;eCh_Vbf$?aV0Nw+9^aHTTy7C2C~;rR4zWo zR$oeMvJe4b;apxyk;t?wzP8U*Y(rED>rTMrT`hiOvZsEU>_QwDX(v%*HX)2nYSq9p zy!B7~$q=(os2=E4+ap4`xqV6qPE1EdC}XyUX+(timQK}|qSsd0ciB!9VXW}*!X9%-xzszx4L2gZ-$=^(o#p<(m)6b1pz3Viv#$A>9RQN=$IsWi~ZC)PV zGwca|iQmf3Z`7{YC}EE8st;B%&vtDHzye;dH-$yiIpWA0KEskXX#8UTDR;(mOB^LE z;T7jzv+as6d+s4yE?fC== +==== + +h4. Tracing + +The *Tracing* feature allows to enable generation of tracing callback functions: + +# __enterState__ (Boolean, optional): whether to generate a callback that is used to notify about 'state enter' events. +# __exitState__ (Boolean, optional): whether to generate a callback that is used to notify about 'state exit' events. + +Sample configuration: + +bc(prettyprint).. +feature Tracing { + enterState = true + exitState = true +} +p. ==== + ==== h4. GeneratorOptions diff --git a/plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/extension/GenericDomainInjectorProvider.java b/plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/extension/GenericDomainInjectorProvider.java index 0f48124e97..0a63db6c2a 100644 --- a/plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/extension/GenericDomainInjectorProvider.java +++ b/plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/extension/GenericDomainInjectorProvider.java @@ -82,7 +82,6 @@ public Module getSequencerModule() { return new GenericSequencerModule(); } - protected Module getResourceModule() { Module uiModule = Modules.override(getLanguageRuntimeModule()).with(getLanguageUIModule()); Module result = Modules.override(uiModule).with(getSharedStateModule()); @@ -117,14 +116,22 @@ public Injector getResourceInjector() { public Injector getSimulationInjector() { return Guice.createInjector(getSimulationModule()); } - + @Override public Injector getSequencerInjector() { return Guice.createInjector(getSequencerModule()); } + + @Override + public Injector getSequencerInjector(Module overrides) { + if(overrides != null) { + return Guice.createInjector(Modules.override(getSequencerModule()).with(overrides)); + } + return getSequencerInjector(); + } @Override public Injector getEditorInjector() { - return Guice.createInjector(new GenericEditorModule()); + return Guice.createInjector(new GenericEditorModule()); } } diff --git a/plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/modules/GenericSequencerModule.java b/plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/modules/GenericSequencerModule.java index ef9d0e111d..d58485cc8b 100644 --- a/plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/modules/GenericSequencerModule.java +++ b/plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/modules/GenericSequencerModule.java @@ -52,8 +52,8 @@ public Class bindIQualifiedNameProvider() { public Class bindITypeSystemInferrer() { return STextTypeInferrer.class; } - - public Class bindITypesystem(){ + + public Class bindITypesystem() { return GenericTypeSystem.class; } diff --git a/plugins/org.yakindu.sct.domain/src/org/yakindu/sct/domain/extension/IDomainInjectorProvider.java b/plugins/org.yakindu.sct.domain/src/org/yakindu/sct/domain/extension/IDomainInjectorProvider.java index dabddde58b..95c69ea1f8 100644 --- a/plugins/org.yakindu.sct.domain/src/org/yakindu/sct/domain/extension/IDomainInjectorProvider.java +++ b/plugins/org.yakindu.sct.domain/src/org/yakindu/sct/domain/extension/IDomainInjectorProvider.java @@ -13,6 +13,7 @@ import org.yakindu.sct.model.sgraph.resource.AbstractSCTResource; import com.google.inject.Injector; +import com.google.inject.Module; /** * @author andreas muelder - Initial contribution and API @@ -33,10 +34,17 @@ public interface IDomainInjectorProvider { public Injector getSimulationInjector(); /** - * Returns the Injector for the model sequencing + * Returns the Injector for the model sequencing without overriding existing + * bindings. */ public Injector getSequencerInjector(); + /** + * Returns the Injector for the model sequencing, giving precedence to those + * bindings in the overrides module. + */ + public Injector getSequencerInjector(Module overrides); + /** * Injector used to create the embedded in-diagram Xtext Editor * @@ -46,7 +54,6 @@ public interface IDomainInjectorProvider { */ public Injector getEmbeddedEditorInjector(String elementKey); - /** * Returns an injector for all editor and UI related stuff. */ diff --git a/plugins/org.yakindu.sct.generator.c/META-INF/MANIFEST.MF b/plugins/org.yakindu.sct.generator.c/META-INF/MANIFEST.MF index e10a0d8eda..4d223d37e6 100644 --- a/plugins/org.yakindu.sct.generator.c/META-INF/MANIFEST.MF +++ b/plugins/org.yakindu.sct.generator.c/META-INF/MANIFEST.MF @@ -20,7 +20,8 @@ Require-Bundle: org.yakindu.sct.model.sexec, org.yakindu.sct.generator.genmodel;bundle-version="1.0.0", org.yakindu.base.types;bundle-version="1.0.0", org.eclipse.xtext.xbase.lib;bundle-version="2.3.0", - org.eclipse.xtext.builder;bundle-version="2.3.0" + org.eclipse.xtext.builder;bundle-version="2.3.0", + org.yakindu.sct.domain.generic Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Export-Package: org.yakindu.sct.generator.c, org.yakindu.sct.generator.c.features, diff --git a/plugins/org.yakindu.sct.generator.c/library/FeatureTypeLibrary.xmi b/plugins/org.yakindu.sct.generator.c/library/FeatureTypeLibrary.xmi index e6e855cdbe..52e27b4abb 100644 --- a/plugins/org.yakindu.sct.generator.c/library/FeatureTypeLibrary.xmi +++ b/plugins/org.yakindu.sct.generator.c/library/FeatureTypeLibrary.xmi @@ -22,4 +22,17 @@ name="separator" optional="true"/> + + + + diff --git a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CCodeGenerator.java b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CCodeGenerator.java index cdefa49d24..65ee25f273 100644 --- a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CCodeGenerator.java +++ b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CCodeGenerator.java @@ -1,40 +1,47 @@ /** - * Copyright (c) 2012 committers of YAKINDU and others. + * Copyright (c) 2012, 2015 Committers of YAKINDU and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * Contributors: - * committers of YAKINDU - initial API and implementation + * + * Andreas Mülder - Initial API and implementation + * Alexander Nyßen - Support for 'Tracing' feature * */ package org.yakindu.sct.generator.c; import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec; +import org.yakindu.sct.domain.generic.modules.GenericSequencerModule; +import org.yakindu.sct.generator.c.features.ICFeatureConstants; import org.yakindu.sct.generator.c.types.CTypeSystemAccess; import org.yakindu.sct.generator.core.impl.GenericJavaBasedGenerator; import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess; import org.yakindu.sct.model.sexec.ExecutionFlow; import org.yakindu.sct.model.sexec.naming.INamingService; +import org.yakindu.sct.model.sgen.FeatureConfiguration; import org.yakindu.sct.model.sgen.GeneratorEntry; import org.yakindu.sct.model.sgraph.Statechart; import com.google.inject.Binder; import com.google.inject.Module; +import com.google.inject.name.Names; import com.google.inject.util.Modules; /** + * Provides a C code generator implementation that is based on SExec. * - * @author andreas muelder + * @author Andreas Mülder + * @author Alexander Nyßen * */ public class CCodeGenerator extends GenericJavaBasedGenerator { @Override public void runGenerator(Statechart statechart, GeneratorEntry entry) { - CSCTGenerator delegate = getInjector(entry).getInstance( - CSCTGenerator.class); + CGenerator delegate = getInjector(entry).getInstance(CGenerator.class); ExecutionFlow flow = createExecutionFlow(statechart, entry); if (isDumpSexec(entry)) { dumpSexec(entry, flow); @@ -43,14 +50,34 @@ public void runGenerator(Statechart statechart, GeneratorEntry entry) { } @Override - protected Module getChildInjectorModule(final GeneratorEntry entry) { - Module module = super.getChildInjectorModule(entry); + protected Module getOverridesModule(final GeneratorEntry entry) { + Module module = super.getOverridesModule(entry); + return Modules.override(module).with(new Module() { public void configure(Binder binder) { - binder.bind(ICodegenTypeSystemAccess.class) - .to(CTypeSystemAccess.class); - binder.bind(INamingService.class).to(CNamingService.class); + binder.bind(GeneratorEntry.class).toInstance(entry); + binder.bind(INamingService.class).to(CNamingService.class); + binder.bind(ICodegenTypeSystemAccess.class).to(CTypeSystemAccess.class); + + // Enable generation of trace steps in case the Tracing feature + // is specified and at least one of enter/exit states is + // enabled. + FeatureConfiguration tracingFeatureConfiguration = entry + .getFeatureConfiguration(ICFeatureConstants.FEATURE_TRACING); + if (tracingFeatureConfiguration != null && ((tracingFeatureConfiguration + .getParameterValue(ICFeatureConstants.PARAMETER_TRACING_ENTER_STATE) != null + && tracingFeatureConfiguration + .getParameterValue(ICFeatureConstants.PARAMETER_TRACING_ENTER_STATE) + .getBooleanValue() == true) + || (tracingFeatureConfiguration + .getParameterValue(ICFeatureConstants.PARAMETER_TRACING_EXIT_STATE) != null + && tracingFeatureConfiguration + .getParameterValue(ICFeatureConstants.PARAMETER_TRACING_EXIT_STATE) + .getBooleanValue() == true))) { + binder.bind(Boolean.class).annotatedWith(Names.named(GenericSequencerModule.ADD_TRACES)) + .toInstance(Boolean.TRUE); + } } }); } diff --git a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CSCTGenerator.xtend b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CGenerator.xtend similarity index 71% rename from plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CSCTGenerator.xtend rename to plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CGenerator.xtend index a35ee61d34..189768227a 100644 --- a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CSCTGenerator.xtend +++ b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CGenerator.xtend @@ -22,27 +22,20 @@ import org.yakindu.sct.model.sgraph.Statechart * * @author Axel Terfloth */ -class CSCTGenerator implements IExecutionFlowGenerator { +class CGenerator implements IExecutionFlowGenerator { @Inject extension Types - @Inject extension Statemachine - @Inject extension StatemachineC - @Inject extension StatemachineRequired + @Inject extension StatemachineHeader + @Inject extension StatemachineSource + @Inject extension StatemachineRequiredHeader @Inject extension Navigation override generate(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) { - flow.generateTypesH(flow.sourceElement as Statechart, fsa, entry) - - flow.generateStatemachineH(flow.sourceElement as Statechart, fsa, entry) - + flow.generateStatemachineHeader(flow.sourceElement as Statechart, fsa, entry) if (flow.timed || !flow.operations.empty) { - flow.generateStatemachineClientH(flow.sourceElement as Statechart, fsa, entry) + flow.generateStatemachineRequiredHeader(flow.sourceElement as Statechart, fsa, entry) } - - flow.generateStatemachineC(flow.sourceElement as Statechart, fsa, entry) - + flow.generateStatemachineSource(flow.sourceElement as Statechart, fsa, entry) } - - } \ No newline at end of file diff --git a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/FlowCode.xtend b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/FlowCode.xtend index b346f67701..0a17b1d0e7 100644 --- a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/FlowCode.xtend +++ b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/FlowCode.xtend @@ -24,8 +24,12 @@ import org.yakindu.sct.model.sexec.ScheduleTimeEvent import org.yakindu.sct.model.sexec.Sequence import org.yakindu.sct.model.sexec.StateSwitch import org.yakindu.sct.model.sexec.Step +import org.yakindu.sct.model.sexec.Trace +import org.yakindu.sct.model.sexec.TraceStateEntered +import org.yakindu.sct.model.sexec.TraceStateExited import org.yakindu.sct.model.sexec.UnscheduleTimeEvent import org.yakindu.sct.model.sexec.naming.INamingService +import org.yakindu.sct.model.sgen.GeneratorEntry class FlowCode { @@ -33,6 +37,9 @@ class FlowCode { @Inject extension Navigation @Inject extension ExpressionCode @Inject extension INamingService + @Inject extension GenmodelEntries + + @Inject GeneratorEntry entry def stepComment(Step it) ''' «IF !comment.nullOrEmpty» @@ -43,6 +50,21 @@ class FlowCode { def dispatch CharSequence code(Step it) ''' #error ActionCode for Step '«getClass().name»' not defined ''' + +// ignore all trace steps not explicitly supported + def dispatch CharSequence code(Trace it)'''''' + + def dispatch CharSequence code(TraceStateEntered it) ''' + «IF entry.tracingEnterState» + stateEntered(«it.state.shortName»); + «ENDIF» + ''' + + def dispatch CharSequence code(TraceStateExited it) ''' + «IF entry.tracingExitState» + stateExited(«it.state.shortName»); + «ENDIF» + ''' def dispatch CharSequence code(SaveHistory it) ''' «stepComment» diff --git a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/GenmodelEntries.xtend b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/GenmodelEntries.xtend index 27625d68dd..f8b351c0ed 100644 --- a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/GenmodelEntries.xtend +++ b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/GenmodelEntries.xtend @@ -12,7 +12,7 @@ package org.yakindu.sct.generator.c import org.yakindu.sct.generator.core.features.ICoreFeatureConstants import org.yakindu.sct.model.sgen.FeatureParameterValue import org.yakindu.sct.model.sgen.GeneratorEntry -import org.yakindu.sct.generator.c.features.CFeatureConstants +import org.yakindu.sct.generator.c.features.ICFeatureConstants class GenmodelEntries { @@ -32,11 +32,11 @@ class GenmodelEntries { } def private getIdentifierSettingsFeature(GeneratorEntry it) { - getFeatureConfiguration(CFeatureConstants::FEATURE_IDENTIFIER_SETTINGS) + getFeatureConfiguration(ICFeatureConstants::FEATURE_NAMING) } def private FeatureParameterValue getMaxIdentifierLengthParameter(GeneratorEntry it) { - identifierSettingsFeature?.getParameterValue(CFeatureConstants::PARAMETER_MAX_IDENTIFIER_LENGTH) + identifierSettingsFeature?.getParameterValue(ICFeatureConstants::PARAMETER_NAMING_MAX_IDENTIFIER_LENGTH) } def getIdentifierLength(GeneratorEntry it) { @@ -52,7 +52,7 @@ class GenmodelEntries { } def private FeatureParameterValue getSeparatorParameter(GeneratorEntry it) { - identifierSettingsFeature?.getParameterValue(CFeatureConstants::PARAMETER_SEPARATOR) + identifierSettingsFeature?.getParameterValue(ICFeatureConstants::PARAMETER_NAMING_SEPARATOR) } def getSeparator(GeneratorEntry it) { @@ -60,7 +60,7 @@ class GenmodelEntries { } def private FeatureParameterValue getStatemachinePrefixParameter(GeneratorEntry it) { - identifierSettingsFeature?.getParameterValue(CFeatureConstants::PARAMETER_STATEMACHINE_PREFIX) + identifierSettingsFeature?.getParameterValue(ICFeatureConstants::PARAMETER_NAMING_STATEMACHINE_PREFIX) } def getStatemachinePrefix(GeneratorEntry it) { @@ -68,10 +68,31 @@ class GenmodelEntries { } def private FeatureParameterValue getModuleNameParameter(GeneratorEntry it) { - identifierSettingsFeature?.getParameterValue(CFeatureConstants::PARAMETER_MODULE_NAME) + identifierSettingsFeature?.getParameterValue(ICFeatureConstants::PARAMETER_NAMING_MODULE_NAME) } def getModuleName(GeneratorEntry it) { return moduleNameParameter?.stringValue } + + + def private getTracingFeature(GeneratorEntry it) { + getFeatureConfiguration(ICFeatureConstants::FEATURE_TRACING) + } + + def getTracingEnterState(GeneratorEntry it){ + val enterStateParameter = tracingFeature?.getParameterValue(ICFeatureConstants::PARAMETER_TRACING_ENTER_STATE) + if (enterStateParameter != null) { + return enterStateParameter.booleanValue + } + return false + } + + def getTracingExitState(GeneratorEntry it){ + val exitStateParameter = tracingFeature?.getParameterValue(ICFeatureConstants::PARAMETER_TRACING_EXIT_STATE) + if (exitStateParameter != null) { + return exitStateParameter.booleanValue + } + return false + } } \ No newline at end of file diff --git a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Statemachine.xtend b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineHeader.xtend similarity index 96% rename from plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Statemachine.xtend rename to plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineHeader.xtend index a1186985a8..937781c74c 100644 --- a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Statemachine.xtend +++ b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineHeader.xtend @@ -29,7 +29,7 @@ import org.yakindu.sct.model.stext.stext.VariableDefinition import static org.eclipse.xtext.util.Strings.* -class Statemachine { +class StatemachineHeader { @Inject extension Naming cNaming @Inject extension Navigation @@ -37,12 +37,12 @@ class Statemachine { @Inject extension GenmodelEntries @Inject extension INamingService - def generateStatemachineH(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) { + def generateStatemachineHeader(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) { flow.initializeNamingService - fsa.generateFile(flow.module.h, flow.statemachineHContent(entry)) + fsa.generateFile(flow.module.h, flow.generateStatemachineHeaderContents(entry)) } - def statemachineHContent(ExecutionFlow it, GeneratorEntry entry) ''' + def generateStatemachineHeaderContents(ExecutionFlow it, GeneratorEntry entry) ''' «entry.licenseText» #ifndef «module.define»_H_ diff --git a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineRequired.xtend b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineRequiredHeader.xtend similarity index 84% rename from plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineRequired.xtend rename to plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineRequiredHeader.xtend index 05122f0fdd..bfaafe9d1f 100644 --- a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineRequired.xtend +++ b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineRequiredHeader.xtend @@ -21,7 +21,7 @@ import org.yakindu.sct.model.sgraph.Statechart import org.yakindu.sct.model.stext.stext.OperationDefinition import org.yakindu.sct.model.stext.stext.StatechartScope -class StatemachineRequired { +class StatemachineRequiredHeader { @Inject extension Naming cNaming @Inject extension Navigation @@ -29,11 +29,11 @@ class StatemachineRequired { @Inject extension GenmodelEntries @Inject extension INamingService - def generateStatemachineClientH(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) { - fsa.generateFile(flow.module.client.h, flow.statemachineClientHContent(entry) ) + def generateStatemachineRequiredHeader(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) { + fsa.generateFile(flow.module.client.h, flow.statemachineRequiredHeaderContents(entry) ) } - def statemachineClientHContent(ExecutionFlow it, GeneratorEntry entry) ''' + def statemachineRequiredHeaderContents(ExecutionFlow it, GeneratorEntry entry) ''' «entry.licenseText» #ifndef «module.client.define»_H_ @@ -95,6 +95,22 @@ class StatemachineRequired { extern void «type.toFirstLower»_unsetTimer(«scHandleDecl», const sc_eventid evid); «ENDIF» + + «IF entry.tracingEnterState || entry.tracingExitState» + /*! + * Tracing callback functions + */ + «IF entry.tracingEnterState» + /*! This function is called when a state is entered. */ + extern void stateEntered(const SCTStates state); + «ENDIF» + + «IF entry.tracingExitState» + /*! This function is called when a state is exited. */ + extern void stateExited(const SCTStates state); + «ENDIF» + «ENDIF» + #ifdef __cplusplus } #endif diff --git a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineC.xtend b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineSource.xtend similarity index 97% rename from plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineC.xtend rename to plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineSource.xtend index 6929856257..2dbcb4dda9 100644 --- a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineC.xtend +++ b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineSource.xtend @@ -25,7 +25,7 @@ import org.yakindu.sct.model.stext.stext.VariableDefinition import org.yakindu.sct.model.stext.stext.StatechartScope import org.eclipse.xtext.util.Strings -class StatemachineC { +class StatemachineSource { @Inject extension Naming @Inject extension GenmodelEntries @@ -36,14 +36,14 @@ class StatemachineC { @Inject extension ConstantInitializationResolver @Inject protected extension StateVectorExtensions - def generateStatemachineC(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) { + def generateStatemachineSource(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) { flow.initializeNamingService - var content = flow.statemachineCContent(entry) + var content = flow.generateStatemachineSourceContents(entry) var target = flow.module.c fsa.generateFile(target , content) } - def statemachineCContent(ExecutionFlow it, GeneratorEntry entry) ''' + def generateStatemachineSourceContents(ExecutionFlow it, GeneratorEntry entry) ''' «entry.licenseText» #include diff --git a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/features/CDefaultFeatureValueProvider.java b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/features/CDefaultFeatureValueProvider.java index 54de2e9ccc..a59a8efbee 100644 --- a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/features/CDefaultFeatureValueProvider.java +++ b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/features/CDefaultFeatureValueProvider.java @@ -1,12 +1,14 @@ /** - * Copyright (c) 2011 committers of YAKINDU and others. + * Copyright (c) 2011, 2015 Committers of YAKINDU and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * Contributors: - * committers of YAKINDU - initial API and implementation * + * Contributors: + * Andreas Mülder - Initial contribution and API + * Markus Mühlbrandt - Added support for 'IdentifierSettings' feature + * Alexander Nyßen - Added support for 'Tracing' feature; general refactorings */ package org.yakindu.sct.generator.c.features; @@ -21,63 +23,65 @@ import org.yakindu.sct.model.sgraph.Statechart; /** - * Feature value provider for c code generator. - * - * @author andreas muelder - Initial contribution and API - * @author Markus Mühlbrandt - Added additional features + * Provides default values and support for validating parameter values of C code + * generator generator model. * + * @author Andreas Mülder + * @author Markus Mühlbrandt + * @author Alexander Nyßen */ -public class CDefaultFeatureValueProvider extends - AbstractDefaultFeatureValueProvider { +public class CDefaultFeatureValueProvider extends AbstractDefaultFeatureValueProvider { private static final String INVALID_IDENTIFIER_REGEX = "[^a-z&&[^A-Z&&[^0-9]]]"; private static final String VALID_IDENTIFIER_REGEX = "[_a-zA-Z][_a-zA-Z0-9]*"; + @Override public boolean isProviderFor(FeatureTypeLibrary library) { - return CFeatureConstants.LIBRARY_NAME.equals(library.getName()); + return ICFeatureConstants.LIBRARY_NAME.equals(library.getName()); } @Override - protected void setDefaultValue(FeatureParameterValue parameterValue, - EObject contextElement) { + protected void setDefaultValue(FeatureParameterValue parameterValue, EObject contextElement) { GeneratorEntry entry = (GeneratorEntry) contextElement; Statechart statechart = (Statechart) entry.getElementRef(); + String parameterName = parameterValue.getParameter().getName(); - if (parameterValue.getParameter().getName() - .equals(CFeatureConstants.PARAMETER_MODULE_NAME)) { + if (ICFeatureConstants.PARAMETER_NAMING_MODULE_NAME.equals(parameterName)) { parameterValue.setValue(asIdentifier(statechart.getName(), "_")); - } else if (parameterValue.getParameter().getName() - .equals(CFeatureConstants.PARAMETER_STATEMACHINE_PREFIX)) { - parameterValue.setValue(StringExtensions.toFirstLower(asIdentifier( - statechart.getName(), "_"))); - } else if (parameterValue.getParameter().getName() - .equals(CFeatureConstants.PARAMETER_MAX_IDENTIFIER_LENGTH)) { + } else if (ICFeatureConstants.PARAMETER_NAMING_STATEMACHINE_PREFIX.equals(parameterName)) { + parameterValue.setValue(StringExtensions.toFirstLower(asIdentifier(statechart.getName(), "_"))); + } else if (ICFeatureConstants.PARAMETER_NAMING_MAX_IDENTIFIER_LENGTH.equals(parameterName)) { parameterValue.setValue("31"); - } else if (parameterValue.getParameter().getName() - .equals(CFeatureConstants.PARAMETER_SEPARATOR)) { + } else if (ICFeatureConstants.PARAMETER_NAMING_SEPARATOR.equals(parameterName)) { parameterValue.setValue("_"); + } else if (ICFeatureConstants.PARAMETER_TRACING_ENTER_STATE.equals(parameterName)) { + parameterValue.setValue(true); + } else if (ICFeatureConstants.PARAMETER_TRACING_EXIT_STATE.equals(parameterName)) { + parameterValue.setValue(true); + } else { + throw new IllegalArgumentException("Unsupported parameter '" + parameterName + "'."); } } - /** - * Executes some validations on the given {@link FeatureParameterValue} - */ + @Override public IStatus validateParameterValue(FeatureParameterValue parameter) { String parameterName = parameter.getParameter().getName(); - if (CFeatureConstants.PARAMETER_MODULE_NAME.equals(parameterName)) { + if (ICFeatureConstants.PARAMETER_NAMING_MODULE_NAME.equals(parameterName)) { if (!parameter.getStringValue().matches(VALID_IDENTIFIER_REGEX)) { return error("Invalid module name"); } - } else if (CFeatureConstants.PARAMETER_STATEMACHINE_PREFIX.equals(parameterName)) { + } else if (ICFeatureConstants.PARAMETER_NAMING_STATEMACHINE_PREFIX.equals(parameterName)) { if (!parameter.getStringValue().matches(VALID_IDENTIFIER_REGEX)) { return error("Invalid function prefix name"); } - } else if (CFeatureConstants.PARAMETER_SEPARATOR.equals(parameterName)) { + } else if (ICFeatureConstants.PARAMETER_NAMING_SEPARATOR.equals(parameterName)) { if (!parameter.getStringValue().matches(VALID_IDENTIFIER_REGEX)) { return error("Invalid separator"); } } + // No specific validation is required for 'enterState' and 'exitState' + // parameters of 'Tracing' feature, as they are boolean. return Status.OK_STATUS; } diff --git a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/features/CFeatureConstants.java b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/features/CFeatureConstants.java deleted file mode 100644 index 803931cf18..0000000000 --- a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/features/CFeatureConstants.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2011 committers of YAKINDU and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * Contributors: - * committers of YAKINDU - initial API and implementation - * - */ -package org.yakindu.sct.generator.c.features; - -/** - * - * @author holger willebrandt - Initial contribution and API - * @author Markus Mühlbrandt - Additional feature identifiers - * - */ -public interface CFeatureConstants { - public static final String LIBRARY_NAME = "C Generator"; - - public static final String FEATURE_IDENTIFIER_SETTINGS = "IdentifierSettings"; - - public static final String PARAMETER_MODULE_NAME = "moduleName"; - - public static final String PARAMETER_STATEMACHINE_PREFIX = "statemachinePrefix"; - - public static final String PARAMETER_MAX_IDENTIFIER_LENGTH = "maxIdentifierLength"; - - public static final String PARAMETER_SEPARATOR = "separator"; -} diff --git a/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/features/ICFeatureConstants.java b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/features/ICFeatureConstants.java new file mode 100644 index 0000000000..6005ba237c --- /dev/null +++ b/plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/features/ICFeatureConstants.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2011, 2015 Committers of YAKINDU and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Holger Willebrandt - Initial API and implementation + * Markus Mühlbrandt - Added 'IdentifierSettings' feature and related parameters + * Alexander Nyßen - Added 'Tracing' feature and renamed constants + * + */ +package org.yakindu.sct.generator.c.features; + +/** + * Defines constants to refer to features and parameters within C code generator + * generator model. + * + * @author Holger Willebrandt + * @author Markus Mühlbrandt + * @author Alexander Nyßen + */ +public interface ICFeatureConstants { + + public static final String LIBRARY_NAME = "C Generator"; + + // TODO: Change value of FEATURE_NAMING to 'Naming' and extract it to a + // general code generator feature (see issue #267). + public static final String FEATURE_NAMING = "IdentifierSettings"; + + public static final String PARAMETER_NAMING_MODULE_NAME = "moduleName"; + + public static final String PARAMETER_NAMING_STATEMACHINE_PREFIX = "statemachinePrefix"; + + public static final String PARAMETER_NAMING_MAX_IDENTIFIER_LENGTH = "maxIdentifierLength"; + + public static final String PARAMETER_NAMING_SEPARATOR = "separator"; + + public static final String FEATURE_TRACING = "Tracing"; + + public static final String PARAMETER_TRACING_ENTER_STATE = "enterState"; + + public static final String PARAMETER_TRACING_EXIT_STATE = "exitState"; +} diff --git a/plugins/org.yakindu.sct.generator.core/META-INF/MANIFEST.MF b/plugins/org.yakindu.sct.generator.core/META-INF/MANIFEST.MF index 8ef762b44e..b54206c454 100644 --- a/plugins/org.yakindu.sct.generator.core/META-INF/MANIFEST.MF +++ b/plugins/org.yakindu.sct.generator.core/META-INF/MANIFEST.MF @@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.ui, org.yakindu.base.types;bundle-version="1.0.0", org.eclipse.xtext.builder;bundle-version="2.3.0", org.yakindu.sct.commons;bundle-version="1.0.0", - org.yakindu.sct.domain;bundle-version="2.4.1" + org.yakindu.sct.domain;bundle-version="2.4.1", + org.yakindu.sct.domain.generic;bundle-version="2.5.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Export-Package: org.yakindu.sct.builder.nature, diff --git a/plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSExecModelGenerator.java b/plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSExecModelGenerator.java index 37dc32f76f..90ba531462 100644 --- a/plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSExecModelGenerator.java +++ b/plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSExecModelGenerator.java @@ -31,6 +31,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.yakindu.sct.domain.generic.modules.GenericSequencerModule; import org.yakindu.sct.model.sexec.ExecutionFlow; import org.yakindu.sct.model.sexec.transformation.FlowOptimizer; import org.yakindu.sct.model.sexec.transformation.IModelSequencer; @@ -38,7 +39,11 @@ import org.yakindu.sct.model.sgen.GeneratorEntry; import org.yakindu.sct.model.sgraph.Statechart; +import com.google.inject.Binder; import com.google.inject.Injector; +import com.google.inject.Module; +import com.google.inject.name.Names; +import com.google.inject.util.Modules; /** * abstract base class for all code generators that want to generate code based @@ -47,8 +52,7 @@ * @author andreas muelder - Initial contribution and API * */ -public abstract class AbstractSExecModelGenerator extends - AbstractSGraphModelGenerator { +public abstract class AbstractSExecModelGenerator extends AbstractSGraphModelGenerator { private static final String SEXEC_FILE_EXTENSION = "sexec"; @@ -60,45 +64,49 @@ public AbstractSExecModelGenerator() { protected void runGenerator(Statechart statechart, GeneratorEntry entry) { if (this instanceof IExecutionFlowGenerator) { IExecutionFlowGenerator flowGenerator = (IExecutionFlowGenerator) this; - flowGenerator.generate(createExecutionFlow(statechart, entry), - entry, null); + flowGenerator.generate(createExecutionFlow(statechart, entry), entry, null); } super.runGenerator(statechart, entry); } + @Override + protected Module getOverridesModule(GeneratorEntry entry) { + Module module = super.getOverridesModule(entry); + + return Modules.override(module).with(new Module() { + public void configure(Binder binder) { + // by default, traces should not be generated + binder.bind(Boolean.class).annotatedWith(Names.named(GenericSequencerModule.ADD_TRACES)) + .toInstance(Boolean.FALSE); + } + }); + } + /** * Transforms the {@link Statechart} model to a {@link ExecutionFlow} model */ - protected ExecutionFlow createExecutionFlow(Statechart statechart, - GeneratorEntry entry) { + protected ExecutionFlow createExecutionFlow(Statechart statechart, GeneratorEntry entry) { Injector injector = getInjector(entry); IModelSequencer sequencer = injector.getInstance(IModelSequencer.class); ExecutionFlow flow = sequencer.transform(statechart); Assert.isNotNull(flow, "Error creation ExecutionFlow"); - FeatureConfiguration optimizeConfig = entry - .getFeatureConfiguration(FUNCTION_INLINING_FEATURE); + FeatureConfiguration optimizeConfig = entry.getFeatureConfiguration(FUNCTION_INLINING_FEATURE); FlowOptimizer optimizer = injector.getInstance(FlowOptimizer.class); - optimizer.inlineReactions(getBoolValue(optimizeConfig, - FUNCTION_INLINING_FEATURE_INLINE_REACTIONS, false)); - optimizer.inlineExitActions(getBoolValue(optimizeConfig, - FUNCTION_INLINING_FEATURE_INLINE_EXIT_ACTIONS, false)); - optimizer.inlineEntryActions(getBoolValue(optimizeConfig, - FUNCTION_INLINING_FEATURE_INLINE_ENTRY_ACTIONS, false)); - optimizer.inlineEnterSequences(getBoolValue(optimizeConfig, - FUNCTION_INLINING_FEATURE_INLINE_ENTER_SEQUENCES, false)); - optimizer.inlineExitSequences(getBoolValue(optimizeConfig, - FUNCTION_INLINING_FEATURE_INLINE_EXIT_SEQUENCES, false)); - optimizer.inlineChoices(getBoolValue(optimizeConfig, - FUNCTION_INLINING_FEATURE_INLINE_CHOICES, false)); - optimizer.inlineEntries(getBoolValue(optimizeConfig, - FUNCTION_INLINING_FEATURE_INLINE_ENTRIES, false)); - optimizer.inlineEnterRegion(getBoolValue(optimizeConfig, - FUNCTION_INLINING_FEATURE_INLINE_ENTER_REGION, false)); - optimizer.inlineExitRegion(getBoolValue(optimizeConfig, - FUNCTION_INLINING_FEATURE_INLINE_EXIT_REGION, false)); + optimizer.inlineReactions(getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_REACTIONS, false)); + optimizer.inlineExitActions(getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_EXIT_ACTIONS, false)); + optimizer.inlineEntryActions( + getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTRY_ACTIONS, false)); + optimizer.inlineEnterSequences( + getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTER_SEQUENCES, false)); + optimizer.inlineExitSequences( + getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_EXIT_SEQUENCES, false)); + optimizer.inlineChoices(getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_CHOICES, false)); + optimizer.inlineEntries(getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTRIES, false)); + optimizer.inlineEnterRegion(getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTER_REGION, false)); + optimizer.inlineExitRegion(getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_EXIT_REGION, false)); flow = optimizer.transform(flow); @@ -107,13 +115,10 @@ protected ExecutionFlow createExecutionFlow(Statechart statechart, protected void dumpSexec(GeneratorEntry entry, ExecutionFlow flow) { ResourceSet resourceSet = new ResourceSetImpl(); - resourceSet - .getResourceFactoryRegistry() - .getExtensionToFactoryMap() - .put(Resource.Factory.Registry.DEFAULT_EXTENSION, - new XMIResourceFactoryImpl()); - URI fileURI = entry.getElementRef().eResource().getURI() - .trimFileExtension().appendFileExtension(SEXEC_FILE_EXTENSION); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() + .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); + URI fileURI = entry.getElementRef().eResource().getURI().trimFileExtension() + .appendFileExtension(SEXEC_FILE_EXTENSION); Resource resource = resourceSet.createResource(fileURI); resource.getContents().add(flow); try { diff --git a/plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSGraphModelGenerator.java b/plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSGraphModelGenerator.java index b59ec1bc87..44fe302f30 100644 --- a/plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSGraphModelGenerator.java +++ b/plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSGraphModelGenerator.java @@ -6,7 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * committers of YAKINDU - initial API and implementation + * Andreas Mülder - Initial API and implementation + * Alexaner Nyßen - Refactored to use overriding module instead of child injector */ package org.yakindu.sct.generator.core.impl; @@ -38,7 +39,7 @@ * abstract base class for all code generators that want to generate code based * on the {@link ExecutionFlow} * - * @author andreas muelder - Initial contribution and API + * @author Andreas Mülder - Initial contribution and API * */ public abstract class AbstractSGraphModelGenerator implements ISCTGenerator { @@ -73,7 +74,7 @@ public File getTargetProject(GeneratorEntry entry) { public File getTargetFolder(GeneratorEntry entry) { return GeneratorUtils.getTargetFolder(entry); } - + public File getLibraryTargetFolder(GeneratorEntry entry) { return GeneratorUtils.getLibraryTargetFolder(entry); } @@ -137,11 +138,11 @@ protected void finishGenerator(GeneratorEntry entry) { private Injector injector; protected Injector createInjector(GeneratorEntry entry) { - Injector sequencerInjector = DomainRegistry.getDomainDescriptor(entry.getElementRef()).getDomainInjectorProvider().getSequencerInjector(); - return sequencerInjector.createChildInjector(getChildInjectorModule(entry)); + return DomainRegistry.getDomainDescriptor(entry.getElementRef()).getDomainInjectorProvider() + .getSequencerInjector(getOverridesModule(entry)); } - protected Module getChildInjectorModule(GeneratorEntry entry) { + protected Module getOverridesModule(GeneratorEntry entry) { Module bridgeModule = new Module() { public void configure(Binder binder) { binder.bind(IGeneratorBridge.class).toInstance(bridge); @@ -180,7 +181,7 @@ private MessageConsole getConsole() { } } MessageConsole myConsole = new MessageConsole(SCT_GENERATOR_CONSOLE, null); - conMan.addConsoles(new IConsole[] { myConsole }); + conMan.addConsoles(new IConsole[]{myConsole}); return myConsole; } diff --git a/plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/GenericJavaBasedGenerator.java b/plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/GenericJavaBasedGenerator.java index b09071d061..0af1619f82 100644 --- a/plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/GenericJavaBasedGenerator.java +++ b/plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/GenericJavaBasedGenerator.java @@ -10,8 +10,8 @@ */ package org.yakindu.sct.generator.core.impl; -import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_TARGET_FOLDER; import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_LIBRARY_TARGET_FOLDER; +import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_TARGET_FOLDER; import static org.yakindu.sct.generator.core.features.impl.IGenericJavaFeatureConstants.CONFIGURATION_MODULE; import static org.yakindu.sct.generator.core.features.impl.IGenericJavaFeatureConstants.GENERATOR_CLASS; import static org.yakindu.sct.generator.core.features.impl.IGenericJavaFeatureConstants.GENERATOR_PROJECT; @@ -45,8 +45,8 @@ public class GenericJavaBasedGenerator extends AbstractSExecModelGenerator { @Override - protected Module getChildInjectorModule(final GeneratorEntry entry) { - Module defaultModule = super.getChildInjectorModule(entry); + protected Module getOverridesModule(final GeneratorEntry entry) { + Module defaultModule = super.getOverridesModule(entry); String overridingModuleClass = null; FeatureConfiguration featureConfiguration = entry.getFeatureConfiguration(TEMPLATE_FEATURE); diff --git a/plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppCodeGenerator.java b/plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppCodeGenerator.java index 658a0a8d9d..cc7a90fd15 100644 --- a/plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppCodeGenerator.java +++ b/plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppCodeGenerator.java @@ -43,8 +43,8 @@ public void runGenerator(Statechart statechart, GeneratorEntry entry) { } @Override - protected Module getChildInjectorModule(final GeneratorEntry entry) { - Module module = super.getChildInjectorModule(entry); + protected Module getOverridesModule(final GeneratorEntry entry) { + Module module = super.getOverridesModule(entry); return Modules.override(module).with(new Module() { public void configure(Binder binder) { binder.bind(ICodegenTypeSystemAccess.class).to( diff --git a/plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend b/plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend index 754695e9e0..e8a78168a6 100644 --- a/plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend +++ b/plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend @@ -15,7 +15,6 @@ import java.util.List import org.eclipse.xtend2.lib.StringConcatenation import org.eclipse.xtext.generator.IFileSystemAccess import org.yakindu.base.types.Direction -import org.yakindu.sct.generator.c.Statemachine import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess import org.yakindu.sct.generator.cpp.features.GenmodelEntriesExtension import org.yakindu.sct.model.sexec.Check @@ -31,7 +30,7 @@ import org.yakindu.sct.model.stext.stext.InternalScope import org.yakindu.sct.model.stext.stext.StatechartScope import org.yakindu.sct.model.stext.stext.VariableDefinition -class StatemachineHeader extends Statemachine { +class StatemachineHeader extends org.yakindu.sct.generator.c.StatemachineHeader { @Inject extension Naming @Inject extension Navigation @@ -41,12 +40,12 @@ class StatemachineHeader extends Statemachine { protected GeneratorEntry entry - def generateStatemachineHeader(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) { + override generateStatemachineHeader(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) { this.entry = entry - fsa.generateFile(flow.module().h, flow.statemachineHContent(entry)) + fsa.generateFile(flow.module().h, flow.generateStatemachineHeaderContents(entry)) } - override statemachineHContent(ExecutionFlow it, GeneratorEntry entry) ''' + override generateStatemachineHeaderContents(ExecutionFlow it, GeneratorEntry entry) ''' «entry.licenseText» #ifndef «module().define»_H_ diff --git a/plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/features/CPPDefaultFeatureValueProvider.java b/plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/features/CPPDefaultFeatureValueProvider.java index dc9675a7a5..b27a90ad6f 100644 --- a/plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/features/CPPDefaultFeatureValueProvider.java +++ b/plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/features/CPPDefaultFeatureValueProvider.java @@ -16,7 +16,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.emf.ecore.EObject; import org.eclipse.xtext.xbase.lib.StringExtensions; -import org.yakindu.sct.generator.c.features.CFeatureConstants; +import org.yakindu.sct.generator.c.features.ICFeatureConstants; import org.yakindu.sct.generator.core.features.AbstractDefaultFeatureValueProvider; import org.yakindu.sct.generator.cpp.features.CPPFeatureConstants.Visibility; import org.yakindu.sct.model.sgen.FeatureParameterValue; @@ -46,17 +46,17 @@ protected void setDefaultValue(FeatureParameterValue parameterValue, Statechart statechart = (Statechart) entry.getElementRef(); if (parameterValue.getParameter().getName() - .equals(CFeatureConstants.PARAMETER_MODULE_NAME)) { + .equals(ICFeatureConstants.PARAMETER_NAMING_MODULE_NAME)) { parameterValue.setValue(asIdentifier(statechart.getName(), "_")); } else if (parameterValue.getParameter().getName() - .equals(CFeatureConstants.PARAMETER_STATEMACHINE_PREFIX)) { + .equals(ICFeatureConstants.PARAMETER_NAMING_STATEMACHINE_PREFIX)) { parameterValue.setValue(StringExtensions.toFirstLower(asIdentifier( statechart.getName(), "_"))); } else if (parameterValue.getParameter().getName() - .equals(CFeatureConstants.PARAMETER_MAX_IDENTIFIER_LENGTH)) { + .equals(ICFeatureConstants.PARAMETER_NAMING_MAX_IDENTIFIER_LENGTH)) { parameterValue.setValue("31"); } else if (parameterValue.getParameter().getName() - .equals(CFeatureConstants.PARAMETER_SEPARATOR)) { + .equals(ICFeatureConstants.PARAMETER_NAMING_SEPARATOR)) { parameterValue.setValue("_"); } else if (parameterValue .getParameter() @@ -71,16 +71,16 @@ protected void setDefaultValue(FeatureParameterValue parameterValue, public IStatus validateParameterValue(FeatureParameterValue parameter) { String parameterName = parameter.getParameter().getName(); - if (CFeatureConstants.PARAMETER_MODULE_NAME.equals(parameterName)) { + if (ICFeatureConstants.PARAMETER_NAMING_MODULE_NAME.equals(parameterName)) { if (!parameter.getStringValue().matches(VALID_IDENTIFIER_REGEX)) { return error("Invalid module name"); } - } else if (CFeatureConstants.PARAMETER_STATEMACHINE_PREFIX + } else if (ICFeatureConstants.PARAMETER_NAMING_STATEMACHINE_PREFIX .equals(parameterName)) { if (!parameter.getStringValue().matches(VALID_IDENTIFIER_REGEX)) { return error("Invalid function prefix name"); } - } else if (CFeatureConstants.PARAMETER_SEPARATOR.equals(parameterName)) { + } else if (ICFeatureConstants.PARAMETER_NAMING_SEPARATOR.equals(parameterName)) { if (!parameter.getStringValue().matches(VALID_IDENTIFIER_REGEX)) { return error("Invalid separator"); } diff --git a/plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaCodeGenerator.java b/plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaCodeGenerator.java index 438464b7f7..7362b35387 100644 --- a/plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaCodeGenerator.java +++ b/plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaCodeGenerator.java @@ -41,8 +41,8 @@ public void generate(Statechart statechart, GeneratorEntry entry) { } @Override - protected Module getChildInjectorModule(final GeneratorEntry entry) { - Module module = super.getChildInjectorModule(entry); + protected Module getOverridesModule(final GeneratorEntry entry) { + Module module = super.getOverridesModule(entry); final GenmodelEntries entries = new GenmodelEntries(); return Modules.override(module).with(new Module() { public void configure(Binder binder) { diff --git a/plugins/org.yakindu.sct.model.sexec/META-INF/MANIFEST.MF b/plugins/org.yakindu.sct.model.sexec/META-INF/MANIFEST.MF index e86308eab8..f290c41c63 100644 --- a/plugins/org.yakindu.sct.model.sexec/META-INF/MANIFEST.MF +++ b/plugins/org.yakindu.sct.model.sexec/META-INF/MANIFEST.MF @@ -13,14 +13,14 @@ Export-Package: org.yakindu.sct.model.sexec, org.yakindu.sct.model.sexec.naming, org.yakindu.sct.model.sexec.transformation, org.yakindu.sct.model.sexec.util -Require-Bundle: org.eclipse.core.runtime, +Require-Bundle: com.google.inject, + org.eclipse.core.runtime, org.eclipse.emf.ecore;visibility:=reexport, - org.yakindu.sct.model.sgraph;visibility:=reexport, - org.yakindu.base.types;visibility:=reexport, - org.yakindu.base.expressions;visibility:=reexport, - com.google.inject, org.eclipse.xtext.xbase.lib, + org.eclipse.xtend.lib;bundle-version="2.3.0", org.eclipse.xtext, + org.yakindu.base.types;visibility:=reexport, + org.yakindu.base.expressions;visibility:=reexport, org.yakindu.sct.model.stext, - org.eclipse.xtend.lib;bundle-version="2.3.0" + org.yakindu.sct.model.sgraph;visibility:=reexport Bundle-ActivationPolicy: lazy diff --git a/plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.xtend b/plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.xtend index 8ebe71c3ca..4fff92d00d 100644 --- a/plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.xtend +++ b/plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.xtend @@ -18,6 +18,7 @@ import org.yakindu.base.expressions.expressions.BoolLiteral import org.yakindu.base.expressions.expressions.DoubleLiteral import org.yakindu.base.expressions.expressions.Expression import org.yakindu.base.expressions.expressions.ExpressionsFactory +import org.yakindu.base.expressions.expressions.FloatLiteral import org.yakindu.base.expressions.expressions.IntLiteral import org.yakindu.base.expressions.expressions.MultiplicativeOperator import org.yakindu.base.expressions.expressions.NumericalMultiplyDivideExpression @@ -41,7 +42,6 @@ import org.yakindu.sct.model.stext.stext.TimeUnit import org.yakindu.sct.model.stext.stext.VariableDefinition import static extension org.eclipse.emf.ecore.util.EcoreUtil.* -import org.yakindu.base.expressions.expressions.FloatLiteral class SequenceBuilder { @@ -53,7 +53,8 @@ class SequenceBuilder { @Inject extension ITypeValueProvider - @Inject @Named("ADD_TRACES") + @Inject + @Named("ADD_TRACES") boolean _addTraceSteps static String DEFAULT_SEQUENCE_NAME = "default"