Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2018-07-06 13:19:51 -0400
committerHenrik Rentz-Reichert2018-07-06 13:22:00 -0400
commit0509ac03bea494b08a92251e68e9efc92e415a20 (patch)
treed070ca8800c829827df8aff75c1b773fe1115908 /plugins/org.eclipse.etrice.generator.cpp
parentc2dfdeabf15d7e367bcd92731e6ac8651ffb9cac (diff)
parentbed42b94fbf934db15e792b247ee747f0c37ebf4 (diff)
downloadorg.eclipse.etrice-0509ac03bea494b08a92251e68e9efc92e415a20.tar.gz
org.eclipse.etrice-0509ac03bea494b08a92251e68e9efc92e415a20.tar.xz
org.eclipse.etrice-0509ac03bea494b08a92251e68e9efc92e415a20.zip
Merge remote-tracking branch 'newfsmgen_finalize'
Conflicts: plugins/org.eclipse.etrice.ui.behavior.fsm/META-INF/MANIFEST.MF plugins/org.eclipse.etrice.ui.behavior/META-INF/MANIFEST.MF Change-Id: Icc81a851cdcdb35081b8eaa3d5b025c1f850de54
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.cpp')
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/.classpath4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend11
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend23
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend29
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend58
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Validator.java2
10 files changed, 88 insertions, 57 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/.classpath b/plugins/org.eclipse.etrice.generator.cpp/.classpath
index ef5811bf8..87e8cd659 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/.classpath
+++ b/plugins/org.eclipse.etrice.generator.cpp/.classpath
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="xtend-gen"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/plugins/org.eclipse.etrice.generator.cpp/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.etrice.generator.cpp/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..0c68a61dc
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF
index ff597c263..5af209e91 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF
@@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.etrice.core.genmodel;bundle-version="1.1.3",
org.eclipse.etrice.generator.doc;bundle-version="1.1.3",
org.eclipse.xtend.lib;bundle-version="2.6.0",
org.eclipse.xtext.generator;bundle-version="2.6.0",
- org.eclipse.xtext.util;bundle-version="2.6.0"
+ org.eclipse.xtext.util;bundle-version="2.6.0",
+ org.eclipse.etrice.core.genmodel.fsm
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.etrice.generator.cpp,
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
index 6ff717e2d..2791ee88a 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
@@ -19,6 +19,7 @@ import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType
import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.core.genmodel.etricegen.WiredActorClass
+import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions
import org.eclipse.etrice.core.room.ActorClass
import org.eclipse.etrice.generator.cpp.Main
import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers
@@ -158,16 +159,16 @@ class ActorClassGen extends GenericActorClassGenerator {
virtual void destroy();
«IF ac.hasNonEmptyStateMachine»
- «xpac.genStateMachineConstants»
+ «xpac.graphContainer.genStateMachineConstants»
- «xpac.genStateMachineMethods(false)»
+ «xpac.graphContainer.genStateMachineMethods(false)»
«IF ac.commType == ComponentCommunicationType::DATA_DRIVEN»
void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* generic_data);
«ENDIF»
«IF ac.commType == ComponentCommunicationType::ASYNCHRONOUS || ac.commType == ComponentCommunicationType::DATA_DRIVEN»
virtual void receive(const etRuntime::Message* msg);
«ENDIF»
- «ELSEIF xpac.stateMachine.empty»
+ «ELSEIF FsmGenExtensions.isEmpty(xpac.graphContainer.graph)»
««« no state machine in the super classes
//--------------------- no state machine
virtual void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data);
@@ -347,7 +348,7 @@ class ActorClassGen extends GenericActorClassGenerator {
«operationsImplementation(ac.operations, ac.name)»
«IF ac.hasNonEmptyStateMachine»
- «xpac.genStateMachineMethods(true)»
+ «xpac.graphContainer.genStateMachineMethods(true)»
«IF ac.commType == ComponentCommunicationType::DATA_DRIVEN»
void «ac.name»::receiveEvent(InterfaceItemBase* ifitem, int evt, void* generic_data) {
handleSystemEvent(ifitem, evt, generic_data);
@@ -362,7 +363,7 @@ class ActorClassGen extends GenericActorClassGenerator {
«ENDIF»
}
«ENDIF»
- «ELSEIF xpac.stateMachine.empty»
+ «ELSEIF FsmGenExtensions.isEmpty(xpac.graphContainer.graph)»
««« no state machine in the super classes
//--------------------- no state machine
void «ac.name»::receiveEvent(InterfaceItemBase* ifitem, int evt, void* data) {
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
index c788cd293..0020d5d42 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
@@ -24,16 +24,16 @@ import java.util.List
import org.eclipse.emf.ecore.EObject
import org.eclipse.etrice.core.etphys.eTPhys.NodeRef
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
-import org.eclipse.etrice.core.genmodel.fsm.fsmgen.IDiagnostician
+import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician
import org.eclipse.etrice.core.room.ActorClass
import org.eclipse.etrice.core.room.DataType
import org.eclipse.etrice.core.room.EnumLiteral
import org.eclipse.etrice.core.room.EnumerationType
import org.eclipse.etrice.core.room.ExternalType
import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.MessageData
import org.eclipse.etrice.core.room.PrimitiveType
import org.eclipse.etrice.core.room.RoomClass
-import org.eclipse.etrice.core.room.VarDecl
import org.eclipse.etrice.core.room.util.RoomHelpers
import org.eclipse.etrice.generator.generic.ILanguageExtension
import org.eclipse.etrice.generator.generic.RoomExtensions
@@ -50,7 +50,7 @@ class CppExtensions implements ILanguageExtension {
@Inject extension RoomExtensions
override String getTypedDataDefinition(EObject msg) {
- generateArglistAndTypedData((msg as Message).data).get(1)
+ generateArglistAndTypedData((msg as Message).data).get(TypedDataKind.DECLARATION_AND_INITIALIZATION.ordinal)
}
def String getCppHeaderFileName(RoomClass rc) { rc.name + ".h" }
@@ -202,10 +202,11 @@ class CppExtensions implements ILanguageExtension {
}
override generateArglistAndTypedData(EObject d) {
- if (d==null || !(d instanceof VarDecl))
+ // TODO 529445: d will be a RefableType, not MessageData
+ if (d===null || !(d instanceof MessageData))
return newArrayList("", "", "")
- val data = d as VarDecl
+ val data = d as MessageData
val castExpr = switch it : data.refType.type {
PrimitiveType case !Strings.isEmpty(castName): castName
@@ -219,15 +220,15 @@ class CppExtensions implements ILanguageExtension {
}
var deRef = if(!data.refType.ref) '*' else ''
- val typedData = '''«typeExpr» «data.name» = «deRef»(static_cast<«castExpr»>(generic_data__et));''' + NEWLINE
- val dataArg = ''', «data.name»'''
- val typedArgList = ''', «typeExpr» «data.name»'''
+ val dataArg = ''', «GENERIC_DATA_NAME»'''
+ val typedData = '''«typeExpr» «GENERIC_DATA_NAME» = «deRef»(static_cast<«castExpr»>(generic_data__et));''' + NEWLINE
+ val typedArgList = ''', «typeExpr» «GENERIC_DATA_NAME»'''
return #[dataArg, typedData, typedArgList]
}
override getTargetType(EnumerationType type) {
- if (type.getPrimitiveType()!=null)
+ if (type.getPrimitiveType()!==null)
type.getPrimitiveType().getTargetName()
else
type.getName()
@@ -237,14 +238,14 @@ class CppExtensions implements ILanguageExtension {
val type = literal.eContainer() as EnumerationType
val cast = type.targetType
- if (type.primitiveType!=null)
+ if (type.primitiveType!==null)
Long.toString(literal.getLiteralValue())
else
"(("+cast+")"+Long.toString(literal.getLiteralValue())+")"
}
override getCastType(EnumerationType type) {
- if (type.getPrimitiveType()!=null)
+ if (type.getPrimitiveType()!==null)
type.getPrimitiveType().getCastName()
else
type.getName()
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.java b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.java
index 5b04cf94f..40c5d2c31 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppTranslationProvider.java
@@ -12,7 +12,7 @@
package org.eclipse.etrice.generator.cpp.gen;
-import java.util.ArrayList;
+import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
@@ -39,7 +39,7 @@ public class CppTranslationProvider extends DefaultTranslationProvider {
}
@Override
- public String getInterfaceItemMessageText(AbstractInterfaceItem item, EObject abstractMsg, ArrayList<String> args, String index, String orig) {
+ public String getInterfaceItemMessageText(AbstractInterfaceItem item, EObject abstractMsg, List<String> args, String index, String orig) {
if (index==null)
return orig;
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
index 105f639fc..c629ccef3 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
@@ -16,13 +16,13 @@ import com.google.inject.Inject
import com.google.inject.Singleton
import java.util.List
import org.eclipse.etrice.core.genmodel.etricegen.Root
-import org.eclipse.etrice.core.genmodel.fsm.base.ILogger
+import org.eclipse.etrice.core.genmodel.fsm.ILogger
import org.eclipse.etrice.core.room.Attribute
import org.eclipse.etrice.core.room.ComplexType
import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.core.room.util.RoomHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
-import org.eclipse.etrice.core.room.util.RoomHelpers
@Singleton
class DataClassGen {
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
index 38f0da881..561a2f69d 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
@@ -16,7 +16,7 @@ import com.google.inject.Inject
import com.google.inject.Singleton
import java.util.List
import org.eclipse.etrice.core.genmodel.etricegen.Root
-import org.eclipse.etrice.core.genmodel.fsm.base.ILogger
+import org.eclipse.etrice.core.genmodel.fsm.ILogger
import org.eclipse.etrice.core.room.CommunicationType
import org.eclipse.etrice.core.room.InterfaceItem
import org.eclipse.etrice.core.room.Message
@@ -32,6 +32,7 @@ import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.generator.generic.ILanguageExtension
@Singleton
class ProtocolClassGen extends GenericProtocolClassGenerator {
@@ -131,7 +132,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// «IF conj»conjugated «ENDIF»port class
//------------------------------------------------------------------------------------------------------------
class «portClassName» : public etRuntime::PortBase {
- «IF pclass!=null»
+ «IF pclass!==null»
«pclass.userCode.userCode»
«ENDIF»
public:
@@ -144,7 +145,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
virtual void receive(const etRuntime::Message* m);
- «IF pclass!=null»
+ «IF pclass!==null»
«pclass.attributes.attributes»
«pclass.operations.operationsDeclaration(portClassName)»
«ENDIF»
@@ -251,7 +252,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«portClassName»::«portClassName»(IInterfaceItemOwner* actor, const String& name, int localId, int idx)
«pclass.generateConstructorInitalizerList('idx')»
{
- «IF pclass != null»«initHelper.genExtraInitializers(pclass.attributes)»«ENDIF»
+ «IF pclass !== null»«initHelper.genExtraInitializers(pclass.attributes)»«ENDIF»
}
«IF Main::settings.generateMSCInstrumentation»
@@ -291,7 +292,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«ENDIF»
}
- «IF pclass!=null»
+ «IF pclass!==null»
«pclass.operations.operationsImplementation(portClassName)»
«ENDIF»
@@ -335,34 +336,34 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
val List<CharSequence> initList = newArrayList
initList += '''PortBase(actor, name, localId, «index»)'''
- if(pc != null)
+ if(pc !== null)
initList += pc.attributes.map['''«name»(«initializerListValue»)''']
initList.generateCtorInitializerList
}
def protected messageCall(Message m, boolean impl) {
- '''«m.name»«IF impl»_impl«ENDIF»(«IF m.data!=null» «m.data.name»«ENDIF»)'''
+ '''«m.name»«IF impl»_impl«ENDIF»(«IF m.data!==null» «ILanguageExtension.GENERIC_DATA_NAME»«ENDIF»)'''
}
def protected messageSignature(Message m, boolean impl) {
- '''«IF m.priv||impl»private:«ELSE»public:«ENDIF» void «m.name»«IF impl»_impl«ENDIF»(«IF m.data!=null»«m.data.refType.signatureString» «m.data.name»«ENDIF»)'''
+ '''«IF m.priv||impl»private:«ELSE»public:«ENDIF» void «m.name»«IF impl»_impl«ENDIF»(«IF m.data!==null»«m.data.refType.signatureString» «ILanguageExtension.GENERIC_DATA_NAME»«ENDIF»)'''
}
def protected messageSignatureDefinition(Message m, String classPrefix, boolean impl) {
- '''void «classPrefix»::«m.name»«IF impl»_impl«ENDIF»(«IF m.data!=null»«m.data.refType.signatureString» «m.data.name»«ENDIF»)'''
+ '''void «classPrefix»::«m.name»«IF impl»_impl«ENDIF»(«IF m.data!==null»«m.data.refType.signatureString» «ILanguageExtension.GENERIC_DATA_NAME»«ENDIF»)'''
}
def protected sendMessage(Message m, String portClassName, String classPrefix, boolean conj) {
var dir = if (conj) "IN" else "OUT"
var hdlr = m.getSendHandler(conj)
- val dataArg = if(m.data != null) ''', «m.data.name»'''
- val messageType = if(m.data != null && !m.data.refType.ref) '''DataMessage<«m.data.refType.type.typeName»>''' else '''Message'''
+ val dataArg = if(m.data !== null) ''', «ILanguageExtension.GENERIC_DATA_NAME»'''
+ val messageType = if(m.data !== null && !m.data.refType.ref) '''DataMessage<«m.data.refType.type.typeName»>''' else '''Message'''
val message = '''new (buffer) «messageType»(getPeerAddress(), «portClassName»::«dir»_«m.name»«dataArg?:''»)'''
'''
«messageSignatureDefinition(m, classPrefix, false)» {
- «IF hdlr!=null»
+ «IF hdlr!==null»
«FOR command : hdlr.detailCode.lines» «command»
«ENDFOR»
«ELSE»
@@ -389,7 +390,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
def protected generateDataDrivenHeaderFile(Root root, ProtocolClass pc) {
- val sentMsgs = pc.allIncomingMessages.filter(m|m.data!=null)
+ val sentMsgs = pc.allIncomingMessages.filter(m|m.data!==null)
'''
/**
* @author generated by eTrice
@@ -464,7 +465,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
}
def protected generateDataDrivenSourceFile(Root root, ProtocolClass pc) {
- val sentMsgs = pc.allIncomingMessages.filter(m|m.data!=null)
+ val sentMsgs = pc.allIncomingMessages.filter(m|m.data!==null)
'''
/**
* @author generated by eTrice
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
index 514cd75db..5af70d5a6 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
@@ -13,29 +13,26 @@
package org.eclipse.etrice.generator.cpp.gen
-import com.google.inject.Inject
import com.google.inject.Singleton
-import org.eclipse.etrice.core.genmodel.fsm.fsmgen.ExpandedModelComponent
+import java.util.Comparator
+import org.eclipse.etrice.core.fsm.fSM.State
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node
import org.eclipse.etrice.generator.cpp.Main
import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator
-import org.eclipse.etrice.generator.generic.RoomExtensions
+
+import static extension org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions.*
@Singleton
class StateMachineGen extends GenericStateMachineGenerator {
- @Inject extension RoomExtensions
-
- override genExtra(ExpandedModelComponent xpac, boolean generateImplementation) {
- val states = newArrayList
- var ac = xpac.modelComponent
- val clsName = xpac.modelComponent.componentName
+ val nodeComparator = new NodeComparator
+
+ override genExtra(GraphContainer gc, boolean generateImplementation) {
+ var ac = gc.component
+ val clsName = ac.componentName
+ val orderedStateNodes = gc.graph.allStateNodes.toList.sortWith(nodeComparator)
-// it is crucial that we obey the order that is used for state IDs
-// that means we have to collect base classes first and each base class list with leaf states last
- while (ac!=null) {
- states.addAll(0, ac.allBaseStates.leafStatesLast)
- ac = ac.base
- }
if(generateImplementation)
'''
«IF Main::settings.generateMSCInstrumentation || Main::settings.generateWithVerboseOutput»
@@ -43,12 +40,12 @@ class StateMachineGen extends GenericStateMachineGenerator {
const String «clsName»::s_stateStrings[] = {
"<no state>",
"<top>",
- «FOR state : states SEPARATOR ","»
- "«state.genStatePathName»"
+ «FOR state : orderedStateNodes SEPARATOR ","»
+ "«(state.stateGraphNode as State).genStatePathName»"
«ENDFOR»
};
«ENDIF»
- const int «clsName»::s_numberOfStates = «2+states.size»;
+ const int «clsName»::s_numberOfStates = «2+orderedStateNodes.size»;
void «clsName»::setState(int new_state) {
«IF Main::settings.generateMSCInstrumentation»
@@ -69,7 +66,7 @@ class StateMachineGen extends GenericStateMachineGenerator {
«ENDIF»
static const int s_numberOfStates;
- int history[«2+states.size»];
+ int history[«2+orderedStateNodes.size»];
void setState(int new_state);
'''
@@ -83,4 +80,27 @@ class StateMachineGen extends GenericStateMachineGenerator {
"etBool"
}
+ private static class NodeComparator implements Comparator<Node> {
+
+ // it is crucial that we obey the order that is used for state IDs
+ // that means we have to collect base classes first and each base class list with leaf states last
+ override int compare(Node o1, Node o2) {
+ if (o1.inheritanceLevel==o2.inheritanceLevel) {
+ if (o1.isLeaf && o2.isLeaf) {
+ return 0
+ }
+ if (o1.isLeaf) {
+ return 1
+ }
+ if (o2.isLeaf) {
+ return -1
+ }
+ return 0
+ }
+ else {
+ return Integer.compare(o1.inheritanceLevel, o1.inheritanceLevel)
+ }
+ }
+
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Validator.java b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Validator.java
index e813049dd..3d065a596 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Validator.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Validator.java
@@ -13,7 +13,7 @@
package org.eclipse.etrice.generator.cpp.gen;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.genmodel.fsm.base.ILogger;
+import org.eclipse.etrice.core.genmodel.fsm.ILogger;
import com.google.inject.Inject;

Back to the top