Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-02-27 16:03:29 +0000
committerHenrik Rentz-Reichert2012-02-27 16:03:29 +0000
commit9b63ec1b9654dd00d644ceb94f664df3e61d6c4e (patch)
tree3607453cd83d3e2963fd2a415a84289931d29e22 /plugins
parent1b19f7079ee48921ad2fb0169eb73d537f9eab1e (diff)
parentfa4a03389b5596fbaa65d5acb0e198013c1820a8 (diff)
downloadorg.eclipse.etrice-9b63ec1b9654dd00d644ceb94f664df3e61d6c4e.tar.gz
org.eclipse.etrice-9b63ec1b9654dd00d644ceb94f664df3e61d6c4e.tar.xz
org.eclipse.etrice-9b63ec1b9654dd00d644ceb94f664df3e61d6c4e.zip
Merge remote branch 'refs/remotes/origin/master'
Conflicts: plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericProtocolClassGenerator.java
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend11
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend8
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java34
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend230
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend17
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend14
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java3
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java12
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java203
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java2
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java21
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java22
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend10
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaLanguageGenerator.java30
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend28
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java3
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java110
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java684
-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/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
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java4
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java6
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TypeHelpers.java4
-rw-r--r--plugins/org.eclipse.etrice.logging/bin/log4j.properties7
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.zipbin27511 -> 27617 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zipbin91999 -> 176946 bytes
32 files changed, 658 insertions, 866 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 f9c689c15..ccc9013ac 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
@@ -80,7 +80,7 @@ class ActorClassGen extends GenericActorClassGenerator {
«generateIncludeGuardBegin(xpac.name)»
#include "etDatatypes.h"
- #include "etMessage.h"
+ #include "messaging/etMessage.h"
«FOR dataClass : root.getReferencedDataClasses(ac)»
#include "«dataClass.name».h"
@@ -148,9 +148,10 @@ class ActorClassGen extends GenericActorClassGenerator {
#include "«xpac.getCHeaderFileName»"
- #include "etActor.h"
- #include "etLogger.h"
- #include "etMSCLogger.h"
+ #include "modelbase/etActor.h"
+ #include "debugging/etLogger.h"
+ #include "debugging/etMSCLogger.h"
+ #include "platform/etMemory.h"
«FOR pc : root.getReferencedProtocolClasses(ac)»
#include "«pc.getCHeaderFileName»"
@@ -178,7 +179,7 @@ class ActorClassGen extends GenericActorClassGenerator {
ET_MSC_LOGGER_SYNC_ENTRY("«xpac.name»", "ReceiveMessage")
«IF xpac.hasNonEmptyStateMachine»
- receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(&msg[1]));
+ receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage))));
«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 bea5bdd0a..598ae9024 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
@@ -25,7 +25,7 @@ import org.eclipse.etrice.core.room.RoomClass
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
import org.eclipse.etrice.generator.etricegen.TransitionChain
import org.eclipse.etrice.generator.generic.ILanguageExtension
-import org.eclipse.etrice.generator.generic.LanguageGenerator
+import org.eclipse.etrice.generator.generic.AbstractLanguageGenerator
import java.util.List
import org.eclipse.xtext.util.Pair
@@ -34,7 +34,7 @@ import org.eclipse.xtext.util.Pair
@Singleton
class CExtensions implements ILanguageExtension {
- @Inject LanguageGenerator languageGen
+ @Inject AbstractLanguageGenerator languageGen
override String getTypedDataDefinition(Message m) {
@@ -133,4 +133,8 @@ class CExtensions implements ILanguageExtension {
def String getExecuteChainCode(ExpandedActorClass ac, TransitionChain tc) {
return languageGen.getExecuteChain(ac, tc)
}
+
+ override String arrayDeclaration(String type, int size, String name) {
+ type+" "+name+"["+size+"]";
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java
new file mode 100644
index 000000000..c25db77be
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java
@@ -0,0 +1,34 @@
+package org.eclipse.etrice.generator.c.gen;
+
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.generic.AbstractLanguageGenerator;
+
+public class CLanguageGenerator extends AbstractLanguageGenerator {
+
+ public String[] getArglistAndTypedData(VarDecl data) {
+ if (data==null)
+ return new String[] {"", "", ""};
+
+ String typeName = data.getRefType().getType().getName();
+ String castTypeName = typeName+"*";
+ boolean byVal = false;
+ if (data.getRefType().getType() instanceof PrimitiveType) {
+ typeName = ((PrimitiveType)data.getRefType().getType()).getTargetName();
+ String ct = ((PrimitiveType)data.getRefType().getType()).getCastName();
+ byVal = true;
+ if (ct!=null && !ct.isEmpty())
+ castTypeName = ct;
+ }
+ else {
+ typeName = typeName+"*";
+ }
+
+ String typedData = typeName+" "+data.getName() + " = "+(byVal? "*":"")+"(("+castTypeName+") generic_data);\n";
+ String dataArg = ", "+data.getName();
+ String typedArgList = ", "+typeName+" "+data.getName();
+
+ return new String[]{dataArg, typedData, typedArgList};
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
index ba1eae7a7..80f06f6da 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
@@ -1,116 +1,116 @@
-/*******************************************************************************
- * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
- * 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:
- * Henrik Rentz-Reichert (initial contribution)
- * Thomas Schuetz (changed for C code generator)
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.generator.c.gen
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import org.eclipse.etrice.core.room.DataClass
-import org.eclipse.etrice.generator.base.ILogger
-import org.eclipse.etrice.generator.etricegen.Root
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
-import org.eclipse.etrice.generator.extensions.RoomExtensions
-import org.eclipse.etrice.generator.generic.ProcedureHelpers
-
-
-@Singleton
-class DataClassGen {
-
- @Inject extension JavaIoFileSystemAccess fileAccess
- @Inject extension CExtensions stdExt
- @Inject extension RoomExtensions roomExt
- @Inject extension ProcedureHelpers helpers
- @Inject ILogger logger
-
- def doGenerate(Root root) {
- for (dc: root.usedDataClasses) {
- var path = dc.generationTargetPath+dc.getPath
-
- // header file
- logger.logInfo("generating DataClass header '"+dc.getCHeaderFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(dc.getCHeaderFileName, root.generateHeaderFile(dc))
-
- // source file
- logger.logInfo("generating DataClass source '"+dc.getCSourceFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(dc.getCSourceFileName, root.generateSourceFile(dc))
-
- }
- }
-
- def generateHeaderFile(Root root, DataClass dc) {'''
- /**
- * @author generated by eTrice
- *
- * Header File of DataClass «dc.name»
- *
- */
-
- «generateIncludeGuardBegin(dc.name)»
-
- #include "etDatatypes.h"
-
-««« TODO: includes only for used DataClasses, also for other models
- «FOR dataClass : root.getReferencedDataClasses(dc)»
- #include "«dataClass.name».h"
- «ENDFOR»
-
- «helpers.userCode(dc.userCode1)»
-
- typedef struct {
- »«helpers.attributes(dc.allAttributes)»
- } «dc.name»
-
-««« TODO: do we need setters and getters for C and C++ ?
-
- «helpers.operationsDeclaration(dc.operations, dc.name)»
-
- /* deep copy */
- void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target);
-
- «helpers.userCode(dc.userCode2)»
-
- «generateIncludeGuardEnd(dc.name)»
-
- '''
- }
-
- def generateSourceFile(Root root, DataClass dc) {'''
- /**
- * @author generated by eTrice
- *
- * Source File of DataClass «dc.name»
- *
- */
-
- #include "«dc.getCHeaderFileName»"
-
- #include <string.h>
-
- «helpers.userCode(dc.userCode3)»
-
-««« TODO: do we need setters and getters for C and C++ ?
-
- «helpers.operationsImplementation(dc.operations, dc.name)»
-
- // deep copy
- void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target) {
- memcpy(target, source, sizeof(«dc.name»));
- }
-
-
- '''}
-
-
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ * Thomas Schuetz (changed for C code generator)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.c.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.generator.base.ILogger
+import org.eclipse.etrice.generator.etricegen.Root
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.extensions.RoomExtensions
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+
+
+@Singleton
+class DataClassGen {
+
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject extension CExtensions stdExt
+ @Inject extension RoomExtensions roomExt
+ @Inject extension ProcedureHelpers helpers
+ @Inject ILogger logger
+
+ def doGenerate(Root root) {
+ for (dc: root.usedDataClasses) {
+ var path = dc.generationTargetPath+dc.getPath
+
+ // header file
+ logger.logInfo("generating DataClass header '"+dc.getCHeaderFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(dc.getCHeaderFileName, root.generateHeaderFile(dc))
+
+ // source file
+ logger.logInfo("generating DataClass source '"+dc.getCSourceFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(dc.getCSourceFileName, root.generateSourceFile(dc))
+
+ }
+ }
+
+ def generateHeaderFile(Root root, DataClass dc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of DataClass «dc.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(dc.name)»
+
+ #include "etDatatypes.h"
+
+««« TODO: includes only for used DataClasses, also for other models
+ «FOR dataClass : root.getReferencedDataClasses(dc)»
+ #include "«dataClass.name».h"
+ «ENDFOR»
+
+ «helpers.userCode(dc.userCode1)»
+
+ typedef struct {
+ «helpers.attributes(dc.allAttributes)»
+ } «dc.name»;
+
+««« TODO: do we need setters and getters for C and C++ ?
+
+ «helpers.operationsDeclaration(dc.operations, dc.name)»
+
+ /* deep copy */
+ void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target);
+
+ «helpers.userCode(dc.userCode2)»
+
+ «generateIncludeGuardEnd(dc.name)»
+
+ '''
+ }
+
+ def generateSourceFile(Root root, DataClass dc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of DataClass «dc.name»
+ *
+ */
+
+ #include "«dc.getCHeaderFileName»"
+
+ #include <string.h>
+
+ «helpers.userCode(dc.userCode3)»
+
+««« TODO: do we need setters and getters for C and C++ ?
+
+ «helpers.operationsImplementation(dc.operations, dc.name)»
+
+ // deep copy
+ void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target) {
+ memcpy(target, source, sizeof(«dc.name»));
+ }
+
+
+ '''}
+
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
index d4ecf5e36..9934fcfea 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
@@ -64,7 +64,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«generateIncludeGuardBegin(pc.name)»
#include "etDatatypes.h"
- #include "etPort.h"
+ #include "modelbase/etPort.h"
«helpers.userCode(pc.userCode1)»
@@ -102,7 +102,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
*/
#include "«pc.getCHeaderFileName»"
- #include "etMSCLogger.h"
+ #include "debugging/etMSCLogger.h"
«helpers.userCode(pc.userCode3)»
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
index ce83ef9c1..a1fc872c6 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
@@ -111,8 +111,8 @@ class SubSystemClassGen {
#include "«ssc.getInstSourceFileName»"
#include "«ssc.getDispSourceFileName»"
- #include "etLogger.h"
- #include "etMSCLogger.h"
+ #include "debugging/etLogger.h"
+ #include "debugging/etMSCLogger.h"
«helpers.userCode(ssc.userCode3)»
@@ -187,14 +187,11 @@ class SubSystemClassGen {
* - configuration of data and connection of ports
*/
- #include "etMessageService.h"
+ #include "messaging/etMessageService.h"
+ #include "platform/etMemory.h"
/* instantiation of message services */
- /* pool and block size */
- #define MESSAGE_POOL_MAX 10
- #define MESSAGE_BLOCK_SIZE 32
-
/* MessageService for Thread1 */
static uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];
static etMessageService msgService_Thread1;
@@ -310,9 +307,9 @@ class SubSystemClassGen {
* - one generated dispatcher for each MessageService (Thread)
*/
- #include "etMessageReceiver.h"
- #include "etLogger.h"
- #include "etMSCLogger.h"
+ #include "messaging/etMessageReceiver.h"
+ #include "debugging/etLogger.h"
+ #include "debugging/etMSCLogger.h"
static void MsgDispatcher_Thread1_receiveMessage(const etMessage* msg){
ET_MSC_LOGGER_SYNC_ENTRY("MsgDispatcher_Thread1", "receiveMessage")
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend
index 740c0b0f9..72d95f03d 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend
@@ -45,8 +45,9 @@ class SubSystemRunnerGen {
#include "«ssi.name».h"
- #include "etLogger.h"
- #include "etMSCLogger.h"
+ #include "debugging/etLogger.h"
+ #include "debugging/etMSCLogger.h"
+ #include "platform/etPlatform.h"
/**
@@ -55,7 +56,8 @@ class SubSystemRunnerGen {
*/
int main(void) {
-
+ etUserEntry(); /* platform specific */
+
etLogger_logInfo("*** T H E B E G I N ***");
ET_MSC_LOGGER_OPEN("main");
@@ -63,9 +65,13 @@ class SubSystemRunnerGen {
«ssi.name»_init(); /* lifecycle init */
«ssi.name»_start(); /* lifecycle start */
+ etUserPreRun(); /* platform specific */
+
/* run Scheduler */
«ssi.name»_run();
+ etUserPostRun(); /* platform specific */
+
/* shutdown sequence of lifecycle */
«ssi.name»_stop(); /* lifecycle stop */
«ssi.name»_destroy(); /* lifecycle destroy */
@@ -73,6 +79,8 @@ class SubSystemRunnerGen {
ET_MSC_LOGGER_CLOSE
etLogger_logInfo("*** T H E E N D ***");
+ etUserExit(); /* platform specific */
+
return 0;
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java
index ef3849a1b..5adccb9ec 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java
@@ -16,9 +16,11 @@ import org.eclipse.etrice.generator.base.AbstractGenerator;
import org.eclipse.etrice.generator.base.GeneratorBaseModule;
import org.eclipse.etrice.generator.base.ITranslationProvider;
import org.eclipse.etrice.generator.c.Main;
+import org.eclipse.etrice.generator.c.gen.CLanguageGenerator;
import org.eclipse.etrice.generator.c.gen.CTranslationProvider;
import org.eclipse.etrice.generator.c.gen.MainGen;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.AbstractLanguageGenerator;
import org.eclipse.xtext.generator.IGenerator;
import org.eclipse.etrice.generator.c.gen.CExtensions;
@@ -35,6 +37,7 @@ public class GeneratorModule extends GeneratorBaseModule {
// bind language specific code to generic Interfaces
binder.bind(ILanguageExtension.class).to(CExtensions.class);
+ binder.bind(AbstractLanguageGenerator.class).to(CLanguageGenerator.class);
binder.bind(ITranslationProvider.class).to(CTranslationProvider.class);
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
index 38cf9fef9..901c01e79 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
@@ -156,7 +156,7 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
_builder.append("#include \"etDatatypes.h\"");
_builder.newLine();
- _builder.append("#include \"etMessage.h\"");
+ _builder.append("#include \"messaging/etMessage.h\"");
_builder.newLine();
_builder.newLine();
{
@@ -359,11 +359,13 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\"");
_builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.append("#include \"etActor.h\"");
+ _builder.append("#include \"modelbase/etActor.h\"");
_builder.newLine();
- _builder.append("#include \"etLogger.h\"");
+ _builder.append("#include \"debugging/etLogger.h\"");
_builder.newLine();
- _builder.append("#include \"etMSCLogger.h\"");
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"platform/etMemory.h\"");
_builder.newLine();
_builder.newLine();
{
@@ -444,7 +446,7 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
- _builder.append("receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(&msg[1]));");
+ _builder.append("receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage))));");
_builder.newLine();
}
}
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
deleted file mode 100644
index 98bee5eaf..000000000
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
+++ /dev/null
@@ -1,203 +0,0 @@
-package org.eclipse.etrice.generator.c.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.RoomClass;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.TransitionChain;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.LanguageGenerator;
-import org.eclipse.xtext.util.Pair;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class CExtensions implements ILanguageExtension {
- @Inject
- private LanguageGenerator languageGen;
-
- public String getTypedDataDefinition(final Message m) {
- String _typedData = this.languageGen.getTypedData(m);
- return _typedData;
- }
-
- public String accessLevelPrivate() {
- return "static ";
- }
-
- public String accessLevelProtected() {
- return "static ";
- }
-
- public String accessLevelPublic() {
- return "";
- }
-
- public String memberAccess() {
- return "self->";
- }
-
- public String selfPointer(final String classname, final boolean hasArgs) {
- String _xifexpression = null;
- if (hasArgs) {
- _xifexpression = "* self, ";
- } else {
- _xifexpression = "* self";
- }
- String _operator_plus = StringExtensions.operator_plus(classname, _xifexpression);
- return _operator_plus;
- }
-
- public String selfPointer(final boolean hasArgs) {
- String _xifexpression = null;
- if (hasArgs) {
- _xifexpression = "self, ";
- } else {
- _xifexpression = "self";
- }
- return _xifexpression;
- }
-
- public String operationScope(final String classname, final boolean isDeclaration) {
- String _operator_plus = StringExtensions.operator_plus(classname, "_");
- return _operator_plus;
- }
-
- public String memberInDeclaration(final String namespace, final String member) {
- String _operator_plus = StringExtensions.operator_plus(namespace, "_");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
- return _operator_plus_1;
- }
-
- public String memberInUse(final String namespace, final String member) {
- String _operator_plus = StringExtensions.operator_plus(namespace, "_");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
- return _operator_plus_1;
- }
-
- /**
- * TODO: move specific code elsewhere
- */
- public String getCHeaderFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, ".h");
- return _operator_plus;
- }
-
- public String getCSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, ".c");
- return _operator_plus;
- }
-
- public String getInstSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, "_Inst.h");
- return _operator_plus;
- }
-
- public String getDispSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, "_Disp.h");
- return _operator_plus;
- }
-
- public StringConcatenation getIncludeGuardString(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("_");
- String _upperCase = filename.toUpperCase();
- _builder.append(_upperCase, "");
- _builder.append("_H_");
- return _builder;
- }
-
- public StringConcatenation generateIncludeGuardBegin(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#ifndef ");
- StringConcatenation _includeGuardString = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString, "");
- _builder.newLineIfNotEmpty();
- _builder.append("#define ");
- StringConcatenation _includeGuardString_1 = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString_1, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public StringConcatenation generateIncludeGuardEnd(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#endif /* ");
- StringConcatenation _includeGuardString = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString, "");
- _builder.append(" */");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public boolean usesInheritance() {
- return false;
- }
-
- public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
- String _xblockexpression = null;
- {
- boolean _isEmpty = entries.isEmpty();
- if (_isEmpty) {
- return "/* empty enum not generated */";
- }
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("enum ");
- _builder.append(name, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean hasAnyElements = false;
- for(final Pair<String,String> entry : entries) {
- if (!hasAnyElements) {
- hasAnyElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t");
- String _first = entry.getFirst();
- _builder.append(_first, " ");
- _builder.append(" = ");
- String _second = entry.getSecond();
- _builder.append(_second, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("};");
- _builder.newLine();
- String _string = _builder.toString();
- _xblockexpression = (_string);
- }
- return _xblockexpression;
- }
-
- public String booleanConstant(final boolean b) {
- String _xifexpression = null;
- if (b) {
- _xifexpression = "TRUE";
- } else {
- _xifexpression = "FALSE";
- }
- return _xifexpression;
- }
-
- public String nullPointer() {
- return "NULL";
- }
-
- public String voidPointer() {
- return "void*";
- }
-
- public String getExecuteChainCode(final ExpandedActorClass ac, final TransitionChain tc) {
- String _executeChain = this.languageGen.getExecuteChain(ac, tc);
- return _executeChain;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
index 2dbbb5e4b..cfd16ac7a 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
@@ -118,7 +118,6 @@ public class DataClassGen {
_builder.append("typedef struct {");
_builder.newLine();
_builder.append("\t");
- _builder.append("\u00BB");
List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dc);
StringConcatenation _attributes = this.helpers.attributes(_allAttributes);
_builder.append(_attributes, " ");
@@ -126,6 +125,7 @@ public class DataClassGen {
_builder.append("} ");
String _name_3 = dc.getName();
_builder.append(_name_3, "");
+ _builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.newLine();
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
index 2d0f17ed9..e66b042f0 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
@@ -108,7 +108,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.newLine();
_builder.append("#include \"etDatatypes.h\"");
_builder.newLine();
- _builder.append("#include \"etPort.h\"");
+ _builder.append("#include \"modelbase/etPort.h\"");
_builder.newLine();
_builder.newLine();
DetailCode _userCode1 = pc.getUserCode1();
@@ -193,7 +193,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append(_cHeaderFileName, "");
_builder.append("\"");
_builder.newLineIfNotEmpty();
- _builder.append("#include \"etMSCLogger.h\"");
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
_builder.newLine();
_builder.newLine();
DetailCode _userCode3 = pc.getUserCode3();
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
index 3ea4f0c18..1a508a747 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
@@ -237,9 +237,9 @@ public class SubSystemClassGen {
_builder.append("\"");
_builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.append("#include \"etLogger.h\"");
+ _builder.append("#include \"debugging/etLogger.h\"");
_builder.newLine();
- _builder.append("#include \"etMSCLogger.h\"");
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
_builder.newLine();
_builder.newLine();
_builder.newLine();
@@ -477,17 +477,12 @@ public class SubSystemClassGen {
_builder.append("*/");
_builder.newLine();
_builder.newLine();
- _builder.append("#include \"etMessageService.h\"");
+ _builder.append("#include \"messaging/etMessageService.h\"");
_builder.newLine();
+ _builder.append("#include \"platform/etMemory.h\"");
_builder.newLine();
- _builder.append("/* instantiation of message services */");
- _builder.newLine();
- _builder.newLine();
- _builder.append("/* pool and block size */");
_builder.newLine();
- _builder.append("#define MESSAGE_POOL_MAX 10");
- _builder.newLine();
- _builder.append("#define MESSAGE_BLOCK_SIZE 32");
+ _builder.append("/* instantiation of message services */");
_builder.newLine();
_builder.newLine();
_builder.append("/* MessageService for Thread1 */");
@@ -870,11 +865,11 @@ public class SubSystemClassGen {
_builder.append("*/");
_builder.newLine();
_builder.newLine();
- _builder.append("#include \"etMessageReceiver.h\"");
+ _builder.append("#include \"messaging/etMessageReceiver.h\"");
_builder.newLine();
- _builder.append("#include \"etLogger.h\"");
+ _builder.append("#include \"debugging/etLogger.h\"");
_builder.newLine();
- _builder.append("#include \"etMSCLogger.h\"");
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
_builder.newLine();
_builder.newLine();
_builder.append("static void MsgDispatcher_Thread1_receiveMessage(const etMessage* msg){");
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
index 125f76155..11ba80213 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
@@ -71,9 +71,11 @@ public class SubSystemRunnerGen {
_builder.append(".h\"");
_builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.append("#include \"etLogger.h\"");
+ _builder.append("#include \"debugging/etLogger.h\"");
_builder.newLine();
- _builder.append("#include \"etMSCLogger.h\"");
+ _builder.append("#include \"debugging/etMSCLogger.h\"");
+ _builder.newLine();
+ _builder.append("#include \"platform/etPlatform.h\"");
_builder.newLine();
_builder.newLine();
_builder.newLine();
@@ -91,6 +93,10 @@ public class SubSystemRunnerGen {
_builder.newLine();
_builder.append("int main(void) {");
_builder.newLine();
+ _builder.append("\t");
+ _builder.append("etUserEntry(); /* platform specific */");
+ _builder.newLine();
+ _builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("etLogger_logInfo(\"*** T H E B E G I N ***\");");
@@ -114,6 +120,10 @@ public class SubSystemRunnerGen {
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
+ _builder.append("etUserPreRun(); /* platform specific */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
_builder.append("/* run Scheduler */");
_builder.newLine();
_builder.append("\t");
@@ -123,6 +133,10 @@ public class SubSystemRunnerGen {
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
+ _builder.append("etUserPostRun(); /* platform specific */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
_builder.append("/* shutdown sequence of lifecycle */");
_builder.newLine();
_builder.append("\t");
@@ -144,6 +158,10 @@ public class SubSystemRunnerGen {
_builder.newLine();
_builder.newLine();
_builder.append("\t");
+ _builder.append("etUserExit(); /* platform specific */");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
_builder.append("return 0;");
_builder.newLine();
_builder.append("}");
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 51a8bd24d..f37afe00c 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
@@ -23,8 +23,8 @@ import org.eclipse.etrice.core.room.RoomClass
import org.eclipse.etrice.core.room.Message
import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
import org.eclipse.etrice.generator.etricegen.TransitionChain
-import org.eclipse.etrice.generator.generic.LanguageGenerator
import org.eclipse.etrice.generator.generic.ILanguageExtension
+import org.eclipse.etrice.generator.generic.AbstractLanguageGenerator
import java.util.List
import org.eclipse.xtext.util.Pair
@@ -32,7 +32,7 @@ import org.eclipse.xtext.util.Pair
@Singleton
class JavaExtensions implements ILanguageExtension {
- @Inject LanguageGenerator languageGen
+ @Inject AbstractLanguageGenerator languageGen
override String getTypedDataDefinition(Message m) {
@@ -86,4 +86,8 @@ class JavaExtensions implements ILanguageExtension {
def String getExecuteChainCode(ExpandedActorClass ac, TransitionChain tc) {
return languageGen.getExecuteChain(ac, tc)
}
-} \ No newline at end of file
+
+ override String arrayDeclaration(String type, int size, String name) {
+ type+" "+name+"[]";
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaLanguageGenerator.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaLanguageGenerator.java
new file mode 100644
index 000000000..02feb7c0b
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaLanguageGenerator.java
@@ -0,0 +1,30 @@
+package org.eclipse.etrice.generator.java.gen;
+
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.generic.AbstractLanguageGenerator;
+
+public class JavaLanguageGenerator extends AbstractLanguageGenerator {
+
+ @Override
+ 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};
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
index ded007498..e0d3f981a 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
@@ -88,21 +88,23 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
'''
}
- def portClass(ProtocolClass pc, Boolean conj) {'''
- «var name = pc.getPortClassName(conj)»
- «var pclass = pc.getPortClass(conj)»
+ def portClass(ProtocolClass pc, Boolean conj) {
+ var pclass = pc.getPortClass(conj)
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+ '''
// port class
- static public class «name» extends PortBase {
+ static public class «portClassName» extends PortBase {
«IF pclass!=null»
«helpers.userCode(pclass.userCode)»
«ENDIF»
// constructors
- public «name»(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ public «portClassName»(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
super(actor, name, localId, 0, addr, peerAddress);
DebuggingService.getInstance().addPortInstance(this);
}
- public «name»(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
+ public «portClassName»(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
super(actor, name, localId, idx, addr, peerAddress);
DebuggingService.getInstance().addPortInstance(this);
}
@@ -144,7 +146,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«IF pclass!=null»
«helpers.attributes(pclass.attributes)»
- «helpers.operationsImplementation(pclass.operations, name)»
+ «helpers.operationsImplementation(pclass.operations, portClassName)»
«ENDIF»
// sent messages
@@ -154,16 +156,16 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
}
// replicated port class
- static public class «name»Repl {
- private ArrayList<«name»> ports;
+ static public class «replPortClassName» {
+ private ArrayList<«portClassName»> ports;
private int replication;
- public «name»Repl(IEventReceiver actor, String name, int localId, Address[] addr,
+ public «replPortClassName»(IEventReceiver actor, String name, int localId, Address[] addr,
Address[] peerAddress) {
replication = addr.length;
- ports = new ArrayList<«pc.name».«name»>(replication);
+ ports = new ArrayList<«pc.name».«portClassName»>(replication);
for (int i=0; i<replication; ++i) {
- ports.add(new «name»(
+ ports.add(new «portClassName»(
actor, name+i, localId, i, addr[i], peerAddress[i]));
}
}
@@ -176,7 +178,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
return ifitem.getIdx();
}
- public «name» get(int i) {
+ public «portClassName» get(int i) {
return ports.get(i);
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java
index b5518d6d8..4c604f41e 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java
@@ -17,9 +17,11 @@ import org.eclipse.etrice.generator.base.DefaultTranslationProvider;
import org.eclipse.etrice.generator.base.GeneratorBaseModule;
import org.eclipse.etrice.generator.base.ITranslationProvider;
import org.eclipse.etrice.generator.java.Main;
+import org.eclipse.etrice.generator.java.gen.JavaLanguageGenerator;
import org.eclipse.etrice.generator.java.gen.MainGen;
import org.eclipse.xtext.generator.IGenerator;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.AbstractLanguageGenerator;
import org.eclipse.etrice.generator.java.gen.JavaExtensions;
@@ -39,6 +41,7 @@ public class GeneratorModule extends GeneratorBaseModule {
// bind language specific code to generic Interfaces
binder.bind(ILanguageExtension.class).to(JavaExtensions.class);
+ binder.bind(AbstractLanguageGenerator.class).to(JavaLanguageGenerator.class);
}
}
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
deleted file mode 100644
index 04905d5dd..000000000
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.RoomClass;
-import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.generator.etricegen.TransitionChain;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.LanguageGenerator;
-import org.eclipse.xtext.util.Pair;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-import org.eclipse.xtext.xtend2.lib.StringConcatenation;
-
-@SuppressWarnings("all")
-@Singleton
-public class JavaExtensions implements ILanguageExtension {
- @Inject
- private LanguageGenerator languageGen;
-
- public String getTypedDataDefinition(final Message m) {
- String _typedData = this.languageGen.getTypedData(m);
- return _typedData;
- }
-
- public String getJavaFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _operator_plus = StringExtensions.operator_plus(_name, ".java");
- return _operator_plus;
- }
-
- public String accessLevelPrivate() {
- return "private ";
- }
-
- public String accessLevelProtected() {
- return "protected ";
- }
-
- public String accessLevelPublic() {
- return "public ";
- }
-
- public String memberAccess() {
- return "this.";
- }
-
- public String selfPointer(final String classname, final boolean hasArgs) {
- return "";
- }
-
- public String selfPointer(final boolean hasArgs) {
- return "";
- }
-
- public String operationScope(final String classname, final boolean isDeclaration) {
- return "";
- }
-
- public String memberInDeclaration(final String namespace, final String member) {
- return member;
- }
-
- public String memberInUse(final String namespace, final String member) {
- String _operator_plus = StringExtensions.operator_plus(namespace, ".");
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, member);
- return _operator_plus_1;
- }
-
- public boolean usesInheritance() {
- return true;
- }
-
- public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Pair<String,String> entry : entries) {
- _builder.append("public static final int ");
- String _first = entry.getFirst();
- _builder.append(_first, "");
- _builder.append(" = ");
- String _second = entry.getSecond();
- _builder.append(_second, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- String _string = _builder.toString();
- return _string;
- }
-
- public String booleanConstant(final boolean b) {
- String _string = ((Boolean)b).toString();
- return _string;
- }
-
- public String nullPointer() {
- return "null";
- }
-
- public String voidPointer() {
- return "Object";
- }
-
- public String getExecuteChainCode(final ExpandedActorClass ac, final TransitionChain tc) {
- String _executeChain = this.languageGen.getExecuteChain(ac, tc);
- return _executeChain;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
index a7e5011a1..2e108a505 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
@@ -197,361 +197,365 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
}
public StringConcatenation portClass(final ProtocolClass pc, final Boolean conj) {
- StringConcatenation _builder = new StringConcatenation();
- String _portClassName = this.roomExt.getPortClassName(pc, conj);
- String name = _portClassName;
- _builder.newLineIfNotEmpty();
- PortClass _portClass = this.roomExt.getPortClass(pc, conj);
- PortClass pclass = _portClass;
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("// port class");
- _builder.newLine();
- _builder.append("static public class ");
- _builder.append(name, "");
- _builder.append(" extends PortBase {");
- _builder.newLineIfNotEmpty();
+ StringConcatenation _xblockexpression = null;
{
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(pclass, null);
- if (_operator_notEquals) {
- _builder.append("\t");
- DetailCode _userCode = pclass.getUserCode();
- StringConcatenation _userCode_1 = this.helpers.userCode(_userCode);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
+ PortClass _portClass = this.roomExt.getPortClass(pc, conj);
+ PortClass pclass = _portClass;
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("// port class");
+ _builder.newLine();
+ _builder.append("static public class ");
+ _builder.append(portClassName, "");
+ _builder.append(" extends PortBase {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(pclass, null);
+ if (_operator_notEquals) {
+ _builder.append("\t");
+ DetailCode _userCode = pclass.getUserCode();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
}
- }
- _builder.append("\t");
- _builder.append("// constructors");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(name, " ");
- _builder.append("(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("super(actor, name, localId, 0, addr, peerAddress);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("DebuggingService.getInstance().addPortInstance(this);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(name, " ");
- _builder.append("(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("super(actor, name, localId, idx, addr, peerAddress);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("DebuggingService.getInstance().addPortInstance(this);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void receive(Message m) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("if (!(m instanceof EventMessage))");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("return;");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("EventMessage msg = (EventMessage) m;");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("System.out.println(\"unknown\");");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("else {");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("if (messageStrings[msg.getEvtId()] != \"timerTick\"){");
- _builder.newLine();
- _builder.append("\t\t\t\t\t");
- _builder.append("DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("}");
- _builder.newLine();
- {
- boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
- if (_handlesReceive) {
- _builder.append("\t\t\t\t");
- _builder.append("switch (msg.getEvtId()) {");
- _builder.newLine();
- {
- List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
- for(final MessageHandler hdlr : _receiveHandlers) {
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("case ");
- Message _msg = hdlr.getMsg();
- String _codeName = this.roomExt.getCodeName(_msg);
- _builder.append(_codeName, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- {
- DetailCode _detailCode = hdlr.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String command : _commands) {
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("// constructors");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(portClassName, " ");
+ _builder.append("(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("super(actor, name, localId, 0, addr, peerAddress);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("DebuggingService.getInstance().addPortInstance(this);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(portClassName, " ");
+ _builder.append("(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("super(actor, name, localId, idx, addr, peerAddress);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("DebuggingService.getInstance().addPortInstance(this);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void receive(Message m) {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("if (!(m instanceof EventMessage))");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("return;");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("EventMessage msg = (EventMessage) m;");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("System.out.println(\"unknown\");");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("else {");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("if (messageStrings[msg.getEvtId()] != \"timerTick\"){");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t");
+ _builder.append("DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
+ if (_handlesReceive) {
+ _builder.append("\t\t\t\t");
+ _builder.append("switch (msg.getEvtId()) {");
+ _builder.newLine();
+ {
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
+ for(final MessageHandler hdlr : _receiveHandlers) {
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("case ");
+ Message _msg = hdlr.getMsg();
+ String _codeName = this.roomExt.getCodeName(_msg);
+ _builder.append(_codeName, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
}
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
}
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
}
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("default:");
+ _builder.newLine();
}
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("default:");
- _builder.newLine();
}
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("if (msg instanceof EventWithDataMessage)");
- _builder.newLine();
- _builder.append("\t\t\t\t\t\t");
- _builder.append("getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());");
- _builder.newLine();
- _builder.append("\t\t\t\t\t");
- _builder.append("else");
- _builder.newLine();
- _builder.append("\t\t\t\t\t\t");
- _builder.append("getActor().receiveEvent(this, msg.getEvtId(), null);");
- _builder.newLine();
- {
- boolean _handlesReceive_1 = this.roomExt.handlesReceive(pc, conj);
- if (_handlesReceive_1) {
- _builder.append("\t\t\t\t");
- _builder.append("}");
- _builder.newLine();
+ _builder.append("\t\t\t\t\t");
+ _builder.append("if (msg instanceof EventWithDataMessage)");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t\t");
+ _builder.append("getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t");
+ _builder.append("else");
+ _builder.newLine();
+ _builder.append("\t\t\t\t\t\t");
+ _builder.append("getActor().receiveEvent(this, msg.getEvtId(), null);");
+ _builder.newLine();
+ {
+ boolean _handlesReceive_1 = this.roomExt.handlesReceive(pc, conj);
+ if (_handlesReceive_1) {
+ _builder.append("\t\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
}
- }
- _builder.append("\t\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(pclass, null);
- if (_operator_notEquals_1) {
- _builder.append("\t");
- EList<Attribute> _attributes = pclass.getAttributes();
- StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<PortOperation> _operations = pclass.getOperations();
- StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, name);
- _builder.append(_operationsImplementation, " ");
- _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(pclass, null);
+ if (_operator_notEquals_1) {
+ _builder.append("\t");
+ EList<Attribute> _attributes = pclass.getAttributes();
+ StringConcatenation _attributes_1 = this.helpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ EList<PortOperation> _operations = pclass.getOperations();
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, portClassName);
+ _builder.append(_operationsImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ }
}
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// sent messages");
- _builder.newLine();
- {
- List<Message> _outgoing = this.roomExt.getOutgoing(pc, conj);
- for(final Message m : _outgoing) {
- _builder.append("\t");
- StringConcatenation _sendMessage = this.sendMessage(m, conj);
- _builder.append(_sendMessage, " ");
- _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// sent messages");
+ _builder.newLine();
+ {
+ List<Message> _outgoing = this.roomExt.getOutgoing(pc, conj);
+ for(final Message m : _outgoing) {
+ _builder.append("\t");
+ StringConcatenation _sendMessage = this.sendMessage(m, conj);
+ _builder.append(_sendMessage, " ");
+ _builder.newLineIfNotEmpty();
+ }
}
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("// replicated port class");
- _builder.newLine();
- _builder.append("static public class ");
- _builder.append(name, "");
- _builder.append("Repl {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("private ArrayList<");
- _builder.append(name, " ");
- _builder.append("> ports;");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("private int replication;");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(name, " ");
- _builder.append("Repl(IEventReceiver actor, String name, int localId, Address[] addr,");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("Address[] peerAddress) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("replication = addr.length;");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("ports = new ArrayList<");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.append(".");
- _builder.append(name, " ");
- _builder.append(">(replication);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("for (int i=0; i<replication; ++i) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("ports.add(new ");
- _builder.append(name, " ");
- _builder.append("(");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t\t\t");
- _builder.append("actor, name+i, localId, i, addr[i], peerAddress[i]));");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public int getReplication() {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return replication;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public int getIndexOf(InterfaceItemBase ifitem){");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return ifitem.getIdx();");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- _builder.append(name, " ");
- _builder.append(" get(int i) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("return ports.get(i);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- {
- if (conj) {
- _builder.append("\t");
- _builder.append("// incoming messages");
- _builder.newLine();
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\t");
- StringConcatenation _messageSignature = this.messageSignature(m_1);
- _builder.append(_messageSignature, " ");
- _builder.append("{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("for (int i=0; i<replication; ++i) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t\t");
- _builder.append("ports.get(i).");
- StringConcatenation _messageCall = this.messageCall(m_1);
- _builder.append(_messageCall, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("// replicated port class");
+ _builder.newLine();
+ _builder.append("static public class ");
+ _builder.append(replPortClassName, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("private ArrayList<");
+ _builder.append(portClassName, " ");
+ _builder.append("> ports;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("private int replication;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(replPortClassName, " ");
+ _builder.append("(IEventReceiver actor, String name, int localId, Address[] addr,");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("Address[] peerAddress) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("replication = addr.length;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("ports = new ArrayList<");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.append(".");
+ _builder.append(portClassName, " ");
+ _builder.append(">(replication);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("ports.add(new ");
+ _builder.append(portClassName, " ");
+ _builder.append("(");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t\t");
+ _builder.append("actor, name+i, localId, i, addr[i], peerAddress[i]));");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public int getReplication() {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return replication;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public int getIndexOf(InterfaceItemBase ifitem){");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return ifitem.getIdx();");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ _builder.append(portClassName, " ");
+ _builder.append(" get(int i) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("return ports.get(i);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ if (conj) {
+ _builder.append("\t");
+ _builder.append("// incoming messages");
+ _builder.newLine();
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\t");
+ StringConcatenation _messageSignature = this.messageSignature(m_1);
+ _builder.append(_messageSignature, " ");
+ _builder.append("{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append("ports.get(i).");
+ StringConcatenation _messageCall = this.messageCall(m_1);
+ _builder.append(_messageCall, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
}
- }
- } else {
- _builder.append("\t");
- _builder.append("// outgoing messages");
- _builder.newLine();
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m_2 : _allOutgoingMessages) {
- _builder.append("\t");
- StringConcatenation _messageSignature_1 = this.messageSignature(m_2);
- _builder.append(_messageSignature_1, " ");
- _builder.append("{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("for (int i=0; i<replication; ++i) {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t\t");
- _builder.append("ports.get(i).");
- StringConcatenation _messageCall_1 = this.messageCall(m_2);
- _builder.append(_messageCall_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
+ } else {
+ _builder.append("\t");
+ _builder.append("// outgoing messages");
+ _builder.newLine();
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m_2 : _allOutgoingMessages) {
+ _builder.append("\t");
+ StringConcatenation _messageSignature_1 = this.messageSignature(m_2);
+ _builder.append(_messageSignature_1, " ");
+ _builder.append("{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append("ports.get(i).");
+ StringConcatenation _messageCall_1 = this.messageCall(m_2);
+ _builder.append(_messageCall_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
}
}
}
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _xblockexpression = (_builder);
}
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- return _builder;
+ return _xblockexpression;
}
public StringConcatenation messageSignature(final Message m) {
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/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)
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
index cc45783bd..4f0c59f68 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/GenericStateMachineGenerator.java
@@ -23,9 +23,9 @@ import org.eclipse.etrice.generator.etricegen.ExpandedActorClass;
import org.eclipse.etrice.generator.etricegen.TransitionChain;
import org.eclipse.etrice.generator.extensions.RoomExtensions;
import org.eclipse.etrice.generator.extensions.RoomNameProv;
+import org.eclipse.etrice.generator.generic.AbstractLanguageGenerator;
import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.LanguageGenerator;
import org.eclipse.xtext.util.Pair;
import org.eclipse.xtext.util.Tuples;
import org.eclipse.xtext.xbase.lib.BooleanExtensions;
@@ -47,7 +47,7 @@ public class GenericStateMachineGenerator {
public GenericProtocolClassGenerator pcGen;
@Inject
- public LanguageGenerator languageGen;
+ public AbstractLanguageGenerator languageGen;
@Inject
public ITranslationProvider translator;
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
index 8306d6875..4ef74b649 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
@@ -81,10 +81,10 @@ public class ProcedureHelpers {
RefableType _refType_1 = attribute.getRefType();
DataType _type_1 = _refType_1.getType();
String _typeName_1 = this._typeHelpers.typeName(_type_1);
- _builder.append(_typeName_1, "");
- _builder.append("[] ");
+ int _size_1 = attribute.getSize();
String _name_1 = attribute.getName();
- _builder.append(_name_1, "");
+ String _arrayDeclaration = this.languageExt.arrayDeclaration(_typeName_1, _size_1, _name_1);
+ _builder.append(_arrayDeclaration, "");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TypeHelpers.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TypeHelpers.java
index a5adc82ba..32d8572db 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TypeHelpers.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/TypeHelpers.java
@@ -8,14 +8,14 @@ import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.PrimitiveType;
import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.generic.LanguageGenerator;
+import org.eclipse.etrice.generator.generic.AbstractLanguageGenerator;
import org.eclipse.xtext.xbase.lib.StringExtensions;
@SuppressWarnings("all")
@Singleton
public class TypeHelpers {
@Inject
- private LanguageGenerator languageGen;
+ private AbstractLanguageGenerator languageGen;
public String typeName(final DataType type) {
if ((type instanceof PrimitiveType)) {
diff --git a/plugins/org.eclipse.etrice.logging/bin/log4j.properties b/plugins/org.eclipse.etrice.logging/bin/log4j.properties
new file mode 100644
index 000000000..4bb6f37ad
--- /dev/null
+++ b/plugins/org.eclipse.etrice.logging/bin/log4j.properties
@@ -0,0 +1,7 @@
+log4j.rootCategory=INFO, S
+
+log4j.logger.org.eclipse.xtext=INFO
+
+log4j.appender.S = org.apache.log4j.ConsoleAppender
+log4j.appender.S.layout = org.apache.log4j.PatternLayout
+log4j.appender.S.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.zip
index 3fe0d83b9..2fe2588b2 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
index 31fb0f276..a8d15ba15 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
Binary files differ

Back to the top