summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Karlitschek2012-06-08 02:24:34 (EDT)
committerPeter Karlitschek2012-06-08 02:24:34 (EDT)
commitdac6231d8e0f7588110078496162f8de481ec801 (patch)
tree942ba90015b6bfc2074e802d9c95881237b02c82
parent838d39140604e6ec59b4b6e2233f2bae11849bd8 (diff)
downloadorg.eclipse.etrice-dac6231d8e0f7588110078496162f8de481ec801.zip
org.eclipse.etrice-dac6231d8e0f7588110078496162f8de481ec801.tar.gz
org.eclipse.etrice-dac6231d8e0f7588110078496162f8de481ec801.tar.bz2
Commit before pull of last etrice updates.refs/changes/20/8120/1
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.classbin6150 -> 6214 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$1.classbin1639 -> 1639 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$2.classbin1548 -> 1548 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$3.classbin1639 -> 1639 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$4.classbin1548 -> 1548 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.classbin17709 -> 21890 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend96
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.classbin2290 -> 2473 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$1.classbin0 -> 1726 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$2.classbin0 -> 1726 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.classbin0 -> 53380 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend619
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend96
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend619
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java5
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java335
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java5
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java2227
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.cpp/META-INF/MANIFEST.MF4
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/.cproject126
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/.project71
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/.settings/org.eclipse.cdt.managedbuilder.core.prefs9
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/Debug/liborg.eclipse.etrice.runtime.cpp.abin0 -> 55354 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/debugging/DebuggingService.obin0 -> 12007 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/messaging/Address.obin0 -> 8880 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/messaging/Message.obin0 -> 10402 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/modelbase/InterfaceItemBase.obin0 -> 10858 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/modelbase/PortBase.obin0 -> 11320 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp23
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h55
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp21
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h29
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp21
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h25
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp21
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h55
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.cpp21
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h28
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/platforms/generic/etDatatypes.h73
43 files changed, 4438 insertions, 162 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.class
index 750fb90..03021eb 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.class
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.class
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
index 8fb9d90..361deea 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
@@ -67,7 +67,7 @@ class CppExtensions implements ILanguageExtension {
override String genEnumeration(String name, List<Pair<String, String>> entries) {
'''
«FOR entry: entries»
- public static final int «entry.first» = «entry.second»;
+ static const int «entry.first» = «entry.second»;
«ENDFOR»
'''.toString
}
@@ -98,7 +98,7 @@ class CppExtensions implements ILanguageExtension {
}
def getIncludeGuardString(String filename){
- '''_«filename.toUpperCase»_H_'''
+ '''_«filename.replaceAll("\\/.", "_").toUpperCase»_H_'''
}
def generateIncludeGuardBegin(String filename){'''
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$1.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$1.class
index c13ade3..94ff085 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$1.class
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$1.class
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$2.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$2.class
index d9cc97d..c94b321 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$2.class
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$2.class
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$3.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$3.class
index b41de37..ba3280a 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$3.class
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$3.class
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$4.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$4.class
index 6f25c01..99adc7a 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$4.class
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen$4.class
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.class
index 5d653cf..9179633 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.class
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.class
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
index 41bb1a4..d88c900 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
@@ -25,7 +25,8 @@ import org.eclipse.etrice.generator.etricegen.Root
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.ProcedureHelpers
-import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.core.room.RoomModel
@Singleton
@@ -60,13 +61,20 @@ class DataClassGen {
def generateHeaderFile(Root root, DataClass dc) {
val ctor = dc.operations.filter(op|op.constructor).head
val dtor = dc.operations.filter(op|op.destructor).head
-
+ //TODO: getReferencedDataClasses does not contain a base class of the own package
'''
- «generateIncludeGuardBegin(dc.name)»
+ «generateIncludeGuardBegin(dc.path + dc.name)»
+
+ «IF dc.base!=null»
+ #include "«dc.base.name».h"
+ «ENDIF»
+ «FOR classes : root.getReferencedDataClasses(dc)»
+ #include "«classes.name».h"
+ «ENDFOR»
«var models = root.getReferencedModels(dc)»
«FOR model : models»
«FOR classes : model.dataClasses»
- #include «classes.path»«classes.name».h;
+ #include "«classes.path»«classes.name».h"
«ENDFOR»
«ENDFOR»
@@ -75,6 +83,7 @@ class DataClassGen {
class «dc.name»«IF dc.base!=null» : public «dc.base.name»«ENDIF» {
+ public:
«helpers.userCode(dc.userCode2)»
«helpers.attributes(dc.attributes)»
@@ -83,10 +92,10 @@ class DataClassGen {
«helpers.operationsDeclaration(dc.operations, dc.name)»
- // default constructor
+ // default constructor, copy constructor and assignment operator
«dc.name»();
«dc.name»(const «dc.name»& rhs);
- operator=(const «dc.name»& rhs);
+ «dc.name»& operator=(const «dc.name»& rhs);
// constructor using fields
«dc.name»(«dc.argList»);
@@ -107,47 +116,68 @@ class DataClassGen {
* @author generated by eTrice
*
* Source File of DataClass «dc.name»
- *
*/
#include "«dc.getCppHeaderFileName»"
- #include <string.h>
-
«helpers.userCode(dc.userCode3)»
-««« TODO: do we need setters and getters for C and C++ ?
- «dc.name»::«dc.name»() {
- «dc.attributes.attributeInitialization(true)»
+ // default constructor
+ «dc.name»::«dc.name»()
+ «IF dc.base!=null»
+ :«dc.base.name»()
+ «ENDIF»
+ {
+ «dc.attributes.attributeInitialization(false)»
«IF ctor!=null»
-
- {
- // user defined constructor body
- «FOR l : ctor.detailCode.commands»
- «l»
- «ENDFOR»
- }
+ {
+ // user defined constructor body
+ «FOR l : ctor.detailCode.commands»
+ «l»
+ «ENDFOR»
+ }
«ENDIF»
}
- // constructor using fields
+ // copy constructor
+ «dc.name»::«dc.name»(const «dc.name»& rhs)
+ :
+ «IF dc.base!=null»
+ «dc.base.name»(rhs),
+ «ENDIF»
+ «FOR a : dc.attributes SEPARATOR ","»
+ «a.name»(rhs.«a.name»)
+ «ENDFOR»
+ {
+ }
+
+ // constructor using fields
«dc.name»::«dc.name»(«dc.argList»)
+ :
«IF dc.base!=null»
- :«dc.base.name»(«dc.base.paramList»),
+ «dc.base.name»(«dc.base.paramList»),
«ENDIF»
- «FOR a : dc.attributes»
- «a.name»(«a.name»),
+ «FOR a : dc.attributes SEPARATOR ","»
+ «a.name»(«a.name»_)
«ENDFOR»
{
}
- «helpers.operationsImplementation(dc.operations, dc.name)»
+ // assignment operator
+ «dc.name»& «dc.name»::operator=(const «dc.name»& rhs)
+ {
+ if (this == &rhs) { return *this; };
+ «IF dc.base!=null»
+ «dc.base.name»::operator=(rhs);
+ «ENDIF»
+ «FOR a : dc.attributes»
+ «a.name»= rhs.«a.name»;
+ «ENDFOR»
+ return *this;
+ }
- // deep copy
- void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target) {
- memcpy(target, source, sizeof(«dc.name»));
- }
+ «helpers.operationsImplementation(dc.operations, dc.name)»
'''}
@@ -164,14 +194,14 @@ class DataClassGen {
}
def paramList(List<Attribute> attributes) {
- '''«FOR a: attributes SEPARATOR ", "»«a.name»«ENDFOR»'''
+ '''«FOR a: attributes SEPARATOR ", "»«a.name»_«ENDFOR»'''
}
def argList(DataClass _dc) {
var result = ""
var dc = _dc
while (dc!=null) {
- result = dc.attributes.argList.toString + result
+ result = dc.attributes.argListConstructor.toString + result
dc = dc.base
if (dc!=null)
result = ", "+result
@@ -179,6 +209,12 @@ class DataClassGen {
return result
}
+ def argListConstructor(List<Attribute> attributes) {
+ '''«FOR a : attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>1»[]«ENDIF» «a.name»_«ENDFOR»'''
+ }
+
+
+
def deepCopy(DataClass _dc) {
var result = ""
var dc = _dc
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.class
index 19f3dda..d991099 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.class
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.class
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
index 3f2fea7..71bb376 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
@@ -24,7 +24,7 @@ import org.eclipse.etrice.generator.generic.PrepareFileSystem
class MainGen implements IGenerator {
@Inject DataClassGen dataClassGen
-// @Inject ProtocolClassGen protocolClassGen
+ @Inject ProtocolClassGen protocolClassGen
// @Inject ActorClassGen actorClassGen
// @Inject SubSystemClassGen subsystemClassGen
// @Inject SubSystemRunnerGen subsystemRunnerGen
@@ -41,7 +41,7 @@ class MainGen implements IGenerator {
def void doGenerate(Root e) {
dataClassGen.doGenerate(e);
-// protocolClassGen.doGenerate(e);
+ protocolClassGen.doGenerate(e);
// actorClassGen.doGenerate(e);
// subsystemClassGen.doGenerate(e);
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$1.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$1.class
new file mode 100644
index 0000000..ae13d5b
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$1.class
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$2.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$2.class
new file mode 100644
index 0000000..a9ff6f1
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen$2.class
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.class b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.class
new file mode 100644
index 0000000..7212cb0
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.class
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
new file mode 100644
index 0000000..7de4158
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/bin/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
@@ -0,0 +1,619 @@
+/*******************************************************************************
+ * 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.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.core.room.CommunicationType
+import org.eclipse.etrice.core.room.PrimitiveType
+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.generic.RoomExtensions
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
+import org.eclipse.etrice.core.room.DataClass
+
+
+@Singleton
+class ProtocolClassGen extends GenericProtocolClassGenerator {
+
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject extension CppExtensions stdExt
+ @Inject extension RoomExtensions roomExt
+ @Inject extension ProcedureHelpers helpers
+ @Inject extension TypeHelpers
+ @Inject ILogger logger
+
+ def doGenerate(Root root) {
+ for (pc: root.usedProtocolClasses) {
+ var path = pc.generationTargetPath+pc.getPath
+
+ logger.logInfo("generating ProtocolClass header '"+pc.getCppHeaderFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(pc.getCppHeaderFileName, root.generateHeaderFile(pc))
+
+ logger.logInfo("generating ProtocolClass source '"+pc.getCppSourceFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(pc.getCppSourceFileName, root.generateSourceFile(pc))
+ }
+ }
+
+
+ def private generateHeaderFile(Root root, ProtocolClass pc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of ProtocolClass «pc.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(pc.name)»
+
+ #include "platforms/generic/etDatatypes.h"
+ #include "common/modelbase/PortBase.h"
+ #include "common/modelbase/InterfaceItemBase.h"
+ #include "common/messaging/Address.h"
+ #include "common/messaging/Message.h"
+ #include <list>
+
+ namespace etRuntime {
+ class IEventReceiver;
+ }
+
+ «helpers.userCode(pc.userCode1)»
+
+ «FOR dataClass : root.getReferencedDataClasses(pc)»
+ #include "«dataClass.name».h"
+ «ENDFOR»
+
+ class «pc.name» {
+ public:
+ «IF pc.commType==CommunicationType::EVENT_DRIVEN» /* message IDs */
+ «genMessageIDs(pc)»
+ «ELSEIF pc.commType==CommunicationType::DATA_DRIVEN»
+ «ELSEIF pc.commType==CommunicationType::SYNCHRONOUS»
+ #error "synchronous protocols not implemented yet"
+ «ENDIF»
+ «helpers.userCode(pc.userCode2)»
+
+ private:
+ static char messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR» «FOR m : pc.getAllIncomingMessages()»"«m.name»",«ENDFOR»"MAX"};
+
+ public:
+ char* getMessageString(int msg_id);
+
+ «portClassDeclaration(pc, false)»
+ «portClassDeclaration(pc, true)»
+ };
+ «generateIncludeGuardEnd(pc.name)»
+ '''
+ }
+
+ def portClassDeclaration(ProtocolClass pc, Boolean conj) {
+ var pclass = pc.getPortClass(conj)
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+ '''
+ //------------------------------------------------------------------------------------------------------------
+ // «IF conj»conjugated «ENDIF»port class
+ //------------------------------------------------------------------------------------------------------------
+ class «portClassName» : public etRuntime::PortBase {
+ «IF pclass!=null»
+ «helpers.userCode(pclass.userCode)»
+ «ENDIF»
+ public:
+ // constructors
+ «portClassName»(etRuntime::IEventReceiver actor, char* name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress);
+ «portClassName»(etRuntime::IEventReceiver actor, char* name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress);
+
+ virtual void receive(etRuntime::Message m);
+ «IF pclass!=null»
+ «helpers.attributes(pclass.attributes)»
+ «helpers.operationsDeclaration(pclass.operations, portClassName)»
+ «ENDIF»
+
+ // sent messages
+ «FOR m : pc.getOutgoing(conj)»
+ «sendMessageDeclaration(m,conj)»
+ «ENDFOR»
+ };
+
+ //------------------------------------------------------------------------------------------------------------
+ // «IF conj»conjugated «ENDIF»replicated port class
+ //------------------------------------------------------------------------------------------------------------
+ class «replPortClassName» {
+ private:
+ std::list<«portClassName»> ports;
+ int replication;
+
+ public:
+ // constructor
+ «replPortClassName»(etRuntime::IEventReceiver actor, char* name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress);
+
+ int getReplication() { return replication; }
+ int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx(); }
+ «portClassName» get(int i) {return ports[i];}
+
+ «IF pc.commType==CommunicationType::EVENT_DRIVEN»
+ «IF conj»
+ // incoming messages
+
+ «FOR m : pc.getAllIncomingMessages()» «messageSignature(m)»;
+ «ENDFOR»
+ «ELSE»
+ // outgoing messages
+ «FOR m : pc.getAllOutgoingMessages()» «messageSignature(m)»;
+ «ENDFOR»
+ «ENDIF»
+ «ELSEIF pc.commType==CommunicationType::DATA_DRIVEN»
+ /*--------------------- port structs and methods */
+ «pc.genDataDrivenPortHeaders»
+ «ELSEIF pc.commType==CommunicationType::SYNCHRONOUS»
+ #error "synchronous protocols not implemented yet"
+ «ENDIF»
+
+ };
+ '''
+ }
+
+ def portClassImplementation(ProtocolClass pc, Boolean conj) {
+ var pclass = pc.getPortClass(conj)
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+ '''
+ «pc.name»::«portClassName»::«portClassName»(IEventReceiver actor, char* name, int localId, Address addr, Address peerAddress)
+ : PortBase(actor, name, localId, 0, addr, peerAddress)
+ {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+
+ «pc.name»::«portClassName»::«portClassName»(IEventReceiver actor, char* name, int localId, int idx, Address addr, Address peerAddress)
+ : PortBase(actor, name, localId, idx, addr, peerAddress)
+ {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+
+ void «pc.name»::«portClassName»::receive(Message m) {
+ if (!(m instanceof EventMessage)) return;
+ EventMessage msg = (EventMessage) m;
+ if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
+ System.out.println("unknown");
+ else {
+ if (messageStrings[msg.getEvtId()] != "timerTick"){
+««« TODOTS: model switch for activation
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
+ }
+ }
+ «IF pc.handlesReceive(conj)»
+ switch (msg.getEvtId()) {
+ «FOR hdlr : pc.getReceiveHandlers(conj)»
+ case «hdlr.msg.getCodeName()»:
+ {
+ «FOR command : hdlr.detailCode.commands»
+ «command»
+ «ENDFOR»
+ }
+ break;
+ «ENDFOR»
+ default:
+ «ENDIF»
+ if (msg instanceof EventWithDataMessage)
+ getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+ else
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ «IF pc.handlesReceive(conj)»
+ }
+ «ENDIF»
+ }
+ «IF pclass!=null»
+ «helpers.operationsImplementation(pclass.operations, portClassName)»
+ «ENDIF»
+
+ // sent messages
+ «FOR m : pc.getOutgoing(conj)»
+ «sendMessage(m, pc.name + "::" + portClassName, conj)»
+ «ENDFOR»
+
+ //-------------------------------------------------------------------------------
+ // replicated port class
+ //-------------------------------------------------------------------------------
+ «pc.name»::«replPortClassName»::«replPortClassName»(IEventReceiver actor, char* name, int localId, Address addr, Address peerAddress) {
+ replication = addr==null? 0:addr.length;
+ ports = new ArrayList<«pc.name».«portClassName»>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new «portClassName»(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ «IF conj»
+ // incoming messages
+ «FOR m : pc.getAllIncomingMessages()»
+ «messageSignatureDefinition(m, pc.name + "::" + replPortClassName)»{
+ for (int i=0; i<replication; ++i) {
+ ports[i].«messageCall(m)»;
+ }
+ }
+ «ENDFOR»
+ «ELSE»
+ // outgoing messages
+ «FOR m : pc.getAllOutgoingMessages()»
+ «messageSignatureDefinition(m, pc.name + "::" + replPortClassName)»{
+ for (int i=0; i<replication; ++i) {
+ ports[i].«messageCall(m)»;
+ }
+ }
+ «ENDFOR»
+ «ENDIF»
+ '''
+ }
+
+ def private generateSourceFile(Root root, ProtocolClass pc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of ProtocolClass «pc.name»
+ *
+ */
+
+ #include "«pc.getCppHeaderFileName»"
+ #include "common/debugging/DebuggingService.h"
+
+ using namespace etRuntime;
+
+ «helpers.userCode(pc.userCode3)»
+
+ «IF pc.commType==CommunicationType::EVENT_DRIVEN»
+
+ //----------------------------------------------
+ // java code
+ //----------------------------------------------
+
+ «helpers.userCode(pc.userCode2)»
+
+ //private static char* messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR» «FOR m : pc.getAllIncomingMessages()»"«m.name»",«ENDFOR»"MAX"};
+
+ char* «pc.name»::getMessageString(int msg_id) {
+ if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){
+ // id out of range
+ return "Message ID out of range";
+ }
+ else{
+ return messageStrings[msg_id];
+ }
+ }
+
+ «portClassImplementation(pc, false)»
+ «portClassImplementation(pc, true)»
+
+ /*--------------------- debug helpers */
+ «generateDebugHelpersImplementation(root, pc)»
+ «ELSEIF pc.commType==CommunicationType::DATA_DRIVEN»
+ «pc.genDataDrivenPortSources»
+ «ELSEIF pc.commType==CommunicationType::SYNCHRONOUS»
+ #error "synchronoue protocols not implemented yet"
+ «ENDIF»
+
+
+ '''
+ }
+
+ def private portClassHeader(ProtocolClass pc, Boolean conj){
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+ var messages = if (conj) pc.allIncomingMessages else pc.allOutgoingMessages
+
+ '''
+ typedef etPort «portClassName»;
+ typedef etReplPort «replPortClassName»;
+
+ «IF pc.getPortClass(conj)!=null»
+ «IF !(pc.getPortClass(conj).attributes.empty)»
+/* variable part of PortClass (RAM) */
+typedef struct «portClassName»_var «portClassName»_var;
+struct «portClassName»_var {
+ «helpers.attributes(pc.getPortClass(conj).attributes)»
+ };
+ «FOR a:pc.getPortClass(conj).attributes»
+ «IF a.defaultValueLiteral!=null»
+ «logger.logInfo(portClassName+" "+a.name+": Attribute initialization not supported in C")»
+ «ENDIF»
+ «ENDFOR»
+ «ENDIF»
+ «ENDIF»
+
+ «FOR message : messages»
+ «var hasData = message.data!=null»
+ «var typeName = if (hasData) message.data.refType.type.typeName else ""»
+ «var refp = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
+ «var data = if (hasData) ", "+typeName+refp+" data" else ""»
+ «messageSignature(portClassName, message.name, "", data)»;
+ «messageSignature(replPortClassName, message.name, "_broadcast", data)»;
+ «messageSignature(replPortClassName, message.name, "", ", int idx"+data)»;
+ «ENDFOR»
+
+ «IF (pc.getPortClass(conj) != null)»
+ «helpers.operationsDeclaration(pc.getPortClass(conj).operations, portClassName)»
+ «helpers.operationsDeclaration(pc.getPortClass(conj).operations, replPortClassName)»
+ «ENDIF»
+
+ «IF pc.handlesReceive(conj)»
+ «FOR h:getReceiveHandlers(pc,conj)»
+void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);
+ «ENDFOR»
+ «ENDIF»
+ '''
+ }
+
+
+
+ def private genDataDrivenPortHeaders(ProtocolClass pc) {
+ var sentMsgs = pc.allIncomingMessages.filter(m|m.data!=null)
+
+ '''
+ /* data driven send port (conjugated) */
+ typedef struct {
+ «FOR msg : sentMsgs»
+ «var typeName = msg.data.refType.type.typeName»
+ «var refp = if (msg.data.refType.ref) "*" else ""»
+ «typeName»«refp» «msg.name»;
+ «ENDFOR»
+ }
+ «pc.getPortClassName(true)»;
+
+ /* data driven receive port (regular) */
+ typedef struct {
+ const «pc.getPortClassName(true)»* peer;
+ }
+ «pc.getPortClassName(false)»;
+
+ «FOR message : sentMsgs»
+ «var hasData = message.data!=null»
+ «var typeName = if (hasData) message.data.refType.type.typeName else ""»
+ «var refp = if (hasData && !(message.data.refType.type instanceof PrimitiveType)) "*" else ""»
+ «var data = if (hasData) ", "+typeName+refp+" data" else ""»
+ «messageSetterSignature(pc.getPortClassName(true), message.name, data)»;
+ «messageGetterSignature(pc.getPortClassName(false), message.name, typeName)»;
+
+ «ENDFOR»
+ '''
+ }
+ def private genDataDrivenPortSources(ProtocolClass pc) {
+ var messages = pc.allIncomingMessages.filter(m|m.data!=null)
+ '''
+ «FOR message : messages»
+ «var typeName =message.data.refType.type.typeName»
+ «var refp = if (!(message.data.refType.type instanceof PrimitiveType)) "*" else ""»
+ «var refa = if ((message.data.refType.type instanceof PrimitiveType)) "&" else ""»
+ «var data = ", "+typeName+refp+" data"»
+ «messageSetterSignature(pc.getPortClassName(true), message.name, data)» {
+ self->«message.name» = data;
+ }
+ «messageGetterSignature(pc.getPortClassName(false), message.name, typeName)» {
+ return self->peer->«message.name»;
+ }
+
+ «ENDFOR»
+ '''
+ }
+
+ def private portClassSource(ProtocolClass pc, Boolean conj){
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+ var messages = if (conj) pc.allIncomingMessages else pc.allOutgoingMessages
+ var dir = if (conj) "IN_" else "OUT_"
+
+ '''
+ «FOR message : messages»
+ «var hasData = message.data!=null»
+ «var typeName = if (hasData) message.data.refType.type.typeName else ""»
+ «var refp = if (hasData && ((message.data.refType.ref))) "*" else ""»
+ «var refpd = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
+ «var refa = if (hasData && (!(message.data.refType.type instanceof PrimitiveType))&&(!(message.data.refType.ref))) "" else "&"»
+ «var data = if (hasData) ", "+typeName+refpd+" data" else ""»
+ «var dataCall = if (hasData) ", data" else ""»
+ «var hdlr = message.getSendHandler(conj)»
+
+ «messageSignature(portClassName, message.name, "", data)» {
+ «IF hdlr != null»
+ «FOR command : hdlr.detailCode.commands» «command»
+ «ENDFOR»
+ «ELSE»
+ ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
+ «sendMessageCall(hasData, "self", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
+ ET_MSC_LOGGER_SYNC_EXIT
+ «ENDIF»
+ }
+
+ «messageSignature(replPortClassName, message.name, "_broadcast", data)» {
+ «IF hdlr != null»
+ int i;
+ for (i=0; i<((etReplPort*)self)->size; ++i) {
+ «portClassName»_«message.name»((etPort*)&((etReplPort*)self)->ports[i]«dataCall»);
+ }
+ «ELSE»
+ int i;
+ ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
+ for (i=0; i<((etReplPort*)self)->size; ++i) {
+ «sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[i])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+ «ENDIF»
+ }
+
+ «messageSignature(replPortClassName, message.name, "", ", int idx"+data)» {
+ «IF hdlr != null»
+ «portClassName»_«message.name»((etPort*)&((etReplPort*)self)->ports[idx]«dataCall»);
+ «ELSE»
+ ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
+ if (0<=idx && idx<((etReplPort*)self)->size) {
+ «sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[idx])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+ «ENDIF»
+ }
+ «ENDFOR»
+
+ «IF (pc.getPortClass(conj) != null)»
+ «helpers.operationsImplementation(pc.getPortClass(conj).operations, portClassName)»
+ «helpers.operationsImplementation(pc.getPortClass(conj).operations, replPortClassName)»
+ «ENDIF»
+
+ // getReplication
+ etInt32 «replPortClassName»_getReplication(const «replPortClassName»* self) {
+ return ((etReplPort*)self)->size;
+ }
+
+ «IF pc.handlesReceive(conj)»
+ «genReceiveHandlers(pc,conj)»
+ «ENDIF»
+
+ '''
+ }
+
+ def private sendMessageCall(boolean hasData, String self, String msg, String typeName, String data) {
+ if (hasData)
+ "etPort_sendMessage("+self+", "+msg+", sizeof("+typeName+"), "+data+");"
+ else
+ "etPort_sendMessage("+self+", "+msg+", 0, NULL);"
+ }
+
+ def private messageSignature(String className, String messageName, String methodSuffix, String data) {
+ "void "+className+"_"+messageName+methodSuffix+"(const "+className+"* self"+data+")"
+ }
+
+ def private messageSetterSignature(String className, String messageName, String data) {
+ "void "+className+"_"+messageName+"_set("+className+"* self"+data+")"
+ }
+
+ def private messageGetterSignature(String className, String messageName, String type) {
+ type+" "+className+"_"+messageName+"_get(const "+className+"* const self)"
+ }
+
+ def private messageCall(Message m) {'''
+ «m.name»(«IF m.data!=null» «m.data.name»«ENDIF»)
+ '''}
+
+// def sendMessage(Message m, boolean conj) {'''
+// «var dir = if (conj) "IN" else "OUT"»
+// «var hdlr = m.getSendHandler(conj)»
+// «messageSignature(m)»{
+// if (getPeerAddress()!=null)
+// «IF m.data==null»getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), «dir»_«m.name»));
+// «ELSE»getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), «dir»_«m.name», «m.data.name»«IF (!m.data.ref)».deepCopy()«ENDIF»));
+// «ENDIF»
+// }
+// '''
+// }
+
+ def private genReceiveHandlers(ProtocolClass pc, Boolean conj){
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+
+ '''
+ /* receiver handlers */
+ «FOR h:getReceiveHandlers(pc,conj)»
+ void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){
+ «userCode(h.detailCode)»
+ /* hand over the message to the actor: */
+ /* (*receiveMessageFunc)(actor, self, msg); */
+ }
+ «ENDFOR»
+ '''}
+
+
+
+ def private generateDebugHelpersImplementation(Root root, ProtocolClass pc){'''
+
+««« TODO: make this optional or different for smaller footprint
+ /* message names as strings for debugging (generate MSC) */
+ static const char* «pc.name»_messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR»«FOR m : pc.getAllIncomingMessages()»"«m.name»", «ENDFOR»"MAX"};
+
+ const char* «pc.name»_getMessageString(int msg_id) {
+ if (msg_id<«pc.name»_MSG_MIN || msg_id>«pc.name»_MSG_MAX+1){
+ /* id out of range */
+ return "Message ID out of range";
+ }
+ else{
+ return «pc.name»_messageStrings[msg_id];
+ }
+ }
+ '''
+ }
+
+ //----------------------------------------------------
+ // from java generator
+ //---------------------------------------------------
+ def messageSignature(Message m) {
+ '''«IF m.priv»private:«ELSE»public:«ENDIF» void «m.name»(«IF m.data!=null»«m.data.refType.type.typeName» «m.data.name»«ENDIF»)'''
+ }
+
+ def messageSignatureExplicit(Message m) {
+ var dc = (m.data.refType.type as DataClass)
+ '''public: void «m.name»(«IF dc.base!=null»«dc.base.typeName» _super, «ENDIF»«FOR a : dc.attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>1»[]«ENDIF» «a.name»«ENDFOR»)'''
+ }
+
+ def messageSignatureDefinition(Message m, String classPrefix) {
+ '''void «classPrefix»::«m.name»(«IF m.data!=null»«m.data.refType.type.typeName» «m.data.name»«ENDIF»)'''
+ }
+
+ def messageSignatureExplicitDefinition(Message m, String classPrefix) {
+ var dc = (m.data.refType.type as DataClass)
+ '''void «classPrefix»::«m.name»(«IF dc.base!=null»«dc.base.typeName» _super, «ENDIF»«FOR a : dc.attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>1»[]«ENDIF» «a.name»«ENDFOR»)'''
+ }
+
+// def messageCall(Message m) {
+// '''«m.name»(«IF m.data!=null» «m.data.name»«ENDIF»)'''
+// }
+
+ def sendMessageDeclaration(Message m, boolean conj) {
+ '''
+ «messageSignature(m)»;
+ «IF m.data!=null && m.data.refType.type instanceof DataClass»
+ «messageSignatureExplicit(m)»;
+ «ENDIF»
+ '''
+ }
+ def sendMessage(Message m, String classPrefix, boolean conj) {
+ var dir = if (conj) "IN" else "OUT"
+ var hdlr = m.getSendHandler(conj)
+ '''
+ «messageSignatureDefinition(m, classPrefix)» {
+ «IF hdlr!=null»
+ «FOR command : hdlr.detailCode.commands» «command»
+ «ENDFOR»
+ «ELSE»
+ if (messageStrings[ «dir»_«m.name»] != "timerTick"){
+««« TODOTS: model switch for activation
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[«dir»_«m.name»]);
+ }
+ if (getPeerAddress()!=null)
+ «IF m.data==null»getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), «dir»_«m.name»));
+ «ELSE»getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), «dir»_«m.name», «m.data.name»«IF (!m.data.refType.ref && !(m.data.refType.type instanceof PrimitiveType))».deepCopy()«ENDIF»));
+ «ENDIF»
+ «ENDIF»
+ }
+ «IF m.data!=null && m.data.refType.type instanceof DataClass»
+ «messageSignatureExplicitDefinition(m, classPrefix)» {
+ «m.name»(new «m.data.refType.type.name»(«IF (m.data.refType.type as DataClass).base!=null»_super, «ENDIF»«FOR a : (m.data.refType.type as DataClass).attributes SEPARATOR ", "»«a.name»«ENDFOR»));
+ }
+ «ENDIF»
+ '''
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
index 8fb9d90..361deea 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
@@ -67,7 +67,7 @@ class CppExtensions implements ILanguageExtension {
override String genEnumeration(String name, List<Pair<String, String>> entries) {
'''
«FOR entry: entries»
- public static final int «entry.first» = «entry.second»;
+ static const int «entry.first» = «entry.second»;
«ENDFOR»
'''.toString
}
@@ -98,7 +98,7 @@ class CppExtensions implements ILanguageExtension {
}
def getIncludeGuardString(String filename){
- '''_«filename.toUpperCase»_H_'''
+ '''_«filename.replaceAll("\\/.", "_").toUpperCase»_H_'''
}
def generateIncludeGuardBegin(String filename){'''
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
index 41bb1a4..d88c900 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
@@ -25,7 +25,8 @@ import org.eclipse.etrice.generator.etricegen.Root
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.ProcedureHelpers
-import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.core.room.RoomModel
@Singleton
@@ -60,13 +61,20 @@ class DataClassGen {
def generateHeaderFile(Root root, DataClass dc) {
val ctor = dc.operations.filter(op|op.constructor).head
val dtor = dc.operations.filter(op|op.destructor).head
-
+ //TODO: getReferencedDataClasses does not contain a base class of the own package
'''
- «generateIncludeGuardBegin(dc.name)»
+ «generateIncludeGuardBegin(dc.path + dc.name)»
+
+ «IF dc.base!=null»
+ #include "«dc.base.name».h"
+ «ENDIF»
+ «FOR classes : root.getReferencedDataClasses(dc)»
+ #include "«classes.name».h"
+ «ENDFOR»
«var models = root.getReferencedModels(dc)»
«FOR model : models»
«FOR classes : model.dataClasses»
- #include «classes.path»«classes.name».h;
+ #include "«classes.path»«classes.name».h"
«ENDFOR»
«ENDFOR»
@@ -75,6 +83,7 @@ class DataClassGen {
class «dc.name»«IF dc.base!=null» : public «dc.base.name»«ENDIF» {
+ public:
«helpers.userCode(dc.userCode2)»
«helpers.attributes(dc.attributes)»
@@ -83,10 +92,10 @@ class DataClassGen {
«helpers.operationsDeclaration(dc.operations, dc.name)»
- // default constructor
+ // default constructor, copy constructor and assignment operator
«dc.name»();
«dc.name»(const «dc.name»& rhs);
- operator=(const «dc.name»& rhs);
+ «dc.name»& operator=(const «dc.name»& rhs);
// constructor using fields
«dc.name»(«dc.argList»);
@@ -107,47 +116,68 @@ class DataClassGen {
* @author generated by eTrice
*
* Source File of DataClass «dc.name»
- *
*/
#include "«dc.getCppHeaderFileName»"
- #include <string.h>
-
«helpers.userCode(dc.userCode3)»
-««« TODO: do we need setters and getters for C and C++ ?
- «dc.name»::«dc.name»() {
- «dc.attributes.attributeInitialization(true)»
+ // default constructor
+ «dc.name»::«dc.name»()
+ «IF dc.base!=null»
+ :«dc.base.name»()
+ «ENDIF»
+ {
+ «dc.attributes.attributeInitialization(false)»
«IF ctor!=null»
-
- {
- // user defined constructor body
- «FOR l : ctor.detailCode.commands»
- «l»
- «ENDFOR»
- }
+ {
+ // user defined constructor body
+ «FOR l : ctor.detailCode.commands»
+ «l»
+ «ENDFOR»
+ }
«ENDIF»
}
- // constructor using fields
+ // copy constructor
+ «dc.name»::«dc.name»(const «dc.name»& rhs)
+ :
+ «IF dc.base!=null»
+ «dc.base.name»(rhs),
+ «ENDIF»
+ «FOR a : dc.attributes SEPARATOR ","»
+ «a.name»(rhs.«a.name»)
+ «ENDFOR»
+ {
+ }
+
+ // constructor using fields
«dc.name»::«dc.name»(«dc.argList»)
+ :
«IF dc.base!=null»
- :«dc.base.name»(«dc.base.paramList»),
+ «dc.base.name»(«dc.base.paramList»),
«ENDIF»
- «FOR a : dc.attributes»
- «a.name»(«a.name»),
+ «FOR a : dc.attributes SEPARATOR ","»
+ «a.name»(«a.name»_)
«ENDFOR»
{
}
- «helpers.operationsImplementation(dc.operations, dc.name)»
+ // assignment operator
+ «dc.name»& «dc.name»::operator=(const «dc.name»& rhs)
+ {
+ if (this == &rhs) { return *this; };
+ «IF dc.base!=null»
+ «dc.base.name»::operator=(rhs);
+ «ENDIF»
+ «FOR a : dc.attributes»
+ «a.name»= rhs.«a.name»;
+ «ENDFOR»
+ return *this;
+ }
- // deep copy
- void «dc.name»_deepCopy(«dc.name»* source, «dc.name»* target) {
- memcpy(target, source, sizeof(«dc.name»));
- }
+ «helpers.operationsImplementation(dc.operations, dc.name)»
'''}
@@ -164,14 +194,14 @@ class DataClassGen {
}
def paramList(List<Attribute> attributes) {
- '''«FOR a: attributes SEPARATOR ", "»«a.name»«ENDFOR»'''
+ '''«FOR a: attributes SEPARATOR ", "»«a.name»_«ENDFOR»'''
}
def argList(DataClass _dc) {
var result = ""
var dc = _dc
while (dc!=null) {
- result = dc.attributes.argList.toString + result
+ result = dc.attributes.argListConstructor.toString + result
dc = dc.base
if (dc!=null)
result = ", "+result
@@ -179,6 +209,12 @@ class DataClassGen {
return result
}
+ def argListConstructor(List<Attribute> attributes) {
+ '''«FOR a : attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>1»[]«ENDIF» «a.name»_«ENDFOR»'''
+ }
+
+
+
def deepCopy(DataClass _dc) {
var result = ""
var dc = _dc
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
index 3f2fea7..71bb376 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/MainGen.xtend
@@ -24,7 +24,7 @@ import org.eclipse.etrice.generator.generic.PrepareFileSystem
class MainGen implements IGenerator {
@Inject DataClassGen dataClassGen
-// @Inject ProtocolClassGen protocolClassGen
+ @Inject ProtocolClassGen protocolClassGen
// @Inject ActorClassGen actorClassGen
// @Inject SubSystemClassGen subsystemClassGen
// @Inject SubSystemRunnerGen subsystemRunnerGen
@@ -41,7 +41,7 @@ class MainGen implements IGenerator {
def void doGenerate(Root e) {
dataClassGen.doGenerate(e);
-// protocolClassGen.doGenerate(e);
+ protocolClassGen.doGenerate(e);
// actorClassGen.doGenerate(e);
// subsystemClassGen.doGenerate(e);
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
new file mode 100644
index 0000000..7de4158
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
@@ -0,0 +1,619 @@
+/*******************************************************************************
+ * 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.cpp.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.core.room.CommunicationType
+import org.eclipse.etrice.core.room.PrimitiveType
+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.generic.RoomExtensions
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
+import org.eclipse.etrice.core.room.DataClass
+
+
+@Singleton
+class ProtocolClassGen extends GenericProtocolClassGenerator {
+
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject extension CppExtensions stdExt
+ @Inject extension RoomExtensions roomExt
+ @Inject extension ProcedureHelpers helpers
+ @Inject extension TypeHelpers
+ @Inject ILogger logger
+
+ def doGenerate(Root root) {
+ for (pc: root.usedProtocolClasses) {
+ var path = pc.generationTargetPath+pc.getPath
+
+ logger.logInfo("generating ProtocolClass header '"+pc.getCppHeaderFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(pc.getCppHeaderFileName, root.generateHeaderFile(pc))
+
+ logger.logInfo("generating ProtocolClass source '"+pc.getCppSourceFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(pc.getCppSourceFileName, root.generateSourceFile(pc))
+ }
+ }
+
+
+ def private generateHeaderFile(Root root, ProtocolClass pc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of ProtocolClass «pc.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(pc.name)»
+
+ #include "platforms/generic/etDatatypes.h"
+ #include "common/modelbase/PortBase.h"
+ #include "common/modelbase/InterfaceItemBase.h"
+ #include "common/messaging/Address.h"
+ #include "common/messaging/Message.h"
+ #include <list>
+
+ namespace etRuntime {
+ class IEventReceiver;
+ }
+
+ «helpers.userCode(pc.userCode1)»
+
+ «FOR dataClass : root.getReferencedDataClasses(pc)»
+ #include "«dataClass.name».h"
+ «ENDFOR»
+
+ class «pc.name» {
+ public:
+ «IF pc.commType==CommunicationType::EVENT_DRIVEN» /* message IDs */
+ «genMessageIDs(pc)»
+ «ELSEIF pc.commType==CommunicationType::DATA_DRIVEN»
+ «ELSEIF pc.commType==CommunicationType::SYNCHRONOUS»
+ #error "synchronous protocols not implemented yet"
+ «ENDIF»
+ «helpers.userCode(pc.userCode2)»
+
+ private:
+ static char messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR» «FOR m : pc.getAllIncomingMessages()»"«m.name»",«ENDFOR»"MAX"};
+
+ public:
+ char* getMessageString(int msg_id);
+
+ «portClassDeclaration(pc, false)»
+ «portClassDeclaration(pc, true)»
+ };
+ «generateIncludeGuardEnd(pc.name)»
+ '''
+ }
+
+ def portClassDeclaration(ProtocolClass pc, Boolean conj) {
+ var pclass = pc.getPortClass(conj)
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+ '''
+ //------------------------------------------------------------------------------------------------------------
+ // «IF conj»conjugated «ENDIF»port class
+ //------------------------------------------------------------------------------------------------------------
+ class «portClassName» : public etRuntime::PortBase {
+ «IF pclass!=null»
+ «helpers.userCode(pclass.userCode)»
+ «ENDIF»
+ public:
+ // constructors
+ «portClassName»(etRuntime::IEventReceiver actor, char* name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress);
+ «portClassName»(etRuntime::IEventReceiver actor, char* name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress);
+
+ virtual void receive(etRuntime::Message m);
+ «IF pclass!=null»
+ «helpers.attributes(pclass.attributes)»
+ «helpers.operationsDeclaration(pclass.operations, portClassName)»
+ «ENDIF»
+
+ // sent messages
+ «FOR m : pc.getOutgoing(conj)»
+ «sendMessageDeclaration(m,conj)»
+ «ENDFOR»
+ };
+
+ //------------------------------------------------------------------------------------------------------------
+ // «IF conj»conjugated «ENDIF»replicated port class
+ //------------------------------------------------------------------------------------------------------------
+ class «replPortClassName» {
+ private:
+ std::list<«portClassName»> ports;
+ int replication;
+
+ public:
+ // constructor
+ «replPortClassName»(etRuntime::IEventReceiver actor, char* name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress);
+
+ int getReplication() { return replication; }
+ int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx(); }
+ «portClassName» get(int i) {return ports[i];}
+
+ «IF pc.commType==CommunicationType::EVENT_DRIVEN»
+ «IF conj»
+ // incoming messages
+
+ «FOR m : pc.getAllIncomingMessages()» «messageSignature(m)»;
+ «ENDFOR»
+ «ELSE»
+ // outgoing messages
+ «FOR m : pc.getAllOutgoingMessages()» «messageSignature(m)»;
+ «ENDFOR»
+ «ENDIF»
+ «ELSEIF pc.commType==CommunicationType::DATA_DRIVEN»
+ /*--------------------- port structs and methods */
+ «pc.genDataDrivenPortHeaders»
+ «ELSEIF pc.commType==CommunicationType::SYNCHRONOUS»
+ #error "synchronous protocols not implemented yet"
+ «ENDIF»
+
+ };
+ '''
+ }
+
+ def portClassImplementation(ProtocolClass pc, Boolean conj) {
+ var pclass = pc.getPortClass(conj)
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+ '''
+ «pc.name»::«portClassName»::«portClassName»(IEventReceiver actor, char* name, int localId, Address addr, Address peerAddress)
+ : PortBase(actor, name, localId, 0, addr, peerAddress)
+ {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+
+ «pc.name»::«portClassName»::«portClassName»(IEventReceiver actor, char* name, int localId, int idx, Address addr, Address peerAddress)
+ : PortBase(actor, name, localId, idx, addr, peerAddress)
+ {
+ DebuggingService::getInstance().addPortInstance(*this);
+ }
+
+ void «pc.name»::«portClassName»::receive(Message m) {
+ if (!(m instanceof EventMessage)) return;
+ EventMessage msg = (EventMessage) m;
+ if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
+ System.out.println("unknown");
+ else {
+ if (messageStrings[msg.getEvtId()] != "timerTick"){
+««« TODOTS: model switch for activation
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
+ }
+ }
+ «IF pc.handlesReceive(conj)»
+ switch (msg.getEvtId()) {
+ «FOR hdlr : pc.getReceiveHandlers(conj)»
+ case «hdlr.msg.getCodeName()»:
+ {
+ «FOR command : hdlr.detailCode.commands»
+ «command»
+ «ENDFOR»
+ }
+ break;
+ «ENDFOR»
+ default:
+ «ENDIF»
+ if (msg instanceof EventWithDataMessage)
+ getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+ else
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ «IF pc.handlesReceive(conj)»
+ }
+ «ENDIF»
+ }
+ «IF pclass!=null»
+ «helpers.operationsImplementation(pclass.operations, portClassName)»
+ «ENDIF»
+
+ // sent messages
+ «FOR m : pc.getOutgoing(conj)»
+ «sendMessage(m, pc.name + "::" + portClassName, conj)»
+ «ENDFOR»
+
+ //-------------------------------------------------------------------------------
+ // replicated port class
+ //-------------------------------------------------------------------------------
+ «pc.name»::«replPortClassName»::«replPortClassName»(IEventReceiver actor, char* name, int localId, Address addr, Address peerAddress) {
+ replication = addr==null? 0:addr.length;
+ ports = new ArrayList<«pc.name».«portClassName»>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new «portClassName»(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ «IF conj»
+ // incoming messages
+ «FOR m : pc.getAllIncomingMessages()»
+ «messageSignatureDefinition(m, pc.name + "::" + replPortClassName)»{
+ for (int i=0; i<replication; ++i) {
+ ports[i].«messageCall(m)»;
+ }
+ }
+ «ENDFOR»
+ «ELSE»
+ // outgoing messages
+ «FOR m : pc.getAllOutgoingMessages()»
+ «messageSignatureDefinition(m, pc.name + "::" + replPortClassName)»{
+ for (int i=0; i<replication; ++i) {
+ ports[i].«messageCall(m)»;
+ }
+ }
+ «ENDFOR»
+ «ENDIF»
+ '''
+ }
+
+ def private generateSourceFile(Root root, ProtocolClass pc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of ProtocolClass «pc.name»
+ *
+ */
+
+ #include "«pc.getCppHeaderFileName»"
+ #include "common/debugging/DebuggingService.h"
+
+ using namespace etRuntime;
+
+ «helpers.userCode(pc.userCode3)»
+
+ «IF pc.commType==CommunicationType::EVENT_DRIVEN»
+
+ //----------------------------------------------
+ // java code
+ //----------------------------------------------
+
+ «helpers.userCode(pc.userCode2)»
+
+ //private static char* messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR» «FOR m : pc.getAllIncomingMessages()»"«m.name»",«ENDFOR»"MAX"};
+
+ char* «pc.name»::getMessageString(int msg_id) {
+ if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){
+ // id out of range
+ return "Message ID out of range";
+ }
+ else{
+ return messageStrings[msg_id];
+ }
+ }
+
+ «portClassImplementation(pc, false)»
+ «portClassImplementation(pc, true)»
+
+ /*--------------------- debug helpers */
+ «generateDebugHelpersImplementation(root, pc)»
+ «ELSEIF pc.commType==CommunicationType::DATA_DRIVEN»
+ «pc.genDataDrivenPortSources»
+ «ELSEIF pc.commType==CommunicationType::SYNCHRONOUS»
+ #error "synchronoue protocols not implemented yet"
+ «ENDIF»
+
+
+ '''
+ }
+
+ def private portClassHeader(ProtocolClass pc, Boolean conj){
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+ var messages = if (conj) pc.allIncomingMessages else pc.allOutgoingMessages
+
+ '''
+ typedef etPort «portClassName»;
+ typedef etReplPort «replPortClassName»;
+
+ «IF pc.getPortClass(conj)!=null»
+ «IF !(pc.getPortClass(conj).attributes.empty)»
+/* variable part of PortClass (RAM) */
+typedef struct «portClassName»_var «portClassName»_var;
+struct «portClassName»_var {
+ «helpers.attributes(pc.getPortClass(conj).attributes)»
+ };
+ «FOR a:pc.getPortClass(conj).attributes»
+ «IF a.defaultValueLiteral!=null»
+ «logger.logInfo(portClassName+" "+a.name+": Attribute initialization not supported in C")»
+ «ENDIF»
+ «ENDFOR»
+ «ENDIF»
+ «ENDIF»
+
+ «FOR message : messages»
+ «var hasData = message.data!=null»
+ «var typeName = if (hasData) message.data.refType.type.typeName else ""»
+ «var refp = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
+ «var data = if (hasData) ", "+typeName+refp+" data" else ""»
+ «messageSignature(portClassName, message.name, "", data)»;
+ «messageSignature(replPortClassName, message.name, "_broadcast", data)»;
+ «messageSignature(replPortClassName, message.name, "", ", int idx"+data)»;
+ «ENDFOR»
+
+ «IF (pc.getPortClass(conj) != null)»
+ «helpers.operationsDeclaration(pc.getPortClass(conj).operations, portClassName)»
+ «helpers.operationsDeclaration(pc.getPortClass(conj).operations, replPortClassName)»
+ «ENDIF»
+
+ «IF pc.handlesReceive(conj)»
+ «FOR h:getReceiveHandlers(pc,conj)»
+void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);
+ «ENDFOR»
+ «ENDIF»
+ '''
+ }
+
+
+
+ def private genDataDrivenPortHeaders(ProtocolClass pc) {
+ var sentMsgs = pc.allIncomingMessages.filter(m|m.data!=null)
+
+ '''
+ /* data driven send port (conjugated) */
+ typedef struct {
+ «FOR msg : sentMsgs»
+ «var typeName = msg.data.refType.type.typeName»
+ «var refp = if (msg.data.refType.ref) "*" else ""»
+ «typeName»«refp» «msg.name»;
+ «ENDFOR»
+ }
+ «pc.getPortClassName(true)»;
+
+ /* data driven receive port (regular) */
+ typedef struct {
+ const «pc.getPortClassName(true)»* peer;
+ }
+ «pc.getPortClassName(false)»;
+
+ «FOR message : sentMsgs»
+ «var hasData = message.data!=null»
+ «var typeName = if (hasData) message.data.refType.type.typeName else ""»
+ «var refp = if (hasData && !(message.data.refType.type instanceof PrimitiveType)) "*" else ""»
+ «var data = if (hasData) ", "+typeName+refp+" data" else ""»
+ «messageSetterSignature(pc.getPortClassName(true), message.name, data)»;
+ «messageGetterSignature(pc.getPortClassName(false), message.name, typeName)»;
+
+ «ENDFOR»
+ '''
+ }
+ def private genDataDrivenPortSources(ProtocolClass pc) {
+ var messages = pc.allIncomingMessages.filter(m|m.data!=null)
+ '''
+ «FOR message : messages»
+ «var typeName =message.data.refType.type.typeName»
+ «var refp = if (!(message.data.refType.type instanceof PrimitiveType)) "*" else ""»
+ «var refa = if ((message.data.refType.type instanceof PrimitiveType)) "&" else ""»
+ «var data = ", "+typeName+refp+" data"»
+ «messageSetterSignature(pc.getPortClassName(true), message.name, data)» {
+ self->«message.name» = data;
+ }
+ «messageGetterSignature(pc.getPortClassName(false), message.name, typeName)» {
+ return self->peer->«message.name»;
+ }
+
+ «ENDFOR»
+ '''
+ }
+
+ def private portClassSource(ProtocolClass pc, Boolean conj){
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+ var messages = if (conj) pc.allIncomingMessages else pc.allOutgoingMessages
+ var dir = if (conj) "IN_" else "OUT_"
+
+ '''
+ «FOR message : messages»
+ «var hasData = message.data!=null»
+ «var typeName = if (hasData) message.data.refType.type.typeName else ""»
+ «var refp = if (hasData && ((message.data.refType.ref))) "*" else ""»
+ «var refpd = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
+ «var refa = if (hasData && (!(message.data.refType.type instanceof PrimitiveType))&&(!(message.data.refType.ref))) "" else "&"»
+ «var data = if (hasData) ", "+typeName+refpd+" data" else ""»
+ «var dataCall = if (hasData) ", data" else ""»
+ «var hdlr = message.getSendHandler(conj)»
+
+ «messageSignature(portClassName, message.name, "", data)» {
+ «IF hdlr != null»
+ «FOR command : hdlr.detailCode.commands» «command»
+ «ENDFOR»
+ «ELSE»
+ ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
+ «sendMessageCall(hasData, "self", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
+ ET_MSC_LOGGER_SYNC_EXIT
+ «ENDIF»
+ }
+
+ «messageSignature(replPortClassName, message.name, "_broadcast", data)» {
+ «IF hdlr != null»
+ int i;
+ for (i=0; i<((etReplPort*)self)->size; ++i) {
+ «portClassName»_«message.name»((etPort*)&((etReplPort*)self)->ports[i]«dataCall»);
+ }
+ «ELSE»
+ int i;
+ ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
+ for (i=0; i<((etReplPort*)self)->size; ++i) {
+ «sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[i])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+ «ENDIF»
+ }
+
+ «messageSignature(replPortClassName, message.name, "", ", int idx"+data)» {
+ «IF hdlr != null»
+ «portClassName»_«message.name»((etPort*)&((etReplPort*)self)->ports[idx]«dataCall»);
+ «ELSE»
+ ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
+ if (0<=idx && idx<((etReplPort*)self)->size) {
+ «sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[idx])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+ «ENDIF»
+ }
+ «ENDFOR»
+
+ «IF (pc.getPortClass(conj) != null)»
+ «helpers.operationsImplementation(pc.getPortClass(conj).operations, portClassName)»
+ «helpers.operationsImplementation(pc.getPortClass(conj).operations, replPortClassName)»
+ «ENDIF»
+
+ // getReplication
+ etInt32 «replPortClassName»_getReplication(const «replPortClassName»* self) {
+ return ((etReplPort*)self)->size;
+ }
+
+ «IF pc.handlesReceive(conj)»
+ «genReceiveHandlers(pc,conj)»
+ «ENDIF»
+
+ '''
+ }
+
+ def private sendMessageCall(boolean hasData, String self, String msg, String typeName, String data) {
+ if (hasData)
+ "etPort_sendMessage("+self+", "+msg+", sizeof("+typeName+"), "+data+");"
+ else
+ "etPort_sendMessage("+self+", "+msg+", 0, NULL);"
+ }
+
+ def private messageSignature(String className, String messageName, String methodSuffix, String data) {
+ "void "+className+"_"+messageName+methodSuffix+"(const "+className+"* self"+data+")"
+ }
+
+ def private messageSetterSignature(String className, String messageName, String data) {
+ "void "+className+"_"+messageName+"_set("+className+"* self"+data+")"
+ }
+
+ def private messageGetterSignature(String className, String messageName, String type) {
+ type+" "+className+"_"+messageName+"_get(const "+className+"* const self)"
+ }
+
+ def private messageCall(Message m) {'''
+ «m.name»(«IF m.data!=null» «m.data.name»«ENDIF»)
+ '''}
+
+// def sendMessage(Message m, boolean conj) {'''
+// «var dir = if (conj) "IN" else "OUT"»
+// «var hdlr = m.getSendHandler(conj)»
+// «messageSignature(m)»{
+// if (getPeerAddress()!=null)
+// «IF m.data==null»getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), «dir»_«m.name»));
+// «ELSE»getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), «dir»_«m.name», «m.data.name»«IF (!m.data.ref)».deepCopy()«ENDIF»));
+// «ENDIF»
+// }
+// '''
+// }
+
+ def private genReceiveHandlers(ProtocolClass pc, Boolean conj){
+ var portClassName = pc.getPortClassName(conj)
+ var replPortClassName = pc.getPortClassName(conj, true)
+
+ '''
+ /* receiver handlers */
+ «FOR h:getReceiveHandlers(pc,conj)»
+ void «portClassName»_«h.msg.name»_receiveHandler(«portClassName»* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){
+ «userCode(h.detailCode)»
+ /* hand over the message to the actor: */
+ /* (*receiveMessageFunc)(actor, self, msg); */
+ }
+ «ENDFOR»
+ '''}
+
+
+
+ def private generateDebugHelpersImplementation(Root root, ProtocolClass pc){'''
+
+««« TODO: make this optional or different for smaller footprint
+ /* message names as strings for debugging (generate MSC) */
+ static const char* «pc.name»_messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR»«FOR m : pc.getAllIncomingMessages()»"«m.name»", «ENDFOR»"MAX"};
+
+ const char* «pc.name»_getMessageString(int msg_id) {
+ if (msg_id<«pc.name»_MSG_MIN || msg_id>«pc.name»_MSG_MAX+1){
+ /* id out of range */
+ return "Message ID out of range";
+ }
+ else{
+ return «pc.name»_messageStrings[msg_id];
+ }
+ }
+ '''
+ }
+
+ //----------------------------------------------------
+ // from java generator
+ //---------------------------------------------------
+ def messageSignature(Message m) {
+ '''«IF m.priv»private:«ELSE»public:«ENDIF» void «m.name»(«IF m.data!=null»«m.data.refType.type.typeName» «m.data.name»«ENDIF»)'''
+ }
+
+ def messageSignatureExplicit(Message m) {
+ var dc = (m.data.refType.type as DataClass)
+ '''public: void «m.name»(«IF dc.base!=null»«dc.base.typeName» _super, «ENDIF»«FOR a : dc.attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>1»[]«ENDIF» «a.name»«ENDFOR»)'''
+ }
+
+ def messageSignatureDefinition(Message m, String classPrefix) {
+ '''void «classPrefix»::«m.name»(«IF m.data!=null»«m.data.refType.type.typeName» «m.data.name»«ENDIF»)'''
+ }
+
+ def messageSignatureExplicitDefinition(Message m, String classPrefix) {
+ var dc = (m.data.refType.type as DataClass)
+ '''void «classPrefix»::«m.name»(«IF dc.base!=null»«dc.base.typeName» _super, «ENDIF»«FOR a : dc.attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>1»[]«ENDIF» «a.name»«ENDFOR»)'''
+ }
+
+// def messageCall(Message m) {
+// '''«m.name»(«IF m.data!=null» «m.data.name»«ENDIF»)'''
+// }
+
+ def sendMessageDeclaration(Message m, boolean conj) {
+ '''
+ «messageSignature(m)»;
+ «IF m.data!=null && m.data.refType.type instanceof DataClass»
+ «messageSignatureExplicit(m)»;
+ «ENDIF»
+ '''
+ }
+ def sendMessage(Message m, String classPrefix, boolean conj) {
+ var dir = if (conj) "IN" else "OUT"
+ var hdlr = m.getSendHandler(conj)
+ '''
+ «messageSignatureDefinition(m, classPrefix)» {
+ «IF hdlr!=null»
+ «FOR command : hdlr.detailCode.commands» «command»
+ «ENDFOR»
+ «ELSE»
+ if (messageStrings[ «dir»_«m.name»] != "timerTick"){
+««« TODOTS: model switch for activation
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[«dir»_«m.name»]);
+ }
+ if (getPeerAddress()!=null)
+ «IF m.data==null»getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), «dir»_«m.name»));
+ «ELSE»getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), «dir»_«m.name», «m.data.name»«IF (!m.data.refType.ref && !(m.data.refType.type instanceof PrimitiveType))».deepCopy()«ENDIF»));
+ «ENDIF»
+ «ENDIF»
+ }
+ «IF m.data!=null && m.data.refType.type instanceof DataClass»
+ «messageSignatureExplicitDefinition(m, classPrefix)» {
+ «m.name»(new «m.data.refType.type.name»(«IF (m.data.refType.type as DataClass).base!=null»_super, «ENDIF»«FOR a : (m.data.refType.type as DataClass).attributes SEPARATOR ", "»«a.name»«ENDFOR»));
+ }
+ «ENDIF»
+ '''
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
index a306184..c0adff9 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
@@ -80,7 +80,7 @@ public class CppExtensions implements ILanguageExtension {
StringConcatenation _builder = new StringConcatenation();
{
for(final Pair<String,String> entry : entries) {
- _builder.append("public static final int ");
+ _builder.append("static const int ");
String _first = entry.getFirst();
_builder.append(_first, "");
_builder.append(" = ");
@@ -138,7 +138,8 @@ public class CppExtensions implements ILanguageExtension {
public StringConcatenation getIncludeGuardString(final String filename) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("_");
- String _upperCase = filename.toUpperCase();
+ String _replaceAll = filename.replaceAll("\\/.", "_");
+ String _upperCase = _replaceAll.toUpperCase();
_builder.append(_upperCase, "");
_builder.append("_H_");
return _builder;
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
index e1942d8..38f806f 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
@@ -2,6 +2,7 @@ package org.eclipse.etrice.generator.cpp.gen;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import java.util.HashSet;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.etrice.core.room.Attribute;
@@ -20,6 +21,7 @@ import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.etrice.generator.generic.TypeHelpers;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
@@ -104,10 +106,35 @@ public class DataClassGen {
StandardOperation _head_1 = IterableExtensions.<StandardOperation>head(_filter_1);
final StandardOperation dtor = _head_1;
StringConcatenation _builder = new StringConcatenation();
+ String _path = this.roomExt.getPath(dc);
String _name = dc.getName();
- StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name);
+ String _operator_plus = StringExtensions.operator_plus(_path, _name);
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_operator_plus);
_builder.append(_generateIncludeGuardBegin, "");
_builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ DataClass _base = dc.getBase();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_notEquals) {
+ _builder.append("#include \"");
+ DataClass _base_1 = dc.getBase();
+ String _name_1 = _base_1.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
+ for(final DataClass classes : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = classes.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
EList<RoomModel> _referencedModels = root.getReferencedModels(dc);
EList<RoomModel> models = _referencedModels;
_builder.newLineIfNotEmpty();
@@ -115,13 +142,13 @@ public class DataClassGen {
for(final RoomModel model : models) {
{
EList<DataClass> _dataClasses = model.getDataClasses();
- for(final DataClass classes : _dataClasses) {
- _builder.append("#include ");
- String _path = this.roomExt.getPath(classes);
- _builder.append(_path, "");
- String _name_1 = classes.getName();
- _builder.append(_name_1, "");
- _builder.append(".h;");
+ for(final DataClass classes_1 : _dataClasses) {
+ _builder.append("#include \"");
+ String _path_1 = this.roomExt.getPath(classes_1);
+ _builder.append(_path_1, "");
+ String _name_3 = classes_1.getName();
+ _builder.append(_name_3, "");
+ _builder.append(".h\"");
_builder.newLineIfNotEmpty();
}
}
@@ -135,22 +162,24 @@ public class DataClassGen {
_builder.newLine();
_builder.newLine();
_builder.append("class ");
- String _name_2 = dc.getName();
- _builder.append(_name_2, "");
+ String _name_4 = dc.getName();
+ _builder.append(_name_4, "");
{
- DataClass _base = dc.getBase();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals) {
+ DataClass _base_2 = dc.getBase();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_base_2, null);
+ if (_operator_notEquals_1) {
_builder.append(" : public ");
- DataClass _base_1 = dc.getBase();
- String _name_3 = _base_1.getName();
- _builder.append(_name_3, "");
+ DataClass _base_3 = dc.getBase();
+ String _name_5 = _base_3.getName();
+ _builder.append(_name_5, "");
}
}
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
+ _builder.append("public:");
+ _builder.newLine();
_builder.append("\t");
DetailCode _userCode2 = dc.getUserCode2();
StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
@@ -167,40 +196,42 @@ public class DataClassGen {
_builder.newLine();
_builder.append("\t");
EList<Attribute> _attributes_2 = dc.getAttributes();
- String _name_4 = dc.getName();
- StringConcatenation _attributeSettersGettersImplementation = this.helpers.attributeSettersGettersImplementation(_attributes_2, _name_4);
+ String _name_6 = dc.getName();
+ StringConcatenation _attributeSettersGettersImplementation = this.helpers.attributeSettersGettersImplementation(_attributes_2, _name_6);
_builder.append(_attributeSettersGettersImplementation, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
EList<StandardOperation> _operations_2 = dc.getOperations();
- String _name_5 = dc.getName();
- StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations_2, _name_5);
+ String _name_7 = dc.getName();
+ StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations_2, _name_7);
_builder.append(_operationsDeclaration, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
- _builder.append("// default constructor");
+ _builder.append("// default constructor, copy constructor and assignment operator");
_builder.newLine();
_builder.append("\t");
- String _name_6 = dc.getName();
- _builder.append(_name_6, " ");
+ String _name_8 = dc.getName();
+ _builder.append(_name_8, " ");
_builder.append("();");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- String _name_7 = dc.getName();
- _builder.append(_name_7, " ");
+ String _name_9 = dc.getName();
+ _builder.append(_name_9, " ");
_builder.append("(const ");
- String _name_8 = dc.getName();
- _builder.append(_name_8, " ");
+ String _name_10 = dc.getName();
+ _builder.append(_name_10, " ");
_builder.append("& rhs);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- _builder.append("operator=(const ");
- String _name_9 = dc.getName();
- _builder.append(_name_9, " ");
+ String _name_11 = dc.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("& operator=(const ");
+ String _name_12 = dc.getName();
+ _builder.append(_name_12, " ");
_builder.append("& rhs);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -209,8 +240,8 @@ public class DataClassGen {
_builder.append("// constructor using fields");
_builder.newLine();
_builder.append("\t");
- String _name_10 = dc.getName();
- _builder.append(_name_10, " ");
+ String _name_13 = dc.getName();
+ _builder.append(_name_13, " ");
_builder.append("(");
String _argList = this.argList(dc);
_builder.append(_argList, " ");
@@ -221,8 +252,8 @@ public class DataClassGen {
_builder.append("};");
_builder.newLine();
_builder.newLine();
- String _name_11 = dc.getName();
- StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_11);
+ String _name_14 = dc.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_14);
_builder.append(_generateIncludeGuardEnd, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
@@ -269,9 +300,6 @@ public class DataClassGen {
_builder.append(_name, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.newLine();
@@ -281,32 +309,44 @@ public class DataClassGen {
_builder.append("\"");
_builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.append("#include <string.h>");
- _builder.newLine();
- _builder.newLine();
DetailCode _userCode3 = dc.getUserCode3();
StringConcatenation _userCode = this.helpers.userCode(_userCode3);
_builder.append(_userCode, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.newLine();
+ _builder.append("// default constructor");
+ _builder.newLine();
String _name_1 = dc.getName();
_builder.append(_name_1, "");
_builder.append("::");
String _name_2 = dc.getName();
_builder.append(_name_2, "");
- _builder.append("() {");
+ _builder.append("() ");
_builder.newLineIfNotEmpty();
+ {
+ DataClass _base = dc.getBase();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_notEquals) {
+ _builder.append("\t");
+ _builder.append(":");
+ DataClass _base_1 = dc.getBase();
+ String _name_3 = _base_1.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("()");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("{");
+ _builder.newLine();
_builder.append("\t");
EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes, true);
+ StringConcatenation _attributeInitialization = this.helpers.attributeInitialization(_attributes, false);
_builder.append(_attributeInitialization, " ");
_builder.newLineIfNotEmpty();
{
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(ctor, null);
- if (_operator_notEquals) {
- _builder.append("\t");
- _builder.newLine();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(ctor, null);
+ if (_operator_notEquals_1) {
_builder.append("\t");
_builder.append("{");
_builder.newLine();
@@ -333,46 +373,104 @@ public class DataClassGen {
_builder.newLine();
_builder.append("\t");
_builder.newLine();
+ _builder.append("// copy constructor");
+ _builder.newLine();
+ String _name_4 = dc.getName();
+ _builder.append(_name_4, "");
+ _builder.append("::");
+ String _name_5 = dc.getName();
+ _builder.append(_name_5, "");
+ _builder.append("(const ");
+ String _name_6 = dc.getName();
+ _builder.append(_name_6, "");
+ _builder.append("& rhs)");
+ _builder.newLineIfNotEmpty();
_builder.append("\t");
+ _builder.append(":");
+ _builder.newLine();
+ {
+ DataClass _base_2 = dc.getBase();
+ boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_base_2, null);
+ if (_operator_notEquals_2) {
+ _builder.append("\t");
+ DataClass _base_3 = dc.getBase();
+ String _name_7 = _base_3.getName();
+ _builder.append(_name_7, " ");
+ _builder.append("(rhs),");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<Attribute> _attributes_1 = dc.getAttributes();
+ boolean hasAnyElements = false;
+ for(final Attribute a : _attributes_1) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t");
+ String _name_8 = a.getName();
+ _builder.append(_name_8, " ");
+ _builder.append("(rhs.");
+ String _name_9 = a.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
_builder.append("// constructor using fields");
_builder.newLine();
- String _name_3 = dc.getName();
- _builder.append(_name_3, "");
+ String _name_10 = dc.getName();
+ _builder.append(_name_10, "");
_builder.append("::");
- String _name_4 = dc.getName();
- _builder.append(_name_4, "");
+ String _name_11 = dc.getName();
+ _builder.append(_name_11, "");
_builder.append("(");
String _argList = this.argList(dc);
_builder.append(_argList, "");
_builder.append(") ");
_builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(":");
+ _builder.newLine();
{
- DataClass _base = dc.getBase();
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_base, null);
- if (_operator_notEquals_1) {
+ DataClass _base_4 = dc.getBase();
+ boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_base_4, null);
+ if (_operator_notEquals_3) {
_builder.append("\t");
- _builder.append(":");
- DataClass _base_1 = dc.getBase();
- String _name_5 = _base_1.getName();
- _builder.append(_name_5, " ");
+ DataClass _base_5 = dc.getBase();
+ String _name_12 = _base_5.getName();
+ _builder.append(_name_12, " ");
_builder.append("(");
- DataClass _base_2 = dc.getBase();
- String _paramList = this.paramList(_base_2);
+ DataClass _base_6 = dc.getBase();
+ String _paramList = this.paramList(_base_6);
_builder.append(_paramList, " ");
_builder.append("),");
_builder.newLineIfNotEmpty();
}
}
{
- EList<Attribute> _attributes_1 = dc.getAttributes();
- for(final Attribute a : _attributes_1) {
+ EList<Attribute> _attributes_2 = dc.getAttributes();
+ boolean hasAnyElements_1 = false;
+ for(final Attribute a_1 : _attributes_2) {
+ if (!hasAnyElements_1) {
+ hasAnyElements_1 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
_builder.append("\t");
- String _name_6 = a.getName();
- _builder.append(_name_6, " ");
+ String _name_13 = a_1.getName();
+ _builder.append(_name_13, " ");
_builder.append("(");
- String _name_7 = a.getName();
- _builder.append(_name_7, " ");
- _builder.append("),");
+ String _name_14 = a_1.getName();
+ _builder.append(_name_14, " ");
+ _builder.append("_)");
_builder.newLineIfNotEmpty();
}
}
@@ -381,34 +479,60 @@ public class DataClassGen {
_builder.append("}");
_builder.newLine();
_builder.newLine();
- EList<StandardOperation> _operations_2 = dc.getOperations();
- String _name_8 = dc.getName();
- StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations_2, _name_8);
- _builder.append(_operationsImplementation, "");
+ _builder.append("// assignment operator");
+ _builder.newLine();
+ String _name_15 = dc.getName();
+ _builder.append(_name_15, "");
+ _builder.append("& ");
+ String _name_16 = dc.getName();
+ _builder.append(_name_16, "");
+ _builder.append("::operator=(const ");
+ String _name_17 = dc.getName();
+ _builder.append(_name_17, "");
+ _builder.append("& rhs)");
_builder.newLineIfNotEmpty();
+ _builder.append("{\t\t");
_builder.newLine();
- _builder.append("// deep copy");
+ _builder.append("\t");
+ _builder.append("if (this == &rhs) { return *this; };");
_builder.newLine();
- _builder.append("void ");
- String _name_9 = dc.getName();
- _builder.append(_name_9, "");
- _builder.append("_deepCopy(");
- String _name_10 = dc.getName();
- _builder.append(_name_10, "");
- _builder.append("* source, ");
- String _name_11 = dc.getName();
- _builder.append(_name_11, "");
- _builder.append("* target) {");
- _builder.newLineIfNotEmpty();
+ {
+ DataClass _base_7 = dc.getBase();
+ boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(_base_7, null);
+ if (_operator_notEquals_4) {
+ _builder.append("\t");
+ DataClass _base_8 = dc.getBase();
+ String _name_18 = _base_8.getName();
+ _builder.append(_name_18, " ");
+ _builder.append("::operator=(rhs);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<Attribute> _attributes_3 = dc.getAttributes();
+ for(final Attribute a_2 : _attributes_3) {
+ _builder.append("\t");
+ String _name_19 = a_2.getName();
+ _builder.append(_name_19, " ");
+ _builder.append("= rhs.");
+ String _name_20 = a_2.getName();
+ _builder.append(_name_20, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.append("\t");
- _builder.append("memcpy(target, source, sizeof(");
- String _name_12 = dc.getName();
- _builder.append(_name_12, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
+ _builder.append("return *this;");
+ _builder.newLine();
+ _builder.append("}\t\t\t");
_builder.newLine();
_builder.newLine();
+ EList<StandardOperation> _operations_2 = dc.getOperations();
+ String _name_21 = dc.getName();
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations_2, _name_21);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
_xblockexpression = (_builder);
}
return _xblockexpression;
@@ -452,6 +576,7 @@ public class DataClassGen {
}
String _name = a.getName();
_builder.append(_name, "");
+ _builder.append("_");
}
}
return _builder;
@@ -465,8 +590,8 @@ public class DataClassGen {
while (_xwhileexpression) {
{
EList<Attribute> _attributes = dc.getAttributes();
- StringConcatenation _argList = this.helpers.argList(_attributes);
- String _string = _argList.toString();
+ StringConcatenation _argListConstructor = this.argListConstructor(_attributes);
+ String _string = _argListConstructor.toString();
String _operator_plus = StringExtensions.operator_plus(_string, result);
result = _operator_plus;
DataClass _base = dc.getBase();
@@ -483,6 +608,36 @@ public class DataClassGen {
return result;
}
+ public StringConcatenation argListConstructor(final List<Attribute> attributes) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean hasAnyElements = false;
+ for(final Attribute a : attributes) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(", ", "");
+ }
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this.typeHelpers.typeName(_type);
+ _builder.append(_typeName, "");
+ {
+ int _size = a.getSize();
+ boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
+ if (_operator_greaterThan) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ String _name = a.getName();
+ _builder.append(_name, "");
+ _builder.append("_");
+ }
+ }
+ return _builder;
+ }
+
public String deepCopy(final DataClass _dc) {
String result = "";
DataClass dc = _dc;
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
index 0455f08..81f63c9 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
@@ -6,6 +6,7 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.etrice.generator.cpp.gen.DataClassGen;
+import org.eclipse.etrice.generator.cpp.gen.ProtocolClassGen;
import org.eclipse.etrice.generator.etricegen.Root;
import org.eclipse.etrice.generator.generic.PrepareFileSystem;
import org.eclipse.xtext.generator.IFileSystemAccess;
@@ -19,6 +20,9 @@ public class MainGen implements IGenerator {
private DataClassGen dataClassGen;
@Inject
+ private ProtocolClassGen protocolClassGen;
+
+ @Inject
private PrepareFileSystem prepFS;
public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
@@ -33,6 +37,7 @@ public class MainGen implements IGenerator {
public void doGenerate(final Root e) {
this.dataClassGen.doGenerate(e);
+ this.protocolClassGen.doGenerate(e);
boolean _isLibrary = e.isLibrary();
boolean _operator_not = BooleanExtensions.operator_not(_isLibrary);
if (_operator_not) {
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
new file mode 100644
index 0000000..c72971d
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
@@ -0,0 +1,2227 @@
+package org.eclipse.etrice.generator.cpp.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.CommunicationType;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageHandler;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.PortOperation;
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.base.ILogger;
+import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+@Singleton
+public class ProtocolClassGen extends GenericProtocolClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CppExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
+ for (final ProtocolClass pc : _usedProtocolClasses) {
+ {
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(pc);
+ String _path = this.roomExt.getPath(pc);
+ String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
+ String path = _operator_plus;
+ String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(pc);
+ String _operator_plus_1 = StringExtensions.operator_plus("generating ProtocolClass header \'", _cppHeaderFileName);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
+ this.logger.logInfo(_operator_plus_4);
+ this.fileAccess.setOutputPath(path);
+ String _cppHeaderFileName_1 = this.stdExt.getCppHeaderFileName(pc);
+ StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, pc);
+ this.fileAccess.generateFile(_cppHeaderFileName_1, _generateHeaderFile);
+ String _cppSourceFileName = this.stdExt.getCppSourceFileName(pc);
+ String _operator_plus_5 = StringExtensions.operator_plus("generating ProtocolClass source \'", _cppSourceFileName);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
+ this.logger.logInfo(_operator_plus_8);
+ this.fileAccess.setOutputPath(path);
+ String _cppSourceFileName_1 = this.stdExt.getCppSourceFileName(pc);
+ StringConcatenation _generateSourceFile = this.generateSourceFile(root, pc);
+ this.fileAccess.generateFile(_cppSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ private StringConcatenation generateHeaderFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Header File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = pc.getName();
+ StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"platforms/generic/etDatatypes.h\"");
+ _builder.newLine();
+ _builder.append("#include \"common/modelbase/PortBase.h\"");
+ _builder.newLine();
+ _builder.append("#include \"common/modelbase/InterfaceItemBase.h\"");
+ _builder.newLine();
+ _builder.append("#include \"common/messaging/Address.h\"");
+ _builder.newLine();
+ _builder.append("#include \"common/messaging/Message.h\"");
+ _builder.newLine();
+ _builder.append("#include <list>");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("namespace etRuntime {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("class IEventReceiver;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode1 = pc.getUserCode1();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
+ for(final DataClass dataClass : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = dataClass.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("class ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("public:");
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_operator_equals) {
+ _builder.append("\t /* message IDs */");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t ");
+ String _genMessageIDs = this.genMessageIDs(pc);
+ _builder.append(_genMessageIDs, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_operator_equals_1) {
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_operator_equals_2) {
+ _builder.append("#error \"synchronous protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t\t");
+ DetailCode _userCode2 = pc.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("private:");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("static char messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\"");
+ String _name_4 = m.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("\",");
+ }
+ }
+ _builder.append(" ");
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\"");
+ String _name_5 = m_1.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\",");
+ }
+ }
+ _builder.append("\"MAX\"};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("char* getMessageString(int msg_id);");
+ _builder.newLine();
+ _builder.append("\t \t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ StringConcatenation _portClassDeclaration = this.portClassDeclaration(pc, ((Boolean)false));
+ _builder.append(_portClassDeclaration, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ StringConcatenation _portClassDeclaration_1 = this.portClassDeclaration(pc, ((Boolean)true));
+ _builder.append(_portClassDeclaration_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("};");
+ _builder.newLine();
+ String _name_6 = pc.getName();
+ StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_6);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public StringConcatenation portClassDeclaration(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ 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.append("//------------------------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("// ");
+ {
+ if (conj) {
+ _builder.append("conjugated ");
+ }
+ }
+ _builder.append("port class");
+ _builder.newLineIfNotEmpty();
+ _builder.append("//------------------------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("class ");
+ _builder.append(portClassName, "");
+ _builder.append(" : public etRuntime::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(" ");
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// constructors");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append(portClassName, " ");
+ _builder.append("(etRuntime::IEventReceiver actor, char* name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress); ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t ");
+ _builder.append(portClassName, " ");
+ _builder.append("(etRuntime::IEventReceiver actor, char* name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("virtual void receive(etRuntime::Message m);");
+ _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 _operationsDeclaration = this.helpers.operationsDeclaration(_operations, portClassName);
+ _builder.append(_operationsDeclaration, " ");
+ _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 _sendMessageDeclaration = this.sendMessageDeclaration(m, conj);
+ _builder.append(_sendMessageDeclaration, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("//------------------------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("// ");
+ {
+ if (conj) {
+ _builder.append("conjugated ");
+ }
+ }
+ _builder.append("replicated port class");
+ _builder.newLineIfNotEmpty();
+ _builder.append("//------------------------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("class ");
+ _builder.append(replPortClassName, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("private:");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("std::list<");
+ _builder.append(portClassName, " ");
+ _builder.append("> ports;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t ");
+ _builder.append("int replication;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// constructor");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append(replPortClassName, " ");
+ _builder.append("(etRuntime::IEventReceiver actor, char* name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int getReplication() {\treturn replication; }");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx();\t}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append(" get(int i) {return ports[i];}");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_operator_equals) {
+ {
+ if (conj) {
+ _builder.append("\t");
+ _builder.append("// incoming messages");
+ _builder.newLine();
+ _builder.append("\t");
+ _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();
+ }
+ }
+ } 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();
+ }
+ }
+ }
+ }
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_operator_equals_1) {
+ _builder.append(" ");
+ _builder.append("/*--------------------- port structs and methods */");
+ _builder.newLine();
+ StringConcatenation _genDataDrivenPortHeaders = this.genDataDrivenPortHeaders(pc);
+ _builder.append(_genDataDrivenPortHeaders, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_operator_equals_2) {
+ _builder.append("#error \"synchronous protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public StringConcatenation portClassImplementation(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ 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();
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("::");
+ _builder.append(portClassName, "");
+ _builder.append("::");
+ _builder.append(portClassName, "");
+ _builder.append("(IEventReceiver actor, char* name, int localId, Address addr, Address peerAddress)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(": PortBase(actor, name, localId, 0, addr, peerAddress)");
+ _builder.newLine();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("DebuggingService::getInstance().addPortInstance(*this);");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = pc.getName();
+ _builder.append(_name_1, "");
+ _builder.append("::");
+ _builder.append(portClassName, "");
+ _builder.append("::");
+ _builder.append(portClassName, "");
+ _builder.append("(IEventReceiver actor, char* name, int localId, int idx, Address addr, Address peerAddress)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(": PortBase(actor, name, localId, idx, addr, peerAddress)");
+ _builder.newLine();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("DebuggingService::getInstance().addPortInstance(*this);");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_2 = pc.getName();
+ _builder.append(_name_2, "");
+ _builder.append("::");
+ _builder.append(portClassName, "");
+ _builder.append("::receive(Message m) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (!(m instanceof EventMessage)) return;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("EventMessage msg = (EventMessage) m;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("System.out.println(\"unknown\");");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("else {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("if (messageStrings[msg.getEvtId()] != \"timerTick\"){");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
+ if (_handlesReceive) {
+ _builder.append("\t");
+ _builder.append("switch (msg.getEvtId()) {");
+ _builder.newLine();
+ {
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
+ for(final MessageHandler hdlr : _receiveHandlers) {
+ _builder.append("\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");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("default:");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("if (msg instanceof EventWithDataMessage)");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("else");
+ _builder.newLine();
+ _builder.append("\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");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ {
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(pclass, null);
+ if (_operator_notEquals) {
+ EList<PortOperation> _operations = pclass.getOperations();
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, portClassName);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("// sent messages");
+ _builder.newLine();
+ {
+ List<Message> _outgoing = this.roomExt.getOutgoing(pc, conj);
+ for(final Message m : _outgoing) {
+ String _name_3 = pc.getName();
+ String _operator_plus = StringExtensions.operator_plus(_name_3, "::");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, portClassName);
+ StringConcatenation _sendMessage = this.sendMessage(m, _operator_plus_1, conj);
+ _builder.append(_sendMessage, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("//-------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("// replicated port class");
+ _builder.newLine();
+ _builder.append("//-------------------------------------------------------------------------------");
+ _builder.newLine();
+ String _name_4 = pc.getName();
+ _builder.append(_name_4, "");
+ _builder.append("::");
+ _builder.append(replPortClassName, "");
+ _builder.append("::");
+ _builder.append(replPortClassName, "");
+ _builder.append("(IEventReceiver actor, char* name, int localId, Address addr, Address peerAddress) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("replication = addr==null? 0:addr.length;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ports = new ArrayList<");
+ String _name_5 = pc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append(".");
+ _builder.append(portClassName, " ");
+ _builder.append(">(replication);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("ports.add(new ");
+ _builder.append(portClassName, " ");
+ _builder.append("(");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
+ _builder.append("actor, name+i, localId, i, addr[i], peerAddress[i]));");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ if (conj) {
+ _builder.append("// incoming messages");
+ _builder.newLine();
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ String _name_6 = pc.getName();
+ String _operator_plus_2 = StringExtensions.operator_plus(_name_6, "::");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, replPortClassName);
+ StringConcatenation _messageSignatureDefinition = this.messageSignatureDefinition(m_1, _operator_plus_3);
+ _builder.append(_messageSignatureDefinition, "");
+ _builder.append("{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("ports[i].");
+ StringConcatenation _messageCall = this.messageCall(m_1);
+ _builder.append(_messageCall, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ } else {
+ _builder.append("// outgoing messages");
+ _builder.newLine();
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m_2 : _allOutgoingMessages) {
+ String _name_7 = pc.getName();
+ String _operator_plus_4 = StringExtensions.operator_plus(_name_7, "::");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, replPortClassName);
+ StringConcatenation _messageSignatureDefinition_1 = this.messageSignatureDefinition(m_2, _operator_plus_5);
+ _builder.append(_messageSignatureDefinition_1, "");
+ _builder.append("{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("ports[i].");
+ StringConcatenation _messageCall_1 = this.messageCall(m_2);
+ _builder.append(_messageCall_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation generateSourceFile(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\t");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* Source File of ProtocolClass ");
+ String _name = pc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"");
+ String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(pc);
+ _builder.append(_cppHeaderFileName, " ");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("#include \"common/debugging/DebuggingService.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("using namespace etRuntime;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ DetailCode _userCode3 = pc.getUserCode3();
+ StringConcatenation _userCode = this.helpers.userCode(_userCode3);
+ _builder.append(_userCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_operator_equals) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//----------------------------------------------");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// java code");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//----------------------------------------------");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ DetailCode _userCode2 = pc.getUserCode2();
+ StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//private static char* messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\"");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("\",");
+ }
+ }
+ _builder.append(" ");
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\"");
+ String _name_2 = m_1.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("\",");
+ }
+ }
+ _builder.append("\"MAX\"};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("char* ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("::getMessageString(int msg_id) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("// id out of range");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return \"Message ID out of range\";");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("else{");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return messageStrings[msg_id];");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ StringConcatenation _portClassImplementation = this.portClassImplementation(pc, ((Boolean)false));
+ _builder.append(_portClassImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ StringConcatenation _portClassImplementation_1 = this.portClassImplementation(pc, ((Boolean)true));
+ _builder.append(_portClassImplementation_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/*--------------------- debug helpers */");
+ _builder.newLine();
+ _builder.append("\t");
+ StringConcatenation _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
+ _builder.append(_generateDebugHelpersImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_operator_equals_1) {
+ StringConcatenation _genDataDrivenPortSources = this.genDataDrivenPortSources(pc);
+ _builder.append(_genDataDrivenPortSources, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _operator_equals_2 = ObjectExtensions.operator_equals(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_operator_equals_2) {
+ _builder.append("#error \"synchronoue protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ return _builder;
+ }
+
+ private StringConcatenation portClassHeader(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ List<Message> _xifexpression = null;
+ if (conj) {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("typedef etPort ");
+ _builder.append(portClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("typedef etReplPort ");
+ _builder.append(replPortClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ PortClass _portClass = this.roomExt.getPortClass(pc, conj);
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_portClass, null);
+ if (_operator_notEquals) {
+ {
+ PortClass _portClass_1 = this.roomExt.getPortClass(pc, conj);
+ EList<Attribute> _attributes = _portClass_1.getAttributes();
+ boolean _isEmpty = _attributes.isEmpty();
+ boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+ if (_operator_not) {
+ _builder.append("/* variable part of PortClass (RAM) */");
+ _builder.newLine();
+ _builder.append("typedef struct ");
+ _builder.append(portClassName, "");
+ _builder.append("_var ");
+ _builder.append(portClassName, "");
+ _builder.append("_var; ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("struct ");
+ _builder.append(portClassName, "");
+ _builder.append("_var {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ PortClass _portClass_2 = this.roomExt.getPortClass(pc, conj);
+ EList<Attribute> _attributes_1 = _portClass_2.getAttributes();
+ StringConcatenation _attributes_2 = this.helpers.attributes(_attributes_1);
+ _builder.append(_attributes_2, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("};");
+ _builder.newLine();
+ {
+ PortClass _portClass_3 = this.roomExt.getPortClass(pc, conj);
+ EList<Attribute> _attributes_3 = _portClass_3.getAttributes();
+ for(final Attribute a : _attributes_3) {
+ {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null);
+ if (_operator_notEquals_1) {
+ _builder.append("\t\t\t\t");
+ String _operator_plus = StringExtensions.operator_plus(portClassName, " ");
+ String _name = a.getName();
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _name);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ": Attribute initialization not supported in C");
+ this.logger.logInfo(_operator_plus_2);
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_data, null);
+ boolean hasData = _operator_notEquals_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ if (hasData) {
+ VarDecl _data_1 = message.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _xifexpression_1 = _typeName;
+ } else {
+ _xifexpression_1 = "";
+ }
+ String typeName = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ boolean _operator_and = false;
+ if (!hasData) {
+ _operator_and = false;
+ } else {
+ boolean _operator_or = false;
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _operator_not_1 = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
+ if (_operator_not_1) {
+ _operator_or = true;
+ } else {
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ boolean _isRef = _refType_2.isRef();
+ _operator_or = BooleanExtensions.operator_or(_operator_not_1, _isRef);
+ }
+ _operator_and = BooleanExtensions.operator_and(hasData, _operator_or);
+ }
+ if (_operator_and) {
+ _xifexpression_2 = "*";
+ } else {
+ _xifexpression_2 = "";
+ }
+ String refp = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ if (hasData) {
+ String _operator_plus_3 = StringExtensions.operator_plus(", ", typeName);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, refp);
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, " data");
+ _xifexpression_3 = _operator_plus_5;
+ } else {
+ _xifexpression_3 = "";
+ }
+ String data = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _name_1 = message.getName();
+ String _messageSignature = this.messageSignature(portClassName, _name_1, "", data);
+ _builder.append(_messageSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _name_2 = message.getName();
+ String _messageSignature_1 = this.messageSignature(replPortClassName, _name_2, "_broadcast", data);
+ _builder.append(_messageSignature_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _name_3 = message.getName();
+ String _operator_plus_6 = StringExtensions.operator_plus(", int idx", data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_3, "", _operator_plus_6);
+ _builder.append(_messageSignature_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ PortClass _portClass_4 = this.roomExt.getPortClass(pc, conj);
+ boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_portClass_4, null);
+ if (_operator_notEquals_3) {
+ PortClass _portClass_5 = this.roomExt.getPortClass(pc, conj);
+ EList<PortOperation> _operations = _portClass_5.getOperations();
+ StringConcatenation _operationsDeclaration = this.helpers.operationsDeclaration(_operations, portClassName);
+ _builder.append(_operationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass_6 = this.roomExt.getPortClass(pc, conj);
+ EList<PortOperation> _operations_1 = _portClass_6.getOperations();
+ StringConcatenation _operationsDeclaration_1 = this.helpers.operationsDeclaration(_operations_1, replPortClassName);
+ _builder.append(_operationsDeclaration_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
+ if (_handlesReceive) {
+ {
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _name_4 = _msg.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_receiveHandler(");
+ _builder.append(portClassName, "");
+ _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation genDataDrivenPortHeaders(final ProtocolClass pc) {
+ StringConcatenation _xblockexpression = null;
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
+ public Boolean apply(final Message m) {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ return ((Boolean)_operator_notEquals);
+ }
+ };
+ Iterable<Message> _filter = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
+ Iterable<Message> sentMsgs = _filter;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* data driven send port (conjugated) */");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ {
+ for(final Message msg : sentMsgs) {
+ _builder.append("\t");
+ VarDecl _data = msg.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ String typeName = _typeName;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _xifexpression = null;
+ VarDecl _data_1 = msg.getData();
+ RefableType _refType_1 = _data_1.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ if (_isRef) {
+ _xifexpression = "*";
+ } else {
+ _xifexpression = "";
+ }
+ String refp = _xifexpression;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(typeName, " ");
+ _builder.append(refp, " ");
+ _builder.append(" ");
+ String _name = msg.getName();
+ _builder.append(_name, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName = this.roomExt.getPortClassName(pc, true);
+ _builder.append(_portClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* data driven receive port (regular) */");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, true);
+ _builder.append(_portClassName_1, " ");
+ _builder.append("* peer;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName_2 = this.roomExt.getPortClassName(pc, false);
+ _builder.append(_portClassName_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ for(final Message message : sentMsgs) {
+ VarDecl _data_2 = message.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data_2, null);
+ boolean hasData = _operator_notEquals;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ if (hasData) {
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ String _typeName_1 = this._typeHelpers.typeName(_type_1);
+ _xifexpression_1 = _typeName_1;
+ } else {
+ _xifexpression_1 = "";
+ }
+ String typeName_1 = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ boolean _operator_and = false;
+ if (!hasData) {
+ _operator_and = false;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ boolean _operator_not = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
+ _operator_and = BooleanExtensions.operator_and(hasData, _operator_not);
+ }
+ if (_operator_and) {
+ _xifexpression_2 = "*";
+ } else {
+ _xifexpression_2 = "";
+ }
+ String refp_1 = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ if (hasData) {
+ String _operator_plus = StringExtensions.operator_plus(", ", typeName_1);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp_1);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
+ _xifexpression_3 = _operator_plus_2;
+ } else {
+ _xifexpression_3 = "";
+ }
+ String data = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _portClassName_3 = this.roomExt.getPortClassName(pc, true);
+ String _name_1 = message.getName();
+ String _messageSetterSignature = this.messageSetterSignature(_portClassName_3, _name_1, data);
+ _builder.append(_messageSetterSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _portClassName_4 = this.roomExt.getPortClassName(pc, false);
+ String _name_2 = message.getName();
+ String _messageGetterSignature = this.messageGetterSignature(_portClassName_4, _name_2, typeName_1);
+ _builder.append(_messageGetterSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation genDataDrivenPortSources(final ProtocolClass pc) {
+ StringConcatenation _xblockexpression = null;
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
+ public Boolean apply(final Message m) {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ return ((Boolean)_operator_notEquals);
+ }
+ };
+ Iterable<Message> _filter = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
+ Iterable<Message> messages = _filter;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ String typeName = _typeName;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression = null;
+ VarDecl _data_1 = message.getData();
+ RefableType _refType_1 = _data_1.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
+ if (_operator_not) {
+ _xifexpression = "*";
+ } else {
+ _xifexpression = "";
+ }
+ String refp = _xifexpression;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_2 = _data_2.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ if ((_type_2 instanceof PrimitiveType)) {
+ _xifexpression_1 = "&";
+ } else {
+ _xifexpression_1 = "";
+ }
+ String refa = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _operator_plus = StringExtensions.operator_plus(", ", typeName);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
+ String data = _operator_plus_2;
+ _builder.newLineIfNotEmpty();
+ String _portClassName = this.roomExt.getPortClassName(pc, true);
+ String _name = message.getName();
+ String _messageSetterSignature = this.messageSetterSignature(_portClassName, _name, data);
+ _builder.append(_messageSetterSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("self->");
+ String _name_1 = message.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" = data;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, false);
+ String _name_2 = message.getName();
+ String _messageGetterSignature = this.messageGetterSignature(_portClassName_1, _name_2, typeName);
+ _builder.append(_messageGetterSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return self->peer->");
+ String _name_3 = message.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation portClassSource(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _portClassName = this.roomExt.getPortClassName(pc, conj);
+ String portClassName = _portClassName;
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, conj, true);
+ String replPortClassName = _portClassName_1;
+ List<Message> _xifexpression = null;
+ if (conj) {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ String _xifexpression_1 = null;
+ if (conj) {
+ _xifexpression_1 = "IN_";
+ } else {
+ _xifexpression_1 = "OUT_";
+ }
+ String dir = _xifexpression_1;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ boolean hasData = _operator_notEquals;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ if (hasData) {
+ VarDecl _data_1 = message.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _xifexpression_2 = _typeName;
+ } else {
+ _xifexpression_2 = "";
+ }
+ String typeName = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ boolean _operator_and = false;
+ if (!hasData) {
+ _operator_and = false;
+ } else {
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ _operator_and = BooleanExtensions.operator_and(hasData, _isRef);
+ }
+ if (_operator_and) {
+ _xifexpression_3 = "*";
+ } else {
+ _xifexpression_3 = "";
+ }
+ String refp = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_4 = null;
+ boolean _operator_and_1 = false;
+ if (!hasData) {
+ _operator_and_1 = false;
+ } else {
+ boolean _operator_or = false;
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
+ if (_operator_not) {
+ _operator_or = true;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ boolean _isRef_1 = _refType_3.isRef();
+ _operator_or = BooleanExtensions.operator_or(_operator_not, _isRef_1);
+ }
+ _operator_and_1 = BooleanExtensions.operator_and(hasData, _operator_or);
+ }
+ if (_operator_and_1) {
+ _xifexpression_4 = "*";
+ } else {
+ _xifexpression_4 = "";
+ }
+ String refpd = _xifexpression_4;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_5 = null;
+ boolean _operator_and_2 = false;
+ boolean _operator_and_3 = false;
+ if (!hasData) {
+ _operator_and_3 = false;
+ } else {
+ VarDecl _data_5 = message.getData();
+ RefableType _refType_4 = _data_5.getRefType();
+ DataType _type_2 = _refType_4.getType();
+ boolean _operator_not_1 = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
+ _operator_and_3 = BooleanExtensions.operator_and(hasData, _operator_not_1);
+ }
+ if (!_operator_and_3) {
+ _operator_and_2 = false;
+ } else {
+ VarDecl _data_6 = message.getData();
+ RefableType _refType_5 = _data_6.getRefType();
+ boolean _isRef_2 = _refType_5.isRef();
+ boolean _operator_not_2 = BooleanExtensions.operator_not(_isRef_2);
+ _operator_and_2 = BooleanExtensions.operator_and(_operator_and_3, _operator_not_2);
+ }
+ if (_operator_and_2) {
+ _xifexpression_5 = "";
+ } else {
+ _xifexpression_5 = "&";
+ }
+ String refa = _xifexpression_5;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_6 = null;
+ if (hasData) {
+ String _operator_plus = StringExtensions.operator_plus(", ", typeName);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refpd);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
+ _xifexpression_6 = _operator_plus_2;
+ } else {
+ _xifexpression_6 = "";
+ }
+ String data = _xifexpression_6;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_7 = null;
+ if (hasData) {
+ _xifexpression_7 = ", data";
+ } else {
+ _xifexpression_7 = "";
+ }
+ String dataCall = _xifexpression_7;
+ _builder.newLineIfNotEmpty();
+ MessageHandler _sendHandler = this.roomExt.getSendHandler(message, conj);
+ MessageHandler hdlr = _sendHandler;
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name = message.getName();
+ String _messageSignature = this.messageSignature(portClassName, _name, "", data);
+ _builder.append(_messageSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(hdlr, null);
+ if (_operator_notEquals_1) {
+ _builder.append("\t");
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(portClassName, " ");
+ _builder.append("\", \"");
+ String _name_1 = message.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_2 = pc.getName();
+ String _name_3 = message.getName();
+ String _operator_plus_3 = StringExtensions.operator_plus(dir, _name_3);
+ String _memberInUse = this.stdExt.memberInUse(_name_2, _operator_plus_3);
+ String _operator_plus_4 = StringExtensions.operator_plus(typeName, refp);
+ String _operator_plus_5 = StringExtensions.operator_plus(refa, "data");
+ String _sendMessageCall = this.sendMessageCall(hasData, "self", _memberInUse, _operator_plus_4, _operator_plus_5);
+ _builder.append(_sendMessageCall, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_4 = message.getName();
+ String _messageSignature_1 = this.messageSignature(replPortClassName, _name_4, "_broadcast", data);
+ _builder.append(_messageSignature_1, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(hdlr, null);
+ if (_operator_notEquals_2) {
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name_5 = message.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("((etPort*)&((etReplPort*)self)->ports[i]");
+ _builder.append(dataCall, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}\t\t\t\t\t");
+ _builder.newLine();
+ } else {
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_6 = message.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_7 = pc.getName();
+ String _name_8 = message.getName();
+ String _operator_plus_6 = StringExtensions.operator_plus(dir, _name_8);
+ String _memberInUse_1 = this.stdExt.memberInUse(_name_7, _operator_plus_6);
+ String _operator_plus_7 = StringExtensions.operator_plus(typeName, refp);
+ String _operator_plus_8 = StringExtensions.operator_plus(refa, "data");
+ String _sendMessageCall_1 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[i])", _memberInUse_1, _operator_plus_7, _operator_plus_8);
+ _builder.append(_sendMessageCall_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_9 = message.getName();
+ String _operator_plus_9 = StringExtensions.operator_plus(", int idx", data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_9, "", _operator_plus_9);
+ _builder.append(_messageSignature_2, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(hdlr, null);
+ if (_operator_notEquals_3) {
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name_10 = message.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("((etPort*)&((etReplPort*)self)->ports[idx]");
+ _builder.append(dataCall, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_11 = message.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (0<=idx && idx<((etReplPort*)self)->size) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_12 = pc.getName();
+ String _name_13 = message.getName();
+ String _operator_plus_10 = StringExtensions.operator_plus(dir, _name_13);
+ String _memberInUse_2 = this.stdExt.memberInUse(_name_12, _operator_plus_10);
+ String _operator_plus_11 = StringExtensions.operator_plus(typeName, refp);
+ String _operator_plus_12 = StringExtensions.operator_plus(refa, "data");
+ String _sendMessageCall_2 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[idx])", _memberInUse_2, _operator_plus_11, _operator_plus_12);
+ _builder.append(_sendMessageCall_2, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.newLine();
+ {
+ PortClass _portClass = this.roomExt.getPortClass(pc, conj);
+ boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(_portClass, null);
+ if (_operator_notEquals_4) {
+ PortClass _portClass_1 = this.roomExt.getPortClass(pc, conj);
+ EList<PortOperation> _operations = _portClass_1.getOperations();
+ StringConcatenation _operationsImplementation = this.helpers.operationsImplementation(_operations, portClassName);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass_2 = this.roomExt.getPortClass(pc, conj);
+ EList<PortOperation> _operations_1 = _portClass_2.getOperations();
+ StringConcatenation _operationsImplementation_1 = this.helpers.operationsImplementation(_operations_1, replPortClassName);
+ _builder.append(_operationsImplementation_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("// getReplication");
+ _builder.newLine();
+ _builder.append("etInt32 ");
+ _builder.append(replPortClassName, "");
+ _builder.append("_getReplication(const ");
+ _builder.append(replPortClassName, "");
+ _builder.append("* self) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return ((etReplPort*)self)->size;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this.roomExt.handlesReceive(pc, conj);
+ if (_handlesReceive) {
+ StringConcatenation _genReceiveHandlers = this.genReceiveHandlers(pc, conj);
+ _builder.append(_genReceiveHandlers, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private String sendMessageCall(final boolean hasData, final String self, final String msg, final String typeName, final String data) {
+ String _xifexpression = null;
+ if (hasData) {
+ String _operator_plus = StringExtensions.operator_plus("etPort_sendMessage(", self);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ", ");
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, msg);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, ", sizeof(");
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, typeName);
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "), ");
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, data);
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ");");
+ _xifexpression = _operator_plus_7;
+ } else {
+ String _operator_plus_8 = StringExtensions.operator_plus("etPort_sendMessage(", self);
+ String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, ", ");
+ String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, msg);
+ String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ", 0, NULL);");
+ _xifexpression = _operator_plus_11;
+ }
+ return _xifexpression;
+ }
+
+ private String messageSignature(final String className, final String messageName, final String methodSuffix, final String data) {
+ String _operator_plus = StringExtensions.operator_plus("void ", className);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, messageName);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, methodSuffix);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "(const ");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, className);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "* self");
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, data);
+ String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ")");
+ return _operator_plus_8;
+ }
+
+ private String messageSetterSignature(final String className, final String messageName, final String data) {
+ String _operator_plus = StringExtensions.operator_plus("void ", className);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, messageName);
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "_set(");
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, className);
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "* self");
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, data);
+ String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ")");
+ return _operator_plus_7;
+ }
+
+ private String messageGetterSignature(final String className, final String messageName, final String type) {
+ String _operator_plus = StringExtensions.operator_plus(type, " ");
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, className);
+ String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_");
+ String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, messageName);
+ String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "_get(const ");
+ String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, className);
+ String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "* const self)");
+ return _operator_plus_6;
+ }
+
+ private StringConcatenation messageCall(final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (_operator_notEquals) {
+ _builder.append(" ");
+ VarDecl _data_1 = m.getData();
+ String _name_1 = _data_1.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ private StringConcatenation genReceiveHandlers(final ProtocolClass pc, final Boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ 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.append("/* receiver handlers */");
+ _builder.newLine();
+ {
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, conj);
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _name = _msg.getName();
+ _builder.append(_name, "");
+ _builder.append("_receiveHandler(");
+ _builder.append(portClassName, "");
+ _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ DetailCode _detailCode = h.getDetailCode();
+ StringConcatenation _userCode = this.helpers.userCode(_detailCode);
+ _builder.append(_userCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* hand over the message to the actor: */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* (*receiveMessageFunc)(actor, self, msg); */");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private StringConcatenation generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.newLine();
+ _builder.append("/* message names as strings for debugging (generate MSC) */");
+ _builder.newLine();
+ _builder.append("static const char* ");
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("_messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\"");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, "");
+ _builder.append("\",");
+ }
+ }
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\"");
+ String _name_2 = m_1.getName();
+ _builder.append(_name_2, "");
+ _builder.append("\", ");
+ }
+ }
+ _builder.append("\"MAX\"};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("const char* ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_getMessageString(int msg_id) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (msg_id<");
+ String _name_4 = pc.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("_MSG_MIN || msg_id>");
+ String _name_5 = pc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("_MSG_MAX+1){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("/* id out of range */");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return \"Message ID out of range\";");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("else{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return ");
+ String _name_6 = pc.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("_messageStrings[msg_id];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public StringConcatenation messageSignature(final Message m) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _isPriv = m.isPriv();
+ if (_isPriv) {
+ _builder.append("private:");
+ } else {
+ _builder.append("public:");
+ }
+ }
+ _builder.append(" void ");
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (_operator_notEquals) {
+ VarDecl _data_1 = m.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _builder.append(_typeName, "");
+ _builder.append(" ");
+ VarDecl _data_2 = m.getData();
+ String _name_1 = _data_2.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ return _builder;
+ }
+
+ public StringConcatenation messageSignatureExplicit(final Message m) {
+ StringConcatenation _xblockexpression = null;
+ {
+ VarDecl _data = m.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ DataClass dc = ((DataClass) _type);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("public: void ");
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ DataClass _base = dc.getBase();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_notEquals) {
+ DataClass _base_1 = dc.getBase();
+ String _typeName = this._typeHelpers.typeName(_base_1);
+ _builder.append(_typeName, "");
+ _builder.append(" _super, ");
+ }
+ }
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ boolean hasAnyElements = false;
+ for(final Attribute a : _attributes) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(", ", "");
+ }
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _typeName_1 = this._typeHelpers.typeName(_type_1);
+ _builder.append(_typeName_1, "");
+ {
+ int _size = a.getSize();
+ boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
+ if (_operator_greaterThan) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ String _name_1 = a.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public StringConcatenation messageSignatureDefinition(final Message m, final String classPrefix) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("void ");
+ _builder.append(classPrefix, "");
+ _builder.append("::");
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (_operator_notEquals) {
+ VarDecl _data_1 = m.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _builder.append(_typeName, "");
+ _builder.append(" ");
+ VarDecl _data_2 = m.getData();
+ String _name_1 = _data_2.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ return _builder;
+ }
+
+ public StringConcatenation messageSignatureExplicitDefinition(final Message m, final String classPrefix) {
+ StringConcatenation _xblockexpression = null;
+ {
+ VarDecl _data = m.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ DataClass dc = ((DataClass) _type);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("void ");
+ _builder.append(classPrefix, "");
+ _builder.append("::");
+ String _name = m.getName();
+ _builder.append(_name, "");
+ _builder.append("(");
+ {
+ DataClass _base = dc.getBase();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_notEquals) {
+ DataClass _base_1 = dc.getBase();
+ String _typeName = this._typeHelpers.typeName(_base_1);
+ _builder.append(_typeName, "");
+ _builder.append(" _super, ");
+ }
+ }
+ {
+ EList<Attribute> _attributes = dc.getAttributes();
+ boolean hasAnyElements = false;
+ for(final Attribute a : _attributes) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(", ", "");
+ }
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _typeName_1 = this._typeHelpers.typeName(_type_1);
+ _builder.append(_typeName_1, "");
+ {
+ int _size = a.getSize();
+ boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)1));
+ if (_operator_greaterThan) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ String _name_1 = a.getName();
+ _builder.append(_name_1, "");
+ }
+ }
+ _builder.append(")");
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public StringConcatenation sendMessageDeclaration(final Message m, final boolean conj) {
+ StringConcatenation _builder = new StringConcatenation();
+ StringConcatenation _messageSignature = this.messageSignature(m);
+ _builder.append(_messageSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_and = false;
+ VarDecl _data = m.getData();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_data, null);
+ if (!_operator_notEquals) {
+ _operator_and = false;
+ } else {
+ VarDecl _data_1 = m.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ _operator_and = BooleanExtensions.operator_and(_operator_notEquals, (_type instanceof DataClass));
+ }
+ if (_operator_and) {
+ StringConcatenation _messageSignatureExplicit = this.messageSignatureExplicit(m);
+ _builder.append(_messageSignatureExplicit, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public StringConcatenation sendMessage(final Message m, final String classPrefix, final boolean conj) {
+ StringConcatenation _xblockexpression = null;
+ {
+ String _xifexpression = null;
+ if (conj) {
+ _xifexpression = "IN";
+ } else {
+ _xifexpression = "OUT";
+ }
+ String dir = _xifexpression;
+ MessageHandler _sendHandler = this.roomExt.getSendHandler(m, conj);
+ MessageHandler hdlr = _sendHandler;
+ StringConcatenation _builder = new StringConcatenation();
+ StringConcatenation _messageSignatureDefinition = this.messageSignatureDefinition(m, classPrefix);
+ _builder.append(_messageSignatureDefinition, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(hdlr, null);
+ if (_operator_notEquals) {
+ _builder.append("\t");
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t");
+ _builder.append("if (messageStrings[ ");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name = m.getName();
+ _builder.append(_name, " ");
+ _builder.append("] != \"timerTick\"){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("]);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (getPeerAddress()!=null)");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ {
+ VarDecl _data = m.getData();
+ boolean _operator_equals = ObjectExtensions.operator_equals(_data, null);
+ if (_operator_equals) {
+ _builder.append("getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), ");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_2 = m.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ } else {
+ _builder.append("getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), ");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_3 = m.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(", ");
+ VarDecl _data_1 = m.getData();
+ String _name_4 = _data_1.getName();
+ _builder.append(_name_4, " ");
+ {
+ boolean _operator_and = false;
+ VarDecl _data_2 = m.getData();
+ RefableType _refType = _data_2.getRefType();
+ boolean _isRef = _refType.isRef();
+ boolean _operator_not = BooleanExtensions.operator_not(_isRef);
+ if (!_operator_not) {
+ _operator_and = false;
+ } else {
+ VarDecl _data_3 = m.getData();
+ RefableType _refType_1 = _data_3.getRefType();
+ DataType _type = _refType_1.getType();
+ boolean _operator_not_1 = BooleanExtensions.operator_not((_type instanceof PrimitiveType));
+ _operator_and = BooleanExtensions.operator_and(_operator_not, _operator_not_1);
+ }
+ if (_operator_and) {
+ _builder.append(".deepCopy()");
+ }
+ }
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ {
+ boolean _operator_and_1 = false;
+ VarDecl _data_4 = m.getData();
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_data_4, null);
+ if (!_operator_notEquals_1) {
+ _operator_and_1 = false;
+ } else {
+ VarDecl _data_5 = m.getData();
+ RefableType _refType_2 = _data_5.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals_1, (_type_1 instanceof DataClass));
+ }
+ if (_operator_and_1) {
+ StringConcatenation _messageSignatureExplicitDefinition = this.messageSignatureExplicitDefinition(m, classPrefix);
+ _builder.append(_messageSignatureExplicitDefinition, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_5 = m.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("(new ");
+ VarDecl _data_6 = m.getData();
+ RefableType _refType_3 = _data_6.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ String _name_6 = _type_2.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("(");
+ {
+ VarDecl _data_7 = m.getData();
+ RefableType _refType_4 = _data_7.getRefType();
+ DataType _type_3 = _refType_4.getType();
+ DataClass _base = ((DataClass) _type_3).getBase();
+ boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_base, null);
+ if (_operator_notEquals_2) {
+ _builder.append("_super, ");
+ }
+ }
+ {
+ VarDecl _data_8 = m.getData();
+ RefableType _refType_5 = _data_8.getRefType();
+ DataType _type_4 = _refType_5.getType();
+ EList<Attribute> _attributes = ((DataClass) _type_4).getAttributes();
+ boolean hasAnyElements = false;
+ for(final Attribute a : _attributes) {
+ if (!hasAnyElements) {
+ hasAnyElements = true;
+ } else {
+ _builder.appendImmediate(", ", " ");
+ }
+ String _name_7 = a.getName();
+ _builder.append(_name_7, " ");
+ }
+ }
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.launch.cpp/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator.launch.cpp/META-INF/MANIFEST.MF
index af784af..4dc43df 100644
--- a/plugins/org.eclipse.etrice.generator.launch.cpp/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.generator.launch.cpp/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: eTrice Java Generator Launcher
-Bundle-SymbolicName: org.eclipse.etrice.generator.launch.java;singleton:=true
+Bundle-Name: eTrice Cpp Generator Launcher
+Bundle-SymbolicName: org.eclipse.etrice.generator.launch.cpp;singleton:=true
Bundle-Version: 0.2.0.qualifier
Bundle-Activator: org.eclipse.etrice.generator.launch.cpp.Activator
Require-Bundle: org.eclipse.etrice.generator;bundle-version="0.1.0",
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/.cproject b/runtime/org.eclipse.etrice.runtime.cpp/.cproject
new file mode 100644
index 0000000..125c50d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/.cproject
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="cdt.managedbuild.config.gnu.mingw.lib.debug.878140176">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.lib.debug.878140176" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+ <externalSettings>
+ <externalSetting>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/org.eclipse.etrice.runtime.cpp"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/org.eclipse.etrice.runtime.cpp/Debug"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="org.eclipse.etrice.runtime.cpp"/>
+ </externalSetting>
+ </externalSettings>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.lib.debug.878140176" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.lib.debug">
+ <folderInfo id="cdt.managedbuild.config.gnu.mingw.lib.debug.878140176." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.lib.debug.1964804313" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.lib.debug">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.lib.debug.1363258846" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.lib.debug"/>
+ <builder buildPath="${workspace_loc:/org.eclipse.etrice.runtime.cpp/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.765054146" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.lib.debug.778368249" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.lib.debug">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1431383431" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.lib.debug.2067321690" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.lib.debug"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.debug.1516705340" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.debug">
+ <option id="gnu.cpp.compiler.mingw.lib.debug.option.optimization.level.143629884" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.lib.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.mingw.lib.debug.option.debugging.level.1636571561" name="Debug Level" superClass="gnu.cpp.compiler.mingw.lib.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.371088988" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.834970834" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug.787652226" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug">
+ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.lib.debug.option.optimization.level.1338147333" name="Optimization Level" superClass="gnu.c.compiler.mingw.lib.debug.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.mingw.lib.debug.option.debugging.level.1088652134" name="Debug Level" superClass="gnu.c.compiler.mingw.lib.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1322245631" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.833683108" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.1619419934" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base"/>
+ </toolChain>
+ </folderInfo>
+ <sourceEntries>
+ <entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+ </sourceEntries>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="cdt.managedbuild.config.gnu.mingw.lib.release.1265017536">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.lib.release.1265017536" moduleId="org.eclipse.cdt.core.settings" name="Release">
+ <externalSettings>
+ <externalSetting>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/org.eclipse.etrice.runtime.cpp"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/org.eclipse.etrice.runtime.cpp/Release"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="org.eclipse.etrice.runtime.cpp"/>
+ </externalSetting>
+ </externalSettings>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.lib.release.1265017536" name="Release" parent="cdt.managedbuild.config.gnu.mingw.lib.release">
+ <folderInfo id="cdt.managedbuild.config.gnu.mingw.lib.release.1265017536." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.lib.release.341416755" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.lib.release">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.lib.release.2033657787" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.lib.release"/>
+ <builder buildPath="${workspace_loc:/org.eclipse.etrice.runtime.cpp/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.629737011" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.lib.release.1791075014" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.lib.release">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1768068662" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.lib.release.633341399" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.lib.release"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.release.567360588" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.release">
+ <option id="gnu.cpp.compiler.mingw.lib.release.option.optimization.level.584961348" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.lib.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.mingw.lib.release.option.debugging.level.1368123052" name="Debug Level" superClass="gnu.cpp.compiler.mingw.lib.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.763277987" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1712453980" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.release.2143016498" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.release">
+ <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.lib.release.option.optimization.level.180068255" name="Optimization Level" superClass="gnu.c.compiler.mingw.lib.release.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.mingw.lib.release.option.debugging.level.1290753638" name="Debug Level" superClass="gnu.c.compiler.mingw.lib.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1857566126" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.536323295" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.2051974509" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base"/>
+ </toolChain>
+ </folderInfo>
+ <sourceEntries>
+ <entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+ </sourceEntries>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="org.eclipse.etrice.runtime.cpp.cdt.managedbuild.target.gnu.mingw.lib.335663705" name="Static Library" projectType="cdt.managedbuild.target.gnu.mingw.lib"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.lib.debug.878140176;cdt.managedbuild.config.gnu.mingw.lib.debug.878140176.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.debug.1516705340;cdt.managedbuild.tool.gnu.cpp.compiler.input.834970834">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.lib.release.1265017536;cdt.managedbuild.config.gnu.mingw.lib.release.1265017536.;cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.release.2143016498;cdt.managedbuild.tool.gnu.c.compiler.input.1857566126">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.lib.release.1265017536;cdt.managedbuild.config.gnu.mingw.lib.release.1265017536.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.release.567360588;cdt.managedbuild.tool.gnu.cpp.compiler.input.1712453980">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.lib.debug.878140176;cdt.managedbuild.config.gnu.mingw.lib.debug.878140176.;cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug.787652226;cdt.managedbuild.tool.gnu.c.compiler.input.1322245631">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="refreshScope"/>
+</cproject>
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/.project b/runtime/org.eclipse.etrice.runtime.cpp/.project
new file mode 100644
index 0000000..fa5e9db
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/.project
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.runtime.cpp</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>?name?</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.append_environment</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildArguments</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildCommand</key>
+ <value>make</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildLocation</key>
+ <value>${workspace_loc:/org.eclipse.etrice.runtime.cpp/Debug}</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.contents</key>
+ <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+ <value>false</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.stopOnError</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+ <value>true</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ </natures>
+</projectDescription>
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/runtime/org.eclipse.etrice.runtime.cpp/.settings/org.eclipse.cdt.managedbuilder.core.prefs
new file mode 100644
index 0000000..8be085b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/.settings/org.eclipse.cdt.managedbuilder.core.prefs
@@ -0,0 +1,9 @@
+eclipse.preferences.version=1
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/CPATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/CPATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/CPLUS_INCLUDE_PATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/CPLUS_INCLUDE_PATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/C_INCLUDE_PATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/C_INCLUDE_PATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/append=true
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.878140176/appendContributed=true
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/Debug/liborg.eclipse.etrice.runtime.cpp.a b/runtime/org.eclipse.etrice.runtime.cpp/Debug/liborg.eclipse.etrice.runtime.cpp.a
new file mode 100644
index 0000000..b06fbff
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/Debug/liborg.eclipse.etrice.runtime.cpp.a
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/debugging/DebuggingService.o b/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/debugging/DebuggingService.o
new file mode 100644
index 0000000..76b93d6
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/debugging/DebuggingService.o
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/messaging/Address.o b/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/messaging/Address.o
new file mode 100644
index 0000000..81d2d84
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/messaging/Address.o
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/messaging/Message.o b/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/messaging/Message.o
new file mode 100644
index 0000000..e3fdf65
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/messaging/Message.o
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/modelbase/InterfaceItemBase.o b/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/modelbase/InterfaceItemBase.o
new file mode 100644
index 0000000..40683d4
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/modelbase/InterfaceItemBase.o
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/modelbase/PortBase.o b/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/modelbase/PortBase.o
new file mode 100644
index 0000000..c1f4766
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/Debug/src/common/modelbase/PortBase.o
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
new file mode 100644
index 0000000..09869d3
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
@@ -0,0 +1,23 @@
+/*
+ * DebuggingService.cpp
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#include "DebuggingService.h"
+
+namespace etRuntime {
+
+DebuggingService* DebuggingService::s_instance = 0;
+
+DebuggingService::DebuggingService() {
+ // TODO Auto-generated constructor stub
+
+}
+
+DebuggingService::~DebuggingService() {
+ // TODO Auto-generated destructor stub
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h
new file mode 100644
index 0000000..59931d1
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h
@@ -0,0 +1,55 @@
+/*
+ * DebuggingService.h
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#ifndef DEBUGGINGSERVICE_H_
+#define DEBUGGINGSERVICE_H_
+
+#include "common/messaging/Address.h"
+
+namespace etRuntime {
+
+class MSCLogger;
+class ActorClassBase;
+class PortBase;
+
+class DebuggingService {
+private:
+ static DebuggingService* s_instance;
+
+public:
+ virtual ~DebuggingService();
+
+ static DebuggingService& getInstance() {
+ if (s_instance == 0) {
+ s_instance = new DebuggingService();
+ }
+ return *s_instance;
+ }
+
+ void addMessageAsyncOut(Address source, Address target, const char * msg);
+ void addMessageAsyncIn(Address source, Address target, const char * msg);
+ void addMessageSyncCall(Address source, Address target, const char * msg);
+ void addMessageSyncReturn(Address source, Address target, const char * msg);
+ void addActorState(const ActorClassBase& actor, const char * state);
+ void addPortInstance(const PortBase& port);
+ MSCLogger getSyncLogger();
+ MSCLogger getAsyncLogger();
+
+private:
+ DebuggingService();
+ DebuggingService(const DebuggingService& right);
+ DebuggingService& operator=(const DebuggingService& right);
+
+};
+
+} /* namespace etRuntime */
+#endif /* DEBUGGINGSERVICE_H_ */
+
+
+
+
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp
new file mode 100644
index 0000000..860643b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp
@@ -0,0 +1,21 @@
+/*
+ * Address.cpp
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#include "Address.h"
+
+namespace etRuntime {
+
+Address::Address() {
+ // TODO Auto-generated constructor stub
+
+}
+
+Address::~Address() {
+ // TODO Auto-generated destructor stub
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h
new file mode 100644
index 0000000..792ad6d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h
@@ -0,0 +1,29 @@
+/*
+ * Address.h
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#ifndef ADDRESS_H_
+#define ADDRESS_H_
+
+namespace etRuntime {
+
+class Address {
+public:
+ Address(int nodeID,int threadID, int objectID)
+ : m_nodeID(nodeID), m_threadID(threadID), m_objectID(objectID) {};
+ ~Address();
+
+ int m_nodeID;
+ int m_threadID;
+ int m_objectID;
+
+private:
+ Address();
+};
+
+} /* namespace etRuntime */
+#endif /* ADDRESS_H_ */
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
new file mode 100644
index 0000000..9adf08b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
@@ -0,0 +1,21 @@
+/*
+ * Message.cpp
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#include "Message.h"
+
+namespace etRuntime {
+
+Message::Message() {
+ // TODO Auto-generated constructor stub
+
+}
+
+Message::~Message() {
+ // TODO Auto-generated destructor stub
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
new file mode 100644
index 0000000..07c8dfb
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
@@ -0,0 +1,25 @@
+/*
+ * Message.h
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#ifndef MESSAGE_H_
+#define MESSAGE_H_
+
+#include "common/messaging/Address.h"
+
+namespace etRuntime {
+
+class Message {
+public:
+ Message(Address addr) {};
+ virtual ~Message();
+
+private:
+ Message();
+};
+
+} /* namespace etRuntime */
+#endif /* MESSAGE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
new file mode 100644
index 0000000..9eeb9bd
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
@@ -0,0 +1,21 @@
+/*
+ * InterfaceItemBaase.cpp
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#include "InterfaceItemBase.h"
+
+namespace etRuntime {
+
+InterfaceItemBase::InterfaceItemBase() {
+ // TODO Auto-generated constructor stub
+
+}
+
+InterfaceItemBase::~InterfaceItemBase() {
+ // TODO Auto-generated destructor stub
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
new file mode 100644
index 0000000..5a6f2ef
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
@@ -0,0 +1,55 @@
+/*
+ * InterfaceItemBaase.h
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#ifndef INTERFACEITEMBASE_H_
+#define INTERFACEITEMBASE_H_
+
+#include "common/messaging/Address.h"
+
+namespace etRuntime {
+class IEventReceiver;
+
+
+class InterfaceItemBase {
+public:
+ InterfaceItemBase (const IEventReceiver& actor, char* name, int localId, int idx, Address ownAddress, Address peerAddress){};
+
+ InterfaceItemBase();
+ virtual ~InterfaceItemBase();
+ int getIdx() { return m_idx; } ;
+ void setMsgReceiver(IMessageReceiver msgReceiver) {
+ m_ownMsgReceiver = msgReceiver;
+ };
+ IEventReceiver getActor() {
+ return (IEventReceiver) getParent();
+ };
+
+ int getLocalId() {return m_localId; };
+
+protected:
+ IMessageReceiver getMsgReceiver() {
+ return m_ownMsgReceiver;
+ };
+
+ IMessageReceiver getPeerMsgReceiver() {
+ return m_peerMsgReceiver;
+ };
+ Address getPeerAddress() {
+ return m_peerAddress;
+ };
+
+private:
+ int m_idx;
+ int m_localId;
+
+ Address m_peerAddress;
+ IMessageReceiver m_ownMsgReceiver;
+ IMessageReceiver m_peerMsgReceiver;
+};
+
+} /* namespace etRuntime */
+#endif /* INTERFACEITEMBASE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.cpp
new file mode 100644
index 0000000..77ceeaa
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.cpp
@@ -0,0 +1,21 @@
+/*
+ * PortBase.cpp
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#include "PortBase.h"
+
+namespace etRuntime {
+
+PortBase::PortBase() {
+ // TODO Auto-generated constructor stub
+
+}
+
+PortBase::~PortBase() {
+ // TODO Auto-generated destructor stub
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h
new file mode 100644
index 0000000..c161272
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h
@@ -0,0 +1,28 @@
+/*
+ * PortBase.h
+ *
+ * Created on: 06.06.2012
+ * Author: karlitsc
+ */
+
+#ifndef PORTBASE_H_
+#define PORTBASE_H_
+
+#include "common/modelbase/InterfaceItemBase.h"
+#include "common/messaging/Address.h"
+
+namespace etRuntime {
+class IEventReceiver;
+
+class PortBase : public InterfaceItemBase{
+public:
+ PortBase (const IEventReceiver& actor, const char * name, int localId, int idx, Address address, Address peerAddress);
+ virtual ~PortBase();
+
+private:
+ PortBase();
+
+};
+
+} /* namespace etRuntime */
+#endif /* PORTBASE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/platforms/generic/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.cpp/src/platforms/generic/etDatatypes.h
new file mode 100644
index 0000000..aac2ec3
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/platforms/generic/etDatatypes.h
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _ETDATATYPES_H_
+#define _ETDATATYPES_H_
+
+/*
+ * typedefs for platform specific datatypes
+ * generic Version for most bigger 32 and 64 bit platforms like Linux an Windows
+ *
+ * */
+
+#include <stdio.h>
+
+/* unsigned integer datatypes */
+typedef unsigned char uint8;
+typedef unsigned short int uint16;
+typedef unsigned long uint32;
+typedef unsigned long long uint64;
+
+/* signed integer datatypes */
+typedef char int8;
+typedef short int int16;
+typedef long int32;
+typedef long long int64;
+
+
+/* float datatypes */
+typedef float float32;
+typedef double float64;
+
+/* boolean datatypes and values */
+typedef char bool; /* TODO: bool, Bool, Boolean, and boolean are already defined in some platforms*/
+typedef bool boolean;
+#ifndef TRUE
+ #define TRUE 1
+#endif
+#ifndef FALSE
+ #define FALSE 0
+#endif
+
+/*
+ * typedefs for eTrice Runtime and Testing
+ *
+ * */
+
+typedef int8 etInt8;
+typedef int16 etInt16;
+typedef int32 etInt32;
+
+typedef uint8 etUInt8;
+typedef uint16 etUInt16;
+typedef uint32 etUInt32;
+
+typedef bool etBool;
+
+typedef float32 etFloat32;
+typedef float64 etFloat64;
+
+typedef FILE* etFileHandle;
+
+typedef int8 etAddressId;
+
+#endif /* _DATATYPES_H_ */