summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Karlitschek2012-08-15 06:34:12 (EDT)
committerPeter Karlitschek2012-08-15 06:34:12 (EDT)
commit3aade696859d47a9fc454b32dd8a3a91752aa03c (patch)
treead3f3c8fd0a52fb48480955e338e75b9e2d11fa7
parentf8dc65379deda59df3d7a8f3c4f2a0b066a83fd5 (diff)
downloadorg.eclipse.etrice-3aade696859d47a9fc454b32dd8a3a91752aa03c.zip
org.eclipse.etrice-3aade696859d47a9fc454b32dd8a3a91752aa03c.tar.gz
org.eclipse.etrice-3aade696859d47a9fc454b32dd8a3a91752aa03c.tar.bz2
generator cpp: adaptions to Junorefs/changes/26/8126/1
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/.gitignore1
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend11
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppLanguageGenerator.java2
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java184
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java742
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java45
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java2181
8 files changed, 3164 insertions, 3 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/.gitignore b/plugins/org.eclipse.etrice.generator.cpp/.gitignore
index 092357e..ba37244 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/.gitignore
+++ b/plugins/org.eclipse.etrice.generator.cpp/.gitignore
@@ -1 +1,2 @@
bin
+*._trace \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF
index 0d5951b..cf32bab 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.generator.cpp/META-INF/MANIFEST.MF
@@ -8,7 +8,6 @@ Require-Bundle: org.eclipse.etrice.core.room.ui;bundle-version="0.1.0",
org.eclipse.core.runtime;bundle-version="3.6.0",
org.eclipse.ui;bundle-version="3.7.0",
org.eclipse.ui.ide;bundle-version="3.7.0",
- org.eclipse.xtext.xtend2.lib;bundle-version="2.1.1",
org.eclipse.etrice.generator.doc;bundle-version="0.1.0",
org.eclipse.xtext;bundle-version="2.1.1",
org.eclipse.etrice.core.genmodel,
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
index 361deea..9a331fe 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppExtensions.xtend
@@ -34,7 +34,7 @@ class CppExtensions implements ILanguageExtension {
override String getTypedDataDefinition(Message m) {
- return chainGenerator.generateTypedData(m)
+ return chainGenerator.generateTypedData(m.data)
}
@@ -113,4 +113,13 @@ class CppExtensions implements ILanguageExtension {
}
+
+ override superCall(String baseClassName, String method, String arguments) {
+ baseClassName+"::"+method+"("+arguments+");"
+ }
+
+ override toCharArrayExpr(String s) {
+ "\"" + s + "\"";
+ }
+
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppLanguageGenerator.java b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppLanguageGenerator.java
index a398053..68c2f48 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppLanguageGenerator.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/CppLanguageGenerator.java
@@ -7,7 +7,7 @@ import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator;
public class CppLanguageGenerator extends AbstractTransitionChainGenerator {
@Override
- protected String[] generateArglistAndTypedData(VarDecl data) {
+ public String[] generateArglistAndTypedData(VarDecl data) {
if (data==null)
return new String[] {"", "", ""};
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
new file mode 100644
index 0000000..c435825
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
@@ -0,0 +1,184 @@
+package org.eclipse.etrice.generator.cpp.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.RoomClass;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.generic.AbstractTransitionChainGenerator;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.util.Pair;
+
+@Singleton
+@SuppressWarnings("all")
+public class CppExtensions implements ILanguageExtension {
+ @Inject
+ private AbstractTransitionChainGenerator chainGenerator;
+
+ public String getTypedDataDefinition(final Message m) {
+ VarDecl _data = m.getData();
+ return this.chainGenerator.generateTypedData(_data);
+ }
+
+ 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 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) {
+ return "";
+ }
+
+ 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 String genEnumeration(final String name, final List<Pair<String,String>> entries) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Pair<String,String> entry : entries) {
+ _builder.append("static const int ");
+ String _first = entry.getFirst();
+ _builder.append(_first, "");
+ _builder.append(" = ");
+ String _second = entry.getSecond();
+ _builder.append(_second, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ String _string = _builder.toString();
+ return _string;
+ }
+
+ public String booleanConstant(final boolean b) {
+ String _string = Boolean.valueOf(b).toString();
+ return _string;
+ }
+
+ public String pointerLiteral() {
+ return "";
+ }
+
+ public String nullPointer() {
+ return "null";
+ }
+
+ public String voidPointer() {
+ return "Object";
+ }
+
+ 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 + "[]");
+ return _plus_2;
+ }
+
+ 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 toCharArrayExpr(final String s) {
+ String _plus = ("\"" + s);
+ String _plus_1 = (_plus + "\"");
+ return _plus_1;
+ }
+}
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
new file mode 100644
index 0000000..b7c8bb7
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
@@ -0,0 +1,742 @@
+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.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.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 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 _name_1 = _base_1.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
+ for(final DataClass classes : _referencedDataClasses) {
+ _builder.append("#include \"");
+ String _name_2 = classes.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ EList<RoomModel> 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_1 = this.roomExt.getPath(classes_1);
+ _builder.append(_path_1, "");
+ String _name_3 = classes_1.getName();
+ _builder.append(_name_3, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _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_2 = dc.getBase();
+ boolean _notEquals_1 = (!Objects.equal(_base_2, null));
+ if (_notEquals_1) {
+ _builder.append(" : public ");
+ DataClass _base_3 = dc.getBase();
+ String _name_5 = _base_3.getName();
+ _builder.append(_name_5, "");
+ }
+ }
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.append("\t");
+ DetailCode _userCode2 = dc.getUserCode2();
+ 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();
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_14 = dc.getName();
+ CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_14);
+ _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();
+ _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.helpers.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();
+ _builder.append("// assignment operator");
+ _builder.newLine();
+ String _name_15 = dc.getName();
+ _builder.append(_name_15, "");
+ _builder.append("& ");
+ String _name_16 = dc.getName();
+ _builder.append(_name_16, "");
+ _builder.append("::operator=(const ");
+ String _name_17 = dc.getName();
+ _builder.append(_name_17, "");
+ _builder.append("& rhs)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("{\t\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (this == &rhs) { return *this; };");
+ _builder.newLine();
+ {
+ DataClass _base_7 = dc.getBase();
+ boolean _notEquals_4 = (!Objects.equal(_base_7, null));
+ if (_notEquals_4) {
+ _builder.append("\t");
+ DataClass _base_8 = dc.getBase();
+ String _name_18 = _base_8.getName();
+ _builder.append(_name_18, " ");
+ _builder.append("::operator=(rhs);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<Attribute> _attributes_3 = dc.getAttributes();
+ for(final Attribute a_2 : _attributes_3) {
+ _builder.append("\t");
+ String _name_19 = a_2.getName();
+ _builder.append(_name_19, " ");
+ _builder.append("= rhs.");
+ String _name_20 = a_2.getName();
+ _builder.append(_name_20, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("return *this;");
+ _builder.newLine();
+ _builder.append("}\t\t\t");
+ _builder.newLine();
+ _builder.newLine();
+ EList<StandardOperation> _operations_2 = dc.getOperations();
+ String _name_21 = dc.getName();
+ CharSequence _operationsImplementation = this.helpers.operationsImplementation(_operations_2, _name_21);
+ _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/MainGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
new file mode 100644
index 0000000..ddd8374
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
@@ -0,0 +1,45 @@
+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.DataClassGen;
+import org.eclipse.etrice.generator.cpp.gen.ProtocolClassGen;
+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 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);
+ boolean _isLibrary = e.isLibrary();
+ boolean _not = (!_isLibrary);
+ if (_not) {
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
new file mode 100644
index 0000000..e05c4de
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
@@ -0,0 +1,2181 @@
+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.CommunicationType;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageHandler;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.PortOperation;
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
+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.Functions.Function1;
+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 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/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.newLine();
+ _builder.append("namespace etRuntime {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("class IEventReceiver;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ DetailCode _userCode1 = pc.getUserCode1();
+ 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 _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 ");
+ String _genMessageIDs = this.genMessageIDs(pc);
+ _builder.append(_genMessageIDs, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _equals_1 = Objects.equal(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_equals_1) {
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _equals_2 = Objects.equal(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_equals_2) {
+ _builder.append("#error \"synchronous protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t\t");
+ DetailCode _userCode2 = pc.getUserCode2();
+ CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("private:");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("static char* messageStrings[];");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("char* getMessageString(int msg_id);");
+ _builder.newLine();
+ _builder.append("\t \t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ CharSequence _portClassDeclaration = this.portClassDeclaration(pc, Boolean.valueOf(false));
+ _builder.append(_portClassDeclaration, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ CharSequence _portClassDeclaration_1 = this.portClassDeclaration(pc, Boolean.valueOf(true));
+ _builder.append(_portClassDeclaration_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("};");
+ _builder.newLine();
+ String _name_4 = pc.getName();
+ CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_4);
+ _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, char* name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress); ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t ");
+ _builder.append(portClassName, " ");
+ _builder.append("(etRuntime::IEventReceiver actor, char* name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("virtual void receive(etRuntime::Message m);");
+ _builder.newLine();
+ {
+ boolean _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("// sent 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("std::vector<");
+ _builder.append(portClassName, " ");
+ _builder.append("> ports;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t ");
+ _builder.append("int replication;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// constructor");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append(replPortClassName, " ");
+ _builder.append("(etRuntime::IEventReceiver actor, char* name, int localId, std::vector<etRuntime::Address> addr, std::vector<etRuntime::Address> peerAddress);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int getReplication() {\treturn replication; }");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx();\t}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append(" get(int i) {return ports[i];}");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ CommunicationType _commType = pc.getCommType();
+ boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
+ if (_equals) {
+ {
+ if ((conj).booleanValue()) {
+ _builder.append("\t");
+ _builder.append("// incoming messages");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\t");
+ CharSequence _messageSignature = this.messageSignature(m_1);
+ _builder.append(_messageSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t");
+ _builder.append("// outgoing messages");
+ _builder.newLine();
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m_2 : _allOutgoingMessages) {
+ _builder.append("\t");
+ CharSequence _messageSignature_1 = this.messageSignature(m_2);
+ _builder.append(_messageSignature_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _equals_1 = Objects.equal(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_equals_1) {
+ _builder.append(" ");
+ _builder.append("/*--------------------- port structs and methods */");
+ _builder.newLine();
+ CharSequence _genDataDrivenPortHeaders = this.genDataDrivenPortHeaders(pc);
+ _builder.append(_genDataDrivenPortHeaders, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _equals_2 = Objects.equal(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_equals_2) {
+ _builder.append("#error \"synchronous protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public 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();
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("::");
+ _builder.append(portClassName, "");
+ _builder.append("::");
+ _builder.append(portClassName, "");
+ _builder.append("(IEventReceiver actor, char* name, int localId, Address addr, Address peerAddress)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(": PortBase(actor, name, localId, 0, addr, peerAddress)");
+ _builder.newLine();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("DebuggingService::getInstance().addPortInstance(*this);");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = pc.getName();
+ _builder.append(_name_1, "");
+ _builder.append("::");
+ _builder.append(portClassName, "");
+ _builder.append("::");
+ _builder.append(portClassName, "");
+ _builder.append("(IEventReceiver actor, char* name, int localId, int idx, Address addr, Address peerAddress)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(": PortBase(actor, name, localId, idx, addr, peerAddress)");
+ _builder.newLine();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("DebuggingService::getInstance().addPortInstance(*this);");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_2 = pc.getName();
+ _builder.append(_name_2, "");
+ _builder.append("::");
+ _builder.append(portClassName, "");
+ _builder.append("::receive(Message msg) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("//if (!(m instanceof EventMessage)) return;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//EventMessage msg = (EventMessage) m;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("printf(\"unknown\");");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("else {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("if (messageStrings[msg.getEvtId()] != \"timerTick\"){");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this.roomExt.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive) {
+ _builder.append("\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");
+ _builder.append("\t");
+ _builder.append("case ");
+ Message _msg = hdlr.getMsg();
+ String _codeName = this.roomExt.getCodeName(_msg);
+ _builder.append(_codeName, " ");
+ _builder.append(":");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ DetailCode _detailCode = hdlr.getDetailCode();
+ EList<String> _commands = _detailCode.getCommands();
+ for(final String command : _commands) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(command, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("break;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("default:");
+ _builder.newLine();
+ _builder.append("\t");
+ }
+ }
+ _builder.append("\tgetActor().receiveEvent(*this, msg.getEvtId(), msg.getData());");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _handlesReceive_1 = this.roomExt.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive_1) {
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ {
+ boolean _notEquals = (!Objects.equal(pclass, null));
+ if (_notEquals) {
+ 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();
+ String _plus = (_name_3 + "::");
+ String _plus_1 = (_plus + portClassName);
+ CharSequence _sendMessage = this.sendMessage(m, _plus_1, (conj).booleanValue());
+ _builder.append(_sendMessage, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("//-------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("// replicated port class");
+ _builder.newLine();
+ _builder.append("//-------------------------------------------------------------------------------");
+ _builder.newLine();
+ String _name_4 = pc.getName();
+ _builder.append(_name_4, "");
+ _builder.append("::");
+ _builder.append(replPortClassName, "");
+ _builder.append("::");
+ _builder.append(replPortClassName, "");
+ _builder.append("(IEventReceiver actor, char* name, int localId, std::vector<Address> addr, std::vector<Address> peerAddress) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("int replication = addr.size();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ports = new std::vector<");
+ String _name_5 = pc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("::");
+ _builder.append(portClassName, " ");
+ _builder.append(">(replication);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("ports[i] = new ");
+ String _name_6 = pc.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("::");
+ _builder.append(portClassName, " ");
+ _builder.append("(actor, name+i, localId, i, addr[i], peerAddress[i]);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ if ((conj).booleanValue()) {
+ _builder.append("// incoming messages");
+ _builder.newLine();
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ String _name_7 = pc.getName();
+ String _plus_2 = (_name_7 + "::");
+ String _plus_3 = (_plus_2 + replPortClassName);
+ CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m_1, _plus_3);
+ _builder.append(_messageSignatureDefinition, "");
+ _builder.append("{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("ports[i].");
+ CharSequence _messageCall = this.messageCall(m_1);
+ _builder.append(_messageCall, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ } else {
+ _builder.append("// outgoing messages");
+ _builder.newLine();
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m_2 : _allOutgoingMessages) {
+ String _name_8 = pc.getName();
+ String _plus_4 = (_name_8 + "::");
+ String _plus_5 = (_plus_4 + replPortClassName);
+ CharSequence _messageSignatureDefinition_1 = this.messageSignatureDefinition(m_2, _plus_5);
+ _builder.append(_messageSignatureDefinition_1, "");
+ _builder.append("{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (int i=0; i<replication; ++i) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("ports[i].");
+ CharSequence _messageCall_1 = this.messageCall(m_2);
+ _builder.append(_messageCall_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private 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 <stdio.h>");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("using namespace etRuntime;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ DetailCode _userCode3 = pc.getUserCode3();
+ 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");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//----------------------------------------------");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// java code");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//----------------------------------------------");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ DetailCode _userCode2 = pc.getUserCode2();
+ CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("char* ");
+ String _name_1 = pc.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("::messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\"");
+ String _name_2 = m.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("\",");
+ }
+ }
+ _builder.append(" ");
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\"");
+ String _name_3 = m_1.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("\",");
+ }
+ }
+ _builder.append("\"MAX\"};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("char* ");
+ String _name_4 = pc.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("::getMessageString(int msg_id) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("// id out of range");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return \"Message ID out of range\";");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("else{");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("return messageStrings[msg_id];");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ 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();
+ } else {
+ CommunicationType _commType_1 = pc.getCommType();
+ boolean _equals_1 = Objects.equal(_commType_1, CommunicationType.DATA_DRIVEN);
+ if (_equals_1) {
+ CharSequence _genDataDrivenPortSources = this.genDataDrivenPortSources(pc);
+ _builder.append(_genDataDrivenPortSources, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ CommunicationType _commType_2 = pc.getCommType();
+ boolean _equals_2 = Objects.equal(_commType_2, CommunicationType.SYNCHRONOUS);
+ if (_equals_2) {
+ _builder.append("#error \"synchronoue protocols not implemented yet\"");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ return _builder;
+ }
+
+ private CharSequence portClassHeader(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ String portClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue());
+ String replPortClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue(), true);
+ List<Message> _xifexpression = null;
+ if ((conj).booleanValue()) {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("typedef etPort ");
+ _builder.append(portClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("typedef etReplPort ");
+ _builder.append(replPortClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ PortClass _portClass = this.roomExt.getPortClass(pc, (conj).booleanValue());
+ boolean _notEquals = (!Objects.equal(_portClass, null));
+ if (_notEquals) {
+ {
+ PortClass _portClass_1 = this.roomExt.getPortClass(pc, (conj).booleanValue());
+ EList<Attribute> _attributes = _portClass_1.getAttributes();
+ boolean _isEmpty = _attributes.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _builder.append("/* variable part of PortClass (RAM) */");
+ _builder.newLine();
+ _builder.append("typedef struct ");
+ _builder.append(portClassName, "");
+ _builder.append("_var ");
+ _builder.append(portClassName, "");
+ _builder.append("_var; ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("struct ");
+ _builder.append(portClassName, "");
+ _builder.append("_var {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ PortClass _portClass_2 = this.roomExt.getPortClass(pc, (conj).booleanValue());
+ EList<Attribute> _attributes_1 = _portClass_2.getAttributes();
+ CharSequence _attributes_2 = this.helpers.attributes(_attributes_1);
+ _builder.append(_attributes_2, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("};");
+ _builder.newLine();
+ {
+ PortClass _portClass_3 = this.roomExt.getPortClass(pc, (conj).booleanValue());
+ EList<Attribute> _attributes_3 = _portClass_3.getAttributes();
+ for(final Attribute a : _attributes_3) {
+ {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _notEquals_1 = (!Objects.equal(_defaultValueLiteral, null));
+ if (_notEquals_1) {
+ _builder.append("\t\t\t\t");
+ String _plus = (portClassName + " ");
+ String _name = a.getName();
+ String _plus_1 = (_plus + _name);
+ String _plus_2 = (_plus_1 + ": Attribute initialization not supported in C");
+ this.logger.logInfo(_plus_2);
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ boolean hasData = (!Objects.equal(_data, null));
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ if (hasData) {
+ VarDecl _data_1 = message.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _xifexpression_1 = _typeName;
+ } else {
+ _xifexpression_1 = "";
+ }
+ String typeName = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ boolean _and = false;
+ if (!hasData) {
+ _and = false;
+ } else {
+ boolean _or = false;
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _not_1 = (!(_type_1 instanceof PrimitiveType));
+ if (_not_1) {
+ _or = true;
+ } else {
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ boolean _isRef = _refType_2.isRef();
+ _or = (_not_1 || _isRef);
+ }
+ _and = (hasData && _or);
+ }
+ if (_and) {
+ _xifexpression_2 = "*";
+ } else {
+ _xifexpression_2 = "";
+ }
+ String refp = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ if (hasData) {
+ String _plus_3 = (", " + typeName);
+ String _plus_4 = (_plus_3 + refp);
+ String _plus_5 = (_plus_4 + " data");
+ _xifexpression_3 = _plus_5;
+ } else {
+ _xifexpression_3 = "";
+ }
+ String data = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _name_1 = message.getName();
+ String _messageSignature = this.messageSignature(portClassName, _name_1, "", data);
+ _builder.append(_messageSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _name_2 = message.getName();
+ String _messageSignature_1 = this.messageSignature(replPortClassName, _name_2, "_broadcast", data);
+ _builder.append(_messageSignature_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _name_3 = message.getName();
+ String _plus_6 = (", int idx" + data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_3, "", _plus_6);
+ _builder.append(_messageSignature_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ PortClass _portClass_4 = this.roomExt.getPortClass(pc, (conj).booleanValue());
+ boolean _notEquals_2 = (!Objects.equal(_portClass_4, null));
+ if (_notEquals_2) {
+ PortClass _portClass_5 = this.roomExt.getPortClass(pc, (conj).booleanValue());
+ EList<PortOperation> _operations = _portClass_5.getOperations();
+ CharSequence _operationsDeclaration = this.helpers.operationsDeclaration(_operations, portClassName);
+ _builder.append(_operationsDeclaration, "");
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass_6 = this.roomExt.getPortClass(pc, (conj).booleanValue());
+ EList<PortOperation> _operations_1 = _portClass_6.getOperations();
+ CharSequence _operationsDeclaration_1 = this.helpers.operationsDeclaration(_operations_1, replPortClassName);
+ _builder.append(_operationsDeclaration_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this.roomExt.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive) {
+ {
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, (conj).booleanValue());
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _name_4 = _msg.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_receiveHandler(");
+ _builder.append(portClassName, "");
+ _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence genDataDrivenPortHeaders(final ProtocolClass pc) {
+ CharSequence _xblockexpression = null;
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
+ public Boolean apply(final Message m) {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ return Boolean.valueOf(_notEquals);
+ }
+ };
+ Iterable<Message> sentMsgs = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* data driven send port (conjugated) */");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ {
+ for(final Message msg : sentMsgs) {
+ _builder.append("\t");
+ VarDecl _data = msg.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ String typeName = this._typeHelpers.typeName(_type);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _xifexpression = null;
+ VarDecl _data_1 = msg.getData();
+ RefableType _refType_1 = _data_1.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ if (_isRef) {
+ _xifexpression = "*";
+ } else {
+ _xifexpression = "";
+ }
+ String refp = _xifexpression;
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(typeName, " ");
+ _builder.append(refp, " ");
+ _builder.append(" ");
+ String _name = msg.getName();
+ _builder.append(_name, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName = this.roomExt.getPortClassName(pc, true);
+ _builder.append(_portClassName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("/* data driven receive port (regular) */");
+ _builder.newLine();
+ _builder.append("typedef struct {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("const ");
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, true);
+ _builder.append(_portClassName_1, " ");
+ _builder.append("* peer;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName_2 = this.roomExt.getPortClassName(pc, false);
+ _builder.append(_portClassName_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ for(final Message message : sentMsgs) {
+ VarDecl _data_2 = message.getData();
+ boolean hasData = (!Objects.equal(_data_2, null));
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ if (hasData) {
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ String _typeName = this._typeHelpers.typeName(_type_1);
+ _xifexpression_1 = _typeName;
+ } else {
+ _xifexpression_1 = "";
+ }
+ String typeName_1 = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ boolean _and = false;
+ if (!hasData) {
+ _and = false;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ boolean _not = (!(_type_2 instanceof PrimitiveType));
+ _and = (hasData && _not);
+ }
+ if (_and) {
+ _xifexpression_2 = "*";
+ } else {
+ _xifexpression_2 = "";
+ }
+ String refp_1 = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ if (hasData) {
+ String _plus = (", " + typeName_1);
+ String _plus_1 = (_plus + refp_1);
+ String _plus_2 = (_plus_1 + " data");
+ _xifexpression_3 = _plus_2;
+ } else {
+ _xifexpression_3 = "";
+ }
+ String data = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _portClassName_3 = this.roomExt.getPortClassName(pc, true);
+ String _name_1 = message.getName();
+ String _messageSetterSignature = this.messageSetterSignature(_portClassName_3, _name_1, data);
+ _builder.append(_messageSetterSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ String _portClassName_4 = this.roomExt.getPortClassName(pc, false);
+ String _name_2 = message.getName();
+ String _messageGetterSignature = this.messageGetterSignature(_portClassName_4, _name_2, typeName_1);
+ _builder.append(_messageGetterSignature, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence genDataDrivenPortSources(final ProtocolClass pc) {
+ CharSequence _xblockexpression = null;
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ final Function1<Message,Boolean> _function = new Function1<Message,Boolean>() {
+ public Boolean apply(final Message m) {
+ VarDecl _data = m.getData();
+ boolean _notEquals = (!Objects.equal(_data, null));
+ return Boolean.valueOf(_notEquals);
+ }
+ };
+ Iterable<Message> messages = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ RefableType _refType = _data.getRefType();
+ DataType _type = _refType.getType();
+ String typeName = this._typeHelpers.typeName(_type);
+ _builder.newLineIfNotEmpty();
+ String _xifexpression = null;
+ VarDecl _data_1 = message.getData();
+ RefableType _refType_1 = _data_1.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _not = (!(_type_1 instanceof PrimitiveType));
+ if (_not) {
+ _xifexpression = "*";
+ } else {
+ _xifexpression = "";
+ }
+ String refp = _xifexpression;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_1 = null;
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_2 = _data_2.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ if ((_type_2 instanceof PrimitiveType)) {
+ _xifexpression_1 = "&";
+ } else {
+ _xifexpression_1 = "";
+ }
+ String refa = _xifexpression_1;
+ _builder.newLineIfNotEmpty();
+ String _plus = (", " + typeName);
+ String _plus_1 = (_plus + refp);
+ String data = (_plus_1 + " data");
+ _builder.newLineIfNotEmpty();
+ String _portClassName = this.roomExt.getPortClassName(pc, true);
+ String _name = message.getName();
+ String _messageSetterSignature = this.messageSetterSignature(_portClassName, _name, data);
+ _builder.append(_messageSetterSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("self->");
+ String _name_1 = message.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" = data;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ String _portClassName_1 = this.roomExt.getPortClassName(pc, false);
+ String _name_2 = message.getName();
+ String _messageGetterSignature = this.messageGetterSignature(_portClassName_1, _name_2, typeName);
+ _builder.append(_messageGetterSignature, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return self->peer->");
+ String _name_3 = message.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence portClassSource(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ String portClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue());
+ String replPortClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue(), true);
+ List<Message> _xifexpression = null;
+ if ((conj).booleanValue()) {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ _xifexpression = _allIncomingMessages;
+ } else {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ _xifexpression = _allOutgoingMessages;
+ }
+ List<Message> messages = _xifexpression;
+ String _xifexpression_1 = null;
+ if ((conj).booleanValue()) {
+ _xifexpression_1 = "IN_";
+ } else {
+ _xifexpression_1 = "OUT_";
+ }
+ String dir = _xifexpression_1;
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Message message : messages) {
+ VarDecl _data = message.getData();
+ boolean hasData = (!Objects.equal(_data, null));
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_2 = null;
+ if (hasData) {
+ VarDecl _data_1 = message.getData();
+ RefableType _refType = _data_1.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _xifexpression_2 = _typeName;
+ } else {
+ _xifexpression_2 = "";
+ }
+ String typeName = _xifexpression_2;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_3 = null;
+ boolean _and = false;
+ if (!hasData) {
+ _and = false;
+ } else {
+ VarDecl _data_2 = message.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ _and = (hasData && _isRef);
+ }
+ if (_and) {
+ _xifexpression_3 = "*";
+ } else {
+ _xifexpression_3 = "";
+ }
+ String refp = _xifexpression_3;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_4 = null;
+ boolean _and_1 = false;
+ if (!hasData) {
+ _and_1 = false;
+ } else {
+ boolean _or = false;
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ boolean _not = (!(_type_1 instanceof PrimitiveType));
+ if (_not) {
+ _or = true;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ boolean _isRef_1 = _refType_3.isRef();
+ _or = (_not || _isRef_1);
+ }
+ _and_1 = (hasData && _or);
+ }
+ if (_and_1) {
+ _xifexpression_4 = "*";
+ } else {
+ _xifexpression_4 = "";
+ }
+ String refpd = _xifexpression_4;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_5 = null;
+ boolean _and_2 = false;
+ boolean _and_3 = false;
+ if (!hasData) {
+ _and_3 = false;
+ } else {
+ VarDecl _data_5 = message.getData();
+ RefableType _refType_4 = _data_5.getRefType();
+ DataType _type_2 = _refType_4.getType();
+ boolean _not_1 = (!(_type_2 instanceof PrimitiveType));
+ _and_3 = (hasData && _not_1);
+ }
+ if (!_and_3) {
+ _and_2 = false;
+ } else {
+ VarDecl _data_6 = message.getData();
+ RefableType _refType_5 = _data_6.getRefType();
+ boolean _isRef_2 = _refType_5.isRef();
+ boolean _not_2 = (!_isRef_2);
+ _and_2 = (_and_3 && _not_2);
+ }
+ if (_and_2) {
+ _xifexpression_5 = "";
+ } else {
+ _xifexpression_5 = "&";
+ }
+ String refa = _xifexpression_5;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_6 = null;
+ if (hasData) {
+ String _plus = (", " + typeName);
+ String _plus_1 = (_plus + refpd);
+ String _plus_2 = (_plus_1 + " data");
+ _xifexpression_6 = _plus_2;
+ } else {
+ _xifexpression_6 = "";
+ }
+ String data = _xifexpression_6;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_7 = null;
+ if (hasData) {
+ _xifexpression_7 = ", data";
+ } else {
+ _xifexpression_7 = "";
+ }
+ String dataCall = _xifexpression_7;
+ _builder.newLineIfNotEmpty();
+ MessageHandler hdlr = this.roomExt.getSendHandler(message, (conj).booleanValue());
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name = message.getName();
+ String _messageSignature = this.messageSignature(portClassName, _name, "", data);
+ _builder.append(_messageSignature, "");
+ _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("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(portClassName, " ");
+ _builder.append("\", \"");
+ String _name_1 = message.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_2 = pc.getName();
+ String _name_3 = message.getName();
+ String _plus_3 = (dir + _name_3);
+ String _memberInUse = this.stdExt.memberInUse(_name_2, _plus_3);
+ String _plus_4 = (typeName + refp);
+ String _plus_5 = (refa + "data");
+ String _sendMessageCall = this.sendMessageCall(hasData, "self", _memberInUse, _plus_4, _plus_5);
+ _builder.append(_sendMessageCall, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_4 = message.getName();
+ String _messageSignature_1 = this.messageSignature(replPortClassName, _name_4, "_broadcast", data);
+ _builder.append(_messageSignature_1, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals_1 = (!Objects.equal(hdlr, null));
+ if (_notEquals_1) {
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name_5 = message.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("((etPort*)&((etReplPort*)self)->ports[i]");
+ _builder.append(dataCall, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}\t\t\t\t\t");
+ _builder.newLine();
+ } else {
+ _builder.append("\t");
+ _builder.append("int i;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_6 = message.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (i=0; i<((etReplPort*)self)->size; ++i) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_7 = pc.getName();
+ String _name_8 = message.getName();
+ String _plus_6 = (dir + _name_8);
+ String _memberInUse_1 = this.stdExt.memberInUse(_name_7, _plus_6);
+ String _plus_7 = (typeName + refp);
+ String _plus_8 = (refa + "data");
+ String _sendMessageCall_1 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[i])", _memberInUse_1, _plus_7, _plus_8);
+ _builder.append(_sendMessageCall_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_9 = message.getName();
+ String _plus_9 = (", int idx" + data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_9, "", _plus_9);
+ _builder.append(_messageSignature_2, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals_2 = (!Objects.equal(hdlr, null));
+ if (_notEquals_2) {
+ _builder.append("\t");
+ _builder.append(portClassName, " ");
+ _builder.append("_");
+ String _name_10 = message.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("((etPort*)&((etReplPort*)self)->ports[idx]");
+ _builder.append(dataCall, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
+ _builder.append(replPortClassName, " ");
+ _builder.append("\", \"");
+ String _name_11 = message.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("\")");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (0<=idx && idx<((etReplPort*)self)->size) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_12 = pc.getName();
+ String _name_13 = message.getName();
+ String _plus_10 = (dir + _name_13);
+ String _memberInUse_2 = this.stdExt.memberInUse(_name_12, _plus_10);
+ String _plus_11 = (typeName + refp);
+ String _plus_12 = (refa + "data");
+ String _sendMessageCall_2 = this.sendMessageCall(hasData, "((etPort*)&((etReplPort*)self)->ports[idx])", _memberInUse_2, _plus_11, _plus_12);
+ _builder.append(_sendMessageCall_2, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.newLine();
+ {
+ PortClass _portClass = this.roomExt.getPortClass(pc, (conj).booleanValue());
+ boolean _notEquals_3 = (!Objects.equal(_portClass, null));
+ if (_notEquals_3) {
+ PortClass _portClass_1 = this.roomExt.getPortClass(pc, (conj).booleanValue());
+ EList<PortOperation> _operations = _portClass_1.getOperations();
+ CharSequence _operationsImplementation = this.helpers.operationsImplementation(_operations, portClassName);
+ _builder.append(_operationsImplementation, "");
+ _builder.newLineIfNotEmpty();
+ PortClass _portClass_2 = this.roomExt.getPortClass(pc, (conj).booleanValue());
+ EList<PortOperation> _operations_1 = _portClass_2.getOperations();
+ CharSequence _operationsImplementation_1 = this.helpers.operationsImplementation(_operations_1, replPortClassName);
+ _builder.append(_operationsImplementation_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("// getReplication");
+ _builder.newLine();
+ _builder.append("etInt32 ");
+ _builder.append(replPortClassName, "");
+ _builder.append("_getReplication(const ");
+ _builder.append(replPortClassName, "");
+ _builder.append("* self) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return ((etReplPort*)self)->size;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _handlesReceive = this.roomExt.handlesReceive(pc, (conj).booleanValue());
+ if (_handlesReceive) {
+ CharSequence _genReceiveHandlers = this.genReceiveHandlers(pc, conj);
+ _builder.append(_genReceiveHandlers, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private String sendMessageCall(final boolean hasData, final String self, final String msg, final String typeName, final String data) {
+ String _xifexpression = null;
+ if (hasData) {
+ String _plus = ("etPort_sendMessage(" + self);
+ String _plus_1 = (_plus + ", ");
+ String _plus_2 = (_plus_1 + msg);
+ String _plus_3 = (_plus_2 + ", sizeof(");
+ String _plus_4 = (_plus_3 + typeName);
+ String _plus_5 = (_plus_4 + "), ");
+ String _plus_6 = (_plus_5 + data);
+ String _plus_7 = (_plus_6 + ");");
+ _xifexpression = _plus_7;
+ } else {
+ String _plus_8 = ("etPort_sendMessage(" + self);
+ String _plus_9 = (_plus_8 + ", ");
+ String _plus_10 = (_plus_9 + msg);
+ String _plus_11 = (_plus_10 + ", 0, NULL);");
+ _xifexpression = _plus_11;
+ }
+ return _xifexpression;
+ }
+
+ private String messageSignature(final String className, final String messageName, final String methodSuffix, final String data) {
+ String _plus = ("void " + className);
+ String _plus_1 = (_plus + "_");
+ String _plus_2 = (_plus_1 + messageName);
+ String _plus_3 = (_plus_2 + methodSuffix);
+ String _plus_4 = (_plus_3 + "(const ");
+ String _plus_5 = (_plus_4 + className);
+ String _plus_6 = (_plus_5 + "* self");
+ String _plus_7 = (_plus_6 + data);
+ String _plus_8 = (_plus_7 + ")");
+ return _plus_8;
+ }
+
+ private String messageSetterSignature(final String className, final String messageName, final String data) {
+ String _plus = ("void " + className);
+ String _plus_1 = (_plus + "_");
+ String _plus_2 = (_plus_1 + messageName);
+ String _plus_3 = (_plus_2 + "_set(");
+ String _plus_4 = (_plus_3 + className);
+ String _plus_5 = (_plus_4 + "* self");
+ String _plus_6 = (_plus_5 + data);
+ String _plus_7 = (_plus_6 + ")");
+ return _plus_7;
+ }
+
+ private String messageGetterSignature(final String className, final String messageName, final String type) {
+ String _plus = (type + " ");
+ String _plus_1 = (_plus + className);
+ String _plus_2 = (_plus_1 + "_");
+ String _plus_3 = (_plus_2 + messageName);
+ String _plus_4 = (_plus_3 + "_get(const ");
+ String _plus_5 = (_plus_4 + className);
+ String _plus_6 = (_plus_5 + "* const self)");
+ return _plus_6;
+ }
+
+ 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(")");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ private CharSequence genReceiveHandlers(final ProtocolClass pc, final Boolean conj) {
+ CharSequence _xblockexpression = null;
+ {
+ String portClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue());
+ String replPortClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue(), true);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/* receiver handlers */");
+ _builder.newLine();
+ {
+ List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, (conj).booleanValue());
+ for(final MessageHandler h : _receiveHandlers) {
+ _builder.append("void ");
+ _builder.append(portClassName, "");
+ _builder.append("_");
+ Message _msg = h.getMsg();
+ String _name = _msg.getName();
+ _builder.append(_name, "");
+ _builder.append("_receiveHandler(");
+ _builder.append(portClassName, "");
+ _builder.append("* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ DetailCode _detailCode = h.getDetailCode();
+ CharSequence _userCode = this.helpers.userCode(_detailCode);
+ _builder.append(_userCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("/* hand over the message to the actor: */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/* (*receiveMessageFunc)(actor, self, msg); */");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private 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("static const char* ");
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("_messageStrings[] = {\"MIN\", ");
+ {
+ List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
+ for(final Message m : _allOutgoingMessages) {
+ _builder.append("\"");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, "");
+ _builder.append("\",");
+ }
+ }
+ {
+ List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
+ for(final Message m_1 : _allIncomingMessages) {
+ _builder.append("\"");
+ String _name_2 = m_1.getName();
+ _builder.append(_name_2, "");
+ _builder.append("\", ");
+ }
+ }
+ _builder.append("\"MAX\"};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("const char* ");
+ String _name_3 = pc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_getMessageString(int msg_id) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if (msg_id < ");
+ String _name_4 = pc.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("::MSG_MIN || msg_id > ");
+ String _name_5 = pc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("::MSG_MAX+1){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("/* id out of range */");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return \"Message ID out of range\";");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("else{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return ");
+ String _name_6 = pc.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("_messageStrings[msg_id];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public 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 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("if (messageStrings[ ");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name = m.getName();
+ _builder.append(_name, " ");
+ _builder.append("] != \"timerTick\"){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_1 = m.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("]);");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (getPeerAddress().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(dir, " ");
+ _builder.append("_");
+ String _name_2 = m.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ } else {
+ _builder.append("getPeerMsgReceiver().receive(new Message(getPeerAddress(), ");
+ _builder.append(dir, " ");
+ _builder.append("_");
+ String _name_3 = m.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(", reinterpret_cast<void*>(");
+ {
+ boolean _and = false;
+ VarDecl _data_1 = m.getData();
+ RefableType _refType = _data_1.getRefType();
+ boolean _isRef = _refType.isRef();
+ if (!_isRef) {
+ _and = false;
+ } else {
+ VarDecl _data_2 = m.getData();
+ RefableType _refType_1 = _data_2.getRefType();
+ DataType _type = _refType_1.getType();
+ boolean _not = (!(_type instanceof PrimitiveType));
+ _and = (_isRef && _not);
+ }
+ if (_and) {
+ _builder.append("&");
+ }
+ }
+ VarDecl _data_3 = m.getData();
+ String _name_4 = _data_3.getName();
+ _builder.append(_name_4, " ");
+ _builder.append(")));");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ {
+ boolean _and_1 = false;
+ VarDecl _data_4 = m.getData();
+ boolean _notEquals_1 = (!Objects.equal(_data_4, null));
+ if (!_notEquals_1) {
+ _and_1 = false;
+ } else {
+ VarDecl _data_5 = m.getData();
+ RefableType _refType_2 = _data_5.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ _and_1 = (_notEquals_1 && (_type_1 instanceof DataClass));
+ }
+ if (_and_1) {
+ CharSequence _messageSignatureExplicitDefinition = this.messageSignatureExplicitDefinition(m, classPrefix);
+ _builder.append(_messageSignatureExplicitDefinition, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_5 = m.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("(new ");
+ VarDecl _data_6 = m.getData();
+ RefableType _refType_3 = _data_6.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ String _name_6 = _type_2.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("(");
+ {
+ VarDecl _data_7 = m.getData();
+ RefableType _refType_4 = _data_7.getRefType();
+ DataType _type_3 = _refType_4.getType();
+ DataClass _base = ((DataClass) _type_3).getBase();
+ boolean _notEquals_2 = (!Objects.equal(_base, null));
+ if (_notEquals_2) {
+ _builder.append("_super, ");
+ }
+ }
+ {
+ VarDecl _data_8 = m.getData();
+ RefableType _refType_5 = _data_8.getRefType();
+ DataType _type_4 = _refType_5.getType();
+ EList<Attribute> _attributes = ((DataClass) _type_4).getAttributes();
+ boolean _hasElements = false;
+ for(final Attribute a : _attributes) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(", ", " ");
+ }
+ String _name_7 = a.getName();
+ _builder.append(_name_7, " ");
+ }
+ }
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}