Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2016-10-05 08:02:07 +0000
committerHenrik Rentz-Reichert2016-10-05 08:18:12 +0000
commit096f19bb7981a01aaecf96c20d0894d229531daf (patch)
treed7f2cf9f356fbcf40f1247fced9c305cea799226
parent821851389cdbba6f0127cabc36b4449926c937e3 (diff)
downloadorg.eclipse.etrice-096f19bb7981a01aaecf96c20d0894d229531daf.tar.gz
org.eclipse.etrice-096f19bb7981a01aaecf96c20d0894d229531daf.tar.xz
org.eclipse.etrice-096f19bb7981a01aaecf96c20d0894d229531daf.zip
Bug 501354 - ids for transition chains not generated completely (C++
Generator) Also with inheritance we don't use base class chain IDs since they might differ for corner cases. So we always generate all IDs and use qualification to make explicit which constant is used. Also the chain IDs are handled properly now in the ExpandedModelClass. Before the genmodel was invalid since chain IDs haven't been stored. Change-Id: I594a90876d56d760e61b899c265aaf1b98e17017
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/ExpandedModelComponentImpl.java28
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch2
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend23
-rw-r--r--plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/ILanguageExtensionBase.java7
-rw-r--r--plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java408
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend1
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java4
11 files changed, 283 insertions, 204 deletions
diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/ExpandedModelComponentImpl.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/ExpandedModelComponentImpl.java
index 1bf543e17..5d60c3b09 100644
--- a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/ExpandedModelComponentImpl.java
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/ExpandedModelComponentImpl.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
+import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
@@ -209,7 +210,6 @@ public class ExpandedModelComponentImpl extends MinimalEObjectImpl.Container imp
private HashMap<StateGraphNode, NodeData> node2data = null;
private HashMap<State, LinkedList<ActiveTrigger>> state2triggers = null;
private HashMap<String, MessageFromIf> triggerstring2mif = null;
- private LinkedList<TransitionChain> trchains = null;
private TransitionToChainBundleMap trans2chainBundle = null;
private HashMap<EObject, EObject> copy2orig = null;
private HashMap<EObject, EObject> orig2copy = null;
@@ -838,7 +838,6 @@ public class ExpandedModelComponentImpl extends MinimalEObjectImpl.Container imp
node2data = new HashMap<StateGraphNode, NodeData>();
state2triggers = new HashMap<State, LinkedList<ActiveTrigger>>();
triggerstring2mif = new HashMap<String, MessageFromIf>();
- trchains = new LinkedList<TransitionChain>();
trans2chainBundle = new TransitionToChainBundleMap();
copy2orig = new HashMap<EObject, EObject>();
orig2copy = new HashMap<EObject, EObject>();
@@ -898,7 +897,6 @@ public class ExpandedModelComponentImpl extends MinimalEObjectImpl.Container imp
node2data = null;
state2triggers = null;
triggerstring2mif = null;
- trchains = null;
trans2chainBundle = null;
copy2orig = null;
}
@@ -1156,7 +1154,7 @@ public class ExpandedModelComponentImpl extends MinimalEObjectImpl.Container imp
collectChainTransitions(tc, t);
- trchains.add(tc);
+ getTransitionChains().add(tc);
return tc;
}
@@ -1164,10 +1162,13 @@ public class ExpandedModelComponentImpl extends MinimalEObjectImpl.Container imp
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated NOT
+ * @generated
*/
public EList<TransitionChain> getTransitionChains() {
- return new BasicEList<TransitionChain>(trchains);
+ if (transitionChains == null) {
+ transitionChains = new EObjectContainmentEList<TransitionChain>(TransitionChain.class, this, FsmGenPackage.EXPANDED_MODEL_COMPONENT__TRANSITION_CHAINS);
+ }
+ return transitionChains;
}
/**
@@ -1178,7 +1179,7 @@ public class ExpandedModelComponentImpl extends MinimalEObjectImpl.Container imp
public EList<TransitionChain> getOwnTransitionChains() {
BasicEList<TransitionChain> result = new BasicEList<TransitionChain>();
- for (TransitionChain tc : trchains) {
+ for (TransitionChain tc : getTransitionChains()) {
if (!targetsOfRefinedTransitions.contains(tc.getTransition()) && isOwnObject(tc.getTransition()))
result.add(tc);
}
@@ -1213,12 +1214,19 @@ public class ExpandedModelComponentImpl extends MinimalEObjectImpl.Container imp
return getModelComponent().getAllAbstractInterfaceItems();
}
+ /*
+ * In case of an abstract class we can have a transition to an EntryPoint
+ * which is not connected inside its state.
+ * For the TransitionChain handling during generation we need to replace
+ * this terminal with a state terminal as if it where it a transition
+ * to history.
+ */
private StateGraphNode getAdjustedTargetNode(Transition t) {
StateGraphNode node = fsmHelpers.getNode(t.getTo());
if (node instanceof EntryPoint) {
- NodeData data = node2data.get(node);
- if (data==null || data.getOutTrans().isEmpty()) {
- if (getModelComponent(node).isAbstract()) {
+ if (getModelComponent(node).isAbstract()) {
+ NodeData data = node2data.get(node);
+ if (data==null || data.getOutTrans().isEmpty()) {
if (node.eContainer().eContainer() instanceof State) {
// in this case
State newTarget = (State) node.eContainer().eContainer();
diff --git a/plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch b/plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch
index a4adb96c5..63704533c 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch
+++ b/plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch
@@ -17,7 +17,7 @@
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
</listAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx512m -XX:MaxPermSize=256m -ea"/>
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 55779bec0..e27d01a2f 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
@@ -73,7 +73,9 @@ class CExtensions implements ILanguageExtension {
override String selfPointer(boolean hasArgs) { if (hasArgs) "self, " else "self" }
- override String operationScope(String classname, boolean isDeclaration){classname+"_"}
+ override String scopeSeparator() {""}
+
+ override String operationScope(String classname, boolean isDeclaration) {classname+"_"}
override String memberInDeclaration(String namespace, String member) {
return namespace+"_"+member
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
index 904e1e204..a6d329401 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
@@ -100,6 +100,10 @@ public class CExtensions implements ILanguageExtension {
return _xifexpression;
}
+ public String scopeSeparator() {
+ return "";
+ }
+
public String operationScope(final String classname, final boolean isDeclaration) {
return (classname + "_");
}
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 bec609553..c788cd293 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
@@ -76,6 +76,8 @@ class CppExtensions implements ILanguageExtension {
override String memberAccess() {"this->"}
override String selfPointer(String classname, boolean hasArgs) {""}
override String selfPointer(boolean hasArgs) { "" }
+
+ override String scopeSeparator() {"::"}
override String operationScope(String classname, boolean isDeclaration) {
if (isDeclaration)
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
index d5cfa4d04..cb62b9fda 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
@@ -123,6 +123,10 @@ public class CppExtensions implements ILanguageExtension {
return "";
}
+ public String scopeSeparator() {
+ return "::";
+ }
+
public String operationScope(final String classname, final boolean isDeclaration) {
String _xifexpression = null;
if (isDeclaration) {
diff --git a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend
index 5c1e7f1e7..f86f9679a 100644
--- a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend
@@ -129,19 +129,21 @@ abstract class AbstractStateMachineGenerator {
/**
* generates transition chain ID constants.
- * Inheritance (if available) is used for base class IDs.
+ * Inheritance can't be used used for base class IDs because of corner cases
+ * where base class and derived class chain IDs deviate (see bug 501354).
*
* @param xpmc the {@link ExpandedModelComponent}
*
* @return the generated code
*/
def public genTransitionChainConstants(ExpandedModelComponent xpmc) {
- xpmc.genTransitionChainConstants(langExt.usesInheritance)
+ xpmc.genTransitionChainConstants(false/*langExt.usesInheritance*/)
}
/**
* generates transition chain ID constants.
- * Inheritance (if available) is used for base class IDs.
+ * Inheritance can't be used used for base class IDs because of corner cases
+ * where base class and derived class chain IDs deviate.
*
* @param xpmc the {@link ExpandedModelComponent}
* @param omitBase use <code>true</code> if no base class transition chain constants are needed
@@ -160,7 +162,7 @@ abstract class AbstractStateMachineGenerator {
list.add(pair(chain.genChainId, offset.toString))
}
- return langExt.genEnumeration("chain_ids", list)
+ return langExt.genEnumeration("ChainIDs", list)
}
/**
@@ -231,6 +233,7 @@ abstract class AbstractStateMachineGenerator {
val eventDriven = mc.commType==ComponentCommunicationType::EVENT_DRIVEN
val ifItemPtr = interfaceItemType()+langExt.pointerLiteral()
val handleEvents = async || eventDriven
+ val chainIDScope = if (langExt.usesInheritance) mc.className+langExt.scopeSeparator else ""
val opScope = langExt.operationScope(mc.className, !generateImplementation)
val opScopePriv = if (langExt.usesInheritance)
opScope
@@ -299,7 +302,7 @@ abstract class AbstractStateMachineGenerator {
switch (chain__et) {
«var allchains = xpmc.getTransitionChains()»
«FOR tc : allchains»
- case «tc.genChainId»:
+ case «chainIDScope»«tc.genChainId»:
{
«transitionChainGenerator.generateExecuteChain(xpmc, tc)»
}
@@ -349,7 +352,7 @@ abstract class AbstractStateMachineGenerator {
/* with init transition */
if («getHistory(state.getGenStateId())»==NO_STATE) {
«var sub_initt = state.subgraph.getInitTransition()»
- state__et = executeTransitionChain(«langExt.selfPointer(true)»«xpmc.getChain(sub_initt).genChainId»«IF handleEvents», «langExt.nullPointer», «langExt.nullPointer»«ENDIF»);
+ state__et = executeTransitionChain(«langExt.selfPointer(true)»«chainIDScope»«xpmc.getChain(sub_initt).genChainId»«IF handleEvents», «langExt.nullPointer», «langExt.nullPointer»«ENDIF»);
}
else {
state__et = «getHistory(state.getGenStateId())»;
@@ -381,7 +384,7 @@ abstract class AbstractStateMachineGenerator {
«IF generateImplementation»
«publicIf»void «opScope»executeInitTransition(«selfOnly») {
«var initt = xpmc.stateMachine.getInitTransition()»
- int chain__et = «xpmc.getChain(initt).genChainId»;
+ int chain__et = «chainIDScope»«xpmc.getChain(initt).genChainId»;
«stateType» next__et = «opScopePriv»executeTransitionChain(«langExt.selfPointer(true)»chain__et«IF handleEvents», «langExt.nullPointer», «langExt.nullPointer»«ENDIF»);
next__et = «opScopePriv»enterHistory(«langExt.selfPointer(true)»next__et«IF usesHdlr», «langExt.booleanConstant(false)»«ENDIF»);
setState(«langExt.selfPointer(true)»next__et);
@@ -513,6 +516,7 @@ abstract class AbstractStateMachineGenerator {
* @return the generated code
*/
def public genDataDrivenTriggers(ExpandedModelComponent xpmc, State state, boolean usesHdlr) {
+ val chainIDScope = if (langExt.usesInheritance) xpmc.className+langExt.scopeSeparator else ""
'''
«genDoCodes(state)»
«var transitions = xpmc.getOutgoingTransitionsHierarchical(state).filter(t|t instanceof GuardedTransition)»
@@ -520,7 +524,7 @@ abstract class AbstractStateMachineGenerator {
if («guard((tr as GuardedTransition), "", xpmc)»)
{
«var chain = xpmc.getChain(tr)»
- chain__et = «chain.genChainId»;
+ chain__et = «chainIDScope»«chain.genChainId»;
catching_state__et = «chain.stateContext.genStateId»;
«IF chain.isHandler() && usesHdlr»
is_handler__et = TRUE;
@@ -544,6 +548,7 @@ abstract class AbstractStateMachineGenerator {
* @return the generated code
*/
def public genEventDrivenTriggers(ExpandedModelComponent xpmc, State state, List<ActiveTrigger> atlist, boolean usesHdlr) {
+ val chainIDScope = if (langExt.usesInheritance) xpmc.className+langExt.scopeSeparator else ""
'''
«FOR at : atlist»
case «xpmc.getTriggerCodeName(at)»:
@@ -553,7 +558,7 @@ abstract class AbstractStateMachineGenerator {
«var chain = xpmc.getChain(tt)»
«guard(chain.getTransition as TriggeredTransition, at.trigger, xpmc)»
{
- chain__et = «chain.genChainId»;
+ chain__et = «chainIDScope»«chain.genChainId»;
catching_state__et = «chain.stateContext.genStateId»;
«IF chain.isHandler() && usesHdlr»
is_handler__et = «langExt.booleanConstant(true)»;
diff --git a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/ILanguageExtensionBase.java b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/ILanguageExtensionBase.java
index a038044c3..2c2c3be69 100644
--- a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/ILanguageExtensionBase.java
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/ILanguageExtensionBase.java
@@ -80,6 +80,11 @@ public interface ILanguageExtensionBase {
String selfPointer(boolean hasArgs);
/**
+ * @return the language specific scope separator, e.g. "::" for C++, "." for Java and "" for C
+ */
+ String scopeSeparator();
+
+ /**
* language specific scoping string for operations
* e.g. nothing in Java (only inside class declaration), nothing and classname:: for C++ and classname_ for C
* @param classname the class name
@@ -87,7 +92,7 @@ public interface ILanguageExtensionBase {
* @return "classname_" for C / for Java and C++ nothing
*/
String operationScope(String classname, boolean isDeclaration);
-
+
/**
* member declaration
*
diff --git a/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java b/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java
index 6c1f30f01..9219333e4 100644
--- a/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java
+++ b/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java
@@ -199,20 +199,21 @@ public abstract class AbstractStateMachineGenerator {
/**
* generates transition chain ID constants.
- * Inheritance (if available) is used for base class IDs.
+ * Inheritance can't be used used for base class IDs because of corner cases
+ * where base class and derived class chain IDs deviate (see bug 501354).
*
* @param xpmc the {@link ExpandedModelComponent}
*
* @return the generated code
*/
public String genTransitionChainConstants(final ExpandedModelComponent xpmc) {
- boolean _usesInheritance = this.langExt.usesInheritance();
- return this.genTransitionChainConstants(xpmc, _usesInheritance);
+ return this.genTransitionChainConstants(xpmc, false);
}
/**
* generates transition chain ID constants.
- * Inheritance (if available) is used for base class IDs.
+ * Inheritance can't be used used for base class IDs because of corner cases
+ * where base class and derived class chain IDs deviate.
*
* @param xpmc the {@link ExpandedModelComponent}
* @param omitBase use <code>true</code> if no base class transition chain constants are needed
@@ -247,7 +248,7 @@ public abstract class AbstractStateMachineGenerator {
list.add(_pair);
}
}
- return this.langExt.genEnumeration("chain_ids", list);
+ return this.langExt.genEnumeration("ChainIDs", list);
}
/**
@@ -370,52 +371,62 @@ public abstract class AbstractStateMachineGenerator {
_or = eventDriven;
}
final boolean handleEvents = _or;
- String _className = this.getClassName(mc);
- final String opScope = this.langExt.operationScope(_className, (!generateImplementation));
String _xifexpression = null;
boolean _usesInheritance = this.langExt.usesInheritance();
if (_usesInheritance) {
- _xifexpression = opScope;
+ String _className = this.getClassName(mc);
+ String _scopeSeparator = this.langExt.scopeSeparator();
+ _xifexpression = (_className + _scopeSeparator);
} else {
_xifexpression = "";
}
- final String opScopePriv = _xifexpression;
+ final String chainIDScope = _xifexpression;
+ String _className_1 = this.getClassName(mc);
+ final String opScope = this.langExt.operationScope(_className_1, (!generateImplementation));
String _xifexpression_1 = null;
boolean _usesInheritance_1 = this.langExt.usesInheritance();
if (_usesInheritance_1) {
- _xifexpression_1 = this.langExt.accessLevelPublic();
+ _xifexpression_1 = opScope;
} else {
- _xifexpression_1 = this.langExt.accessLevelPrivate();
+ _xifexpression_1 = "";
}
- final String publicIf = _xifexpression_1;
- final String privAccess = this.langExt.accessLevelPrivate();
- String _className_1 = this.getClassName(mc);
- final String selfPtr = this.langExt.selfPointer(_className_1, true);
- String _className_2 = this.getClassName(mc);
- final String selfOnly = this.langExt.selfPointer(_className_2, false);
+ final String opScopePriv = _xifexpression_1;
String _xifexpression_2 = null;
boolean _usesInheritance_2 = this.langExt.usesInheritance();
if (_usesInheritance_2) {
- String _xifexpression_3 = null;
+ _xifexpression_2 = this.langExt.accessLevelPublic();
+ } else {
+ _xifexpression_2 = this.langExt.accessLevelPrivate();
+ }
+ final String publicIf = _xifexpression_2;
+ final String privAccess = this.langExt.accessLevelPrivate();
+ String _className_2 = this.getClassName(mc);
+ final String selfPtr = this.langExt.selfPointer(_className_2, true);
+ String _className_3 = this.getClassName(mc);
+ final String selfOnly = this.langExt.selfPointer(_className_3, false);
+ String _xifexpression_3 = null;
+ boolean _usesInheritance_3 = this.langExt.usesInheritance();
+ if (_usesInheritance_3) {
+ String _xifexpression_4 = null;
boolean _usesPointers = this.langExt.usesPointers();
if (_usesPointers) {
- _xifexpression_3 = "->getLocalId()";
+ _xifexpression_4 = "->getLocalId()";
} else {
- _xifexpression_3 = ".getLocalId()";
+ _xifexpression_4 = ".getLocalId()";
}
- _xifexpression_2 = _xifexpression_3;
+ _xifexpression_3 = _xifexpression_4;
} else {
- _xifexpression_2 = "->localId";
+ _xifexpression_3 = "->localId";
}
- final String getLocalId = _xifexpression_2;
- String _xifexpression_4 = null;
+ final String getLocalId = _xifexpression_3;
+ String _xifexpression_5 = null;
boolean _usesPointers_1 = this.langExt.usesPointers();
if (_usesPointers_1) {
- _xifexpression_4 = ("const " + ifItemPtr);
+ _xifexpression_5 = ("const " + ifItemPtr);
} else {
- _xifexpression_4 = ifItemPtr;
+ _xifexpression_5 = ifItemPtr;
}
- final String constIfItemPtr = _xifexpression_4;
+ final String constIfItemPtr = _xifexpression_5;
final boolean usesHdlr = this.usesHandlerTrPoints(xpmc);
StringConcatenation _builder = new StringConcatenation();
_builder.append("/**");
@@ -611,6 +622,7 @@ public abstract class AbstractStateMachineGenerator {
for(final TransitionChain tc : allchains) {
_builder.append("\t\t");
_builder.append("case ");
+ _builder.append(chainIDScope, "\t\t");
String _genChainId = this._codegenHelpers.getGenChainId(tc);
_builder.append(_genChainId, "\t\t");
_builder.append(":");
@@ -740,8 +752,8 @@ public abstract class AbstractStateMachineGenerator {
_builder.append("\t\t");
_builder.append("state__et = ");
{
- boolean _usesInheritance_3 = this.langExt.usesInheritance();
- boolean _not = (!_usesInheritance_3);
+ boolean _usesInheritance_4 = this.langExt.usesInheritance();
+ boolean _not = (!_usesInheritance_4);
if (_not) {
_builder.append("(");
String _stateType_8 = this.stateType();
@@ -849,6 +861,7 @@ public abstract class AbstractStateMachineGenerator {
_builder.append("state__et = executeTransitionChain(");
String _selfPointer_2 = this.langExt.selfPointer(true);
_builder.append(_selfPointer_2, "\t\t\t\t\t");
+ _builder.append(chainIDScope, "\t\t\t\t\t");
TransitionChain _chain = xpmc.getChain(sub_initt);
String _genChainId_1 = this._codegenHelpers.getGenChainId(_chain);
_builder.append(_genChainId_1, "\t\t\t\t\t");
@@ -987,6 +1000,7 @@ public abstract class AbstractStateMachineGenerator {
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("int chain__et = ");
+ _builder.append(chainIDScope, "\t");
TransitionChain _chain_1 = xpmc.getChain(initt);
String _genChainId_2 = this._codegenHelpers.getGenChainId(_chain_1);
_builder.append(_genChainId_2, "\t");
@@ -1055,8 +1069,8 @@ public abstract class AbstractStateMachineGenerator {
_builder.append("void ");
_builder.append(opScope, "");
_builder.append("receiveEventInternal(");
- String _className_3 = this.getClassName(mc);
- String _selfPointer_6 = this.langExt.selfPointer(_className_3, handleEvents);
+ String _className_4 = this.getClassName(mc);
+ String _selfPointer_6 = this.langExt.selfPointer(_className_4, handleEvents);
_builder.append(_selfPointer_6, "");
{
if (handleEvents) {
@@ -1214,8 +1228,8 @@ public abstract class AbstractStateMachineGenerator {
_builder.append("void ");
_builder.append(opScope, "");
_builder.append("receiveEventInternal(");
- String _className_4 = this.getClassName(mc);
- String _selfPointer_12 = this.langExt.selfPointer(_className_4, handleEvents);
+ String _className_5 = this.getClassName(mc);
+ String _selfPointer_12 = this.langExt.selfPointer(_className_5, handleEvents);
_builder.append(_selfPointer_12, "");
{
if (handleEvents) {
@@ -1238,8 +1252,8 @@ public abstract class AbstractStateMachineGenerator {
_builder.append("void ");
_builder.append(opScope, "");
_builder.append("receiveEvent(");
- String _className_5 = this.getClassName(mc);
- String _selfPointer_13 = this.langExt.selfPointer(_className_5, true);
+ String _className_6 = this.getClassName(mc);
+ String _selfPointer_13 = this.langExt.selfPointer(_className_6, true);
_builder.append(_selfPointer_13, "");
_builder.append(ifItemPtr, "");
_builder.append(" ifitem, int evt, ");
@@ -1473,70 +1487,85 @@ public abstract class AbstractStateMachineGenerator {
* @return the generated code
*/
public CharSequence genDataDrivenTriggers(final ExpandedModelComponent xpmc, final State state, final boolean usesHdlr) {
- StringConcatenation _builder = new StringConcatenation();
- String _genDoCodes = this.genDoCodes(state);
- _builder.append(_genDoCodes, "");
- _builder.newLineIfNotEmpty();
- List<Transition> _outgoingTransitionsHierarchical = this._fSMExtensions.getOutgoingTransitionsHierarchical(xpmc, state);
- final Function1<Transition, Boolean> _function = new Function1<Transition, Boolean>() {
- public Boolean apply(final Transition t) {
- return Boolean.valueOf((t instanceof GuardedTransition));
- }
- };
- Iterable<Transition> transitions = IterableExtensions.<Transition>filter(_outgoingTransitionsHierarchical, _function);
- _builder.newLineIfNotEmpty();
+ CharSequence _xblockexpression = null;
{
- for(final Transition tr : transitions) {
- _builder.append("if (");
- String _guard = this.guard(((GuardedTransition) tr), "", xpmc);
- _builder.append(_guard, "");
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- _builder.append("{");
- _builder.newLine();
- _builder.append(" ");
- TransitionChain chain = xpmc.getChain(tr);
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("chain__et = ");
- String _genChainId = this._codegenHelpers.getGenChainId(chain);
- _builder.append(_genChainId, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("catching_state__et = ");
- State _stateContext = chain.getStateContext();
- String _genStateId = this._codegenHelpers.getGenStateId(_stateContext);
- _builder.append(_genStateId, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- {
- boolean _and = false;
- boolean _isHandler = chain.isHandler();
- if (!_isHandler) {
- _and = false;
- } else {
- _and = usesHdlr;
- }
- if (_and) {
- _builder.append(" ");
- _builder.append("is_handler__et = TRUE;");
- _builder.newLine();
- }
+ String _xifexpression = null;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ String _className = this.getClassName(xpmc);
+ String _scopeSeparator = this.langExt.scopeSeparator();
+ _xifexpression = (_className + _scopeSeparator);
+ } else {
+ _xifexpression = "";
+ }
+ final String chainIDScope = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ String _genDoCodes = this.genDoCodes(state);
+ _builder.append(_genDoCodes, "");
+ _builder.newLineIfNotEmpty();
+ List<Transition> _outgoingTransitionsHierarchical = this._fSMExtensions.getOutgoingTransitionsHierarchical(xpmc, state);
+ final Function1<Transition, Boolean> _function = new Function1<Transition, Boolean>() {
+ public Boolean apply(final Transition t) {
+ return Boolean.valueOf((t instanceof GuardedTransition));
}
- _builder.append("}");
- _builder.newLine();
- {
- Transition _last = IterableExtensions.<Transition>last(transitions);
- boolean _notEquals = (!Objects.equal(tr, _last));
- if (_notEquals) {
- _builder.append("else");
- _builder.newLine();
+ };
+ Iterable<Transition> transitions = IterableExtensions.<Transition>filter(_outgoingTransitionsHierarchical, _function);
+ _builder.newLineIfNotEmpty();
+ {
+ for(final Transition tr : transitions) {
+ _builder.append("if (");
+ String _guard = this.guard(((GuardedTransition) tr), "", xpmc);
+ _builder.append(_guard, "");
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append(" ");
+ TransitionChain chain = xpmc.getChain(tr);
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("chain__et = ");
+ _builder.append(chainIDScope, " ");
+ String _genChainId = this._codegenHelpers.getGenChainId(chain);
+ _builder.append(_genChainId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("catching_state__et = ");
+ State _stateContext = chain.getStateContext();
+ String _genStateId = this._codegenHelpers.getGenStateId(_stateContext);
+ _builder.append(_genStateId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _and = false;
+ boolean _isHandler = chain.isHandler();
+ if (!_isHandler) {
+ _and = false;
+ } else {
+ _and = usesHdlr;
+ }
+ if (_and) {
+ _builder.append(" ");
+ _builder.append("is_handler__et = TRUE;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ {
+ Transition _last = IterableExtensions.<Transition>last(transitions);
+ boolean _notEquals = (!Objects.equal(tr, _last));
+ if (_notEquals) {
+ _builder.append("else");
+ _builder.newLine();
+ }
}
}
}
+ _xblockexpression = _builder;
}
- return _builder;
+ return _xblockexpression;
}
/**
@@ -1550,106 +1579,121 @@ public abstract class AbstractStateMachineGenerator {
* @return the generated code
*/
public CharSequence genEventDrivenTriggers(final ExpandedModelComponent xpmc, final State state, final List<ActiveTrigger> atlist, final boolean usesHdlr) {
- StringConcatenation _builder = new StringConcatenation();
+ CharSequence _xblockexpression = null;
{
- for(final ActiveTrigger at : atlist) {
- _builder.append("case ");
- String _triggerCodeName = xpmc.getTriggerCodeName(at);
- _builder.append(_triggerCodeName, "");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- boolean needData = this._fsmGenUtil.hasGuard(at);
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- {
- if (needData) {
- _builder.append("{ ");
- EObject _msg = at.getMsg();
- String _typedDataDefinition = this.langExt.getTypedDataDefinition(_msg);
- _builder.append(_typedDataDefinition, " ");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<TriggeredTransition> _transitions = at.getTransitions();
- boolean _hasElements = false;
- for(final TriggeredTransition tt : _transitions) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(" else ", " ");
+ String _xifexpression = null;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ String _className = this.getClassName(xpmc);
+ String _scopeSeparator = this.langExt.scopeSeparator();
+ _xifexpression = (_className + _scopeSeparator);
+ } else {
+ _xifexpression = "";
+ }
+ final String chainIDScope = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final ActiveTrigger at : atlist) {
+ _builder.append("case ");
+ String _triggerCodeName = xpmc.getTriggerCodeName(at);
+ _builder.append(_triggerCodeName, "");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ boolean needData = this._fsmGenUtil.hasGuard(at);
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ {
+ if (needData) {
+ _builder.append("{ ");
+ EObject _msg = at.getMsg();
+ String _typedDataDefinition = this.langExt.getTypedDataDefinition(_msg);
+ _builder.append(_typedDataDefinition, " ");
}
- _builder.append(" ");
- TransitionChain chain = xpmc.getChain(tt);
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- Transition _transition = chain.getTransition();
- String _trigger = at.getTrigger();
- String _guard = this.guard(((TriggeredTransition) _transition), _trigger, xpmc);
- _builder.append(_guard, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("{");
- _builder.newLine();
- _builder.append(" ");
- _builder.append(" ");
- _builder.append("chain__et = ");
- String _genChainId = this._codegenHelpers.getGenChainId(chain);
- _builder.append(_genChainId, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append(" ");
- _builder.append("catching_state__et = ");
- State _stateContext = chain.getStateContext();
- String _genStateId = this._codegenHelpers.getGenStateId(_stateContext);
- _builder.append(_genStateId, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- {
- boolean _and = false;
- boolean _isHandler = chain.isHandler();
- if (!_isHandler) {
- _and = false;
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<TriggeredTransition> _transitions = at.getTransitions();
+ boolean _hasElements = false;
+ for(final TriggeredTransition tt : _transitions) {
+ if (!_hasElements) {
+ _hasElements = true;
} else {
- _and = usesHdlr;
+ _builder.appendImmediate(" else ", " ");
}
- if (_and) {
- _builder.append(" ");
- _builder.append(" ");
- _builder.append("is_handler__et = ");
- String _booleanConstant = this.langExt.booleanConstant(true);
- _builder.append(_booleanConstant, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ TransitionChain chain = xpmc.getChain(tt);
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ Transition _transition = chain.getTransition();
+ String _trigger = at.getTrigger();
+ String _guard = this.guard(((TriggeredTransition) _transition), _trigger, xpmc);
+ _builder.append(_guard, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append(" ");
+ _builder.append("chain__et = ");
+ _builder.append(chainIDScope, " ");
+ String _genChainId = this._codegenHelpers.getGenChainId(chain);
+ _builder.append(_genChainId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append(" ");
+ _builder.append("catching_state__et = ");
+ State _stateContext = chain.getStateContext();
+ String _genStateId = this._codegenHelpers.getGenStateId(_stateContext);
+ _builder.append(_genStateId, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _and = false;
+ boolean _isHandler = chain.isHandler();
+ if (!_isHandler) {
+ _and = false;
+ } else {
+ _and = usesHdlr;
+ }
+ if (_and) {
+ _builder.append(" ");
+ _builder.append(" ");
+ _builder.append("is_handler__et = ");
+ String _booleanConstant = this.langExt.booleanConstant(true);
+ _builder.append(_booleanConstant, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
}
+ _builder.append(" ");
+ _builder.append("}");
+ _builder.newLine();
}
- _builder.append(" ");
- _builder.append("}");
- _builder.newLine();
}
- }
- _builder.append(" ");
- {
- if (needData) {
- _builder.append("}");
+ _builder.append(" ");
+ {
+ if (needData) {
+ _builder.append("}");
+ }
}
+ _builder.newLineIfNotEmpty();
+ _builder.append("break;");
+ _builder.newLine();
}
- _builder.newLineIfNotEmpty();
- _builder.append("break;");
- _builder.newLine();
}
+ _builder.append("default:");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("/* should not occur */");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("break;");
+ _builder.newLine();
+ _xblockexpression = _builder;
}
- _builder.append("default:");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("/* should not occur */");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("break;");
- _builder.newLine();
- return _builder;
+ return _xblockexpression;
}
public String getClassName(final ExpandedModelComponent xpmc) {
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
index 9db970370..440c3e8d0 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
@@ -103,6 +103,7 @@ class JavaExtensions implements ILanguageExtension {
override String operationScope(String classname, boolean isDeclaration) {""}
+ override String scopeSeparator() {"."}
override String memberInDeclaration(String namespace, String member) {
return member
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
index 0c2cd116d..71682e14e 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
@@ -198,6 +198,10 @@ public class JavaExtensions implements ILanguageExtension {
return "";
}
+ public String scopeSeparator() {
+ return ".";
+ }
+
public String memberInDeclaration(final String namespace, final String member) {
return member;
}

Back to the top