Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Karlitschek2013-01-23 07:26:33 +0000
committerPeter Karlitschek2013-01-23 07:26:33 +0000
commit1e65cf2de6f5cd270853b4cfa1dcd2169078a683 (patch)
tree18cce6833cb3ecda35bb18b817f2cd8db4954312 /plugins/org.eclipse.etrice.generator.cpp/xtend-gen
parentc6f4dda244f74e45aa6f8fb507098a6c97e2566b (diff)
downloadorg.eclipse.etrice-1e65cf2de6f5cd270853b4cfa1dcd2169078a683.tar.gz
org.eclipse.etrice-1e65cf2de6f5cd270853b4cfa1dcd2169078a683.tar.xz
org.eclipse.etrice-1e65cf2de6f5cd270853b4cfa1dcd2169078a683.zip
first c++ tests and single/multithreaded runtime
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.cpp/xtend-gen')
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java821
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.java558
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java412
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java846
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/Initialization.java297
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java60
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java1394
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java143
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.java930
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.java263
10 files changed, 0 insertions, 5724 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java
deleted file mode 100644
index 65bf46776..000000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java
+++ /dev/null
@@ -1,821 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.ActorCommunicationType;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SAPRef;
-import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.core.room.ServiceImplementation;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.base.AbstractGenerator;
-import org.eclipse.etrice.generator.cpp.GeneratorOptions;
-import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
-import org.eclipse.etrice.generator.cpp.gen.Initialization;
-import org.eclipse.etrice.generator.cpp.gen.StateMachineGen;
-import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ListExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-public class ActorClassGen extends GenericActorClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CppExtensions _cppExtensions;
-
- @Inject
- private RoomExtensions _roomExtensions;
-
- @Inject
- private Initialization _initialization;
-
- @Inject
- private ProcedureHelpers _procedureHelpers;
-
- @Inject
- private StateMachineGen _stateMachineGen;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
- for (final ExpandedActorClass xpac : _xpActorClasses) {
- {
- ActorClass _actorClass = xpac.getActorClass();
- String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(_actorClass);
- ActorClass _actorClass_1 = xpac.getActorClass();
- String _path = this._roomExtensions.getPath(_actorClass_1);
- String path = (_generationTargetPath + _path);
- ActorClass _actorClass_2 = xpac.getActorClass();
- String _cppHeaderFileName = this._cppExtensions.getCppHeaderFileName(_actorClass_2);
- String _plus = ("generating ActorClass header \'" + _cppHeaderFileName);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_3 = xpac.getActorClass();
- String _cppHeaderFileName_1 = this._cppExtensions.getCppHeaderFileName(_actorClass_3);
- ActorClass _actorClass_4 = xpac.getActorClass();
- CharSequence _generateHeaderFile = this.generateHeaderFile(root, xpac, _actorClass_4);
- this.fileAccess.generateFile(_cppHeaderFileName_1, _generateHeaderFile);
- ActorClass _actorClass_5 = xpac.getActorClass();
- String _cppSourceFileName = this._cppExtensions.getCppSourceFileName(_actorClass_5);
- String _plus_4 = ("generating ActorClass source \'" + _cppSourceFileName);
- String _plus_5 = (_plus_4 + "\' in \'");
- String _plus_6 = (_plus_5 + path);
- String _plus_7 = (_plus_6 + "\'");
- this.logger.logInfo(_plus_7);
- this.fileAccess.setOutputPath(path);
- ActorClass _actorClass_6 = xpac.getActorClass();
- String _cppSourceFileName_1 = this._cppExtensions.getCppSourceFileName(_actorClass_6);
- ActorClass _actorClass_7 = xpac.getActorClass();
- CharSequence _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_7);
- this.fileAccess.generateFile(_cppSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- private CharSequence generateHeaderFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- CharSequence _xblockexpression = null;
- {
- EList<StandardOperation> _operations = ac.getOperations();
- final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isConstructor = RoomHelpers.isConstructor(op);
- return Boolean.valueOf(_isConstructor);
- }
- };
- Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
- final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
- EList<StandardOperation> _operations_1 = ac.getOperations();
- final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isDestructor = op.isDestructor();
- return Boolean.valueOf(_isDestructor);
- }
- };
- Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
- final StandardOperation dtor = IterableExtensions.<StandardOperation>head(_filter_1);
- 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("* Header File of ActorClass ");
- String _name = ac.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");
- String _name_1 = ac.getName();
- CharSequence _generateIncludeGuardBegin = this._cppExtensions.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"platforms/generic/etDatatypes.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/messaging/IRTObject.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/modelbase/PortBase.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/modelbase/InterfaceItemBase.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/modelbase/ActorClassBase.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/modelbase/SubSystemClassBase.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/messaging/Address.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/messaging/IMessageReceiver.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/debugging/DebuggingService.h\"");
- _builder.newLine();
- {
- boolean _isUseEtUnit = GeneratorOptions.isUseEtUnit();
- if (_isUseEtUnit) {
- _builder.append("\t");
- _builder.append("extern \"C\" {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("#include \"etUnit.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.append("#include <string>");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include <vector>");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- {
- EList<RoomModel> _referencedModels = root.getReferencedModels(ac);
- for(final RoomModel model : _referencedModels) {
- }
- }
- _builder.append("\t");
- _builder.newLine();
- {
- EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
- for(final ProtocolClass pc : _referencedProtocolClasses) {
- _builder.append("\t");
- _builder.append("#include \"");
- String _path = this._roomExtensions.getPath(pc);
- _builder.append(_path, " ");
- String _name_2 = pc.getName();
- _builder.append(_name_2, " ");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac);
- for(final DataClass dc : _referencedDataClasses) {
- _builder.append("\t");
- _builder.append("#include \"");
- String _path_1 = this._roomExtensions.getPath(dc);
- _builder.append(_path_1, " ");
- String _name_3 = dc.getName();
- _builder.append(_name_3, " ");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- CharSequence _userCode = this._procedureHelpers.userCode(ac, 1);
- _builder.append(_userCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("class ");
- String _name_4 = ac.getName();
- _builder.append(_name_4, " ");
- _builder.append(" : public ");
- {
- ActorClass _base = ac.getBase();
- boolean _notEquals = (!Objects.equal(_base, null));
- if (_notEquals) {
- ActorClass _base_1 = ac.getBase();
- String _name_5 = _base_1.getName();
- _builder.append(_name_5, " ");
- } else {
- _builder.append("etRuntime::ActorClassBase");
- }
- }
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("protected:");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("//--------------------- ports");
- _builder.newLine();
- _builder.append("\t\t\t");
- List<Port> _endPorts = this._roomExtensions.getEndPorts(ac);
- final Function1<Port,CharSequence> _function_2 = new Function1<Port,CharSequence>() {
- public CharSequence apply(final Port port) {
- StringConcatenation _builder = new StringConcatenation();
- String _portClassName = ActorClassGen.this._roomExtensions.getPortClassName(port);
- _builder.append(_portClassName, "");
- _builder.append(" ");
- String _name = port.getName();
- _builder.append(_name, "");
- _builder.append(";");
- return _builder;
- }
- };
- List<CharSequence> _map = ListExtensions.<Port, CharSequence>map(_endPorts, _function_2);
- String _join = IterableExtensions.join(_map, "\n");
- _builder.append(_join, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("//--------------------- saps");
- _builder.newLine();
- _builder.append("\t\t\t");
- EList<SAPRef> _strSAPs = ac.getStrSAPs();
- final Function1<SAPRef,CharSequence> _function_3 = new Function1<SAPRef,CharSequence>() {
- public CharSequence apply(final SAPRef sap) {
- StringConcatenation _builder = new StringConcatenation();
- String _portClassName = ActorClassGen.this._roomExtensions.getPortClassName(sap);
- _builder.append(_portClassName, "");
- _builder.append(" ");
- String _name = sap.getName();
- _builder.append(_name, "");
- _builder.append(";");
- return _builder;
- }
- };
- List<CharSequence> _map_1 = ListExtensions.<SAPRef, CharSequence>map(_strSAPs, _function_3);
- String _join_1 = IterableExtensions.join(_map_1, "\n");
- _builder.append(_join_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("//--------------------- services");
- _builder.newLine();
- _builder.append("\t\t\t");
- EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
- final Function1<ServiceImplementation,CharSequence> _function_4 = new Function1<ServiceImplementation,CharSequence>() {
- public CharSequence apply(final ServiceImplementation svc) {
- StringConcatenation _builder = new StringConcatenation();
- String _portClassName = ActorClassGen.this._roomExtensions.getPortClassName(svc);
- _builder.append(_portClassName, "");
- _builder.append(" ");
- SPPRef _spp = svc.getSpp();
- String _name = _spp.getName();
- _builder.append(_name, "");
- _builder.append(";");
- return _builder;
- }
- };
- List<CharSequence> _map_2 = ListExtensions.<ServiceImplementation, CharSequence>map(_serviceImplementations, _function_4);
- String _join_2 = IterableExtensions.join(_map_2, "\n");
- _builder.append(_join_2, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("//--------------------- interface item IDs");
- _builder.newLine();
- _builder.append("\t\t\t");
- String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
- _builder.append(_genInterfaceItemConstants, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t\t");
- _builder.newLine();
- _builder.append("\t\t\t");
- EList<Attribute> _attributes = ac.getAttributes();
- CharSequence _attributes_1 = this._procedureHelpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t\t\t");
- CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(ac);
- _builder.append(_operationsImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("public:");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("//--------------------- construction");
- _builder.newLine();
- _builder.append("\t\t\t");
- String _name_6 = ac.getName();
- _builder.append(_name_6, " ");
- _builder.append("(etRuntime::IRTObject* parent, std::string name, const std::vector<std::vector<etRuntime::Address> >& port_addr, ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ");
- _builder.append("const std::vector<std::vector<etRuntime::Address> >& peer_addr);");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("//--------------------- port getters");
- _builder.newLine();
- {
- List<Port> _endPorts_1 = this._roomExtensions.getEndPorts(ac);
- for(final Port ep : _endPorts_1) {
- _builder.append("\t\t");
- String _portClassName = this._roomExtensions.getPortClassName(ep);
- String _name_7 = ep.getName();
- String _name_8 = ac.getName();
- CharSequence _terImplementation = this._procedureHelpers.getterImplementation(_portClassName, _name_7, _name_8);
- _builder.append(_terImplementation, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
- for(final SAPRef sap : _strSAPs_1) {
- _builder.append("\t\t");
- String _portClassName_1 = this._roomExtensions.getPortClassName(sap);
- String _name_9 = sap.getName();
- String _name_10 = ac.getName();
- CharSequence _terImplementation_1 = this._procedureHelpers.getterImplementation(_portClassName_1, _name_9, _name_10);
- _builder.append(_terImplementation_1, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
- for(final ServiceImplementation svc : _serviceImplementations_1) {
- _builder.append("\t\t");
- String _portClassName_2 = this._roomExtensions.getPortClassName(svc);
- SPPRef _spp = svc.getSpp();
- String _name_11 = _spp.getName();
- String _name_12 = ac.getName();
- CharSequence _terImplementation_2 = this._procedureHelpers.getterImplementation(_portClassName_2, _name_11, _name_12);
- _builder.append(_terImplementation_2, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("//--------------------- lifecycle functions");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("virtual void init();");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("virtual void start();");
- _builder.newLine();
- {
- boolean _overridesStop = this._roomExtensions.overridesStop(ac);
- boolean _not = (!_overridesStop);
- if (_not) {
- _builder.append("\t\t");
- _builder.append("virtual void stop();");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t");
- _builder.append("virtual void destroy();\t\t\t");
- _builder.newLine();
- {
- boolean _hasNonEmptyStateMachine = RoomHelpers.hasNonEmptyStateMachine(ac);
- if (_hasNonEmptyStateMachine) {
- _builder.append("\t\t");
- CharSequence _genStateMachineMethodDeclarations = this._stateMachineGen.genStateMachineMethodDeclarations(xpac);
- _builder.append(_genStateMachineMethodDeclarations, " ");
- _builder.newLineIfNotEmpty();
- } else {
- boolean _hasStateMachine = xpac.hasStateMachine();
- boolean _not_1 = (!_hasStateMachine);
- if (_not_1) {
- _builder.append("\t\t");
- _builder.append("public: ");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("//--------------------- no state machine");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("virtual void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("virtual void executeInitTransition();");
- _builder.newLine();
- }
- }
- }
- _builder.newLine();
- _builder.append("\t\t");
- CharSequence _userCode_1 = this._procedureHelpers.userCode(ac, 2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("};");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- String _name_13 = ac.getName();
- CharSequence _generateIncludeGuardEnd = this._cppExtensions.generateIncludeGuardEnd(_name_13);
- _builder.append(_generateIncludeGuardEnd, " ");
- _builder.newLineIfNotEmpty();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private CharSequence generateConstructorInitalizerList(final ActorClass ac) {
- ArrayList<CharSequence> _arrayList = new ArrayList<CharSequence>();
- ArrayList<CharSequence> initializerList = _arrayList;
- ActorClass _base = ac.getBase();
- boolean _equals = Objects.equal(_base, null);
- if (_equals) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("ActorClassBase( parent, name, port_addr[0][0], peer_addr[0][0])");
- initializerList.add(_builder);
- } else {
- StringConcatenation _builder_1 = new StringConcatenation();
- ActorClass _base_1 = ac.getBase();
- String _name = _base_1.getName();
- _builder_1.append(_name, "");
- _builder_1.append("(*this, parent, name, port_addr, peer_addr)");
- initializerList.add(_builder_1);
- }
- List<Port> _endPorts = this._roomExtensions.getEndPorts(ac);
- for (final Port ep : _endPorts) {
- StringConcatenation _builder_2 = new StringConcatenation();
- String _name_1 = ep.getName();
- _builder_2.append(_name_1, "");
- _builder_2.append("(*this, this, \"");
- String _name_2 = ep.getName();
- _builder_2.append(_name_2, "");
- _builder_2.append("\", IFITEM_");
- String _name_3 = ep.getName();
- _builder_2.append(_name_3, "");
- _builder_2.append(", ");
- {
- int _multiplicity = ep.getMultiplicity();
- boolean _equals_1 = (_multiplicity == 1);
- if (_equals_1) {
- _builder_2.append("0, ");
- }
- }
- _builder_2.append("port_addr[IFITEM_");
- String _name_4 = ep.getName();
- _builder_2.append(_name_4, "");
- _builder_2.append("]");
- {
- int _multiplicity_1 = ep.getMultiplicity();
- boolean _equals_2 = (_multiplicity_1 == 1);
- if (_equals_2) {
- _builder_2.append("[0]");
- }
- }
- _builder_2.append(", peer_addr[IFITEM_");
- String _name_5 = ep.getName();
- _builder_2.append(_name_5, "");
- _builder_2.append("]");
- {
- int _multiplicity_2 = ep.getMultiplicity();
- boolean _equals_3 = (_multiplicity_2 == 1);
- if (_equals_3) {
- _builder_2.append("[0]");
- }
- }
- _builder_2.append(")");
- initializerList.add(_builder_2);
- }
- EList<SAPRef> _strSAPs = ac.getStrSAPs();
- for (final SAPRef sap : _strSAPs) {
- StringConcatenation _builder_3 = new StringConcatenation();
- String _name_6 = sap.getName();
- _builder_3.append(_name_6, "");
- _builder_3.append("(*this, this, \"");
- String _name_7 = sap.getName();
- _builder_3.append(_name_7, "");
- _builder_3.append("\", IFITEM_");
- String _name_8 = sap.getName();
- _builder_3.append(_name_8, "");
- _builder_3.append(", 0, port_addr[IFITEM_");
- String _name_9 = sap.getName();
- _builder_3.append(_name_9, "");
- _builder_3.append("][0], peer_addr[IFITEM_");
- String _name_10 = sap.getName();
- _builder_3.append(_name_10, "");
- _builder_3.append("][0])");
- initializerList.add(_builder_3);
- }
- EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
- for (final ServiceImplementation svc : _serviceImplementations) {
- StringConcatenation _builder_4 = new StringConcatenation();
- SPPRef _spp = svc.getSpp();
- String _name_11 = _spp.getName();
- _builder_4.append(_name_11, "");
- _builder_4.append("(*this, this, \"");
- SPPRef _spp_1 = svc.getSpp();
- String _name_12 = _spp_1.getName();
- _builder_4.append(_name_12, "");
- _builder_4.append("\", IFITEM_");
- SPPRef _spp_2 = svc.getSpp();
- String _name_13 = _spp_2.getName();
- _builder_4.append(_name_13, "");
- _builder_4.append(", port_addr[IFITEM_");
- SPPRef _spp_3 = svc.getSpp();
- String _name_14 = _spp_3.getName();
- _builder_4.append(_name_14, "");
- _builder_4.append("], peer_addr[IFITEM_");
- SPPRef _spp_4 = svc.getSpp();
- String _name_15 = _spp_4.getName();
- _builder_4.append(_name_15, "");
- _builder_4.append("])");
- initializerList.add(_builder_4);
- }
- EList<Attribute> _attributes = ac.getAttributes();
- for (final Attribute attrib : _attributes) {
- CharSequence _attributeInitialization = this._initialization.attributeInitialization(attrib, false);
- initializerList.add(_attributeInitialization);
- }
- StringConcatenation _builder_5 = new StringConcatenation();
- String _join = IterableExtensions.join(initializerList, ",\n");
- _builder_5.append(_join, "");
- _builder_5.newLineIfNotEmpty();
- return _builder_5;
- }
-
- private CharSequence generateSourceFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
- CharSequence _xblockexpression = null;
- {
- EList<StandardOperation> _operations = ac.getOperations();
- final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isConstructor = RoomHelpers.isConstructor(op);
- return Boolean.valueOf(_isConstructor);
- }
- };
- Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
- final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
- EList<StandardOperation> _operations_1 = ac.getOperations();
- final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isDestructor = op.isDestructor();
- return Boolean.valueOf(_isDestructor);
- }
- };
- Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
- final StandardOperation dtor = IterableExtensions.<StandardOperation>head(_filter_1);
- ActorClass _actorClass = xpac.getActorClass();
- ActorCommunicationType _commType = _actorClass.getCommType();
- final boolean async = Objects.equal(_commType, ActorCommunicationType.ASYNCHRONOUS);
- 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("* Source File of ActorClass ");
- String _name = ac.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _cppHeaderFileName = this._cppExtensions.getCppHeaderFileName(ac);
- _builder.append(_cppHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.append("#include \"common/debugging/DebuggingService.h\"");
- _builder.newLine();
- _builder.append("#include <iostream>");
- _builder.newLine();
- _builder.newLine();
- _builder.append("using namespace etRuntime;");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- String _name_1 = ac.getName();
- _builder.append(_name_1, "");
- _builder.append("::");
- String _name_2 = ac.getName();
- _builder.append(_name_2, "");
- _builder.append("(etRuntime::IRTObject* parent, std::string name, const std::vector<std::vector<etRuntime::Address> >& port_addr, ");
- _builder.newLineIfNotEmpty();
- _builder.append(" \t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t\t ");
- _builder.append("const std::vector<std::vector<etRuntime::Address> >& peer_addr)");
- _builder.newLine();
- _builder.append(": ");
- CharSequence _generateConstructorInitalizerList = this.generateConstructorInitalizerList(ac);
- _builder.append(_generateConstructorInitalizerList, "");
- _builder.newLineIfNotEmpty();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("setClassName(\"");
- String _name_3 = ac.getName();
- _builder.append(_name_3, " ");
- _builder.append("\");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<Attribute> _attributes = ac.getAttributes();
- CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes, false);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- if (async) {
- _builder.append("\t");
- _builder.append("getMsgsvc()->addAsyncActor(*this);");
- _builder.newLine();
- }
- }
- {
- boolean _notEquals = (!Objects.equal(ctor, null));
- if (_notEquals) {
- _builder.append("\t");
- _builder.append("// user defined constructor body");
- _builder.newLine();
- _builder.append("\t");
- AbstractGenerator _instance = AbstractGenerator.getInstance();
- DetailCode _detailCode = ctor.getDetailCode();
- String _translatedCode = _instance.getTranslatedCode(_detailCode);
- _builder.append(_translatedCode, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_4 = ac.getName();
- _builder.append(_name_4, "");
- _builder.append("::init(){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("initUser();");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("void ");
- String _name_5 = ac.getName();
- _builder.append(_name_5, "");
- _builder.append("::start(){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("startUser();");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- {
- boolean _overridesStop = this._roomExtensions.overridesStop(ac);
- boolean _not = (!_overridesStop);
- if (_not) {
- _builder.append("void ");
- String _name_6 = ac.getName();
- _builder.append(_name_6, "");
- _builder.append("::stop(){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("stopUser();");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.newLine();
- _builder.append("void ");
- String _name_7 = ac.getName();
- _builder.append(_name_7, "");
- _builder.append("::destroy(){");
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals_1 = (!Objects.equal(dtor, null));
- if (_notEquals_1) {
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("// user defined destructor body");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- AbstractGenerator _instance_1 = AbstractGenerator.getInstance();
- DetailCode _detailCode_1 = dtor.getDetailCode();
- String _translatedCode_1 = _instance_1.getTranslatedCode(_detailCode_1);
- _builder.append(_translatedCode_1, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _hasNonEmptyStateMachine = RoomHelpers.hasNonEmptyStateMachine(ac);
- if (_hasNonEmptyStateMachine) {
- CharSequence _genStateMachine = this._stateMachineGen.genStateMachine(xpac, false);
- _builder.append(_genStateMachine, "");
- _builder.newLineIfNotEmpty();
- } else {
- boolean _hasStateMachine = xpac.hasStateMachine();
- boolean _not_1 = (!_hasStateMachine);
- if (_not_1) {
- _builder.append("//--------------------- no state machine");
- _builder.newLine();
- _builder.append("void ");
- String _name_8 = ac.getName();
- _builder.append(_name_8, "");
- _builder.append("::receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("handleSystemEvent(ifitem, evt, data);");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("void ");
- String _name_9 = ac.getName();
- _builder.append(_name_9, "");
- _builder.append("::executeInitTransition(){");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.java
deleted file mode 100644
index 25db9c587..000000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.java
+++ /dev/null
@@ -1,558 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.InstanceBase;
-import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.ExternalType;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.PortClass;
-import org.eclipse.etrice.core.room.PrimitiveType;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.base.IDataConfiguration;
-import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.xbase.lib.Conversions;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-
-@SuppressWarnings("all")
-public class ConfigGenAddon {
- @Inject
- private CppExtensions stdExt;
-
- @Inject
- private TypeHelpers typeHelpers;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private IDataConfiguration dataConfigExt;
-
- @Inject
- private RoomExtensions _roomExtensions;
-
- public CharSequence genActorInstanceConfig(final ActorInstance ai, final String aiVariableName) {
- StringConcatenation _builder = new StringConcatenation();
- {
- ActorClass _actorClass = ai.getActorClass();
- List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(_actorClass);
- for(final Attribute a : _allAttributes) {
- ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
- List<Attribute> _union = this._roomExtensions.<Attribute>union(_arrayList, a);
- CharSequence _applyInstanceConfig = this.applyInstanceConfig(ai, aiVariableName, _union);
- _builder.append(_applyInstanceConfig, "");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
- for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
- InterfaceItem _interfaceItem = pi.getInterfaceItem();
- PortClass _portClass = RoomHelpers.getPortClass(_interfaceItem);
- EList<Attribute> attribs = _portClass==null?(EList<Attribute>)null:_portClass.getAttributes();
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals = (!Objects.equal(attribs, null));
- if (_notEquals) {
- {
- for(final Attribute a_1 : attribs) {
- String _plus = (aiVariableName + ".");
- String _name = pi.getName();
- CharSequence _invokeGetter = this.helpers.invokeGetter(_name, null);
- String _plus_1 = (_plus + _invokeGetter);
- ArrayList<Attribute> _arrayList_1 = new ArrayList<Attribute>();
- List<Attribute> _union_1 = this._roomExtensions.<Attribute>union(_arrayList_1, a_1);
- CharSequence _applyInstanceConfig_1 = this.applyInstanceConfig(pi, _plus_1, _union_1);
- _builder.append(_applyInstanceConfig_1, "");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- return _builder;
- }
-
- private CharSequence applyInstanceConfig(final InstanceBase instance, final String invokes, final List<Attribute> path) {
- CharSequence _xblockexpression = null;
- {
- Attribute a = IterableExtensions.<Attribute>last(path);
- RefableType _refType = a.getRefType();
- DataType aType = _refType.getType();
- CharSequence _xifexpression = null;
- boolean _isPrimitive = this.typeHelpers.isPrimitive(aType);
- if (_isPrimitive) {
- CharSequence _xblockexpression_1 = null;
- {
- String value = this.typeHelpers.getAttrInstanceConfigValue(path, instance);
- CharSequence _xifexpression_1 = null;
- boolean _equals = Objects.equal(value, null);
- if (_equals) {
- StringConcatenation _builder = new StringConcatenation();
- _xifexpression_1 = _builder;
- } else {
- CharSequence _xifexpression_2 = null;
- boolean _or = false;
- int _size = a.getSize();
- boolean _equals_1 = (_size == 0);
- if (_equals_1) {
- _or = true;
- } else {
- boolean _isCharacterType = this.typeHelpers.isCharacterType(aType);
- _or = (_equals_1 || _isCharacterType);
- }
- if (_or) {
- StringConcatenation _builder_1 = new StringConcatenation();
- _builder_1.append(invokes, "");
- _builder_1.append(".");
- String _name = a.getName();
- String _valueLiteral = this.stdExt.toValueLiteral(((PrimitiveType) aType), value);
- CharSequence _invokeSetter = this.helpers.invokeSetter(_name, null, _valueLiteral);
- _builder_1.append(_invokeSetter, "");
- _builder_1.append(";");
- _xifexpression_2 = _builder_1;
- } else {
- CharSequence _xifexpression_3 = null;
- int _size_1 = a.getSize();
- String[] _split = value.split(",");
- int _size_2 = ((List<String>)Conversions.doWrapArray(_split)).size();
- boolean _equals_2 = (_size_1 == _size_2);
- if (_equals_2) {
- CharSequence _xblockexpression_2 = null;
- {
- StringConcatenation _builder_2 = new StringConcatenation();
- _builder_2.append("{ ");
- {
- String[] _split_1 = value.split(",");
- boolean _hasElements = false;
- for(final String s : _split_1) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder_2.appendImmediate(", ", "");
- }
- String _trim = s.trim();
- String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), _trim);
- _builder_2.append(_valueLiteral_1, "");
- }
- }
- _builder_2.append(" }");
- CharSequence arrayExpr = _builder_2;
- StringConcatenation _builder_3 = new StringConcatenation();
- _builder_3.append(invokes, "");
- _builder_3.append(".");
- String _name_1 = a.getName();
- StringConcatenation _builder_4 = new StringConcatenation();
- _builder_4.append("new ");
- String _typeName = this.typeHelpers.typeName(aType);
- _builder_4.append(_typeName, "");
- _builder_4.append("[] ");
- _builder_4.append(arrayExpr, "");
- String _string = _builder_4.toString();
- CharSequence _invokeSetter_1 = this.helpers.invokeSetter(_name_1, null, _string);
- _builder_3.append(_invokeSetter_1, "");
- _builder_3.append(";");
- _xblockexpression_2 = (_builder_3);
- }
- _xifexpression_3 = _xblockexpression_2;
- } else {
- StringConcatenation _builder_2 = new StringConcatenation();
- _builder_2.append("{");
- _builder_2.newLine();
- _builder_2.append("\t");
- String _typeName = this.typeHelpers.typeName(aType);
- _builder_2.append(_typeName, " ");
- _builder_2.append("[] array = ");
- _builder_2.append(invokes, " ");
- _builder_2.append(".");
- String _name_1 = a.getName();
- CharSequence _invokeGetter = this.helpers.invokeGetter(_name_1, null);
- _builder_2.append(_invokeGetter, " ");
- _builder_2.append(";");
- _builder_2.newLineIfNotEmpty();
- _builder_2.append("\t");
- _builder_2.append("for (int i=0;i<");
- int _size_3 = a.getSize();
- _builder_2.append(_size_3, " ");
- _builder_2.append(";i++){");
- _builder_2.newLineIfNotEmpty();
- _builder_2.append("\t\t");
- _builder_2.append("array[i] = ");
- String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), value);
- _builder_2.append(_valueLiteral_1, " ");
- _builder_2.append(";");
- _builder_2.newLineIfNotEmpty();
- _builder_2.append("}");
- _xifexpression_3 = _builder_2;
- }
- _xifexpression_2 = _xifexpression_3;
- }
- _xifexpression_1 = _xifexpression_2;
- }
- _xblockexpression_1 = (_xifexpression_1);
- }
- _xifexpression = _xblockexpression_1;
- } else {
- CharSequence _xifexpression_1 = null;
- boolean _isDataClass = this.typeHelpers.isDataClass(aType);
- if (_isDataClass) {
- StringConcatenation _builder = new StringConcatenation();
- {
- EList<Attribute> _attributes = ((DataClass) aType).getAttributes();
- for(final Attribute e : _attributes) {
- String _plus = (invokes + ".");
- String _name = a.getName();
- CharSequence _invokeGetter = this.helpers.invokeGetter(_name, null);
- String _plus_1 = (_plus + _invokeGetter);
- List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
- CharSequence _applyInstanceConfig = this.applyInstanceConfig(instance, _plus_1, _union);
- _builder.append(_applyInstanceConfig, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _xifexpression_1 = _builder;
- }
- _xifexpression = _xifexpression_1;
- }
- _xblockexpression = (_xifexpression);
- }
- return _xblockexpression;
- }
-
- public CharSequence genDynConfigGetterSetter(final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- {
- List<Attribute> _dynConfigReadAttributes = this.dataConfigExt.getDynConfigReadAttributes(ac);
- for(final Attribute a : _dynConfigReadAttributes) {
- _builder.append("public ");
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this.typeHelpers.typeName(_type);
- _builder.append(_typeName, "");
- {
- int _size = a.getSize();
- boolean _greaterThan = (_size > 0);
- if (_greaterThan) {
- _builder.append("[]");
- }
- }
- _builder.append(" get");
- String _name = a.getName();
- String _firstUpper = StringExtensions.toFirstUpper(_name);
- _builder.append(_firstUpper, "");
- _builder.append("(){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if(lock_");
- String _name_1 = a.getName();
- _builder.append(_name_1, " ");
- _builder.append(" == null)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("return ");
- String _name_2 = a.getName();
- _builder.append(_name_2, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("else");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("synchronized(lock_");
- String _name_3 = a.getName();
- _builder.append(_name_3, " ");
- _builder.append("){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("return ");
- String _name_4 = a.getName();
- _builder.append(_name_4, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("public void set");
- String _name_5 = a.getName();
- String _firstUpper_1 = StringExtensions.toFirstUpper(_name_5);
- _builder.append(_firstUpper_1, "");
- _builder.append("(");
- 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_1 = a.getSize();
- boolean _greaterThan_1 = (_size_1 > 0);
- if (_greaterThan_1) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_6 = a.getName();
- _builder.append(_name_6, "");
- _builder.append("){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if(lock_");
- String _name_7 = a.getName();
- _builder.append(_name_7, " ");
- _builder.append(" == null)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("this.");
- String _name_8 = a.getName();
- _builder.append(_name_8, " ");
- _builder.append(" = ");
- String _name_9 = a.getName();
- _builder.append(_name_9, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("else");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("synchronized(lock_");
- String _name_10 = a.getName();
- _builder.append(_name_10, " ");
- _builder.append("){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("this.");
- String _name_11 = a.getName();
- _builder.append(_name_11, " ");
- _builder.append(" = ");
- String _name_12 = a.getName();
- _builder.append(_name_12, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("public DynConfigLock get");
- String _name_13 = a.getName();
- String _firstUpper_2 = StringExtensions.toFirstUpper(_name_13);
- _builder.append(_firstUpper_2, "");
- _builder.append("Lock(){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("return lock_");
- String _name_14 = a.getName();
- _builder.append(_name_14, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}\t");
- _builder.newLine();
- }
- }
- {
- List<Attribute> _dynConfigWriteAttributes = this.dataConfigExt.getDynConfigWriteAttributes(ac);
- for(final Attribute a_1 : _dynConfigWriteAttributes) {
- _builder.append("public void setAndWrite");
- String _name_15 = a_1.getName();
- String _firstUpper_3 = StringExtensions.toFirstUpper(_name_15);
- _builder.append(_firstUpper_3, "");
- _builder.append("(");
- RefableType _refType_2 = a_1.getRefType();
- DataType _type_2 = _refType_2.getType();
- String _typeName_2 = this.typeHelpers.typeName(_type_2);
- _builder.append(_typeName_2, "");
- {
- int _size_2 = a_1.getSize();
- boolean _greaterThan_2 = (_size_2 > 0);
- if (_greaterThan_2) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_16 = a_1.getName();
- _builder.append(_name_16, "");
- _builder.append("){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("set");
- String _name_17 = a_1.getName();
- String _firstUpper_4 = StringExtensions.toFirstUpper(_name_17);
- _builder.append(_firstUpper_4, " ");
- _builder.append("(");
- String _name_18 = a_1.getName();
- _builder.append(_name_18, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("variableService.write(this.getInstancePath()+\"/");
- String _name_19 = a_1.getName();
- _builder.append(_name_19, " ");
- _builder.append("\", ");
- String _name_20 = a_1.getName();
- _builder.append(_name_20, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- return _builder;
- }
-
- public CharSequence genMinMaxConstants(final ActorClass ac) {
- StringConcatenation _builder = new StringConcatenation();
- {
- EList<Attribute> _attributes = ac.getAttributes();
- for(final Attribute a : _attributes) {
- String _name = a.getName();
- ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
- List<Attribute> _union = this._roomExtensions.<Attribute>union(_arrayList, a);
- CharSequence _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, _name, _union);
- _builder.append(_genMinMaxConstantsRec, "");
- _builder.newLineIfNotEmpty();
- }
- }
- CharSequence result = _builder;
- int _length = result.length();
- boolean _notEquals = (_length != 0);
- if (_notEquals) {
- StringConcatenation _builder_1 = new StringConcatenation();
- _builder_1.append("//--------------------- Attribute Specifications");
- String _plus = (result + _builder_1.toString());
- result = _plus;
- }
- return result;
- }
-
- private CharSequence genMinMaxConstantsRec(final ActorClass ac, final String varNamePath, final List<Attribute> path) {
- CharSequence _xblockexpression = null;
- {
- String temp = ((String) null);
- CharSequence _xifexpression = null;
- Attribute _last = IterableExtensions.<Attribute>last(path);
- RefableType _refType = _last.getRefType();
- DataType _type = _refType.getType();
- boolean _isDataClass = this.typeHelpers.isDataClass(_type);
- if (_isDataClass) {
- StringConcatenation _builder = new StringConcatenation();
- {
- Attribute _last_1 = IterableExtensions.<Attribute>last(path);
- RefableType _refType_1 = _last_1.getRefType();
- DataType _type_1 = _refType_1.getType();
- List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(((DataClass) _type_1));
- for(final Attribute e : _allAttributes) {
- String _plus = (varNamePath + "_");
- String _name = e.getName();
- String _plus_1 = (_plus + _name);
- List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
- CharSequence _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, _plus_1, _union);
- _builder.append(_genMinMaxConstantsRec, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _xifexpression = _builder;
- } else {
- CharSequence _xifexpression_1 = null;
- Attribute _last_2 = IterableExtensions.<Attribute>last(path);
- RefableType _refType_2 = _last_2.getRefType();
- DataType _type_2 = _refType_2.getType();
- if ((_type_2 instanceof ExternalType)) {
- _xifexpression_1 = null;
- } else {
- CharSequence _xblockexpression_1 = null;
- {
- Attribute _last_3 = IterableExtensions.<Attribute>last(path);
- RefableType _refType_3 = _last_3.getRefType();
- DataType _type_3 = _refType_3.getType();
- PrimitiveType aType = ((PrimitiveType) _type_3);
- StringConcatenation _builder_1 = new StringConcatenation();
- {
- String _attrClassConfigMinValue = this.dataConfigExt.getAttrClassConfigMinValue(ac, path);
- String _temp = temp = _attrClassConfigMinValue;
- boolean _notEquals = (!Objects.equal(_temp, null));
- if (_notEquals) {
- _builder_1.append("public static ");
- String _minMaxType = this.getMinMaxType(aType);
- _builder_1.append(_minMaxType, "");
- _builder_1.append(" MIN_");
- _builder_1.append(varNamePath, "");
- _builder_1.append(" = ");
- String _valueLiteral = this.stdExt.toValueLiteral(aType, temp);
- _builder_1.append(_valueLiteral, "");
- _builder_1.append(";");
- _builder_1.newLineIfNotEmpty();
- }
- }
- {
- String _attrClassConfigMaxValue = this.dataConfigExt.getAttrClassConfigMaxValue(ac, path);
- String _temp_1 = temp = _attrClassConfigMaxValue;
- boolean _notEquals_1 = (!Objects.equal(_temp_1, null));
- if (_notEquals_1) {
- _builder_1.append("public static ");
- String _minMaxType_1 = this.getMinMaxType(aType);
- _builder_1.append(_minMaxType_1, "");
- _builder_1.append(" MAX_");
- _builder_1.append(varNamePath, "");
- _builder_1.append(" = ");
- String _valueLiteral_1 = this.stdExt.toValueLiteral(aType, temp);
- _builder_1.append(_valueLiteral_1, "");
- _builder_1.append(";");
- _builder_1.newLineIfNotEmpty();
- }
- }
- _xblockexpression_1 = (_builder_1);
- }
- _xifexpression_1 = _xblockexpression_1;
- }
- _xifexpression = _xifexpression_1;
- }
- _xblockexpression = (_xifexpression);
- }
- return _xblockexpression;
- }
-
- private String getMinMaxType(final PrimitiveType type) {
- String _switchResult = null;
- String _typeName = this.typeHelpers.typeName(type);
- final String _switchValue = _typeName;
- boolean _matched = false;
- if (!_matched) {
- if (Objects.equal(_switchValue,"byte")) {
- _matched=true;
- _switchResult = "int";
- }
- }
- if (!_matched) {
- if (Objects.equal(_switchValue,"short")) {
- _matched=true;
- _switchResult = "int";
- }
- }
- if (!_matched) {
- if (Objects.equal(_switchValue,"float")) {
- _matched=true;
- _switchResult = "double";
- }
- }
- if (!_matched) {
- String _typeName_1 = this.typeHelpers.typeName(type);
- _switchResult = _typeName_1;
- }
- return _switchResult;
- }
-}
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
deleted file mode 100644
index fff0cfc07..000000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
+++ /dev/null
@@ -1,412 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.etrice.core.genmodel.etricegen.IDiagnostician;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.ExternalType;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.PrimitiveType;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.RoomClass;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.util.Pair;
-import org.eclipse.xtext.xbase.lib.CollectionLiterals;
-import org.eclipse.xtext.xbase.lib.Conversions;
-
-@Singleton
-@SuppressWarnings("all")
-public class CppExtensions implements ILanguageExtension {
- @Inject
- private IDiagnostician diagnostician;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- public String getTypedDataDefinition(final Message m) {
- VarDecl _data = m.getData();
- String[] _generateArglistAndTypedData = this.generateArglistAndTypedData(_data);
- String _get = ((List<String>)Conversions.doWrapArray(_generateArglistAndTypedData)).get(1);
- return _get;
- }
-
- public String getCppHeaderFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _plus = (_name + ".h");
- return _plus;
- }
-
- public String getCppSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _plus = (_name + ".cpp");
- return _plus;
- }
-
- public String getInstSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _plus = (_name + "_Inst.h");
- return _plus;
- }
-
- public String getDispSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _plus = (_name + "_Disp.h");
- return _plus;
- }
-
- public String accessLevelPrivate() {
- return "";
- }
-
- public String accessLevelProtected() {
- return "";
- }
-
- public String accessLevelPublic() {
- return "";
- }
-
- public String memberAccess() {
- return "this->";
- }
-
- public String selfPointer(final String classname, final boolean hasArgs) {
- return "";
- }
-
- public String selfPointer(final boolean hasArgs) {
- return "";
- }
-
- public String operationScope(final String classname, final boolean isDeclaration) {
- String _xifexpression = null;
- if (isDeclaration) {
- _xifexpression = "";
- } else {
- String _plus = (classname + "::");
- _xifexpression = _plus;
- }
- return _xifexpression;
- }
-
- public String memberInDeclaration(final String namespace, final String member) {
- return member;
- }
-
- public String memberInUse(final String namespace, final String member) {
- String _plus = (namespace + ".");
- return (_plus + member);
- }
-
- public boolean usesInheritance() {
- return true;
- }
-
- public boolean usesPointers() {
- return true;
- }
-
- public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("typedef enum {");
- _builder.newLine();
- {
- for(final Pair<String,String> entry : entries) {
- String _first = entry.getFirst();
- _builder.append(_first, "");
- _builder.append(" = ");
- String _second = entry.getSecond();
- _builder.append(_second, "");
- _builder.append(",");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("} ");
- _builder.append(name, "");
- _builder.append(";");
- String _string = _builder.toString();
- return _string;
- }
-
- public String booleanConstant(final boolean b) {
- String _string = Boolean.valueOf(b).toString();
- return _string;
- }
-
- public String pointerLiteral() {
- return "*";
- }
-
- public String nullPointer() {
- return "0";
- }
-
- public String voidPointer() {
- return "void*";
- }
-
- public String arrayDeclaration(final String type, final int size, final String name, final boolean isRef) {
- String _plus = (type + " ");
- String _plus_1 = (_plus + name);
- String _plus_2 = (_plus_1 + "[");
- String _plus_3 = (_plus_2 + Integer.valueOf(size));
- String _plus_4 = (_plus_3 + "]");
- return _plus_4;
- }
-
- public String constructorName(final String cls) {
- return cls;
- }
-
- public String destructorName(final String cls) {
- String _plus = (cls + "_dtor");
- return _plus;
- }
-
- public String constructorReturnType() {
- return "";
- }
-
- public String destructorReturnType() {
- return "void";
- }
-
- public CharSequence getIncludeGuardString(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("_");
- String _replaceAll = filename.replaceAll("\\/.", "_");
- String _upperCase = _replaceAll.toUpperCase();
- _builder.append(_upperCase, "");
- _builder.append("_H_");
- return _builder;
- }
-
- public CharSequence generateIncludeGuardBegin(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#ifndef ");
- CharSequence _includeGuardString = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString, "");
- _builder.newLineIfNotEmpty();
- _builder.append("#define ");
- CharSequence _includeGuardString_1 = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString_1, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public CharSequence generateIncludeGuardEnd(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#endif /* ");
- CharSequence _includeGuardString = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString, "");
- _builder.append(" */");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public String superCall(final String baseClassName, final String method, final String arguments) {
- String _plus = (baseClassName + "::");
- String _plus_1 = (_plus + method);
- String _plus_2 = (_plus_1 + "(");
- String _plus_3 = (_plus_2 + arguments);
- String _plus_4 = (_plus_3 + ");");
- return _plus_4;
- }
-
- public String toValueLiteral(final PrimitiveType type, final String value) {
- UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException("TODO Config for Cpp");
- throw _unsupportedOperationException;
- }
-
- public String defaultValue(final DataType dt) {
- String _xifexpression = null;
- if ((dt instanceof PrimitiveType)) {
- return ((PrimitiveType) dt).getDefaultValueLiteral();
- } else {
- String _xifexpression_1 = null;
- if ((dt instanceof ExternalType)) {
- String _name = dt.getName();
- String _plus = ("initialize external type with default constructor" + _name);
- EObject _eContainer = dt.eContainer();
- EStructuralFeature _eContainingFeature = dt.eContainingFeature();
- this.diagnostician.warning(_plus, _eContainer, _eContainingFeature);
- String _typeName = this._typeHelpers.typeName(dt);
- return (_typeName + "()");
- } else {
- String _xblockexpression = null;
- {
- final DataClass dc = ((DataClass) dt);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("{");
- _builder.newLine();
- {
- EList<Attribute> _attributes = dc.getAttributes();
- boolean _hasElements = false;
- for(final Attribute att : _attributes) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t");
- RefableType _refType = att.getRefType();
- DataType _type = _refType.getType();
- int _size = att.getSize();
- String _initializationWithDefaultValues = this.initializationWithDefaultValues(_type, _size);
- _builder.append(_initializationWithDefaultValues, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _xblockexpression = (_builder.toString());
- }
- _xifexpression_1 = _xblockexpression;
- }
- _xifexpression = _xifexpression_1;
- }
- return _xifexpression;
- }
-
- public String initializationWithDefaultValues(final DataType dt, final int size) {
- String _xblockexpression = null;
- {
- final String dv = this.defaultValue(dt);
- String _xifexpression = null;
- boolean _greaterThan = (size > 1);
- if (_greaterThan) {
- String _xblockexpression_1 = null;
- {
- String res = "{";
- int i = 0;
- boolean _lessThan = (i < size);
- boolean _while = _lessThan;
- while (_while) {
- {
- String _plus = (res + dv);
- res = _plus;
- int _plus_1 = (i + 1);
- i = _plus_1;
- boolean _lessThan_1 = (i < size);
- if (_lessThan_1) {
- String _plus_2 = (res + ",");
- res = _plus_2;
- }
- }
- boolean _lessThan_1 = (i < size);
- _while = _lessThan_1;
- }
- String _plus = (res + "}");
- _xblockexpression_1 = (_plus);
- }
- _xifexpression = _xblockexpression_1;
- } else {
- _xifexpression = dv;
- }
- _xblockexpression = (_xifexpression);
- }
- return _xblockexpression;
- }
-
- public String[] generateArglistAndTypedData(final VarDecl data) {
- String deref = "*";
- boolean _equals = Objects.equal(data, null);
- if (_equals) {
- return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList("", "", ""), String.class));
- }
- String _xifexpression = null;
- RefableType _refType = data.getRefType();
- DataType _type = _refType.getType();
- if ((_type instanceof PrimitiveType)) {
- RefableType _refType_1 = data.getRefType();
- DataType _type_1 = _refType_1.getType();
- String _targetName = ((PrimitiveType) _type_1).getTargetName();
- _xifexpression = _targetName;
- } else {
- RefableType _refType_2 = data.getRefType();
- DataType _type_2 = _refType_2.getType();
- String _name = _type_2.getName();
- _xifexpression = _name;
- }
- String typeName = _xifexpression;
- String _xifexpression_1 = null;
- RefableType _refType_3 = data.getRefType();
- DataType _type_3 = _refType_3.getType();
- if ((_type_3 instanceof PrimitiveType)) {
- String _xblockexpression = null;
- {
- RefableType _refType_4 = data.getRefType();
- DataType _type_4 = _refType_4.getType();
- final String ct = ((PrimitiveType) _type_4).getCastName();
- String _xifexpression_2 = null;
- boolean _and = false;
- boolean _notEquals = (!Objects.equal(ct, null));
- if (!_notEquals) {
- _and = false;
- } else {
- boolean _isEmpty = ct.isEmpty();
- boolean _not = (!_isEmpty);
- _and = (_notEquals && _not);
- }
- if (_and) {
- _xifexpression_2 = ct;
- } else {
- _xifexpression_2 = typeName;
- }
- _xblockexpression = (_xifexpression_2);
- }
- _xifexpression_1 = _xblockexpression;
- } else {
- _xifexpression_1 = typeName;
- }
- String castTypeName = _xifexpression_1;
- String _plus = (castTypeName + "*");
- castTypeName = _plus;
- RefableType _refType_4 = data.getRefType();
- boolean _isRef = _refType_4.isRef();
- if (_isRef) {
- String _plus_1 = (typeName + "*");
- typeName = _plus_1;
- String _plus_2 = (castTypeName + "*");
- castTypeName = _plus_2;
- } else {
- RefableType _refType_5 = data.getRefType();
- DataType _type_4 = _refType_5.getType();
- boolean _not = (!(_type_4 instanceof PrimitiveType));
- if (_not) {
- String _plus_3 = (typeName + "*");
- typeName = _plus_3;
- String _plus_4 = (castTypeName + "*");
- castTypeName = _plus_4;
- } else {
- castTypeName = typeName;
- deref = "";
- }
- }
- String _plus_5 = (typeName + " ");
- String _name_1 = data.getName();
- String _plus_6 = (_plus_5 + _name_1);
- String _plus_7 = (_plus_6 + " = ");
- String _plus_8 = (_plus_7 + deref);
- String _plus_9 = (_plus_8 + "((");
- String _plus_10 = (_plus_9 + castTypeName);
- final String typedData = (_plus_10 + ") generic_data);\n");
- String _name_2 = data.getName();
- final String dataArg = (", " + _name_2);
- String _plus_11 = (", " + typeName);
- String _plus_12 = (_plus_11 + " ");
- String _name_3 = data.getName();
- final String typedArgList = (_plus_12 + _name_3);
- return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList(dataArg, typedData, typedArgList), String.class));
- }
-}
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
deleted file mode 100644
index 8aff81f59..000000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
+++ /dev/null
@@ -1,846 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.common.base.Objects;
-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.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.ComplexType;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.cpp.GeneratorOptions;
-import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
-import org.eclipse.etrice.generator.cpp.gen.Initialization;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-public class DataClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CppExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private TypeHelpers typeHelpers;
-
- @Inject
- private Initialization _initialization;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- this.logger.logInfo("generating code");
- EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
- for (final DataClass dc : _usedDataClasses) {
- {
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(dc);
- String _path = this.roomExt.getPath(dc);
- String path = (_generationTargetPath + _path);
- String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(dc);
- String _plus = ("generating DataClass header \'" + _cppHeaderFileName);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- String _cppHeaderFileName_1 = this.stdExt.getCppHeaderFileName(dc);
- CharSequence _generateHeaderFile = this.generateHeaderFile(root, dc);
- this.fileAccess.generateFile(_cppHeaderFileName_1, _generateHeaderFile);
- String _cppSourceFileName = this.stdExt.getCppSourceFileName(dc);
- String _plus_4 = ("generating DataClass source \'" + _cppSourceFileName);
- String _plus_5 = (_plus_4 + "\' in \'");
- String _plus_6 = (_plus_5 + path);
- String _plus_7 = (_plus_6 + "\'");
- this.logger.logInfo(_plus_7);
- this.fileAccess.setOutputPath(path);
- String _cppSourceFileName_1 = this.stdExt.getCppSourceFileName(dc);
- CharSequence _generateSourceFile = this.generateSourceFile(root, dc);
- this.fileAccess.generateFile(_cppSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- public CharSequence generateHeaderFile(final Root root, final DataClass dc) {
- CharSequence _xblockexpression = null;
- {
- EList<StandardOperation> _operations = dc.getOperations();
- final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isConstructor = RoomHelpers.isConstructor(op);
- return Boolean.valueOf(_isConstructor);
- }
- };
- Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
- final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
- EList<StandardOperation> _operations_1 = dc.getOperations();
- final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isDestructor = op.isDestructor();
- return Boolean.valueOf(_isDestructor);
- }
- };
- Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
- final StandardOperation dtor = IterableExtensions.<StandardOperation>head(_filter_1);
- StringConcatenation _builder = new StringConcatenation();
- String _path = this.roomExt.getPath(dc);
- String _name = dc.getName();
- String _plus = (_path + _name);
- CharSequence _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_plus);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- DataClass _base = dc.getBase();
- boolean _notEquals = (!Objects.equal(_base, null));
- if (_notEquals) {
- _builder.append("#include \"");
- DataClass _base_1 = dc.getBase();
- String _path_1 = this.roomExt.getPath(_base_1);
- _builder.append(_path_1, "");
- DataClass _base_2 = dc.getBase();
- String _name_1 = _base_2.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 _path_2 = this.roomExt.getPath(classes);
- _builder.append(_path_2, "");
- String _name_2 = classes.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- EList<RoomModel> models = root.getReferencedModels(dc);
- _builder.newLineIfNotEmpty();
- {
- for(final RoomModel model : models) {
- {
- EList<DataClass> _dataClasses = model.getDataClasses();
- for(final DataClass classes_1 : _dataClasses) {
- _builder.append("#include \"");
- String _path_3 = this.roomExt.getPath(classes_1);
- _builder.append(_path_3, "");
- String _name_3 = classes_1.getName();
- _builder.append(_name_3, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.newLine();
- DetailCode _userCode1 = dc.getUserCode1();
- CharSequence _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- _builder.append("class ");
- String _name_4 = dc.getName();
- _builder.append(_name_4, "");
- {
- DataClass _base_3 = dc.getBase();
- boolean _notEquals_1 = (!Objects.equal(_base_3, null));
- if (_notEquals_1) {
- _builder.append(" : public ");
- DataClass _base_4 = dc.getBase();
- String _name_5 = _base_4.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();
- CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _attributes_1 = this.helpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes_2 = dc.getAttributes();
- String _name_6 = dc.getName();
- CharSequence _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_7 = dc.getName();
- CharSequence _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, copy constructor and assignment operator");
- _builder.newLine();
- _builder.append("\t");
- String _name_8 = dc.getName();
- _builder.append(_name_8, " ");
- _builder.append("();");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_9 = dc.getName();
- _builder.append(_name_9, " ");
- _builder.append("(const ");
- String _name_10 = dc.getName();
- _builder.append(_name_10, " ");
- _builder.append("& rhs);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- 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");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// constructor using fields");
- _builder.newLine();
- _builder.append("\t");
- String _name_13 = dc.getName();
- _builder.append(_name_13, " ");
- _builder.append("(");
- String _argList = this.argList(dc);
- _builder.append(_argList, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- {
- DataClass _base_5 = dc.getBase();
- boolean _notEquals_2 = (!Objects.equal(_base_5, null));
- if (_notEquals_2) {
- _builder.append("\t");
- _builder.append("// constructor using base class constructor");
- _builder.newLine();
- _builder.append("\t");
- String _name_14 = dc.getName();
- _builder.append(_name_14, " ");
- _builder.append("(");
- DataClass _base_6 = dc.getBase();
- String _name_15 = _base_6.getName();
- _builder.append(_name_15, " ");
- _builder.append(" _super, ");
- EList<Attribute> _attributes_3 = dc.getAttributes();
- CharSequence _argListConstructor = this.argListConstructor(_attributes_3);
- String _string = _argListConstructor.toString();
- _builder.append(_string, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- String _name_16 = dc.getName();
- CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_16);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence generateSourceFile(final Root root, final DataClass dc) {
- CharSequence _xblockexpression = null;
- {
- EList<StandardOperation> _operations = dc.getOperations();
- final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isConstructor = RoomHelpers.isConstructor(op);
- return Boolean.valueOf(_isConstructor);
- }
- };
- Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
- final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
- EList<StandardOperation> _operations_1 = dc.getOperations();
- final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
- public Boolean apply(final StandardOperation op) {
- boolean _isDestructor = op.isDestructor();
- return Boolean.valueOf(_isDestructor);
- }
- };
- Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
- final StandardOperation dtor = IterableExtensions.<StandardOperation>head(_filter_1);
- 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("* Source File of DataClass ");
- String _name = dc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(dc);
- _builder.append(_cppHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- {
- boolean _isUseEtUnit = GeneratorOptions.isUseEtUnit();
- if (_isUseEtUnit) {
- _builder.append("extern \"C\" {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"etUnit.h\"");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.newLine();
- DetailCode _userCode3 = dc.getUserCode3();
- CharSequence _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.newLineIfNotEmpty();
- {
- DataClass _base = dc.getBase();
- boolean _notEquals = (!Objects.equal(_base, null));
- if (_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();
- CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes, false);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals_1 = (!Objects.equal(ctor, null));
- if (_notEquals_1) {
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("// user defined constructor body");
- _builder.newLine();
- {
- DetailCode _detailCode = ctor.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String l : _commands) {
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(l, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _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 _notEquals_2 = (!Objects.equal(_base_2, null));
- if (_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 _hasElements = false;
- for(final Attribute a : _attributes_1) {
- if (!_hasElements) {
- _hasElements = 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_10 = dc.getName();
- _builder.append(_name_10, "");
- _builder.append("::");
- 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_4 = dc.getBase();
- boolean _notEquals_3 = (!Objects.equal(_base_4, null));
- if (_notEquals_3) {
- _builder.append("\t");
- DataClass _base_5 = dc.getBase();
- String _name_12 = _base_5.getName();
- _builder.append(_name_12, " ");
- _builder.append("(");
- DataClass _base_6 = dc.getBase();
- String _paramList = this.paramList(_base_6);
- _builder.append(_paramList, " ");
- _builder.append("),");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<Attribute> _attributes_2 = dc.getAttributes();
- boolean _hasElements_1 = false;
- for(final Attribute a_1 : _attributes_2) {
- if (!_hasElements_1) {
- _hasElements_1 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t");
- String _name_13 = a_1.getName();
- _builder.append(_name_13, " ");
- _builder.append("(");
- String _name_14 = a_1.getName();
- _builder.append(_name_14, " ");
- _builder.append("_)");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("{");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- DataClass _base_7 = dc.getBase();
- boolean _notEquals_4 = (!Objects.equal(_base_7, null));
- if (_notEquals_4) {
- _builder.append("// constructor using base class constructor");
- _builder.newLine();
- String _name_15 = dc.getName();
- _builder.append(_name_15, "");
- _builder.append("::");
- String _name_16 = dc.getName();
- _builder.append(_name_16, "");
- _builder.append("(");
- DataClass _base_8 = dc.getBase();
- String _name_17 = _base_8.getName();
- _builder.append(_name_17, "");
- _builder.append(" _super, ");
- EList<Attribute> _attributes_3 = dc.getAttributes();
- CharSequence _argListConstructor = this.argListConstructor(_attributes_3);
- String _string = _argListConstructor.toString();
- _builder.append(_string, "");
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(":");
- _builder.newLine();
- _builder.append("\t");
- DataClass _base_9 = dc.getBase();
- String _name_18 = _base_9.getName();
- _builder.append(_name_18, " ");
- _builder.append("(_super),");
- _builder.newLineIfNotEmpty();
- {
- EList<Attribute> _attributes_4 = dc.getAttributes();
- boolean _hasElements_2 = false;
- for(final Attribute a_2 : _attributes_4) {
- if (!_hasElements_2) {
- _hasElements_2 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t");
- String _name_19 = a_2.getName();
- _builder.append(_name_19, " ");
- _builder.append("(");
- String _name_20 = a_2.getName();
- _builder.append(_name_20, " ");
- _builder.append("_)");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("{");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.newLine();
- _builder.append("// assignment operator");
- _builder.newLine();
- String _name_21 = dc.getName();
- _builder.append(_name_21, "");
- _builder.append("& ");
- String _name_22 = dc.getName();
- _builder.append(_name_22, "");
- _builder.append("::operator=(const ");
- String _name_23 = dc.getName();
- _builder.append(_name_23, "");
- _builder.append("& rhs)");
- _builder.newLineIfNotEmpty();
- _builder.append("{\t\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (this == &rhs) { return *this; };");
- _builder.newLine();
- {
- DataClass _base_10 = dc.getBase();
- boolean _notEquals_5 = (!Objects.equal(_base_10, null));
- if (_notEquals_5) {
- _builder.append("\t");
- DataClass _base_11 = dc.getBase();
- String _name_24 = _base_11.getName();
- _builder.append(_name_24, " ");
- _builder.append("::operator=(rhs);");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<Attribute> _attributes_5 = dc.getAttributes();
- for(final Attribute a_3 : _attributes_5) {
- _builder.append("\t");
- String _name_25 = a_3.getName();
- _builder.append(_name_25, " ");
- _builder.append("= rhs.");
- String _name_26 = a_3.getName();
- _builder.append(_name_26, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("return *this;");
- _builder.newLine();
- _builder.append("}\t\t\t");
- _builder.newLine();
- _builder.newLine();
- EList<StandardOperation> _operations_2 = dc.getOperations();
- String _name_27 = dc.getName();
- CharSequence _operationsImplementation = this.helpers.operationsImplementation(_operations_2, _name_27);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public String paramList(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _notEquals = (!Objects.equal(dc, null));
- boolean _while = _notEquals;
- while (_while) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _paramList = this.paramList(_attributes);
- String _string = _paramList.toString();
- String _plus = (_string + result);
- result = _plus;
- DataClass _base = dc.getBase();
- dc = _base;
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- if (_notEquals_1) {
- String _plus_1 = (", " + result);
- result = _plus_1;
- }
- }
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- _while = _notEquals_1;
- }
- return result;
- }
-
- public CharSequence paramList(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _hasElements = false;
- for(final Attribute a : attributes) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- String _name = a.getName();
- _builder.append(_name, "");
- _builder.append("_");
- }
- }
- return _builder;
- }
-
- public String argList(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _notEquals = (!Objects.equal(dc, null));
- boolean _while = _notEquals;
- while (_while) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _argListConstructor = this.argListConstructor(_attributes);
- String _string = _argListConstructor.toString();
- String _plus = (_string + result);
- result = _plus;
- DataClass _base = dc.getBase();
- dc = _base;
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- if (_notEquals_1) {
- String _plus_1 = (", " + result);
- result = _plus_1;
- }
- }
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- _while = _notEquals_1;
- }
- return result;
- }
-
- public CharSequence argListConstructor(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _hasElements = false;
- for(final Attribute a : attributes) {
- if (!_hasElements) {
- _hasElements = 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 _greaterThan = (_size > 1);
- if (_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;
- boolean _notEquals = (!Objects.equal(dc, null));
- boolean _while = _notEquals;
- while (_while) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _deepCopy = this.deepCopy(_attributes);
- String _string = _deepCopy.toString();
- String _plus = (_string + result);
- result = _plus;
- DataClass _base = dc.getBase();
- dc = _base;
- }
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- _while = _notEquals_1;
- }
- return result;
- }
-
- public CharSequence deepCopy(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Attribute a : attributes) {
- {
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- if ((_type instanceof ComplexType)) {
- _builder.append("if (");
- String _name = a.getName();
- _builder.append(_name, "");
- _builder.append("!=null) {");
- _builder.newLineIfNotEmpty();
- {
- int _size = a.getSize();
- boolean _equals = (_size == 0);
- if (_equals) {
- _builder.append("\t");
- _builder.append("copy.");
- String _name_1 = a.getName();
- _builder.append(_name_1, " ");
- _builder.append(" = ");
- String _name_2 = a.getName();
- _builder.append(_name_2, " ");
- _builder.append(".deepCopy();");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t");
- _builder.append("for (int i=0;i<");
- String _name_3 = a.getName();
- _builder.append(_name_3, " ");
- _builder.append(".length;i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("copy.");
- String _name_4 = a.getName();
- _builder.append(_name_4, " ");
- _builder.append("[i] = ");
- String _name_5 = a.getName();
- _builder.append(_name_5, " ");
- _builder.append("[i].deepCopy();");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- } else {
- {
- int _size_1 = a.getSize();
- boolean _equals_1 = (_size_1 == 0);
- if (_equals_1) {
- _builder.append("copy.");
- String _name_6 = a.getName();
- _builder.append(_name_6, "");
- _builder.append(" = ");
- String _name_7 = a.getName();
- _builder.append(_name_7, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("for (int i=0;i<");
- String _name_8 = a.getName();
- _builder.append(_name_8, "");
- _builder.append(".length;i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("copy.");
- String _name_9 = a.getName();
- _builder.append(_name_9, " ");
- _builder.append("[i] = ");
- String _name_10 = a.getName();
- _builder.append(_name_10, " ");
- _builder.append("[i];");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- }
- }
- return _builder;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/Initialization.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/Initialization.java
deleted file mode 100644
index 25fb48169..000000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/Initialization.java
+++ /dev/null
@@ -1,297 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.ComplexType;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.generator.base.IDataConfiguration;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.xbase.lib.Conversions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ListExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-public class Initialization {
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private RoomExtensions _roomExtensions;
-
- @Inject
- private ILanguageExtension languageExt;
-
- @Inject
- private IDataConfiguration dataConfigExt;
-
- @Inject
- private ProcedureHelpers procedureHelpers;
-
- public CharSequence attributeInitialization(final List<Attribute> attribs, final boolean useClassDefaultsOnly) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("// initialize attributes");
- _builder.newLine();
- {
- for(final Attribute a : attribs) {
- RefableType _refType = a.getRefType();
- DataType aType = _refType.getType();
- _builder.newLineIfNotEmpty();
- String value = a.getDefaultValueLiteral();
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals = (!Objects.equal(value, null));
- if (_notEquals) {
- {
- boolean _or = false;
- int _size = a.getSize();
- boolean _equals = (_size == 0);
- if (_equals) {
- _or = true;
- } else {
- boolean _isCharacterType = this._typeHelpers.isCharacterType(aType);
- _or = (_equals || _isCharacterType);
- }
- if (_or) {
- } else {
- boolean _startsWith = value.startsWith("{");
- if (_startsWith) {
- String _name = a.getName();
- String _replace = value.replace("{", "");
- String _replace_1 = _replace.replace("}", "");
- String[] _split = _replace_1.split(",");
- CharSequence _initializeArrayWithValues = this.initializeArrayWithValues(_name, _split);
- _builder.append(_initializeArrayWithValues, "");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("for (int i=0;i<");
- int _size_1 = a.getSize();
- _builder.append(_size_1, "");
- _builder.append(";i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_1 = a.getName();
- _builder.append(_name_1, " ");
- _builder.append("[i] = ");
- _builder.append(value, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- } else {
- boolean _or_1 = false;
- boolean _or_2 = false;
- if ((aType instanceof ComplexType)) {
- _or_2 = true;
- } else {
- int _size_2 = a.getSize();
- boolean _greaterThan = (_size_2 > 1);
- _or_2 = ((aType instanceof ComplexType) || _greaterThan);
- }
- if (_or_2) {
- _or_1 = true;
- } else {
- boolean _not = (!useClassDefaultsOnly);
- _or_1 = (_or_2 || _not);
- }
- if (_or_1) {
- {
- int _size_3 = a.getSize();
- boolean _equals_1 = (_size_3 == 0);
- if (_equals_1) {
- } else {
- {
- boolean _not_1 = (!useClassDefaultsOnly);
- if (_not_1) {
- _builder.append("for (int i=0;i<");
- int _size_4 = a.getSize();
- _builder.append(_size_4, "");
- _builder.append(";i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_2 = a.getName();
- _builder.append(_name_2, " ");
- _builder.append("[i] = ");
- {
- RefableType _refType_1 = a.getRefType();
- boolean _isRef = _refType_1.isRef();
- if (_isRef) {
- String _nullPointer = this.languageExt.nullPointer();
- _builder.append(_nullPointer, " ");
- } else {
- String _defaultValue = this.languageExt.defaultValue(aType);
- _builder.append(_defaultValue, " ");
- }
- }
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return _builder;
- }
-
- public CharSequence initializeArrayWithValues(final String varName, final String[] values) {
- StringConcatenation _builder = new StringConcatenation();
- final Function1<String,String> _function = new Function1<String,String>() {
- public String apply(final String v) {
- String _plus = (varName + "[");
- int _indexOf = ((List<String>)Conversions.doWrapArray(values)).indexOf(v);
- String _plus_1 = (_plus + Integer.valueOf(_indexOf));
- String _plus_2 = (_plus_1 + "] = ");
- String _plus_3 = (_plus_2 + v);
- String _plus_4 = (_plus_3 + ";");
- return _plus_4;
- }
- };
- List<String> _map = ListExtensions.<String, String>map(((List<String>)Conversions.doWrapArray(values)), _function);
- String _join = IterableExtensions.join(_map, "\r\n");
- _builder.append(_join, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public CharSequence attributeInitialization(final Attribute a, final boolean useClassDefaultsOnly) {
- CharSequence _xblockexpression = null;
- {
- RefableType _refType = a.getRefType();
- DataType aType = _refType.getType();
- String value = a.getDefaultValueLiteral();
- CharSequence _xifexpression = null;
- boolean _notEquals = (!Objects.equal(value, null));
- if (_notEquals) {
- CharSequence _xifexpression_1 = null;
- boolean _or = false;
- int _size = a.getSize();
- boolean _equals = (_size == 0);
- if (_equals) {
- _or = true;
- } else {
- boolean _isCharacterType = this._typeHelpers.isCharacterType(aType);
- _or = (_equals || _isCharacterType);
- }
- if (_or) {
- CharSequence _xifexpression_2 = null;
- RefableType _refType_1 = a.getRefType();
- boolean _isRef = _refType_1.isRef();
- if (_isRef) {
- StringConcatenation _builder = new StringConcatenation();
- String _name = a.getName();
- _builder.append(_name, "");
- _builder.append("(new ");
- String _name_1 = aType.getName();
- _builder.append(_name_1, "");
- _builder.append("(");
- _builder.append(value, "");
- _builder.append("))");
- _xifexpression_2 = _builder;
- } else {
- StringConcatenation _builder_1 = new StringConcatenation();
- String _name_2 = a.getName();
- _builder_1.append(_name_2, "");
- _builder_1.append("(");
- _builder_1.append(value, "");
- _builder_1.append(")");
- _xifexpression_2 = _builder_1;
- }
- _xifexpression_1 = _xifexpression_2;
- } else {
- CharSequence _xifexpression_3 = null;
- boolean _startsWith = value.startsWith("{");
- if (_startsWith) {
- StringConcatenation _builder_2 = new StringConcatenation();
- String _name_3 = a.getName();
- _builder_2.append(_name_3, "");
- _builder_2.append("()");
- _xifexpression_3 = _builder_2;
- } else {
- StringConcatenation _builder_3 = new StringConcatenation();
- String _name_4 = a.getName();
- _builder_3.append(_name_4, "");
- _builder_3.append("()");
- _xifexpression_3 = _builder_3;
- }
- _xifexpression_1 = _xifexpression_3;
- }
- _xifexpression = _xifexpression_1;
- } else {
- CharSequence _xifexpression_4 = null;
- boolean _or_1 = false;
- boolean _or_2 = false;
- if ((aType instanceof ComplexType)) {
- _or_2 = true;
- } else {
- int _size_1 = a.getSize();
- boolean _greaterThan = (_size_1 > 1);
- _or_2 = ((aType instanceof ComplexType) || _greaterThan);
- }
- if (_or_2) {
- _or_1 = true;
- } else {
- boolean _not = (!useClassDefaultsOnly);
- _or_1 = (_or_2 || _not);
- }
- if (_or_1) {
- CharSequence _xifexpression_5 = null;
- int _size_2 = a.getSize();
- boolean _equals_1 = (_size_2 == 0);
- if (_equals_1) {
- CharSequence _xifexpression_6 = null;
- RefableType _refType_2 = a.getRefType();
- boolean _isRef_1 = _refType_2.isRef();
- if (_isRef_1) {
- StringConcatenation _builder_4 = new StringConcatenation();
- String _name_5 = a.getName();
- _builder_4.append(_name_5, "");
- _builder_4.append("(");
- String _nullPointer = this.languageExt.nullPointer();
- _builder_4.append(_nullPointer, "");
- _builder_4.append(")");
- _xifexpression_6 = _builder_4;
- } else {
- StringConcatenation _builder_5 = new StringConcatenation();
- String _name_6 = a.getName();
- _builder_5.append(_name_6, "");
- _builder_5.append("(");
- String _defaultValue = this.languageExt.defaultValue(aType);
- _builder_5.append(_defaultValue, "");
- _builder_5.append(")");
- _xifexpression_6 = _builder_5;
- }
- _xifexpression_5 = _xifexpression_6;
- } else {
- StringConcatenation _builder_6 = new StringConcatenation();
- String _name_7 = a.getName();
- _builder_6.append(_name_7, "");
- _builder_6.append("()");
- _xifexpression_5 = _builder_6;
- }
- _xifexpression_4 = _xifexpression_5;
- }
- _xifexpression = _xifexpression_4;
- }
- _xblockexpression = (_xifexpression);
- }
- return _xblockexpression;
- }
-}
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
deleted file mode 100644
index f2df9e05c..000000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.generator.cpp.gen.ActorClassGen;
-import org.eclipse.etrice.generator.cpp.gen.DataClassGen;
-import org.eclipse.etrice.generator.cpp.gen.ProtocolClassGen;
-import org.eclipse.etrice.generator.cpp.gen.SubSystemClassGen;
-import org.eclipse.etrice.generator.cpp.gen.SubSystemRunnerGen;
-import org.eclipse.etrice.generator.generic.PrepareFileSystem;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-
-@Singleton
-@SuppressWarnings("all")
-public class MainGen implements IGenerator {
- @Inject
- private DataClassGen dataClassGen;
-
- @Inject
- private ProtocolClassGen protocolClassGen;
-
- @Inject
- private ActorClassGen actorClassGen;
-
- @Inject
- private SubSystemClassGen subsystemClassGen;
-
- @Inject
- private SubSystemRunnerGen subsystemRunnerGen;
-
- @Inject
- private PrepareFileSystem prepFS;
-
- public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
- this.prepFS.prepare(resource);
- EList<EObject> _contents = resource.getContents();
- for (final EObject e : _contents) {
- if ((e instanceof Root)) {
- this.doGenerate(((Root) e));
- }
- }
- }
-
- public void doGenerate(final Root e) {
- this.dataClassGen.doGenerate(e);
- this.protocolClassGen.doGenerate(e);
- this.actorClassGen.doGenerate(e);
- this.subsystemClassGen.doGenerate(e);
- boolean _isLibrary = e.isLibrary();
- boolean _not = (!_isLibrary);
- if (_not) {
- this.subsystemRunnerGen.doGenerate(e);
- }
- }
-}
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
deleted file mode 100644
index f08d2faa3..000000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
+++ /dev/null
@@ -1,1394 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-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.GeneralProtocolClass;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.MessageHandler;
-import org.eclipse.etrice.core.room.Port;
-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.SAPRef;
-import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.cpp.GeneratorOptions;
-import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
-import org.eclipse.etrice.generator.cpp.gen.Initialization;
-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.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-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 Initialization _initialization;
-
- @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 path = (_generationTargetPath + _path);
- String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(pc);
- String _plus = ("generating ProtocolClass header \'" + _cppHeaderFileName);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- String _cppHeaderFileName_1 = this.stdExt.getCppHeaderFileName(pc);
- CharSequence _generateHeaderFile = this.generateHeaderFile(root, pc);
- this.fileAccess.generateFile(_cppHeaderFileName_1, _generateHeaderFile);
- String _cppSourceFileName = this.stdExt.getCppSourceFileName(pc);
- String _plus_4 = ("generating ProtocolClass source \'" + _cppSourceFileName);
- String _plus_5 = (_plus_4 + "\' in \'");
- String _plus_6 = (_plus_5 + path);
- String _plus_7 = (_plus_6 + "\'");
- this.logger.logInfo(_plus_7);
- this.fileAccess.setOutputPath(path);
- String _cppSourceFileName_1 = this.stdExt.getCppSourceFileName(pc);
- CharSequence _generateSourceFile = this.generateSourceFile(root, pc);
- this.fileAccess.generateFile(_cppSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- private CharSequence 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();
- CharSequence _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/messaging/IRTObject.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 <vector>");
- _builder.newLine();
- _builder.append("#include <string>");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("namespace etRuntime {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("class IEventReceiver;");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode1 = pc.getUserCode1();
- CharSequence _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 _path = this.roomExt.getPath(dataClass);
- _builder.append(_path, "");
- 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 _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
- if (_equals) {
- _builder.append("\t /* message IDs */");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- String _genMessageIDs = this.genMessageIDs(pc);
- _builder.append(_genMessageIDs, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("static bool isValidEvtID(int evtId) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return ((MSG_MIN < evtId) && (evtId < MSG_MAX));");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("};");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("static bool isValidOutgoingEvtID(int evtId) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return ((MSG_MIN < evtId) && (evtId < ");
- {
- EList<Message> _incomingMessages = pc.getIncomingMessages();
- int _size = _incomingMessages.size();
- boolean _equals_1 = (_size == 0);
- if (_equals_1) {
- _builder.append("MSG_MAX");
- } else {
- _builder.append("IN_");
- EList<Message> _incomingMessages_1 = pc.getIncomingMessages();
- Message _get = _incomingMessages_1.get(0);
- String _name_4 = _get.getName();
- _builder.append(_name_4, " ");
- }
- }
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("};");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("static bool isValidIncomingEvtID(int evtId) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return ((");
- {
- EList<Message> _incomingMessages_2 = pc.getIncomingMessages();
- int _size_1 = _incomingMessages_2.size();
- boolean _equals_2 = (_size_1 == 0);
- if (_equals_2) {
- _builder.append("MSG_MAX");
- } else {
- _builder.append("IN_");
- EList<Message> _incomingMessages_3 = pc.getIncomingMessages();
- Message _get_1 = _incomingMessages_3.get(0);
- String _name_5 = _get_1.getName();
- _builder.append(_name_5, " ");
- }
- }
- _builder.append(" <= evtId) && (evtId < MSG_MAX));");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("};");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("static std::string getMessageString(int msg_id);");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("private:");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("static std::string s_messageStrings[];");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- DetailCode _userCode2 = pc.getUserCode2();
- CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- CharSequence _portClassDeclaration = this.portClassDeclaration(pc, Boolean.valueOf(false));
- _builder.append(_portClassDeclaration, "");
- _builder.newLineIfNotEmpty();
- CharSequence _portClassDeclaration_1 = this.portClassDeclaration(pc, Boolean.valueOf(true));
- _builder.append(_portClassDeclaration_1, "");
- _builder.newLineIfNotEmpty();
- String _name_6 = pc.getName();
- CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_6);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public CharSequence portClassDeclaration(final ProtocolClass pc, final Boolean conj) {
- CharSequence _xblockexpression = null;
- {
- PortClass pclass = this.roomExt.getPortClass(pc, (conj).booleanValue());
- String portClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue());
- String replPortClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue(), true);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("// ");
- {
- if ((conj).booleanValue()) {
- _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 _notEquals = (!Objects.equal(pclass, null));
- if (_notEquals) {
- _builder.append("\t");
- DetailCode _userCode = pclass.getUserCode();
- CharSequence _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, etRuntime::IRTObject* parent, std::string name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress, bool doRegistration = true); ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t ");
- _builder.append(portClassName, " ");
- _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress, bool doRegistration = true);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("virtual void receive(etRuntime::Message* m);");
- _builder.newLine();
- {
- boolean _notEquals_1 = (!Objects.equal(pclass, null));
- if (_notEquals_1) {
- _builder.append("\t");
- EList<Attribute> _attributes = pclass.getAttributes();
- CharSequence _attributes_1 = this.helpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<PortOperation> _operations = pclass.getOperations();
- CharSequence _operationsDeclaration = this.helpers.operationsDeclaration(_operations, portClassName);
- _builder.append(_operationsDeclaration, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("// outgoing messages");
- _builder.newLine();
- {
- List<Message> _outgoing = this.roomExt.getOutgoing(pc, (conj).booleanValue());
- for(final Message m : _outgoing) {
- _builder.append("\t");
- CharSequence _sendMessageDeclaration = this.sendMessageDeclaration(m, (conj).booleanValue());
- _builder.append(_sendMessageDeclaration, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("// ");
- {
- if ((conj).booleanValue()) {
- _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("int m_replication;");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append(portClassName, " ");
- _builder.append("* m_ports; //dynamic array used instead of vector to avoid copy construction");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public:");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append(replPortClassName, " ");
- _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<etRuntime::Address> addr, std::vector<etRuntime::Address> peerAddress);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("virtual ~");
- _builder.append(replPortClassName, " ");
- _builder.append("() {};");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("int getReplication() {\treturn m_replication; }");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx();\t}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append(portClassName, " ");
- _builder.append(" get(int i) {return m_ports[i];}");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
- if (_equals) {
- _builder.append("\t\t");
- _builder.append(" ");
- _builder.append("// outgoing messages");
- _builder.newLine();
- {
- List<Message> _outgoing_1 = this.roomExt.getOutgoing(pc, (conj).booleanValue());
- for(final Message m_1 : _outgoing_1) {
- _builder.append("\t\t");
- CharSequence _sendMessageDeclaration_1 = this.sendMessageDeclaration(m_1, (conj).booleanValue());
- _builder.append(_sendMessageDeclaration_1, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private CharSequence 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.append("\t");
- _builder.append("#include <iostream>");
- _builder.newLine();
- {
- boolean _isUseEtUnit = GeneratorOptions.isUseEtUnit();
- if (_isUseEtUnit) {
- _builder.append("\t");
- _builder.append("extern \"C\" {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("#include \"etUnit.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _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();
- CharSequence _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
- if (_equals) {
- _builder.append("\t");
- DetailCode _userCode2 = pc.getUserCode2();
- CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- CharSequence _portClassImplementation = this.portClassImplementation(pc, Boolean.valueOf(false));
- _builder.append(_portClassImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- CharSequence _portClassImplementation_1 = this.portClassImplementation(pc, Boolean.valueOf(true));
- _builder.append(_portClassImplementation_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/*--------------------- debug helpers */");
- _builder.newLine();
- _builder.append("\t");
- CharSequence _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
- _builder.append(_generateDebugHelpersImplementation, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- return _builder;
- }
-
- public CharSequence portClassImplementation(final ProtocolClass pc, final Boolean conj) {
- CharSequence _xblockexpression = null;
- {
- PortClass pclass = this.roomExt.getPortClass(pc, (conj).booleanValue());
- String portClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue());
- String replPortClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue(), true);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("// ");
- {
- if ((conj).booleanValue()) {
- _builder.append("conjugated ");
- }
- }
- _builder.append("port class");
- _builder.newLineIfNotEmpty();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.newLine();
- _builder.append(portClassName, "");
- _builder.append("::");
- _builder.append(portClassName, "");
- _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, Address addr, Address peerAddress, bool doRegistration)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(": ");
- CharSequence _generateConstructorInitalizerList = this.generateConstructorInitalizerList(pclass, "0");
- _builder.append(_generateConstructorInitalizerList, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- {
- boolean _notEquals = (!Objects.equal(pclass, null));
- if (_notEquals) {
- EList<Attribute> _attributes = pclass.getAttributes();
- CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes, false);
- _builder.append(_attributeInitialization, " ");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (doRegistration) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("DebuggingService::getInstance().addPortInstance(*this);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append(portClassName, "");
- _builder.append("::");
- _builder.append(portClassName, "");
- _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, Address addr, Address peerAddress, bool doRegistration)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(": ");
- CharSequence _generateConstructorInitalizerList_1 = this.generateConstructorInitalizerList(pclass, "idx");
- _builder.append(_generateConstructorInitalizerList_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- {
- boolean _notEquals_1 = (!Objects.equal(pclass, null));
- if (_notEquals_1) {
- EList<Attribute> _attributes_1 = pclass.getAttributes();
- CharSequence _attributeInitialization_1 = this._initialization.attributeInitialization(_attributes_1, false);
- _builder.append(_attributeInitialization_1, " ");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (doRegistration) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("DebuggingService::getInstance().addPortInstance(*this);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("void ");
- _builder.append(portClassName, "");
- _builder.append("::receive(Message* msg) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (! ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.append("::");
- {
- if ((conj).booleanValue()) {
- _builder.append("isValidOutgoingEvtID");
- } else {
- _builder.append("isValidIncomingEvtID");
- }
- }
- _builder.append("(msg->getEvtId())) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("std::cout << \"unknown\" << std::endl;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("else {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("if (msg->hasDebugFlagSet()) {\t\t\t// TODO: model switch for activation of this flag");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), ");
- String _name_1 = pc.getName();
- _builder.append(_name_1, " ");
- _builder.append("::getMessageString(msg->getEvtId()));");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- {
- boolean _handlesReceive = this.roomExt.handlesReceive(pc, (conj).booleanValue());
- if (_handlesReceive) {
- _builder.append("\t\t");
- _builder.append("switch (msg->getEvtId()) {");
- _builder.newLine();
- {
- List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, (conj).booleanValue());
- for(final MessageHandler hdlr : _receiveHandlers) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("case ");
- String _name_2 = pc.getName();
- _builder.append(_name_2, " ");
- _builder.append("::");
- Message _msg = hdlr.getMsg();
- String _codeName = this.roomExt.getCodeName(_msg);
- _builder.append(_codeName, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _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\t");
- _builder.append("\t");
- _builder.append("\t\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("default:");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("getActor().receiveEvent(this, msg->getEvtId(),\tmsg->getData());");
- _builder.newLine();
- {
- boolean _handlesReceive_1 = this.roomExt.handlesReceive(pc, (conj).booleanValue());
- if (_handlesReceive_1) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("break;");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _notEquals_2 = (!Objects.equal(pclass, null));
- if (_notEquals_2) {
- EList<PortOperation> _operations = pclass.getOperations();
- CharSequence _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).booleanValue());
- for(final Message m : _outgoing) {
- String _name_3 = pc.getName();
- CharSequence _sendMessage = this.sendMessage(m, _name_3, portClassName, (conj).booleanValue());
- _builder.append(_sendMessage, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("// ");
- {
- if ((conj).booleanValue()) {
- _builder.append("conjugated ");
- }
- }
- _builder.append("replicated port class");
- _builder.newLineIfNotEmpty();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append(replPortClassName, "");
- _builder.append("::");
- _builder.append(replPortClassName, "");
- _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<Address> addr, std::vector<Address> peerAddress) ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(": m_replication(addr.size()),");
- _builder.newLine();
- _builder.append(" \t ");
- _builder.append("m_ports()");
- _builder.newLine();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("char numstr[10]; // enough to hold all numbers up to 32-bits");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("m_ports = reinterpret_cast<");
- _builder.append(portClassName, " ");
- _builder.append("*> (new char[sizeof(");
- _builder.append(portClassName, " ");
- _builder.append(") * addr.size()]);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (int i = 0; i < m_replication; ++i) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("snprintf(numstr, sizeof(numstr), \"%d\", i);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("//placement new to avoid copy construction, therefore no vector is used");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("new (&m_ports[i]) ");
- _builder.append(portClassName, " ");
- _builder.append("(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("// outgoing messages");
- _builder.newLine();
- {
- List<Message> _outgoing_1 = this.roomExt.getOutgoing(pc, (conj).booleanValue());
- for(final Message m_1 : _outgoing_1) {
- CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m_1, replPortClassName);
- _builder.append(_messageSignatureDefinition, "");
- _builder.append("{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (int i=0; i<m_replication; ++i) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("m_ports[i].");
- CharSequence _messageCall = this.messageCall(m_1);
- _builder.append(_messageCall, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence generateConstructorInitalizerList(final PortClass pc, final String index) {
- ArrayList<CharSequence> _arrayList = new ArrayList<CharSequence>();
- ArrayList<CharSequence> initializerList = _arrayList;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("PortBase(actor, parent, name, localId, ");
- _builder.append(index, "");
- _builder.append(", addr, peerAddress)");
- initializerList.add(_builder);
- boolean _notEquals = (!Objects.equal(pc, null));
- if (_notEquals) {
- EList<Attribute> _attributes = pc.getAttributes();
- for (final Attribute attrib : _attributes) {
- CharSequence _attributeInitialization = this._initialization.attributeInitialization(attrib, false);
- initializerList.add(_attributeInitialization);
- }
- }
- StringConcatenation _builder_1 = new StringConcatenation();
- String _join = IterableExtensions.join(initializerList, ",\n");
- _builder_1.append(_join, "");
- _builder_1.newLineIfNotEmpty();
- return _builder_1;
- }
-
- private CharSequence messageCall(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- if (_notEquals) {
- _builder.append(" ");
- VarDecl _data_1 = m.getData();
- String _name_1 = _data_1.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- return _builder;
- }
-
- private CharSequence 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("std::string ");
- String _name = pc.getName();
- _builder.append(_name, "");
- _builder.append("::s_messageStrings[] ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("= {\"MIN\", ");
- _builder.newLine();
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m : _allOutgoingMessages) {
- _builder.append("\t\t ");
- _builder.append("\"");
- String _name_1 = m.getName();
- _builder.append(_name_1, " ");
- _builder.append("\",");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\t\t ");
- _builder.append("\"");
- String _name_2 = m_1.getName();
- _builder.append(_name_2, " ");
- _builder.append("\",");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t ");
- _builder.append("\"MAX\"};");
- _builder.newLine();
- _builder.newLine();
- _builder.append("std::string ");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append("::getMessageString(int msg_id) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return s_messageStrings[msg_id];");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("} else {");
- _builder.newLine();
- _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("}");
- _builder.newLine();
- _builder.newLine();
- return _builder;
- }
-
- public CharSequence 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 _notEquals = (!Objects.equal(_data, null));
- if (_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 CharSequence messageSignatureExplicit(final Message m) {
- CharSequence _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 _notEquals = (!Objects.equal(_base, null));
- if (_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 _hasElements = false;
- for(final Attribute a : _attributes) {
- if (!_hasElements) {
- _hasElements = 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 _greaterThan = (_size > 1);
- if (_greaterThan) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_1 = a.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence 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 _notEquals = (!Objects.equal(_data, null));
- if (_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 CharSequence messageSignatureExplicitDefinition(final Message m, final String classPrefix) {
- CharSequence _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 _notEquals = (!Objects.equal(_base, null));
- if (_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 _hasElements = false;
- for(final Attribute a : _attributes) {
- if (!_hasElements) {
- _hasElements = 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 _greaterThan = (_size > 1);
- if (_greaterThan) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_1 = a.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence sendMessageDeclaration(final Message m, final boolean conj) {
- StringConcatenation _builder = new StringConcatenation();
- CharSequence _messageSignature = this.messageSignature(m);
- _builder.append(_messageSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- {
- boolean _and = false;
- VarDecl _data = m.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- if (!_notEquals) {
- _and = false;
- } else {
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- _and = (_notEquals && (_type instanceof DataClass));
- }
- if (_and) {
- CharSequence _messageSignatureExplicit = this.messageSignatureExplicit(m);
- _builder.append(_messageSignatureExplicit, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public CharSequence sendMessage(final Message m, final String portClassName, final String classPrefix, final boolean conj) {
- CharSequence _xblockexpression = null;
- {
- String _xifexpression = null;
- if (conj) {
- _xifexpression = "IN";
- } else {
- _xifexpression = "OUT";
- }
- String dir = _xifexpression;
- MessageHandler hdlr = this.roomExt.getSendHandler(m, conj);
- StringConcatenation _builder = new StringConcatenation();
- CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m, classPrefix);
- _builder.append(_messageSignatureDefinition, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals = (!Objects.equal(hdlr, null));
- if (_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("DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t\t\t\t\t\t\t\t\t\t\t\t ");
- _builder.append(portClassName, " ");
- _builder.append("::getMessageString(");
- _builder.append(portClassName, " ");
- _builder.append("::");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name = m.getName();
- _builder.append(_name, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (getPeerAddress().isValid()){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- {
- VarDecl _data = m.getData();
- boolean _equals = Objects.equal(_data, null);
- if (_equals) {
- _builder.append("getPeerMsgReceiver()->receive(new Message(getPeerAddress(), ");
- _builder.append(portClassName, " ");
- _builder.append("::");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name_1 = m.getName();
- _builder.append(_name_1, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- } else {
- _builder.append("getPeerMsgReceiver()->receive(new Message(getPeerAddress(),");
- _builder.append(portClassName, " ");
- _builder.append("::");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name_2 = m.getName();
- _builder.append(_name_2, " ");
- _builder.append(", ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(" ");
- _builder.append("reinterpret_cast<void*>(");
- {
- boolean _and = false;
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- boolean _isRef = _refType.isRef();
- boolean _not = (!_isRef);
- if (!_not) {
- _and = false;
- } else {
- VarDecl _data_2 = m.getData();
- RefableType _refType_1 = _data_2.getRefType();
- DataType _type = _refType_1.getType();
- boolean _not_1 = (!(_type instanceof PrimitiveType));
- _and = (_not && _not_1);
- }
- if (_and) {
- _builder.append("&");
- }
- }
- VarDecl _data_3 = m.getData();
- String _name_3 = _data_3.getName();
- _builder.append(_name_3, " ");
- _builder.append("),");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(" ");
- _builder.append("sizeof(");
- VarDecl _data_4 = m.getData();
- RefableType _refType_2 = _data_4.getRefType();
- DataType _type_1 = _refType_2.getType();
- String _typeName = this._typeHelpers.typeName(_type_1);
- _builder.append(_typeName, " ");
- _builder.append(")));");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _and_1 = false;
- VarDecl _data_5 = m.getData();
- boolean _notEquals_1 = (!Objects.equal(_data_5, null));
- if (!_notEquals_1) {
- _and_1 = false;
- } else {
- VarDecl _data_6 = m.getData();
- RefableType _refType_3 = _data_6.getRefType();
- DataType _type_2 = _refType_3.getType();
- _and_1 = (_notEquals_1 && (_type_2 instanceof DataClass));
- }
- if (_and_1) {
- CharSequence _messageSignatureExplicitDefinition = this.messageSignatureExplicitDefinition(m, classPrefix);
- _builder.append(_messageSignatureExplicitDefinition, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_4 = m.getName();
- _builder.append(_name_4, " ");
- _builder.append("(");
- VarDecl _data_7 = m.getData();
- RefableType _refType_4 = _data_7.getRefType();
- DataType _type_3 = _refType_4.getType();
- String _name_5 = _type_3.getName();
- _builder.append(_name_5, " ");
- _builder.append("(");
- {
- VarDecl _data_8 = m.getData();
- RefableType _refType_5 = _data_8.getRefType();
- DataType _type_4 = _refType_5.getType();
- DataClass _base = ((DataClass) _type_4).getBase();
- boolean _notEquals_2 = (!Objects.equal(_base, null));
- if (_notEquals_2) {
- _builder.append("_super, ");
- }
- }
- {
- VarDecl _data_9 = m.getData();
- RefableType _refType_6 = _data_9.getRefType();
- DataType _type_5 = _refType_6.getType();
- EList<Attribute> _attributes = ((DataClass) _type_5).getAttributes();
- boolean _hasElements = false;
- for(final Attribute a : _attributes) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(", ", " ");
- }
- String _name_6 = a.getName();
- _builder.append(_name_6, " ");
- }
- }
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public String getMessageID(final Message msg, final InterfaceItem item) {
- if ((item instanceof Port)) {
- Port p = ((Port) item);
- String _xifexpression = null;
- boolean _isConjugated = p.isConjugated();
- if (_isConjugated) {
- _xifexpression = "OUT_";
- } else {
- _xifexpression = "IN_";
- }
- String direction = _xifexpression;
- GeneralProtocolClass _protocol = p.getProtocol();
- String _name = _protocol.getName();
- String _name_1 = msg.getName();
- String _plus = (direction + _name_1);
- return this.enumInUse(_name, _plus);
- } else {
- if ((item instanceof SAPRef)) {
- SAPRef sap = ((SAPRef) item);
- ProtocolClass _protocol_1 = sap.getProtocol();
- String _name_2 = _protocol_1.getName();
- String _name_3 = msg.getName();
- String _plus_1 = ("OUT_" + _name_3);
- return this.enumInUse(_name_2, _plus_1);
- } else {
- if ((item instanceof SPPRef)) {
- SPPRef spp = ((SPPRef) item);
- ProtocolClass _protocol_2 = spp.getProtocol();
- String _name_4 = _protocol_2.getName();
- String _name_5 = msg.getName();
- String _plus_2 = ("IN_" + _name_5);
- return this.enumInUse(_name_4, _plus_2);
- }
- }
- }
- return "unknown interface item";
- }
-
- public String enumInUse(final String namespace, final String member) {
- String _plus = (namespace + "::");
- return (_plus + member);
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java
deleted file mode 100644
index d0ea74df4..000000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.MessageFromIf;
-import org.eclipse.etrice.core.room.State;
-import org.eclipse.etrice.generator.cpp.gen.ProtocolClassGen;
-import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.util.Pair;
-import org.eclipse.xtext.util.Tuples;
-
-@Singleton
-@SuppressWarnings("all")
-public class StateMachineGen extends GenericStateMachineGenerator {
- @Inject
- private RoomExtensions _roomExtensions;
-
- @Inject
- private ProtocolClassGen cppProtGen;
-
- public CharSequence genExtraDecl(final ExpandedActorClass xpac) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("protected:");
- _builder.newLine();
- _builder.append(" \t");
- _builder.append("static std::string s_stateStrings[];");
- _builder.newLine();
- _builder.newLine();
- _builder.append(" \t");
- _builder.append("int history[];");
- _builder.newLine();
- _builder.newLine();
- _builder.append("private:");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("void setState(int new_state);");
- _builder.newLine();
- return _builder;
- }
-
- public CharSequence genExtra(final ExpandedActorClass xpac) {
- CharSequence _xblockexpression = null;
- {
- final ActorClass ac = xpac.getActorClass();
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("std::string ");
- String _name = ac.getName();
- _builder.append(_name, "");
- _builder.append("::s_stateStrings[] = {\"<no state>\",\"<top>\",");
- {
- List<State> _allBaseStatesLeavesLast = this._roomExtensions.getAllBaseStatesLeavesLast(ac);
- boolean _hasElements = false;
- for(final State state : _allBaseStatesLeavesLast) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(",", "");
- }
- _builder.append("\"");
- String _statePathName = this._roomExtensions.getStatePathName(state);
- _builder.append(_statePathName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("};");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("void ");
- String _name_1 = ac.getName();
- _builder.append(_name_1, "");
- _builder.append("::setState(int new_state) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("DebuggingService::getInstance().addActorState(*this, s_stateStrings[new_state]);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (s_stateStrings[new_state]!=\"Idle\") {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("std::cout << getInstancePath() << \" -> \" << s_stateStrings[new_state] << std::endl;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("m_state = new_state;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public String genTriggerConstants(final ExpandedActorClass xpac) {
- EList<MessageFromIf> _xifexpression = null;
- boolean _usesInheritance = this.langExt.usesInheritance();
- if (_usesInheritance) {
- EList<MessageFromIf> _ownTriggers = xpac.getOwnTriggers();
- _xifexpression = _ownTriggers;
- } else {
- EList<MessageFromIf> _triggers = xpac.getTriggers();
- _xifexpression = _triggers;
- }
- final EList<MessageFromIf> triggers = _xifexpression;
- ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
- final ArrayList<Pair<String,String>> list = _arrayList;
- Pair<String,String> _pair = Tuples.<String, String>pair("POLLING", "0");
- list.add(_pair);
- for (final MessageFromIf mif : triggers) {
- String _triggerCodeName = xpac.getTriggerCodeName(mif);
- InterfaceItem _from = mif.getFrom();
- String _name = _from.getName();
- String _plus = ("IFITEM_" + _name);
- String _plus_1 = (_plus + " + EVT_SHIFT*");
- String _messageID = this.cppProtGen.getMessageID(mif);
- String _plus_2 = (_plus_1 + _messageID);
- Pair<String,String> _pair_1 = Tuples.<String, String>pair(_triggerCodeName, _plus_2);
- list.add(_pair_1);
- }
- return this.langExt.genEnumeration("triggers", list);
- }
-
- public String constPointer(final String classname) {
- String _plus = ("const " + classname);
- return (_plus + "*");
- }
-
- public String boolType() {
- return "bool";
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.java
deleted file mode 100644
index 368d980b1..000000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.java
+++ /dev/null
@@ -1,930 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.LogicalThread;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.base.IDataConfiguration;
-import org.eclipse.etrice.generator.base.Indexed;
-import org.eclipse.etrice.generator.cpp.gen.ConfigGenAddon;
-import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-
-@Singleton
-@SuppressWarnings("all")
-public class SubSystemClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CppExtensions _cppExtensions;
-
- @Inject
- private RoomExtensions _roomExtensions;
-
- @Inject
- private ProcedureHelpers _procedureHelpers;
-
- @Inject
- private IDataConfiguration dataConfigExt;
-
- @Inject
- private ConfigGenAddon configGenAddon;
-
- @Inject
- private ConfigGenAddon configAddon;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance ssi : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = ssi.getSubSystemClass();
- String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
- String _path = this._roomExtensions.getPath(_subSystemClass_1);
- String path = (_generationTargetPath + _path);
- SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
- String file = this._cppExtensions.getCppHeaderFileName(_subSystemClass_2);
- String _plus = ("generating SubSystemClass declaration: \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
- CharSequence _generateHeaderFile = this.generateHeaderFile(root, ssi, _subSystemClass_3);
- this.fileAccess.generateFile(file, _generateHeaderFile);
- SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
- String _cppSourceFileName = this._cppExtensions.getCppSourceFileName(_subSystemClass_4);
- file = _cppSourceFileName;
- String _plus_4 = ("generating SubSystemClass implementation: \'" + file);
- String _plus_5 = (_plus_4 + "\' in \'");
- String _plus_6 = (_plus_5 + path);
- String _plus_7 = (_plus_6 + "\'");
- this.logger.logInfo(_plus_7);
- this.fileAccess.setOutputPath(path);
- SubSystemClass _subSystemClass_5 = ssi.getSubSystemClass();
- CharSequence _generateSourceFile = this.generateSourceFile(root, ssi, _subSystemClass_5);
- this.fileAccess.generateFile(file, _generateSourceFile);
- }
- }
- }
-
- public CharSequence generateHeaderFile(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\t");
- _builder.newLine();
- _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("* Header File of SubSystemClass ");
- String _name = cc.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");
- String _name_1 = cc.getName();
- CharSequence _generateIncludeGuardBegin = this._cppExtensions.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"platforms/generic/etDatatypes.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/messaging/IRTObject.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/modelbase/PortBase.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/modelbase/InterfaceItemBase.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/modelbase/ActorClassBase.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/modelbase/SubSystemClassBase.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/messaging/Address.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/messaging/IMessageReceiver.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/debugging/DebuggingService.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include <string>");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include <vector>");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- {
- EList<RoomModel> _referencedModels = root.getReferencedModels(cc);
- for(final RoomModel model : _referencedModels) {
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- CharSequence _userCode = this._procedureHelpers.userCode(cc, 1);
- _builder.append(_userCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("class ");
- String _name_2 = cc.getName();
- _builder.append(_name_2, " ");
- _builder.append(" : public etRuntime::SubSystemClassBase{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t\t");
- CharSequence _userCode_1 = this._procedureHelpers.userCode(cc, 2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("public:");
- _builder.newLine();
- _builder.append("\t\t\t");
- String _name_3 = cc.getName();
- _builder.append(_name_3, " ");
- _builder.append("(IRTObject* parent, std::string name)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t\t");
- _builder.append(": etRuntime::SubSystemClassBase(parent, name)");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("virtual void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data);");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("virtual void instantiateMessageServices();");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("virtual void instantiateActors();");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("private:");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("std::vector<etRuntime::MessageService*> m_msgServices;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("};");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- String _name_4 = cc.getName();
- CharSequence _generateIncludeGuardEnd = this._cppExtensions.generateIncludeGuardEnd(_name_4);
- _builder.append(_generateIncludeGuardEnd, " ");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public CharSequence generateSourceFile(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("\t");
- _builder.newLine();
- _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 SubsystemClass ");
- String _name = cc.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._cppExtensions.getCppHeaderFileName(cc);
- _builder.append(_cppHeaderFileName, " ");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("#include \"common/debugging/DebuggingService.h\"");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"common/messaging/RTSystemServicesProtocol.h\"");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
- for(final ActorInstance ai : _allContainedInstances) {
- _builder.append("\t");
- _builder.append("#include \"");
- ActorClass _actorClass = ai.getActorClass();
- String _path = this._roomExtensions.getPath(_actorClass);
- _builder.append(_path, " ");
- ActorClass _actorClass_1 = ai.getActorClass();
- String _name_1 = _actorClass_1.getName();
- _builder.append(_name_1, " ");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("#include <iostream>");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("using namespace etRuntime;");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("void ");
- String _name_2 = cc.getName();
- _builder.append(_name_2, " ");
- _builder.append("::receiveEvent(InterfaceItemBase* ifitem, int evt, void* data){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("void ");
- String _name_3 = cc.getName();
- _builder.append(_name_3, " ");
- _builder.append("::instantiateMessageServices(){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("m_msgServices.push_back( new MessageService(this, Address(0, 0, 0),\"MessageService_Main\") );");
- _builder.newLine();
- {
- EList<LogicalThread> _threads = cc.getThreads();
- for(final LogicalThread thread : _threads) {
- _builder.append("\t\t");
- _builder.append("m_msgServices.push_back(new MessageService(this, Address(0, ");
- EList<LogicalThread> _threads_1 = cc.getThreads();
- int _indexOf = _threads_1.indexOf(thread);
- int _plus = (_indexOf + 1);
- _builder.append(_plus, " ");
- _builder.append(", 0),\"MessageService_");
- String _name_4 = thread.getName();
- _builder.append(_name_4, " ");
- _builder.append("\", /* threadprio */ 0));");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("for (std::vector<MessageService*>::iterator it=m_msgServices.begin(); it != m_msgServices.end(); ++it) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("RTServices::getInstance().getMsgSvcCtrl().addMsgSvc( *(*it));");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("void ");
- String _name_5 = cc.getName();
- _builder.append(_name_5, " ");
- _builder.append("::instantiateActors(){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("// all addresses");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// Addresses for the Subsystem Systemport");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_1 = comp.getAllContainedInstances();
- int _maxObjId = comp.getMaxObjId();
- Iterable<Indexed<ActorInstance>> _indexed = Indexed.<ActorInstance>indexed(_allContainedInstances_1, _maxObjId);
- for(final Indexed<ActorInstance> ai_1 : _indexed) {
- _builder.append("\t");
- _builder.append("Address addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_2 = comp.getAllContainedInstances();
- ActorInstance _value = ai_1.getValue();
- int _indexOf_1 = _allContainedInstances_2.indexOf(_value);
- _builder.append(_indexOf_1, " ");
- _builder.append("(0,0,");
- int _index1 = ai_1.getIndex1();
- _builder.append(_index1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_3 = comp.getAllContainedInstances();
- for(final ActorInstance ai_2 : _allContainedInstances_3) {
- _builder.append("\t");
- _builder.append("// actor instance ");
- String _path_1 = ai_2.getPath();
- _builder.append(_path_1, " ");
- _builder.append(" itself => Systemport Address");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("// TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Address addr_item_");
- String _path_2 = ai_2.getPath();
- String _pathName = this._roomExtensions.getPathName(_path_2);
- _builder.append(_pathName, " ");
- _builder.append("(0,");
- int _threadId = ai_2.getThreadId();
- _builder.append(_threadId, " ");
- _builder.append(",");
- int _objId = ai_2.getObjId();
- _builder.append(_objId, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("// interface items of ");
- String _path_3 = ai_2.getPath();
- _builder.append(_path_3, " ");
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances = ai_2.getOrderedIfItemInstances();
- for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
- {
- boolean _isReplicated = pi.isReplicated();
- if (_isReplicated) {
- {
- EList<InterfaceItemInstance> _peers = pi.getPeers();
- for(final InterfaceItemInstance peer : _peers) {
- _builder.append("\t");
- EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
- int i = _peers_1.indexOf(peer);
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("Address addr_item_");
- String _path_4 = pi.getPath();
- String _pathName_1 = this._roomExtensions.getPathName(_path_4);
- _builder.append(_pathName_1, " ");
- _builder.append("_");
- _builder.append(i, " ");
- _builder.append("(0,");
- int _threadId_1 = pi.getThreadId();
- _builder.append(_threadId_1, " ");
- _builder.append(",");
- int _objId_1 = pi.getObjId();
- int _plus_1 = (_objId_1 + i);
- _builder.append(_plus_1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t");
- _builder.append("Address addr_item_");
- String _path_5 = pi.getPath();
- String _pathName_2 = this._roomExtensions.getPathName(_path_5);
- _builder.append(_pathName_2, " ");
- _builder.append("(0,");
- int _threadId_2 = ai_2.getThreadId();
- _builder.append(_threadId_2, " ");
- _builder.append(",");
- int _objId_2 = pi.getObjId();
- _builder.append(_objId_2, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// instantiate all actor instances");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("m_instances.reserve(");
- EList<ActorInstance> _allContainedInstances_4 = comp.getAllContainedInstances();
- int _size = _allContainedInstances_4.size();
- _builder.append(_size, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- {
- EList<ActorInstance> _allContainedInstances_5 = comp.getAllContainedInstances();
- for(final ActorInstance ai_3 : _allContainedInstances_5) {
- _builder.append("\t");
- _builder.append("//----------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// addresses for actor instance: ");
- String _name_6 = ai_3.getName();
- _builder.append(_name_6, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("//----------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("\t");
- CharSequence _generateOwnInterfaceItemAddresses = this.generateOwnInterfaceItemAddresses(ai_3);
- _builder.append(_generateOwnInterfaceItemAddresses, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- CharSequence _generatePeerInterfaceItemAddresses = this.generatePeerInterfaceItemAddresses(ai_3, comp);
- _builder.append(_generatePeerInterfaceItemAddresses, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("m_instances[");
- EList<ActorInstance> _allContainedInstances_6 = comp.getAllContainedInstances();
- int _indexOf_2 = _allContainedInstances_6.indexOf(ai_3);
- _builder.append(_indexOf_2, " ");
- _builder.append("] = new ");
- ActorClass _actorClass_2 = ai_3.getActorClass();
- String _name_7 = _actorClass_2.getName();
- _builder.append(_name_7, " ");
- _builder.append("(");
- _builder.newLineIfNotEmpty();
- {
- EObject _eContainer = ai_3.eContainer();
- if ((_eContainer instanceof SubSystemInstance)) {
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("this,");
- _builder.newLine();
- } else {
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("m_instances[");
- EList<ActorInstance> _allContainedInstances_7 = comp.getAllContainedInstances();
- EObject _eContainer_1 = ai_3.eContainer();
- int _indexOf_3 = _allContainedInstances_7.indexOf(_eContainer_1);
- _builder.append(_indexOf_3, " ");
- _builder.append("],");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("\"");
- String _name_8 = ai_3.getName();
- _builder.append(_name_8, " ");
- _builder.append("\",");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- String _name_9 = ai_3.getName();
- _builder.append(_name_9, " ");
- _builder.append("_ownInterfaceItemAddresses,");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- String _name_10 = ai_3.getName();
- _builder.append(_name_10, " ");
- _builder.append("_peerInterfaceItemAddresses");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("); ");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.newLine();
- _builder.append("// apply instance attribute configurations");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_8 = comp.getAllContainedInstances();
- for(final ActorInstance ai_4 : _allContainedInstances_8) {
- final CharSequence cfg = this.configGenAddon.genActorInstanceConfig(ai_4, "inst");
- _builder.newLineIfNotEmpty();
- {
- int _length = cfg.length();
- boolean _greaterThan = (_length > 0);
- if (_greaterThan) {
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- ActorClass _actorClass_3 = ai_4.getActorClass();
- String _name_11 = _actorClass_3.getName();
- _builder.append(_name_11, " ");
- _builder.append(" inst = (");
- ActorClass _actorClass_4 = ai_4.getActorClass();
- String _name_12 = _actorClass_4.getName();
- _builder.append(_name_12, " ");
- _builder.append(") instances[");
- EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
- int _indexOf_4 = _allContainedInstances_9.indexOf(ai_4);
- _builder.append(_indexOf_4, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(cfg, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//----------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// addresses for the subsystem system port");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//----------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("std::vector<Address> ownAddresses(");
- EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
- int _size_1 = _allContainedInstances_10.size();
- _builder.append(_size_1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- {
- EList<ActorInstance> _allContainedInstances_11 = comp.getAllContainedInstances();
- for(final ActorInstance ai_5 : _allContainedInstances_11) {
- _builder.append("\t");
- _builder.append("ownAddresses[");
- EList<ActorInstance> _allContainedInstances_12 = comp.getAllContainedInstances();
- int _indexOf_5 = _allContainedInstances_12.indexOf(ai_5);
- _builder.append(_indexOf_5, " ");
- _builder.append("] = addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_13 = comp.getAllContainedInstances();
- int _indexOf_6 = _allContainedInstances_13.indexOf(ai_5);
- _builder.append(_indexOf_6, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("std::vector<Address> peerAddresses(");
- EList<ActorInstance> _allContainedInstances_14 = comp.getAllContainedInstances();
- int _size_2 = _allContainedInstances_14.size();
- _builder.append(_size_2, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- {
- EList<ActorInstance> _allContainedInstances_15 = comp.getAllContainedInstances();
- for(final ActorInstance ai_6 : _allContainedInstances_15) {
- _builder.append("\t");
- _builder.append("peerAddresses[");
- EList<ActorInstance> _allContainedInstances_16 = comp.getAllContainedInstances();
- int _indexOf_7 = _allContainedInstances_16.indexOf(ai_6);
- _builder.append(_indexOf_7, " ");
- _builder.append("] = addr_item_");
- String _path_6 = ai_6.getPath();
- String _pathName_3 = this._roomExtensions.getPathName(_path_6);
- _builder.append(_pathName_3, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// create the subsystem system port\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("m_RTSystemPort = new RTSystemServicesProtocolConjPortRepl(*this, this, \"RTSystemPort\",");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("0, //local ID");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("ownAddresses,");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("peerAddresses);");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- return _builder;
- }
-
- public CharSequence generateOwnInterfaceItemAddresses(final ActorInstance ai) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("std::vector<std::vector<Address> > ");
- String _name = ai.getName();
- _builder.append(_name, "");
- _builder.append("_ownInterfaceItemAddresses;");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("std::vector<Address> ");
- String _name_1 = ai.getName();
- _builder.append(_name_1, "");
- _builder.append("_actorInstanceAddresses(1);");
- _builder.newLineIfNotEmpty();
- String _name_2 = ai.getName();
- _builder.append(_name_2, "");
- _builder.append("_actorInstanceAddresses[0] = addr_item_");
- String _path = ai.getPath();
- String _pathName = this._roomExtensions.getPathName(_path);
- _builder.append(_pathName, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_3 = ai.getName();
- _builder.append(_name_3, "");
- _builder.append("_ownInterfaceItemAddresses.push_back(");
- String _name_4 = ai.getName();
- _builder.append(_name_4, "");
- _builder.append("_actorInstanceAddresses);");
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
- for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
- {
- boolean _isReplicated = pi.isReplicated();
- if (_isReplicated) {
- {
- EList<InterfaceItemInstance> _peers = pi.getPeers();
- boolean _isEmpty = _peers.isEmpty();
- if (_isEmpty) {
- _builder.append("std::vector<Address> ");
- String _name_5 = ai.getName();
- _builder.append(_name_5, "");
- _builder.append("_");
- String _name_6 = pi.getName();
- _builder.append(_name_6, "");
- _builder.append("Addresses;");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("std::vector<Address> ");
- String _name_7 = ai.getName();
- _builder.append(_name_7, "");
- _builder.append("_");
- String _name_8 = pi.getName();
- _builder.append(_name_8, "");
- _builder.append("Addresses(");
- EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
- int _size = _peers_1.size();
- _builder.append(_size, "");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
- for(final InterfaceItemInstance peer : _peers_2) {
- String _name_9 = ai.getName();
- _builder.append(_name_9, "");
- _builder.append("_");
- String _name_10 = pi.getName();
- _builder.append(_name_10, "");
- _builder.append("Addresses[");
- EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
- int _indexOf = _peers_3.indexOf(peer);
- _builder.append(_indexOf, "");
- _builder.append("] = addr_item_");
- String _path_1 = pi.getPath();
- String _pathName_1 = this._roomExtensions.getPathName(_path_1);
- _builder.append(_pathName_1, "");
- _builder.append("_");
- EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
- int _indexOf_1 = _peers_4.indexOf(peer);
- _builder.append(_indexOf_1, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- } else {
- _builder.append("std::vector<Address> ");
- String _name_11 = ai.getName();
- _builder.append(_name_11, "");
- _builder.append("_");
- String _name_12 = pi.getName();
- _builder.append(_name_12, "");
- _builder.append("Addresses(1);");
- _builder.newLineIfNotEmpty();
- String _name_13 = ai.getName();
- _builder.append(_name_13, "");
- _builder.append("_");
- String _name_14 = pi.getName();
- _builder.append(_name_14, "");
- _builder.append("Addresses[0] = addr_item_");
- String _path_2 = pi.getPath();
- String _pathName_2 = this._roomExtensions.getPathName(_path_2);
- _builder.append(_pathName_2, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- String _name_15 = ai.getName();
- _builder.append(_name_15, "");
- _builder.append("_ownInterfaceItemAddresses.push_back(");
- String _name_16 = ai.getName();
- _builder.append(_name_16, "");
- _builder.append("_");
- String _name_17 = pi.getName();
- _builder.append(_name_17, "");
- _builder.append("Addresses);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- }
- }
- return _builder;
- }
-
- public CharSequence generatePeerInterfaceItemAddresses(final ActorInstance ai, final SubSystemInstance comp) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("std::vector<std::vector<Address> > ");
- String _name = ai.getName();
- _builder.append(_name, "");
- _builder.append("_peerInterfaceItemAddresses;");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("std::vector<Address> ");
- String _name_1 = ai.getName();
- _builder.append(_name_1, "");
- _builder.append("_systemPortAddresses(1);");
- _builder.newLineIfNotEmpty();
- String _name_2 = ai.getName();
- _builder.append(_name_2, "");
- _builder.append("_systemPortAddresses[0] = addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
- int _indexOf = _allContainedInstances.indexOf(ai);
- _builder.append(_indexOf, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- String _name_3 = ai.getName();
- _builder.append(_name_3, "");
- _builder.append("_peerInterfaceItemAddresses.push_back(");
- String _name_4 = ai.getName();
- _builder.append(_name_4, "");
- _builder.append("_systemPortAddresses);");
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
- for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
- {
- boolean _and = false;
- boolean _isReplicated = pi.isReplicated();
- if (!_isReplicated) {
- _and = false;
- } else {
- EList<InterfaceItemInstance> _peers = pi.getPeers();
- boolean _isEmpty = _peers.isEmpty();
- _and = (_isReplicated && _isEmpty);
- }
- if (_and) {
- } else {
- {
- EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
- boolean _isEmpty_1 = _peers_1.isEmpty();
- if (_isEmpty_1) {
- _builder.append("std::vector<Address> ");
- String _name_5 = ai.getName();
- _builder.append(_name_5, "");
- _builder.append("_");
- String _name_6 = pi.getName();
- _builder.append(_name_6, "");
- _builder.append("PeerAddresses;");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("std::vector<Address> ");
- String _name_7 = ai.getName();
- _builder.append(_name_7, "");
- _builder.append("_");
- String _name_8 = pi.getName();
- _builder.append(_name_8, "");
- _builder.append("PeerAddresses(");
- EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
- int _size = _peers_2.size();
- _builder.append(_size, "");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
- for(final InterfaceItemInstance pp : _peers_3) {
- {
- boolean _isReplicated_1 = pp.isReplicated();
- if (_isReplicated_1) {
- String _name_9 = ai.getName();
- _builder.append(_name_9, "");
- _builder.append("_");
- String _name_10 = pi.getName();
- _builder.append(_name_10, "");
- _builder.append("PeerAddresses[");
- EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
- int _indexOf_1 = _peers_4.indexOf(pp);
- _builder.append(_indexOf_1, "");
- _builder.append("] = addr_item_");
- String _path = pp.getPath();
- String _pathName = this._roomExtensions.getPathName(_path);
- _builder.append(_pathName, "");
- _builder.append("_");
- EList<InterfaceItemInstance> _peers_5 = pp.getPeers();
- int _indexOf_2 = _peers_5.indexOf(pi);
- _builder.append(_indexOf_2, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- String _name_11 = ai.getName();
- _builder.append(_name_11, "");
- _builder.append("_");
- String _name_12 = pi.getName();
- _builder.append(_name_12, "");
- _builder.append("PeerAddresses[");
- EList<InterfaceItemInstance> _peers_6 = pi.getPeers();
- int _indexOf_3 = _peers_6.indexOf(pp);
- _builder.append(_indexOf_3, "");
- _builder.append("] = addr_item_");
- String _path_1 = pp.getPath();
- String _pathName_1 = this._roomExtensions.getPathName(_path_1);
- _builder.append(_pathName_1, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- String _name_13 = ai.getName();
- _builder.append(_name_13, "");
- _builder.append("_peerInterfaceItemAddresses.push_back(");
- String _name_14 = ai.getName();
- _builder.append(_name_14, "");
- _builder.append("_");
- String _name_15 = pi.getName();
- _builder.append(_name_15, "");
- _builder.append("PeerAddresses);");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- return _builder;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.java
deleted file mode 100644
index b84ba20fd..000000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.java
+++ /dev/null
@@ -1,263 +0,0 @@
-package org.eclipse.etrice.generator.cpp.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-
-@Singleton
-@SuppressWarnings("all")
-public class SubSystemRunnerGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CppExtensions _cppExtensions;
-
- @Inject
- private RoomExtensions roomExt;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance sc : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = sc.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _plus = (_generationTargetPath + _path);
- this.fileAccess.setOutputPath(_plus);
- SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
- String _name = _subSystemClass_2.getName();
- String _plus_1 = (_name + "_Runner.h");
- SubSystemClass _subSystemClass_3 = sc.getSubSystemClass();
- CharSequence _generateHeaderFile = this.generateHeaderFile(root, sc, _subSystemClass_3);
- this.fileAccess.generateFile(_plus_1, _generateHeaderFile);
- SubSystemClass _subSystemClass_4 = sc.getSubSystemClass();
- String _generationTargetPath_1 = this.roomExt.getGenerationTargetPath(_subSystemClass_4);
- SubSystemClass _subSystemClass_5 = sc.getSubSystemClass();
- String _path_1 = this.roomExt.getPath(_subSystemClass_5);
- String _plus_2 = (_generationTargetPath_1 + _path_1);
- this.fileAccess.setOutputPath(_plus_2);
- SubSystemClass _subSystemClass_6 = sc.getSubSystemClass();
- String _name_1 = _subSystemClass_6.getName();
- String _plus_3 = (_name_1 + "_Runner.cpp");
- SubSystemClass _subSystemClass_7 = sc.getSubSystemClass();
- CharSequence _generateSourceFile = this.generateSourceFile(root, sc, _subSystemClass_7);
- this.fileAccess.generateFile(_plus_3, _generateSourceFile);
- }
- }
- }
-
- public CharSequence generateHeaderFile(final Root root, final SubSystemInstance ssc, final SubSystemClass cc) {
- 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("* this class contains the main function running component ");
- String _name = cc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* it instantiates ");
- String _name_1 = cc.getName();
- _builder.append(_name_1, " ");
- _builder.append(" and starts and ends the lifecycle");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_2 = cc.getName();
- String _plus = (_name_2 + "_Runner");
- CharSequence _generateIncludeGuardBegin = this._cppExtensions.generateIncludeGuardBegin(_plus);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"common/modelbase/SubSystemRunnerBase.h\"");
- _builder.newLine();
- _builder.newLine();
- _builder.append("class ");
- String _name_3 = cc.getName();
- String _plus_1 = (_name_3 + "Runner");
- _builder.append(_plus_1, "");
- _builder.append(" :public etRuntime::SubSystemRunnerBase {");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* main function");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* creates component and starts and stops the lifecycle");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public:");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("static void run(); ");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- String _name_4 = cc.getName();
- String _plus_2 = (_name_4 + "_Runner");
- CharSequence _generateIncludeGuardEnd = this._cppExtensions.generateIncludeGuardEnd(_plus_2);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public CharSequence generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
- 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("* this class contains the main function running component ");
- String _name = ssc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* it instantiates ");
- String _name_1 = ssc.getName();
- _builder.append(_name_1, " ");
- _builder.append(" and starts and ends the lifecycle");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _name_2 = ssc.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- _builder.append("#include \"");
- String _name_3 = ssc.getName();
- _builder.append(_name_3, "");
- _builder.append("_Runner.h\"");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include <iostream>");
- _builder.newLine();
- _builder.newLine();
- _builder.newLine();
- _builder.append("/**");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* main function");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* creates component and starts and stops the lifecycle");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("int main(void) {");
- _builder.newLine();
- _builder.append("\t");
- String _name_4 = ssc.getName();
- String _plus = (_name_4 + "Runner");
- _builder.append(_plus, " ");
- _builder.append("::run();");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("return 0;");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("void ");
- String _name_5 = ssc.getName();
- String _plus_1 = (_name_5 + "Runner");
- _builder.append(_plus_1, "");
- _builder.append("::run() {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_6 = ssc.getName();
- _builder.append(_name_6, " ");
- _builder.append(" main_component(0, \"");
- String _name_7 = ssc.getName();
- _builder.append(_name_7, " ");
- _builder.append("\");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//etUserEntry(); /* platform specific */");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("std::cout << \"*** T H E B E G I N ***\" << std::endl;");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("main_component.init(); // lifecycle init");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("main_component.start(); // lifecycle start");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// application runs until quit ");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("waitForQuit(main_component);");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// end the lifecycle");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("main_component.stop(); // lifecycle stop");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("main_component.destroy(); // lifecycle destroy");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("std::cout << \"*** T H E E N D ***\" << std::endl;");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("//etUserExit(); /* platform specific */");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- return _builder;
- }
-}

Back to the top