Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2015-04-10 06:54:04 +0000
committerHenrik Rentz-Reichert2015-04-17 14:09:56 +0000
commit7cd802923e7efb64bad5fd23250b711ddc4c0c94 (patch)
tree5d9a3ffc32416ab5d440ba7dc56d2c27b4c7326c /plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c
parent509c50bfd19ca15421352ca1fc51182031aa3be2 (diff)
downloadorg.eclipse.etrice-7cd802923e7efb64bad5fd23250b711ddc4c0c94.tar.gz
org.eclipse.etrice-7cd802923e7efb64bad5fd23250b711ddc4c0c94.tar.xz
org.eclipse.etrice-7cd802923e7efb64bad5fd23250b711ddc4c0c94.zip
refactorings for abstract FSM interface
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c')
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend13
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend16
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend15
3 files changed, 31 insertions, 13 deletions
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
index 752412987..a806ab4db 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
@@ -359,8 +359,11 @@ class ActorClassGen extends GenericActorClassGenerator {
void «ac.name»_receiveMessage(void* self, const void* ifitem, const etMessage* msg){
ET_MSC_LOGGER_SYNC_ENTRY("«ac.name»", "_receiveMessage")
«IF !xpac.stateMachine.empty»
-
- «langExt.operationScope(ac.name, false)»receiveEvent(self«IF handleEvents», (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))«ENDIF»);
+ «IF handleEvents»
+ «langExt.operationScope(ac.name, false)»receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage))));
+ «ELSE»
+ «langExt.operationScope(ac.name, false)»receiveEventInternal(self);
+ «ENDIF»
«ENDIF»
ET_MSC_LOGGER_SYNC_EXIT
@@ -371,7 +374,11 @@ class ActorClassGen extends GenericActorClassGenerator {
ET_MSC_LOGGER_SYNC_ENTRY("«ac.name»", "_execute")
«IF !xpac.stateMachine.empty»
- «langExt.operationScope(ac.name, false)»receiveEvent(self«IF handleEvents», NULL, 0, NULL«ENDIF»);
+ «IF handleEvents»
+ «langExt.operationScope(ac.name, false)»receiveEvent(self, NULL, 0, NULL);
+ «ELSE»
+ «langExt.operationScope(ac.name, false)»receiveEventInternal(self);
+ «ENDIF»
«ENDIF»
ET_MSC_LOGGER_SYNC_EXIT
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
index e7ee41667..fcb2d9da7 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
@@ -40,6 +40,7 @@ import org.eclipse.etrice.core.room.EnumerationType
import org.eclipse.etrice.core.room.util.RoomHelpers
import org.eclipse.etrice.core.room.EnumLiteral
+import org.eclipse.emf.ecore.EObject
@Singleton
class CExtensions implements ILanguageExtension {
@@ -47,8 +48,13 @@ class CExtensions implements ILanguageExtension {
@Inject protected IDiagnostician diagnostician
@Inject protected extension RoomHelpers
- override String getTypedDataDefinition(Message m) {
- generateArglistAndTypedData(m.data).get(1)
+ override String getTypedDataDefinition(EObject msg) {
+ if (msg instanceof Message) {
+ generateArglistAndTypedData((msg as Message).data).get(1)
+ }
+ else {
+ ""
+ }
}
// in C no access levels can be defined
@@ -301,7 +307,11 @@ class CExtensions implements ILanguageExtension {
att.type.type.initializationWithDefaultValues(att.size)
}
- override generateArglistAndTypedData(VarDecl data) {
+ override generateArglistAndTypedData(EObject d) {
+ if (d==null || !(d instanceof VarDecl))
+ return newArrayList("", "", "")
+
+ val data = d as VarDecl
if (data==null)
return newArrayList("", "", "")
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
index 8db32c436..da5b3a80d 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
@@ -18,6 +18,7 @@ import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
import org.eclipse.etrice.generator.c.Main
import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator
import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent
@Singleton
class StateMachineGen extends GenericStateMachineGenerator {
@@ -56,9 +57,9 @@ class StateMachineGen extends GenericStateMachineGenerator {
'''
}
- override protected genExtra(ExpandedActorClass xpac) {
- val ac = xpac.actorClass
- val states = xpac.stateMachine.baseStateList.getLeafStatesLast
+ override public genExtra(ExpandedModelComponent xpmc) {
+ val mc = xpmc.modelComponent
+ val states = xpmc.stateMachine.baseStateList.getLeafStatesLast
'''
«IF Main::settings.generateMSCInstrumentation»
/* state names */
@@ -66,20 +67,20 @@ class StateMachineGen extends GenericStateMachineGenerator {
«ENDFOR»};
«ENDIF»
- «langExt.accessLevelPrivate»void setState(«ac.name»* self, «stateType» new_state) {
+ «langExt.accessLevelPrivate»void setState(«mc.componentName»* self, «stateType» new_state) {
self->state = new_state;
«IF Main::settings.generateMSCInstrumentation»
ET_MSC_LOGGER_CHANGE_STATE(self->constData->instName, stateStrings[new_state])
«ENDIF»
}
- «langExt.accessLevelPrivate»«stateType» getState(«ac.name»* self) {
+ «langExt.accessLevelPrivate»«stateType» getState(«mc.componentName»* self) {
return self->state;
}
'''
}
- override protected stateType() {
+ override public stateType() {
"etInt16"
}
@@ -88,7 +89,7 @@ class StateMachineGen extends GenericStateMachineGenerator {
((void)trigger__et); /* avoids unused warning */
'''
}
- override protected unreachableReturn() {
+ override public unreachableReturn() {
"/* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */"
}

Back to the top