Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice')
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/AbstractLanguageGenerator.java (renamed from plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageGenerator.java)26
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java9
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageTransitionChainVisitor.java10
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/TypeHelpers.xtend4
7 files changed, 24 insertions, 31 deletions
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageGenerator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/AbstractLanguageGenerator.java
index 3267367a1..d80501d07 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/AbstractLanguageGenerator.java
@@ -15,7 +15,6 @@ package org.eclipse.etrice.generator.generic;
import org.eclipse.etrice.core.room.InitialTransition;
import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.MessageFromIf;
-import org.eclipse.etrice.core.room.PrimitiveType;
import org.eclipse.etrice.core.room.Transition;
import org.eclipse.etrice.core.room.Trigger;
import org.eclipse.etrice.core.room.TriggeredTransition;
@@ -24,11 +23,12 @@ import org.eclipse.etrice.generator.base.AbstractGenerator;
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
import org.eclipse.etrice.generator.etricegen.TransitionChain;
-public class LanguageGenerator {
+public abstract class AbstractLanguageGenerator {
public String getExecuteChain(ExpandedActorClass ac, TransitionChain tc) {
- LanguageTransitionChainVisitor tcv = new LanguageTransitionChainVisitor(ac, tc);
+ LanguageTransitionChainVisitor tcv = new LanguageTransitionChainVisitor(ac);
AbstractGenerator.getInjector().injectMembers(tcv);
+ tcv.init(tc);
return tc.genExecuteChain(tcv);
}
@@ -59,23 +59,5 @@ public class LanguageGenerator {
return getArglistAndTypedData(m.getData())[2];
}
- public String[] getArglistAndTypedData(VarDecl data) {
- if (data==null)
- return new String[] {"", "", ""};
-
- String typeName = data.getRefType().getType().getName();
- String castTypeName = typeName;
- if (data.getRefType().getType() instanceof PrimitiveType) {
- typeName = ((PrimitiveType)data.getRefType().getType()).getTargetName();
- String ct = ((PrimitiveType)data.getRefType().getType()).getCastName();
- if (ct!=null && !ct.isEmpty())
- castTypeName = ct;
- }
-
- String typedData = typeName+" "+data.getName() + " = ("+castTypeName+") generic_data;\n";
- String dataArg = ", "+data.getName();
- String typedArgList = ", "+typeName+" "+data.getName();
-
- return new String[]{dataArg, typedData, typedArgList};
- }
+ public abstract String[] getArglistAndTypedData(VarDecl data);
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend
index 265cc8df5..9b088a16a 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.xtend
@@ -47,7 +47,7 @@ class GenericProtocolClassGenerator {
offset = offset+1
list.add(pair(memberInDeclaration(pc.name, "MSG_MAX"), offset.toString))
- return langExt.genEnumeration("msg_ids", list)
+ return langExt.genEnumeration(langExt.memberInDeclaration(pc.name, "msg_ids"), list)
}
def getMessageID(MessageFromIf mif) {
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
index 2dbb1de1a..b0023fac1 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.xtend
@@ -31,7 +31,7 @@ class GenericStateMachineGenerator {
@Inject public extension ILanguageExtension langExt
@Inject public extension RoomExtensions roomExt
@Inject public extension GenericProtocolClassGenerator pcGen
- @Inject public extension LanguageGenerator languageGen
+ @Inject public extension org.eclipse.etrice.generator.generic.AbstractLanguageGenerator languageGen
@Inject public ITranslationProvider translator
def private genStateIdConstants(ExpandedActorClass xpac, ActorClass ac) {
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
index 6195e41e3..b0cfd41c4 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
@@ -119,4 +119,13 @@ public interface ILanguageExtension {
* @return void* for C/C++, Object for Java
*/
String voidPointer();
+
+ /**
+ * array declarations differ in Java and C/C++
+ * @param type
+ * @param size
+ * @param name
+ * @return a string that represents the declaration
+ */
+ String arrayDeclaration(String type, int size, String name);
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageTransitionChainVisitor.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageTransitionChainVisitor.java
index 233109327..7d5edebd9 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageTransitionChainVisitor.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/LanguageTransitionChainVisitor.java
@@ -29,14 +29,16 @@ import com.google.inject.Inject;
public class LanguageTransitionChainVisitor implements ITransitionChainVisitor {
private ExpandedActorClass ac;
- private LanguageGenerator javaGen = new LanguageGenerator();
- @Inject ILanguageExtension langExt;
+ @Inject private AbstractLanguageGenerator javaGen;
+ @Inject private ILanguageExtension langExt;
private String typedData = "";
private String dataArg = "";
- LanguageTransitionChainVisitor(ExpandedActorClass ac, TransitionChain tc) {
+ LanguageTransitionChainVisitor(ExpandedActorClass ac) {
this.ac = ac;
-
+ }
+
+ void init(TransitionChain tc) {
if (tc.getTransition() instanceof TriggeredTransition) {
// we rely on the previous checking during the generator model creation
VarDecl data = ((TriggeredTransition)tc.getTransition()).getTriggers().get(0).getMsgFromIfPairs().get(0).getMessage().getData();
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
index 3d4ab1f91..552843aea 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
@@ -52,7 +52,7 @@ class ProcedureHelpers {
«IF attribute.size==0»
«attribute.refType.type.typeName» «attribute.name»;
«ELSE»
- «attribute.refType.type.typeName»[] «attribute.name»;
+ «languageExt.arrayDeclaration(attribute.refType.type.typeName, attribute.size, attribute.name)»;
«ENDIF»
«ENDFOR»
'''
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/TypeHelpers.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/TypeHelpers.xtend
index ab0015520..ad2cb629a 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/TypeHelpers.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/TypeHelpers.xtend
@@ -24,13 +24,13 @@ import org.eclipse.etrice.core.room.ExternalType
import org.eclipse.etrice.core.room.PrimitiveType
import org.eclipse.etrice.core.room.VarDecl
import org.eclipse.etrice.core.room.Message
-import org.eclipse.etrice.generator.generic.LanguageGenerator
+import org.eclipse.etrice.generator.generic.AbstractLanguageGenerator
@Singleton
class TypeHelpers {
- @Inject LanguageGenerator languageGen
+ @Inject AbstractLanguageGenerator languageGen
def String typeName(DataType type) {
if (type instanceof PrimitiveType)

Back to the top